U-Boot启动过程,带你透彻理解U-Boot
2017-01-19 23:02
281 查看
U-Boot第一阶段的启动流程:
这个阶段主要是初始化硬件设备,为加载U-Boot的第二阶段代码准备RAM空间最后跳转到lib_arm/board.c中start_armboot函数,这是第二阶段的入口点。
U-Boot第一阶段的存储器布局
上图中U-Boot安装在Nand Flash,启动时Nand Flash控制器前4KB的代码复制到SRAM中,这4KB的代码再将整个U-Boot复制到SDRAM中,最后跳转到SDRAM中去执行,这就进入了第二阶段。
U-boot启动第二阶段过程图:
U-Boot引导内核分析引导内核分析:
U-Boot的命令为用户提供了交互功能,并且已经实现了几十个常用的命令。如果开发板需要很特殊的操作,可以添加新的U-Boot命令。
U-Boot的每一个命令都是通过U_Boot_CMD宏定义的。这个宏在<include/command.h>头文件中定义
#define U_BOOT_CMD(name,maxargs,rep,cmd,usage,help) \
cmd_tbl_t __u_boot_cmd_##name Struct_Section = {#name, maxargs, rep, cmd, usage}
其中:
· name:命令的名字,他不是一个字符串,不能用双引号括起来
· maxargs:最大的参数个数
· command:对应的函数指针
· usage:一个字符串,简短的使用说明
· help:一个字符串,比较详细的使用说明
对于bootm命令,其定义如下:
1. U_BOOT_CMD(//bootm命令
2. bootm, CFG_MAXARGS, 1, do_bootm,
3. "bootm - boot application image from memory\n",
4. "[addr [arg ...]]\n - boot application image stored in memory\n"
5. "\tpassing arguments 'arg ...'; when booting a Linux kernel,\n"
6. "\t'arg' can be the address of an initrd image\n"
7. #ifdef CONFIG_OF_FLAT_TREE
8. "\tWhen booting a Linux kernel which requires a flat device-tree\n"
9. "\ta third argument is required which is the address of the of the\n"
10. "\tdevice-tree blob. To boot that kernel without an initrd image,\n"
11. "\tuse a '-' for the second argument. If you do not pass a third\n"
12. "\ta bd_info struct will be passed instead\n"
13. #endif
14. );
bootm命令是用来引导经过U-Boot的工具mkimage打包后的kernel image的。U-Boot源代码的tools/目录下有mkimage工具,这个工具可以用来制作不压缩或者压缩的多种可启动映象文件。
mkimage在制作映象文件的时候,是在原来的可执行映象文件的前面加上一个0x40字节的头,记录参数所指定的信息,这样uboot才能识别这个映象是针对哪个CPU体系结构的,哪个OS的,哪种类型,加载内存中的哪个位置, 入口点在内存的那个位置以及映象名是什么。
U-Boot正是通过bootm命令引导Linux内核的。
bootm命令调用do_bootm函数,下面我们来分析一下:
do_bootm函数流程分析
do_bootm_linux函数
转载自:微信公众号嵌入式ARM
这个阶段主要是初始化硬件设备,为加载U-Boot的第二阶段代码准备RAM空间最后跳转到lib_arm/board.c中start_armboot函数,这是第二阶段的入口点。
U-Boot第一阶段的存储器布局
上图中U-Boot安装在Nand Flash,启动时Nand Flash控制器前4KB的代码复制到SRAM中,这4KB的代码再将整个U-Boot复制到SDRAM中,最后跳转到SDRAM中去执行,这就进入了第二阶段。
U-boot启动第二阶段过程图:
U-Boot引导内核分析引导内核分析:
U-Boot的命令为用户提供了交互功能,并且已经实现了几十个常用的命令。如果开发板需要很特殊的操作,可以添加新的U-Boot命令。
U-Boot的每一个命令都是通过U_Boot_CMD宏定义的。这个宏在<include/command.h>头文件中定义
#define U_BOOT_CMD(name,maxargs,rep,cmd,usage,help) \
cmd_tbl_t __u_boot_cmd_##name Struct_Section = {#name, maxargs, rep, cmd, usage}
其中:
· name:命令的名字,他不是一个字符串,不能用双引号括起来
· maxargs:最大的参数个数
· command:对应的函数指针
· usage:一个字符串,简短的使用说明
· help:一个字符串,比较详细的使用说明
对于bootm命令,其定义如下:
1. U_BOOT_CMD(//bootm命令
2. bootm, CFG_MAXARGS, 1, do_bootm,
3. "bootm - boot application image from memory\n",
4. "[addr [arg ...]]\n - boot application image stored in memory\n"
5. "\tpassing arguments 'arg ...'; when booting a Linux kernel,\n"
6. "\t'arg' can be the address of an initrd image\n"
7. #ifdef CONFIG_OF_FLAT_TREE
8. "\tWhen booting a Linux kernel which requires a flat device-tree\n"
9. "\ta third argument is required which is the address of the of the\n"
10. "\tdevice-tree blob. To boot that kernel without an initrd image,\n"
11. "\tuse a '-' for the second argument. If you do not pass a third\n"
12. "\ta bd_info struct will be passed instead\n"
13. #endif
14. );
bootm命令是用来引导经过U-Boot的工具mkimage打包后的kernel image的。U-Boot源代码的tools/目录下有mkimage工具,这个工具可以用来制作不压缩或者压缩的多种可启动映象文件。
mkimage在制作映象文件的时候,是在原来的可执行映象文件的前面加上一个0x40字节的头,记录参数所指定的信息,这样uboot才能识别这个映象是针对哪个CPU体系结构的,哪个OS的,哪种类型,加载内存中的哪个位置, 入口点在内存的那个位置以及映象名是什么。
U-Boot正是通过bootm命令引导Linux内核的。
bootm命令调用do_bootm函数,下面我们来分析一下:
do_bootm函数流程分析
do_bootm_linux函数
转载自:微信公众号嵌入式ARM
相关文章推荐
- 三星s5pv210 uboot启动过程理解
- U-Boot启动过程
- 深入理解linux启动过程
- s3c2410 u-boot启动过程
- U-BOOT启动过程分析 经典文章汇集
- U-Boot启动的函数调用过程(以arm926ejs为例)
- Inside the Linux boot process(linux的启动过程)
- 理解Linux启动过程
- u-boot 启动过程 —— 基于S3C2410
- 深入理解linux启动过程
- 深入理解Linux启动过程
- u-boot启动过程分析——基于lpc2210的移植代码
- u-boot启动过程分析——基于lpc2210的移植代码[转]
- U-Boot的移植之(二)进阶篇:从源代码看系统启动过程
- 深入理解Linux的启动过程
- u-boot启动过程
- Linux 系统启动过程(initrd部分) --- Linux boot process (initrd part)
- The Kernel Boot Process --linux2.6.25内核启动过程
- 深入理解linux启动过程
- U-Boot启动的函数调用过程(以arm926ejs为例)