标题:
Uboot -kerne-root 启动流程
内容:
※uboot启动流程
※Kernel启动流程
※Root启动流程
※构建根文件系统
/*********************************
*u-boot: u-boot2012.04.01
*kernel: linux-2.6.22
*busybox: busybox-1.1.6
*********************************/
一、uboot启动流程
1.初始化硬件
2.把内核从NAND读到SDRAM
3.设置内核启动参数
4.跳转执行内核
执行**个代码:/cpu/arm920t/start.S
**阶段(start.S)
reset:
set the cpu to SVC32 mode //管理模式
turn off the watchdog //关看门狗
mask all IRQs //屏蔽中断
cpu_init_crit
flush v4 I/D caches //关闭caches
disable MMU stuff and caches //关闭MMU
lowlevel_init //配置SDRAM
Relocate //重定位
stack_setup: //设置堆栈
clear_bss: //清楚bss段
start_armboot //跳转执行第二阶段
第二阶段(board.c)
start_armboot (void)
init_sequence
cpu_init, /* basic cpu dependent setup */
board_init, /* basic board dependent setup */
interrupt_init, /* set up exceptions */
env_init, /* initialize environment */
init_baudrate, /* initialze baudrate settings */
serial_init, /* serial communications setup */
console_init_f, /* stage 1 init of console */
display_banner, /* say that we are here */
flash_init 初始化NOR
nand_init() 初始化NAND
env_relocate () 将环境变量读入指定位置
cs8900_get_enetaddr 初始化网络设备
main_loop () 死循环
s = getenv ("bootdelay")
bootdelay = s ? (int)simple_strtol(s, NULL, 10) : CONFIG_BOOTDELAY;
s = getenv ("bootcmd");
Bootcmd=nand read.jffs2 0x30007fc0 kernel;bootm 0x30007fc0 //环境变量
run_command (s, 0);
continue;
Uboot命令的实现
①串口输入命令(字符串)
②动作(函数),命令对应于名字
因而根据命令找到对应函数,来执行。Uboot里面有一个结构体
包含1.名
2.函数
struct cmd_tbl_s {
char *name; /* Command Name */
int maxargs; /* maximum number of arguments */
int repeatable; /* autorepeat allowed? */
/* Implementation function */
int (*cmd)(struct cmd_tbl_s *, int, int, char *[]);
char *usage; /* Usage message (short) */
#ifdef CFG_LONGHELP
char *help; /* Help message (long) */
#endif
#ifdef CONFIG_AUTO_COMPLETE
/* do auto completion on the arguments */
int (*complete)(int argc, char *argv[], char last_char, int maxv, char *cmdv[]);
#endif
};
此时run_command函数根据名字匹配该结构体
Run_command
命令的提取
while (*str) {
/*
* Find separator, or string end
* Allow simple escape of ';' by writing ";"
*/
for (inquotes = 0, sep = str; *sep; sep++) {
if ((*sep==''') &&
(*(sep-1) != '\'))
inquotes=!inquotes;
if (!inquotes &&
(*sep == ';') && /* separator */
( sep != str) && /* past string start */
(*(sep-1) != '\')) /* and NOT escaped */
break;
}
parse_line() //解析命令
Cmdtp=find_cmd() //匹配命令 cmdtp就是指向上面的结构体cmd_tbl_s
百检网秉承“客户至上,服务为先,精诚合作,以人为本”的经营理念,始终站在用户的角度解决问题,为客户提供“一站购物式”的新奇检测体验,打开网站,像挑选商品一样简单,方便。打破行业信息壁垒,建构消费和检测机构之间高效的沟通平台