uboot总的启动linux内核的流程:启动文件start.S基本软硬件环境初始化好之后,调用arm_lib/board.c下的startarm_boot()函数,这个函数最终调用main_loop()函数,内核的调用肯定就在这里面完成了。
因此,首先分析common/main.c:的main_loop函数:
main_loop()
{
char *s;
int bootdelay;
embedsky_lcd_Init();
extern int mtdparts_init(void);
if (!getenv("mtdparts"))
{
run_command("mtdparts default", 0);
}
else
{
mtdparts_init();
}
s = getenv ("bootcmd");
if (bootdelay >= 0 && s && !abortboot (bootdelay))
{
if (bBootFrmNORFlash()) //如果从Nor启动,即进入u-boot菜单下载模式,可以去分析bBootFrmNORFlash()这个函数
{
run_command("menu", 0);
}
/*
* Main Loop for Monitor Command Processing
*/
else //从nand启动:wince和linux的选择
{
#ifdef CONFIG_SURPORT_WINCE //未定义
if (!TOC_Read())//wince匹配
{
/* Launch wince */
char cmd_buf[16];
printf("Booting wince ...\n");
strcpy(cmd_buf, "wince");
run_command(cmd_buf, 0);
}
else//最终匹配加载Linux内核
#endif
{
printf("Booting Linux ...\n");
//boot_zImage(0x200000,0x200000);
//启动内核
run_command (s, 0);
}
}
}
//run_command("menu", 0);
/*进入menu模式后的:获取命令以及操作*/
for (;;) {
len = readline (CFG_PROMPT); //获取命令的长度
flag = 0; /* assume no special flag