x-load的启动选择:
见lib/board.c
初始化顺序,如果配置了CFG_CMD_MMC,则直接从MMC卡启动,否则初始化NAND FLASH。
init_fnc_t *init_sequence[] = {
cpu_init, /* basic cpu dependent setup */
board_init, /* basic board dependent setup */
#ifdef CFG_PRINTF
serial_init, /* serial communications setup */
print_info,
#endif
#ifdef CFG_CMD_MMC
mmc_boot,
#endif
nand_init, /* board specific nand init */
NULL,
};
|
/cpu/omap3/start.S文件中:
ldr pc, _start_armboot /* jump to C code */
_start_armboot: .word start_armboot
跳转到C代码start_armboot。
start_armboot,还是在lib/board.c文件中实现:
void start_armboot (void)
{
init_fnc_t **init_fnc_ptr;
int i;
uchar *buf;
for (init_fnc_ptr = init_sequence; *init_fnc_ptr; ++init_fnc_ptr) {
if ((*init_fnc_ptr)() != 0) {
hang ();
}
}
buf = (uchar*) CFG_LOADADDR;
#ifdef CFG_ONENAND
for (i = ONENAND_START_BLOCK; i < ONENAND_END_BLOCK; i++){
if (!onenand_read_block(buf, i))
buf += ONENAND_BLOCK_SIZE;
}
#else
for (i = NAND_UBOOT_START; i < NAND_UBOOT_END; i+= NAND_BLOCK_SIZE){
if (!nand_read_block(buf, i))
buf += NAND_BLOCK_SIZE; /* advance buf ptr */
}
#endif
if (buf == (uchar *)CFG_LOADADDR)
hang();
/* go run U-Boot and never return */
printf("Starting OS Bootloader...\n");
((init_fnc_t *)CFG_LOADADDR)();
/* should never come here */
}
|
首先根据预定的初始化顺序进行初始化(其中,如果遇到MMC卡可用,配置了CFG_CMD_MMC,即从MMC卡启动),然后根据用户选择的是onenand还是nand,并从其中存放u-boot的地方读取u-boot,然后运行U-Boot。
如何选择就是配置CFG_CMD_MMC与否:
/* For X-loader to be flashed on to NAND disable the below macro */
//#define CFG_CMD_MMC 1
//#define CFG_CMD_FAT 1
//#define CONFIG_MMC 1
//#define CFG_MMC_BASE 0xF0000000
如果不注释上述定义,就从MMC卡启动,注释之后就可以从NAND FLASH启动了。
当然,要保证NAND FLASH驱动可用。
阅读(492) | 评论(0) | 转发(0) |