学习嵌入式中的bootloader时,最常用的就是u-boot了,u-boot一般都是稍微修改或者不改就能用。
但是作为一个非常非常优秀的单片机程序,我认为还是有必要深入学习u-boot。
读一读源码中的README,受益匪浅,部分英语不好的朋友,可以跟着我的文章一起看看README。
#
# (C) Copyright 2000 - 2005(版权所有2000 - 2005年)
# Wolfgang Denk, DENX Software Engineering, wd@denx.de.
#
# See file CREDITS for list of people who contributed to this
# project.(#请参阅文件CREDITS,以获得对该项目做出贡献的人员名单。)
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 2 of
# the License, or (at your option) any later version.(#本程序为免费软件;您可以重新分发它或根据自由软件基金会发布的GNU通用公共许可证条款修改它;无论是版本2的许可证,或(在您的选择)任何更高的版本。)
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.(#发布这个程序是希望它会有用,但不提供任何保修;甚至没有隐含的保证对特定用途的适销性或适用性。详情请参阅#GNU通用公共许可证。)
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
# MA 02111-1307 USA
#
#您应该已经收到一份GNU通用公共许可证的副本与本程序一起;如果没有,写信给自由软件基金会
Summary:简介:
========
This directory contains the source code for U-Boot, a boot loader for
Embedded boards based on PowerPC, ARM, MIPS and several other
processors, which can be installed in a boot ROM and used to
initialize and test the hardware or to download and run application
code.该目录包含U-Boot的源代码,U-Boot是基于PowerPC、ARM、MIPS和其他几个处理器的嵌入式板的引导加载程序,可以安装在引导ROM中,用于初始化和测试硬件,或下载和运行应用程序代码。
The development of U-Boot is closely related to Linux: some parts of
the source code originate in the Linux source tree, we have some
header files in common, and special provision has been made to
support booting of Linux images.U-Boot的开发与Linux密切相关:部分源代码来源于Linux源代码树,我们有一些共同的头文件,并且做了专门的规定来支持Linux映像的引导。
Some attention has been paid to make this software easily
configurable and extendable. For instance, all monitor commands are
implemented with the same call interface, so that it's very easy to
add new commands. Also, instead of permanently adding rarely used
code (for instance hardware test utilities) to the monitor, you can
load and run it dynamically.为了使该软件易于配置和扩展,本文做了一些工作。例如,所有监视器命令都使用相同的调用接口实现,因此很容易添加新命令。另外,您可以动态加载并运行它,而不是永久地向监视器添加很少使用的代码(例如硬件测试实用程序)。
Status:状态:
=======
In general, all boards for which a configuration option exists in the
Makefile have been tested to some extent and can be considered
"working". In fact, many of them are used in production systems.一般来说,所有在Makefile中存在配置选项的板子都经过了某种程度的测试,可以认为是“工作”的。事实上,它们中的许多被用于生产系统。
In case of problems see the CHANGELOG and CREDITS files to find out
who contributed the specific port.如果出现问题,请查看CHANGELOG和CREDITS文件,以找出谁贡献了特定的端口。
Where to get help:从哪里获得帮助:
==================
In case you have questions about, problems with or contributions for
U-Boot you should send a message to the U-Boot mailing list at
<u-boot-users@lists.sourceforge.net>. There is also an archive of
previous traffic on the mailing list - please search the archive
before asking FAQ's. Please see
http://lists.sourceforge.net/lists/listinfo/u-boot-users/
如果你对U-Boot有疑问、问题或贡献,你应该向U-Boot邮件列表<u-boot-users@lists.sourceforge.net>发送消息。在邮件列表中也有一个以前的流量存档-请在问FAQ(常问的问题)之前搜索存档。请参见http://lists.sourceforge.net/lists/listinfo/u-boot-users/
Where we come from:我们来自哪里:
===================
- start from 8xxrom sources-从8xxrom源开始创建
- create PPCBoot project (http://sourceforge.net/projects/ppcboot)PPCBoot项目(http://sourceforge.net/projects/ppcboot)
- clean up code清理代码
- make it easier to add custom boards-使它更容易添加定制板
- make it possible to add other [PowerPC] CPUs
- extend functions, especially:-允许添加其他[PowerPC] cpu扩展功能,特别是:
* Provide extended interface to Linux boot loader*提供Linux引导加载程序的扩展接口
* S-Record downloadS-Record文件的下载
* network boot网络引导
* PCMCIA / CompactFLash / ATA disk / SCSI ... bootPCMCIA / CompactFLash / ATA磁盘/ SCSI…引导
- create ARMBoot project (http://sourceforge.net/projects/armboot)创建ARMBoot项目
- add other CPU families (starting with ARM)添加其他CPU系列(从ARM开始)
- create U-Boot project (http://sourceforge.net/projects/u-boot)创建U-Boot项目
Names and Spelling:名称和拼写:
===================
The "official" name of this project is "Das U-Boot". The spelling
"U-Boot" shall be used in all written text (documentation, comments
in source files etc.). Example:这个项目的“官方”名称是“Das U-Boot”。拼写“U-Boot”应使用在所有书面文本(文档,源文件中的注释等)。例子:
This is the README file for the U-Boot project.
File names etc. shall be based on the string "u-boot". Examples:这是U-Boot项目的README文件。文件名等应基于字符串“u-boot”。例:
include/asm-ppc/u-boot.h
#include <asm/u-boot.h>
Variable names, preprocessor constants etc. shall be either based on
the string "u_boot" or on "U_BOOT". Example:变量名、预处理器常量等必须基于字符串“u_boot”或“u_boot”。例子:
U_BOOT_VERSION u_boot_logo
IH_OS_U_BOOT u_boot_hush_start
Versioning:版本控制:
===========
U-Boot uses a 3 level version number containing a version, a
sub-version, and a patchlevel: "U-Boot-2.34.5" means version "2",
sub-version "34", and patchlevel "4".U-Boot使用3级版本号,包括版本号、子版本号和补丁级别:“U-Boot-2.34.5”表示版本2、子版本34、补丁级别4。
The patchlevel is used to indicate certain stages of development
between released versions, i. e. officially released versions of
U-Boot will always have a patchlevel of "0".补丁级别用来表示发布版本之间的某个开发阶段,即U-Boot的官方发布版本总是会有一个“0”的补丁级别。
Directory Hierarchy:目录层次结构:
====================
- board Board dependent files单板依赖文件
- common Misc architecture independent functions通用异构架构独立功能
- cpu CPU specific filesCPU专用文件
- 74xx_7xx Files specific to Freescale MPC74xx and 7xx CPUs飞思卡尔MPC74xx和7xx CPUsarm720t ARM 720专用文件
- arm720t Files specific to ARM 720 CPUs
- arm920t Files specific to ARM 920 CPUs
- at91rm9200 Files specific to Atmel AT91RM9200 CPU
- imx Files specific to Freescale MC9328 i.MX CPUs
- s3c24x0 Files specific to Samsung S3C24X0 CPUs
- arm925t Files specific to ARM 925 CPUs
- arm926ejs Files specific to ARM 926 CPUs
- arm1136 Files specific to ARM 1136 CPUs
- at32ap Files specific to Atmel AVR32 AP CPUs
- i386 Files specific to i386 CPUs
- ixp Files specific to Intel XScale IXP CPUs
- mcf52x2 Files specific to Freescale ColdFire MCF52x2 CPUs
- mips Files specific to MIPS CPUs
- mpc5xx Files specific to Freescale MPC5xx CPUs
- mpc5xxx Files specific to Freescale MPC5xxx CPUs
- mpc8xx Files specific to Freescale MPC8xx CPUs
- mpc8220 Files specific to Freescale MPC8220 CPUs
- mpc824x Files specific to Freescale MPC824x CPUs
- mpc8260 Files specific to Freescale MPC8260 CPUs
- mpc85xx Files specific to Freescale MPC85xx CPUs
- nios Files specific to Altera NIOS CPUs
- nios2 Files specific to Altera Nios-II CPUs
- ppc4xx Files specific to AMCC PowerPC 4xx CPUs
- pxa Files specific to Intel XScale PXA CPUs
- s3c44b0 Files specific to Samsung S3C44B0 CPUs
- sa1100 Files specific to Intel StrongARM SA1100 CPUs
- disk Code for disk drive partition handling磁盘驱动器分区处理代码
- doc Documentation (don't expect too much)文档(不要期望太多)
- drivers Commonly used device drivers常用的设备驱动程序
- dtt Digital Thermometer and Thermostat drivers数字温度计和温控器驱动器
- examples Example code for standalone applications, etc.独立应用程序的示例代码,等
- include Header Files包含头文件
- lib_arm Files generic to ARM architectureARM架构通用文件
- lib_avr32 Files generic to AVR32 architectureVR32架构通用文件
- lib_generic Files generic to all architectures
- lib_i386 Files generic to i386 architecture
- lib_m68k Files generic to m68k architecture
- lib_mips Files generic to MIPS architecture
- lib_nios Files generic to NIOS architecture
- lib_ppc Files generic to PowerPC architecture
- net Networking code网络代码-
- post Power On Self Test上电自检
- rtc Real Time Clock drivers实时时钟驱动程序
- tools Tools to build S-Record or U-Boot images, etc.建立S-Record或U-Boot映像的工具
Software Configuration:软件配置:
=======================
Configuration is usually done using C preprocessor defines; the
rationale behind that is to avoid dead code whenever possible.配置通常使用C预处理器定义完成;其背后的基本原理是尽可能避免死代码。
There are two classes of configuration variables:有两类配置变量:
* Configuration _OPTIONS_:
These are selectable by the user and have names beginning with
"CONFIG_".用户可以选择它们,名称以“CONFIG”开头。
* Configuration _SETTINGS_:
These depend on the hardware etc. and should not be meddled with if
you don't know what you're doing; they have names beginning with
"CFG_".这些取决于硬件等,如果你不知道自己在做什么,就不应该干预;它们的名字以“CFG_”开头。
Later we will add a configuration tool - probably similar to or even
identical to what's used for the Linux kernel. Right now, we have to
do the configuration by hand, which means creating some symbolic
links and editing some configuration files. We use the TQM8xxL boards
as an example here.稍后我们将添加一个配置工具—可能与Linux内核使用的配置工具类似,甚至相同。现在,我们必须这么做手动进行配置,这意味着创建一些符号链接和编辑一些配置文件。这里我们以TQM8xxL板为例。
Selection of Processor Architecture and Board Type:处理器架构和单板类型的选择:
---------------------------------------------------
For all supported boards there are ready-to-use default
configurations available; just type "make <board_name>_config".对于所有支持的板,都有现成的默认配置可用;只需输入“make <board_name>_config”。
Example: For a TQM823L module type:示例:对于TQM823L模块类型:
cd u-boot
make TQM823L_config
For the Cogent platform, you need to specify the cpu type as well;
e.g. "make cogent_mpc8xx_config". And also configure the cogent
directory according to the instructions in cogent/README.对于Cogent平台,您还需要指定cpu类型;如。“使cogent_mpc8xx_config”。并根据cogent/README中的说明配置cogent目录。