1.1 项目简述
Das U-Boot,DENX开发的开源固件。
支持CPU架构:
Power架构、ARM、MIPS、X86及其它;
首页:
http://www.denx.de/wiki/U-Boot/ ,相关文档和源码可到该首页查看。特别是该网页下的文档,非常棒!
邮件列表:
源码下载:
FTP:ftp://ftp.denx.de/pub/u-boot/
Git:git://www.denx.de/git/u-boot.git
FAQ:
http://www.denx.de/wiki/view/DULG/FaqUBoot
了解U-Boot的入口:
首页:如欲从首页入手,请先查阅 DENX导览
源码下的Readme文件;
1.2 文档来源
手册(Manual):http://www.denx.de/wiki/view/DULG/Manual;
FAQ:http://www.denx.de/wiki/view/DULG/FaqUBoot;
U-Bootdoc:http://www.denx.de/wiki/U-Bootdoc/WebHome,一个预计用来放U-Boot文档的Wiki,目前只有简介;
文档(Document):http://www.denx.de/wiki/U-Boot/Documentation,存放所有相关文档的链接,包括上面素有资源;
1.3 版本记录
1.3.1 版本记录方式
目前U-Boot社区似乎正在酝酿U-Boot 2.x 版本,在那之前,U-Boot的版本记录方式不再采用三级数字累加的方式(如u-boot-1.1.6),而采用日期的方式,如下所示,u-boot-2010.03
VERSION = 2010
PATCHLEVEL = 03
SUBLEVEL =
EXTRAVERSION =
U_BOOT_VERSION = $(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)
另注:底下所有均以 u-boot-2010.03 为例。
1.3.2 U-Boot 2.x设计规划
Ø Support for very early debug output. This early output might be implemented as simple macros using fixed baudrate output, but whenever possible the standard interface (i. e. taking into account user settings like console port, baud rate, etc.) should be used.
Ø Relocation from ROM to the end of available DRAM (auto-detected instead of fixed link address).
Ø If memory (RAM, flash) consists of several banks, then U-Boot shall normally map these as contiguous regions.
Ø Simplistic device model. Hardware is initialized just before and used only for the time of operation. Hardware must be released and reset to a defined post-reset state after operation.
Ø Shall operate in polling IO mode. Interrupts may be used in few, carefully selected cases, if possible as a configurable option.
Ø Shall initialize only such peripherals used by U-Boot itself, and must deinitialize them after use. Note that especially the deinitialization is mandatory!
Ø Shall use C language whenever possible. Reduce assembly sources to the absolute minimum required (e.g. reset code, IRQ/Expt Shells)
Ø ... tbd ...
1.4 设计原则
Ø 1. Keep it Small
Ø 2. Keep it Fast
Ø 3. Keep it Simple
Ø 4. Keep it Portable
Ø 5. Keep it Configurable
Ø 6. Keep it Debuggable
Ø 7. Keep it Usable
Ø 8. Keep it Maintainable
Ø 9. Keep it Beautiful :严格遵守代码风格,坚持代码风格的干净;
Ø 10. Keep it Open
详细见:http://www.denx.de/wiki/U-Boot/DesignPrinciples
1.5 U-Boot特色
本章主要讨论U-Boot一些人性化设计,如脚本语言。
1.5.1 脚本语言
U-BOOT以一种类似Shell脚本的方式支持脚本语言。利用U-BOOT中的autoscr命令,可以在U-BOOT中运行“脚本”:首先在文本文件中输入需要执行的命令,然后用tools/mkimage封装,然后下载到开发板上,用autoscr执行就可以了。以下举例说明(注:本例来自网络):
Ø 编辑如下的脚本example.script。
echo
echo Network Configuration:
echo ----------------------
echo Target:
printenv ipaddr hostname
echo
echo Server:
printenv serverip rootpath
echo
Ø 用tools/mkimage对脚本进行封装。
# mkimage -A ARM -O linux -T script -C none -a 0 -e 0 -n "autoscr example script" -d example.script /tftpboot/example.img
Image Name: autoscr example script
Created: Wes Sep 8 01:15:02 2004
Image Type: ARM Linux Script (uncompressed)
Data Size: 157 Bytes = 0.15 kB = 0.00 MB
Load Address: 0x00000000
Entry Point: 0x00000000
Contents:
Image 0: 149 Bytes = 0 kB = 0 MB
Ø 在U-BOOT中 加载并执行这个脚本。
WT-ARM9# tftp 100000 /tftpboot/example.img
ARP broadcast 1
TFTP from server 10.0.0.2; our IP address is 10.0.0.99
Filename '/tftpboot/TQM860L/example.img'.
Load address: 0x100000
Loading: #
done
Bytes transferred = 221 (dd hex)
WT-ARM9# autoscr 100000
## Executing script at 00100000
Network Configuration:
----------------------
Target:
ipaddr=10.0.0.99
hostname=arm
Server:
serverip=10.0.0.2
rootpath=/nfsroot
WT-ARM9#
1.5.2 自动升级
Ø Problem:
Distribute Software Updates to customers
Ø Solution:
use cheap standard media like USB memory sticks
Ø Implementation
² Keep BOM (Versions, Timestamps etc.) in persistent memory (EEPROM etc.)
² When booting, check whether a USB memory stick is plugged in.
² If one is found:
1. If prepare.img is found load it into memory.
If it is valid then run it (always).
2. If preinst.img is found load it into memory.
If it is valid then run it. Update the EEPROM.
3. If firmware.img is found load it into memory.
If it is valid, burn it into FLASH and update the EEPROM.
4. If kernel.img is found load it into memory.
If it is valid, burn it into FLASH and update the EEPROM.
5. If app.img is found load it into memory.
If it is valid, burn it into FLASH and update the EEPROM.
6. If disk.img is found load it into memory.
If it is valid, burn it into FLASH and update the EEPROM.
7. If postinst.img is found load it into memory.
If it is valid then run it. Update the EEPROM.
1.5.3 standalone
standalone,即 “独立”,在这里指的是“独立程序”的意思。指的是:在u-boot命令行下,我们可以直接直接一些独立程序,当然,这些程序必须是以u-boot支持的二进制格式保存的。
examples\standalone 目录下包含了一些测试范例,这些测试范例在其支持的硬件平台上会随着u-boot一起编译成独立的程序,而后下载到硬件板子上执行。
hello word的示例请参考 5.12.1. "Hello World" Demo。
1.5.4 其他
Ø 支持WatchDog、LCD logo和状态指示功能等。如果系统支持启动画面(splash screen),U-BOOT启 动时,会把这个图像显示到LCD上,给用户更友好的感觉;
Ø 支持MTD和文件系统。U-BOOT作为一种强大的BootLoader,它不仅支持 MTD,而且可以在MTD基础上实现多种文件系统,比如cramfs、fat和jffs2等;
Ø 支持中断。由于传统的BootLoader都分为stage1和stage2,所以在stage2中添加中断处理服务十分困难,比如BLOB;而U-BOOT是把 两个部分放到了一起,所以添加中断服务程序就很方便;
Ø 详细的开发文档。由于大多数BootLoader都是开源项目,所以文档都不是很充分。U-BOOT的维护人员意识到了这个问题,充分记录了开发文档,所以它的移植要比BLOB等缺少文档的BootLoader方便;
1.6 本文档结构
第一章:项目概述;
第一章:配置与编译的方法;
第三章:U-Boot 的源码框架;
第四章开始:移植到各种平台;
最后是 参考文档、附录、联系方式。