大家好,又见面了,我是你们的朋友全栈君。
–Boot SPL
2012.
10
–
04277
–g7aa9f04 (Mar
10
2013
– 00
:
36
:
40)
DRAM
:
1024MB
SUNXI SD
/MMC
:
0
U
–Boot
2012.
10
–
04277
–g7aa9f04 (Mar
10
2013
– 00
:
36
:
40) Allwinner Technology
CPU
: SUNXI Family
Board
: Cubieboard
I2C
: ready
DRAM
:
1 GiB
MMC
: SUNXI SD
/MMC
:
0
*
*
* Warning
– bad CRC, using default environment
In
: serial
Out
: serial
Err
: serial
Hit any key to stop autoboot
:
0
*
* Unable to use mmc
0
:
1
for fatload
*
*
Loading file
“uEnv.txt” from mmc device
0
:
1
Failed to mount ext2 filesystem…
*
* Bad ext2 partition
or disk
– mmc
0
:
1
*
*
ext2load
– load binary file from a Ext2 filesystem
Usage
:
ext2load
<interface
>
<dev[
:part]
> [addr] [filename] [bytes]
– load binary file
‘filename’ from
‘dev’ on
‘interface’
to address
‘addr’ from ext2 filesystem
Loading file
“boot/uEnv.txt” from mmc device
0
:
1
Failed to mount ext2 filesystem…
*
* Bad ext2 partition
or disk
– mmc
0
:
1
*
*
ext2load
– load binary file from a Ext2 filesystem
Usage
:
ext2load
<interface
>
<dev[
:part]
> [addr] [filename] [bytes]
– load binary file
‘filename’ from
‘dev’ on
‘interface’
to address
‘addr’ from ext2 filesystem
*
* Unable to use mmc
0
:
1
for fatload
*
*
Loading file
“boot.scr” from mmc device
0
:
1
Failed to mount ext2 filesystem…
*
* Bad ext2 partition
or disk
– mmc
0
:
1
*
*
ext2load
– load binary file from a Ext2 filesystem
Usage
:
ext2load
<interface
>
<dev[
:part]
> [addr] [filename] [bytes]
– load binary file
‘filename’ from
‘dev’ on
‘interface’
to address
‘addr’ from ext2 filesystem
Loading file
“boot/boot.scr” from mmc device
0
:
1
Failed to mount ext2 filesystem…
*
* Bad ext2 partition
or disk
– mmc
0
:
1
*
*
ext2load
– load binary file from a Ext2 filesystem
Usage
:
ext2load
<interface
>
<dev[
:part]
> [addr] [filename] [bytes]
– load binary file
‘filename’ from
‘dev’ on
‘interface’
to address
‘addr’ from ext2 filesystem
*
* Unable to use mmc
0
:
1
for fatload
*
*
sun4i
#
*dummy1, ulong dummy2)
{
u32 boot_device;
debug(
“>>spl:board_init_r()\n”);
puts(
“>>spl:board_init_r()\n”);
#
ifdef CONFIG_SYS_SPL_MALLOC_START
mem_malloc_init(CONFIG_SYS_SPL_MALLOC_START,
CONFIG_SYS_SPL_MALLOC_SIZE);
#
endif
timer_init();
#
ifdef CONFIG_SPL_BOARD_INIT
spl_board_init();
#
endif
boot_device
= spl_boot_device();
//检测启动设备,此处返回BOOT_DEVICE_MMC1
debug(
“boot device – %d\n”, boot_device);
switch (boot_device) {
#
ifdef CONFIG_SPL_RAM_DEVICE
case BOOT_DEVICE_RAM
:
spl_ram_load_image();
break;
#
endif
#
ifdef CONFIG_SPL_MMC_SUPPORT
case BOOT_DEVICE_MMC1
:
case BOOT_DEVICE_MMC2
:
case BOOT_DEVICE_MMC2_2
:
spl_mmc_load_image();
//通过mmc读取image
break;
#
endif
#
ifdef CONFIG_SPL_NAND_SUPPORT
case BOOT_DEVICE_NAND
:
spl_nand_load_image();
break;
#
endif
#
ifdef CONFIG_SPL_NOR_SUPPORT
case BOOT_DEVICE_NOR
:
spl_nor_load_image();
break;
#
endif
#
ifdef CONFIG_SPL_YMODEM_SUPPORT
case BOOT_DEVICE_UART
:
spl_ymodem_load_image();
break;
#
endif
#
ifdef CONFIG_SPL_SPI_SUPPORT
case BOOT_DEVICE_SPI
:
spl_spi_load_image();
break;
#
endif
#
ifdef CONFIG_SPL_ETH_SUPPORT
case BOOT_DEVICE_CPGMAC
:
#
ifdef CONFIG_SPL_ETH_DEVICE
spl_net_load_image(CONFIG_SPL_ETH_DEVICE);
#
else
spl_net_load_image(NULL);
#
endif
break;
#
endif
default
:
debug(
“SPL: Un-supported Boot Device\n”);
hang();
}
switch (spl_image.os) {
case IH_OS_U_BOOT
:
debug(
“Jumping to U-Boot\n”);
break;
#
ifdef CONFIG_SPL_OS_BOOT
case IH_OS_LINUX
:
debug(
“Jumping to Linux\n”);
spl_board_prepare_for_linux();
jump_to_image_linux((
void
*)CONFIG_SYS_SPL_ARGS_ADDR);
#
endif
default
:
debug(
“Unsupported OS image.. Jumping nevertheless..\n”);
}
jump_to_image_no_args();
}
void) {
u32 cfg;
#
ifdef CONFIG_SPL_NOR_SUPPORT
/* TODO */
#
endif
#
ifdef CONFIG_SPL_MMC_SUPPORT
cfg
= sunxi_gpio_get_cfgpin(SUNXI_GPC(
7));
if( cfg
== SUNXI_GPC7_SDC2_CLK )
return BOOT_DEVICE_MMC2;
#
endif
#
ifdef CONFIG_SPL_NAND_SUPPORT
cfg
= sunxi_gpio_get_cfgpin(SUNXI_GPC(
2));
if( cfg
== SUNXI_GPC2_NCLE )
return BOOT_DEVICE_NAND;
#
endif
#
ifdef CONFIG_SPL_MMC_SUPPORT
cfg
= sunxi_gpio_get_cfgpin(SUNXI_GPF(
2));
if( cfg
== SUNXI_GPF2_SDC0_CLK )
return BOOT_DEVICE_MMC1;
#
endif
/* if we are here, something goes wrong. Fall back on MMC */
return BOOT_DEVICE_MMC1;
}
void)
{
struct mmc
*mmc;
int err;
u32 boot_mode;
mmc_initialize(gd
–
>bd);
/* We register only one device. So, the dev id is always 0 */
mmc
= find_mmc_device(
0);
if (
!mmc) {
puts(
“spl: mmc device not found!!\n”);
hang();
}
err
= mmc_init(mmc);
if (err) {
printf(
“spl: mmc init failed: err – %d\n”, err);
hang();
}
boot_mode
= spl_boot_mode();
// sunxi的代码在此处直接返回了MMCSD_MODE_RAW
if (boot_mode
== MMCSD_MODE_RAW) {
debug(
“boot mode – RAW\n”);
mmc_load_image_raw(mmc);
#
ifdef CONFIG_SPL_FAT_SUPPORT
}
else
if (boot_mode
== MMCSD_MODE_FAT) {
debug(
“boot mode – FAT\n”);
mmc_load_image_fat(mmc);
#
endif
}
else {
puts(
“spl: wrong MMC boot mode\n”);
hang();
}
}
void mmc_load_image_raw(
struct mmc
*mmc)
{
u32 image_size_sectors, err;
const
struct image_header
*header;
header
= (
struct image_header
*)(CONFIG_SYS_TEXT_BASE
–
sizeof(
struct image_header));
/* read image header to find the image size & load address */
err
= mmc
–
>block_dev.block_read(
0,
CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR,
1,
(
void
*)header);
if (err
<
=
0)
goto end;
spl_parse_image_header(header);
/* convert size to sectors – round up */
image_size_sectors
= (spl_image.size
+ mmc
–
>read_bl_len
–
1)
/
mmc
–
>read_bl_len;
/* Read the header too to avoid extra memcpy */
err
= mmc
–
>block_dev.block_read(
0,
CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR,
image_size_sectors, (
void
*)spl_image.load_addr);
//此处确定了Uboot读取位置
end
:
if (err
<
=
0) {
printf(
“spl: mmc blk read err – %d\n”, err);
hang();
}
}
define CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR (
64)
/* 32KB offset */
#
define CONFIG_SYS_U_BOOT_MAX_SIZE_SECTORS (
400)
/* 200KB, enough for a full u-boot.bin */
发布者:全栈程序员-用户IM,转载请注明出处:https://javaforall.cn/163073.html原文链接:https://javaforall.cn
【正版授权,激活自己账号】: Jetbrains全家桶Ide使用,1年售后保障,每天仅需1毛
【官方授权 正版激活】: 官方授权 正版激活 支持Jetbrains家族下所有IDE 使用个人JB账号...