u-boot
来源:互联网 发布:php解密专家 编辑:程序博客网 时间:2024/05/17 08:26
Overview
bootcmd是environment中重要的一个环境变量,u-boot的最后阶段会执行bootcmd定义的命令。
bootcmd通常就会包括load和boot命令(如bootz),即把kernel image & Flatten Device Tree加载到内存,然后执行内核内核。如此,完成u-boot到kernel的启动转换。
调用顺序
前面已经提到过,在u-boot的初始化阶段,会读取environment的值。而bootcmd的执行则在u-boot启动的最后一部分,即main_loop()。
main_loop() -> bootdelay_process() + autoboot_command() -> env "bootcmd"
main_loop()
main_loop()会等待获取用户的输入命令,或(超时后)获取环境变量中的bootcmd,之后调用autoboot_command()执行bootcmd命令序列。
// common/main.c:/* We come here after U-Boot is initialised and ready to process commands */void main_loop(void){ const char *s; bootstage_mark_name(BOOTSTAGE_ID_MAIN_LOOP, "main_loop");#ifdef CONFIG_VERSION_VARIABLE setenv("ver", version_string); /* set version variable */#endif /* CONFIG_VERSION_VARIABLE */ cli_init(); run_preboot_environment_command();#if defined(CONFIG_UPDATE_TFTP) update_tftp(0UL, NULL, NULL);#endif /* CONFIG_UPDATE_TFTP */ s = bootdelay_process(); if (cli_process_fdt(&s)) cli_secure_boot_cmd(s); autoboot_command(s); cli_loop(); panic("No CLI available");}
bootdelay_process()
这里的正常流程会获取环境变量中bootcmd的值,并返回这个值。
// common/autoboot.cconst char *bootdelay_process(void){ char *s; int bootdelay; // ... s = getenv("bootcmd"); // ... return s;}
autoboot_command()
执行命令列表,如load, bootz等,即将内核等映像文件加载到内容,然后跳转到内核的第一条指令处执行,从而启动内核代码。
// common/autoboot.cvoid autoboot_command(const char *s){ debug("### main_loop: bootcmd=\"%s\"\n", s ? s : "<UNDEFINED>"); // ... run_command_list(s, -1, 0); // ...}
阅读全文
0 0
- U-BOOT
- u-boot
- U-boot
- U-Boot
- u-boot
- u-boot
- u-boot!!
- U-BOOT
- U-boot
- U-BOOT
- U BOOT
- U-boot
- u-boot
- U-Boot
- U-boot
- U-boot
- U-boot
- U-Boot
- bestcoder 小C的倍数问题
- 改变一生的经济学规律
- [codevs1225]八数码难题
- SecureCRT等软件连接Linux缓慢问题解决方法
- 错误——
- u-boot
- Linux进程入门学习(三)-进程创建等待
- 织梦怎么调用随机数
- gcc,make,cmake傻傻分不清楚?
- 【折腾】ipv6 go ipv4折腾记 (1)
- java集合之LinkedList
- fcntl设置非阻塞文件描述符
- 信息化运维建设
- C++智能指针简单剖析