图解U-Boot:引导内核分析
2012-03-12 13:21
302 查看
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命令,其定义如下:
[plain]
view plaincopyprint?
U_BOOT_CMD(//bootm命令
bootm, CFG_MAXARGS, 1, do_bootm,
"bootm - boot application image from memory\n",
"[addr [arg ...]]\n - boot application image stored in memory\n"
"\tpassing arguments 'arg ...'; when booting a Linux kernel,\n"
"\t'arg' can be the address of an initrd image\n"
#ifdef CONFIG_OF_FLAT_TREE
"\tWhen booting a Linux kernel which requires a flat device-tree\n"
"\ta third argument is required which is the address of the of the\n"
"\tdevice-tree blob. To boot that kernel without an initrd image,\n"
"\tuse a '-' for the second argument. If you do not pass a third\n"
"\ta bd_info struct will be passed instead\n"
#endif
);
U_BOOT_CMD(//bootm命令
bootm, CFG_MAXARGS, 1, do_bootm,
"bootm - boot application image from memory\n",
"[addr [arg ...]]\n - boot application image stored in memory\n"
"\tpassing arguments 'arg ...'; when booting a Linux kernel,\n"
"\t'arg' can be the address of an initrd image\n"
#ifdef CONFIG_OF_FLAT_TREE
"\tWhen booting a Linux kernel which requires a flat device-tree\n"
"\ta third argument is required which is the address of the of the\n"
"\tdevice-tree blob. To boot that kernel without an initrd image,\n"
"\tuse a '-' for the second argument. If you do not pass a third\n"
"\ta bd_info struct will be passed instead\n"
#endif
);
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函数
#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命令,其定义如下:
[plain]
view plaincopyprint?
U_BOOT_CMD(//bootm命令
bootm, CFG_MAXARGS, 1, do_bootm,
"bootm - boot application image from memory\n",
"[addr [arg ...]]\n - boot application image stored in memory\n"
"\tpassing arguments 'arg ...'; when booting a Linux kernel,\n"
"\t'arg' can be the address of an initrd image\n"
#ifdef CONFIG_OF_FLAT_TREE
"\tWhen booting a Linux kernel which requires a flat device-tree\n"
"\ta third argument is required which is the address of the of the\n"
"\tdevice-tree blob. To boot that kernel without an initrd image,\n"
"\tuse a '-' for the second argument. If you do not pass a third\n"
"\ta bd_info struct will be passed instead\n"
#endif
);
U_BOOT_CMD(//bootm命令
bootm, CFG_MAXARGS, 1, do_bootm,
"bootm - boot application image from memory\n",
"[addr [arg ...]]\n - boot application image stored in memory\n"
"\tpassing arguments 'arg ...'; when booting a Linux kernel,\n"
"\t'arg' can be the address of an initrd image\n"
#ifdef CONFIG_OF_FLAT_TREE
"\tWhen booting a Linux kernel which requires a flat device-tree\n"
"\ta third argument is required which is the address of the of the\n"
"\tdevice-tree blob. To boot that kernel without an initrd image,\n"
"\tuse a '-' for the second argument. If you do not pass a third\n"
"\ta bd_info struct will be passed instead\n"
#endif
);
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函数
相关文章推荐
- 图解U-Boot:引导内核分析
- 图解U-Boot:引导内核分析
- 图解U-Boot:引导内核分析
- Exynos4412 Uboot 移植(四)—— Uboot引导内核过程分析
- Exynos4412 Uboot 移植(四)—— Uboot引导内核过程分析
- Exynos4412 Uboot 移植(四)—— Uboot引导内核过程分析
- u-boot2013.01 smdk2410 启动第二阶段分析之引导内核
- Linux0.11内核--启动引导代码分析bootsect.s
- Linux0.11内核--启动引导代码分析bootsect.s
- Exynos4412 Uboot 移植(四)—— Uboot引导内核过程分析
- U-Boot启动引导内核分析
- U-Boot启动引导内核分析(一)
- Linux0.11内核--启动引导代码分析bootsect.s
- U-Boot启动引导内核分析(二)
- U-Boot启动引导内核分析(三)
- U-boot引导内核流程分析
- 学习笔记--- U-BOOT从启动到引导内核过程分析
- 转: U-Boot启动引导内核分析
- 【嵌入式Linux学习七步曲之第三篇 Linux系统bootlaoder移植】U-BOOT全线移植分析系列之四--U-boot如何引导Linux内核启动?
- U-BOOT下使用bootm引导内核方法