U-Boot的特性和优点不在这里多讲,也不会讲,自己在网上找吧,毕竟我也是初学者。作为初学者,我想没必要纠结要哪种Bootloader,用个大家都在用的,百度/google最容易到手的就可以了。而对我,手里的资料,看的比较多的也就是U-Boot。如果想对U-Boot有比较深的认识,看顶层的README文件是个不错的选择。由于自己英语较差,看了几百行实在看不下去,太累了。但还是推荐大家有时间就看看,还能学习下英语不是。
对U-Boot编译过程的充分或者一定的理解是有对于我们整个移植过程顺利进行的。通过这个分析的过程,将会对U-Boot形成一个整体的框架,也能学习Makefile的一些用法。原先,自己对整个U-Boot的移植感到茫然甚至有点畏惧(U-BOOT和linux内核算是我这个新人接触过的唯一的大型的工程了,看着一级级的文件目录,不清楚其内在的联系真的让人崩溃),但按照资料分析了下编译过程,大脑里有了个比较清晰的认识。
在分析前,先了解整个源码的结构,这个目录序列是2010.06发布的版本。
/arch 架构------------平台相关
/arm ARM架构,这里只是做了这个示例
/cpu 具体芯片体系
/arm920t Files specific to ARM 920 CPUs
...................................
/lib ARM架构库文件
.........
/board 板级支持包--------开发板相关
---------------------------上面就是平台、开发板相关,下面是一些通用函数、说明和工具等等--------------------------------
/api Machine/arch independent API for external apps
/common Misc architecture independent functions
/include Header Files
/lib Files generic to all architectures
/disk Code for disk drive partition handling
/drivers Commonly used device drivers
/fs Filesystem code (cramfs, ext2, jffs2, etc.)
/net Networking code
/post Power On Self Test/rtc Real Time Clock drivers
/nand_spl 从NAND Flash启动支持程序
/onenand_ipl 这个没有找到相关说明,但从字面意思应该是单片NAND Flash的一些支持程序,在内核中也有单独列出onenandflash的情况,不了解原因
/examples Example code for standalone applications, etc
/doc Documentation (don't expect too much)
/tools Tools to build S-Record or U-Boot images, etc.
整个移植要做的就是对平台相关和开发板相关一些文件的操作。整理下目录可以分为4类:
1、平台和开发板相关;
2、通用的函数;
3、通用的设备驱动程序;
4、U-Boot工具、示例程序和文档。
U-Boot的配置过程(以smdk2410为例)
在具体阅读前需要了解真个编译操作是否有特殊要求,搜索顶层README文件中make,得到下面一段话:
////////////////////////////在原文2855行////////////////////////////////////////////////////////
U-Boot is intended to be simple to build. After installing the
sources you must configure U-Boot for one specific board type. This
is done by typing:
make NAME_config
where "NAME_config" is the name of one of the existing configu-
rations; see the main Makefile for supported names.
Note: for some board special configuration names may exist; check if
additional information is available from the board vendor; for
instance, the TQM823L systems are available without (standard)
or with LCD support. You can select such additional "features"
when choosing the configuration, i. e.
make TQM823L_config
- will configure for a plain TQM823L, i. e. no LCD support
make TQM823L_LCD_config
- will configure for a TQM823L with U-Boot console on LCD
etc.
Finally, type "make all", and you should get some working U-Boot
images ready for download to / installation on your system:
- "u-boot.bin" is a raw binary image
- "u-boot" is an image in ELF binary format
- "u-boot.srec" is in Motorola S-Record format
要完成整个编译过程要先执行“make NAME_config”,再执行"make all"。对于smdk2410开发板,就是 make smdk2410_config。
首先查看顶层Makefile文件:
找到平台相关配置——从481行开始到3687行都是平台相关的配置命令,从3688到最后是例程和工具的编译。
106 SRCTREE := $(CURDIR)
......
111 MKCONFIG := $(SRCTREE)/mkconfig
export MKCONFIG
3051 smdk2410_config : unconfig
@$(MKCONFIG) $(@:_config=) arm arm920t smdk2410 samsung s3c24x0
实际上就执行了如下命令
./mkconfig smdk2410 arm arm920t smdk2410 samsung s3c24x0
那么就看mkconfig文件,做了哪些工作: U-Boot移植(二)——U-Boot编译过程分析(2)