韦东山衔接班——1.4_u-boot分析之源码第二阶段
作者:GWD 时间:2019.8.22
目的:怎么读出内核和启动内核
1、UBOOT读写nand
2、环境变量初始化board.c
3、
4、接下来分析main_loop
注:很多#ifndef这类代码,分析的时候先跳过这些看最后需要的,然后在source insight中看哪些没被定义。
/****************************************************************************/
void main_loop (void)
{
#ifndef CFG_HUSH_PARSERstatic char lastcommand[CFG_CBSIZE] = { 0, };int len;int rc = 1;int flag;
#endif#if defined(CONFIG_BOOTDELAY) && (CONFIG_BOOTDELAY >= 0)char *s;int bootdelay;
#endif
#ifdef CONFIG_PREBOOTchar *p;
#endif
#ifdef CONFIG_BOOTCOUNT_LIMITunsigned long bootcount = 0;unsigned long bootlimit = 0;char *bcs;char bcs_set[16];
#endif /* CONFIG_BOOTCOUNT_LIMIT */#if defined(CONFIG_VFD) && defined(VFD_TEST_LOGO)ulong bmp = 0; /* default bitmap */extern int trab_vfd (ulong bitmap);#ifdef CONFIG_MODEM_SUPPORTif (do_mdm_init)bmp = 1; /* alternate bitmap */
#endiftrab_vfd (bmp);
#endif /* CONFIG_VFD && VFD_TEST_LOGO */#ifdef CONFIG_BOOTCOUNT_LIMITbootcount = bootcount_load();bootcount++;bootcount_store (bootcount);sprintf (bcs_set, "%lu", bootcount);setenv ("bootcount", bcs_set);bcs = getenv ("bootlimit");bootlimit = bcs ? simple_strtoul (bcs, NULL, 10) : 0;
#endif /* CONFIG_BOOTCOUNT_LIMIT */#ifdef CONFIG_MODEM_SUPPORTdebug ("DEBUG: main_loop: do_mdm_init=%d\n", do_mdm_init);if (do_mdm_init) {char *str = strdup(getenv("mdm_cmd"));setenv ("preboot", str); /* set or delete definition */if (str != NULL)free (str);mdm_init(); /* wait for modem connection */}
#endif /* CONFIG_MODEM_SUPPORT */#ifdef CONFIG_VERSION_VARIABLE{extern char version_string[];setenv ("ver", version_string); /* set version variable */}
#endif /* CONFIG_VERSION_VARIABLE */#ifdef CFG_HUSH_PARSERu_boot_hush_start ();
#endif#ifdef CONFIG_AUTO_COMPLETEinstall_auto_complete();
#endif#ifdef CONFIG_PREBOOTif ((p = getenv ("preboot")) != NULL) {
# ifdef CONFIG_AUTOBOOT_KEYEDint prev = disable_ctrlc(1); /* disable Control C checking */
# endif# ifndef CFG_HUSH_PARSERrun_command (p, 0);
# elseparse_string_outer(p, FLAG_PARSE_SEMICOLON |FLAG_EXIT_FROM_LOOP);
# endif# ifdef CONFIG_AUTOBOOT_KEYEDdisable_ctrlc(prev); /* restore Control C checking */
# endif}
#endif /* CONFIG_PREBOOT */#if defined(CONFIG_BOOTDELAY) && (CONFIG_BOOTDELAY >= 0)s = getenv ("bootdelay");bootdelay = s ? (int)simple_strtol(s, NULL, 10) : CONFIG_BOOTDELAY;debug ("### main_loop entered: bootdelay=%d\n\n", bootdelay);# ifdef CONFIG_BOOT_RETRY_TIMEinit_cmd_timeout ();
# endif /* CONFIG_BOOT_RETRY_TIME */#ifdef CONFIG_BOOTCOUNT_LIMITif (bootlimit && (bootcount > bootlimit)) {printf ("Warning: Bootlimit (%u) exceeded. Using altbootcmd.\n",(unsigned)bootlimit);s = getenv ("altbootcmd");}else
#endif /* CONFIG_BOOTCOUNT_LIMIT */s = getenv ("bootcmd");debug ("### main_loop: bootcmd=\"%s\"\n", s ? s : "<UNDEFINED>");if (bootdelay >= 0 && s && !abortboot (bootdelay)) {
# ifdef CONFIG_AUTOBOOT_KEYEDint prev = disable_ctrlc(1); /* disable Control C checking */
# endif# ifndef CFG_HUSH_PARSERrun_command (s, 0);
# elseparse_string_outer(s, FLAG_PARSE_SEMICOLON |FLAG_EXIT_FROM_LOOP);
# endif# ifdef CONFIG_AUTOBOOT_KEYEDdisable_ctrlc(prev); /* restore Control C checking */
# endif}# ifdef CONFIG_MENUKEYif (menukey == CONFIG_MENUKEY) {s = getenv("menucmd");if (s) {
# ifndef CFG_HUSH_PARSERrun_command (s, 0);
# elseparse_string_outer(s, FLAG_PARSE_SEMICOLON |FLAG_EXIT_FROM_LOOP);
# endif}}
#endif /* CONFIG_MENUKEY */
#endif /* CONFIG_BOOTDELAY */#ifdef CONFIG_AMIGAONEG3SE{extern void video_banner(void);video_banner();}
#endif/** Main Loop for Monitor Command Processing*/
#ifdef CFG_HUSH_PARSERparse_file_outer();/* This point is never reached */for (;;);
#elsefor (;;) {
#ifdef CONFIG_BOOT_RETRY_TIMEif (rc >= 0) {/* Saw enough of a valid command to* restart the timeout.*/reset_cmd_timeout();}
#endiflen = readline (CFG_PROMPT);flag = 0; /* assume no special flags for now */if (len > 0)strcpy (lastcommand, console_buffer);else if (len == 0)flag |= CMD_FLAG_REPEAT;
#ifdef CONFIG_BOOT_RETRY_TIMEelse if (len == -2) {/* -2 means timed out, retry autoboot*/puts ("\nTimed out waiting for command\n");
# ifdef CONFIG_RESET_TO_RETRY/* Reinit board to run initialization code again */do_reset (NULL, 0, 0, NULL);
# elsereturn; /* retry autoboot */
# endif}
#endifif (len == -1)puts ("<INTERRUPT>\n");elserc = run_command (lastcommand, flag);if (rc <= 0) {/* invalid command or not repeatable, forget it */lastcommand[0] = 0;}}
#endif /*CFG_HUSH_PARSER*/
}
得到bootcmd的值并且打印
Bootcmd是个环境变量,定义了两个环境变量
这些run_commend命令才是u-boot的核心,下面一节课来分析这些命令
韦东山衔接班——1.4_u-boot分析之源码第二阶段相关推荐
- 韦东山衔接班——4.4_构建根文件系统之构建根文件系统
文章地址: https://blog.csdn.net/gongweidi/article/details/100086289?biz_id=102&utm_term=%E9%9F%A6%E4 ...
- 韦东山衔接班——1.2_uboot分析之Makefile结构分析
作者:GWD 时间:2019.8.21 一.分析Makefile的配置过程 (从输入配置命令到创建config.h头文件的过程): 1.顶层Makefile中执行100ask24x0_config后就 ...
- 韦东山衔接班——4.2_构建根文件系统之init进程分析
作者:GWD 时间:2019.8.25 Busybox的引入 根文件系统中有很多命令,命令就相当与一个应用程序,若一个一个编译很麻烦,linux中有一个busybox.当我们执行ls时候就相当于执行了 ...
- 韦东山衔接班——1.1_u-boot分析之编译体验
作者:GWD 时间:2019.8.21 第一节:u-boot分析之编译体验 一.Bootloader简介 1.BootLoader的引入: bootloader就是一小段程序,系统上电后开始执行,初始 ...
- 韦东山衔接班——3.4_linux内核启动流程分析之内核启动
作者:GWD 时间:2018.8.25 一.汇编部分到第一个C之前准备 1.问:内核的工作 答 2.问:为什么有两个head.S 答:其中一个是自解压代码,运行时先解压内核 3.uboot中将参数写入 ...
- 韦东山衔接班——4.3_构建根文件系统之busybox
作者:GWD 时间:2019.8.26 注:Linux中交叉编译用CROSS开头 配置编译busybox 1.解压busybox 2.make menuconfig出现配置菜单 在readme或者in ...
- spring boot 2.0 源码分析(二)
在上一章学习了spring boot 2.0启动的大概流程以后,今天我们来深挖一下SpringApplication实例变量的run函数. 先把这段run函数的代码贴出来: /*** Run the ...
- spring boot 2.0 源码分析(三)
通过上一章的源码分析,我们知道了spring boot里面的listeners到底是什么(META-INF/spring.factories定义的资源的实例),以及它是创建和启动的,今天我们继续深入分 ...
- 【SpringBoot】最新版2019Spring Boot配置解析,源码解析(速成SpringBoot)——学习笔记版【2】
SpringBoot配置文件 文章目录 SpringBoot配置文件 四.配置文件 1.简介 2.YAML用法 2.1 简介 2.2语法 3.为属性注入值 3.1使用.yml配置文件 3.1编写.ym ...
最新文章
- IOS后台运行机制详解(一)
- 软件测试_APP测试_兼容性测试
- linux中权限分离,linux多项目资源分离权限问题
- c++Interpolation search插值搜索的实现算法之一(附完整源码)
- 【caffe-Windows】微软官方caffe之 matlab接口配置
- [react] react非父子组件如何通信?
- 关于计算机软件系统分类能够匹配的有,以下关于计算机软件系统分类能够匹配的有:...
- spring classpath*
- 基于JAVA+Servlet+JSP+MYSQL的教室预订管理系统
- [Win系统][临时方案]系统任务管理器不能使用临时性解决方案
- linux AWK中正则表达式
- linux-vim快捷键
- PreScan快速入门到精通第二讲PreScan功能介绍
- CPU虚拟化是否开启
- wordpress比其它phpcms有什么优势,看完就知道了
- 【冬季】寒冬已至,让这些公众号温暖你的冬天
- nux下导入、导出mysql数据库命令
- 演讲培训——荣耀时刻
- DNA甲基化测序数据的分析流程及相关软件总结
- Oracle DDL锁处理