一:什么是U-boot?
U-boot全称是 Universal Boot Loader,即通用的Bootloader,是遵循GPL条款的开发源代码项目。
越来越多的人选择U-boot作为嵌入式系统的引导程序,它可以用来引导多种操作系统,支持多种CPU架构。
二:U-boot历史 ?
README内容所说:(create PPCBoot projec ,start from 8xxrom sources)
U-Boot的起源于德国DENX软件工程中心PPCOOT工程项目,后来增加对其他体系结构CPU的支持,比如ARM,x86,MIPS等等。
三:U-boot内容 ?
逻辑功能:
功能 说明 硬件相关的初始化 CPU、存储器 复制第二阶段代码到DRAM 重定位uboot到RAM 设置堆栈 堆栈设置 人机交互 第二阶段代码入口
一:硬件相关的初始化
- CPU
- 设置CPU工作模式(SVC32 mode): …. msr cpsr, r0….
- 设置向量表 …ldr pc, _undefined_instruction
- 关看门狗 …ldr r0, =pWTCON…
- 屏蔽中断 …ldr r0, =INTMSK…
- 设置时钟 …ldr r0, =CLKDIVN..
- 关闭cpu级别的MMU和cache …cpu_init_crit:…
- 存储器
- 初始化存储控制器 …lowlevel_init:…
二:复制第二阶段代码到DRAM
- 重定位uboot到RAM relocate: /* relocate U-Boot to RAM */
三:设置堆栈
- 堆栈设置 stack_setup: /* Set up the stack */
四:人机交互
- 第二阶段代码入口 ldr pc, _start_armboot ; void start_armboot (void)
文件目录层次:Directory Hierarchy: 内容来自 README
Directory Hierarchy:
====================
- board ===========> Board dependent files
- common===========>Misc architecture independent functions
- cpu===========>CPU specific files
- 74xx_7xx======>Files specific to Freescale MPC74xx and 7xx CPUs
- 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 architecture
- lib_avr32 ===========>Files generic to AVR32 architecture
- 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.
四:关于README的部分翻译 ?
(C) Copyright 2000 - 2009
(C)版权 2000-2009
See file CREDITS for list of people who contributed to this project.
“CREDITS”文件,这个列举了所有为uboot项目做出贡献的人。
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.
这是一个自由软件。你可以像自由软件基金会那样以GUN通用许可证的名义重新发布甚至修改它,既可以是第二个版本也可以是新版本。
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通用许可证的一份拷贝,如果不幸的话,没有收到,你可以给自由软件基金会写信。地址是:59 Temple Place, Suite 330, Boston, MA 02111-1307 USASummary:
概述:
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.
这个目录包含uboot所有的源代码,它是为基于powerpc,ARM,MIPS以及一些其他的处理器的开发板提供一段启动引导程序,它能被安装在启动只读存储器中,用来初始化和测试系统硬件,或者用来下载程序并运行。
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紧密相关:U-boot的部分源代码源于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.
我们倾注了大量的精力来使得这个软件更易于配置和扩展。例如:所有的显示在屏幕上的命令都是
以同样的调用接口来实现的,因此这使得添加新的命令更加简单,而不是永久性地添加一些很少使用的代码到monitor,比如一些硬件检测工具,你可以动态加载并且运行它。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. The MAINTAINERS file lists board .
如果存在问题,可以查阅CHANGELOG和 CREDITS这两个文件来找到是谁提供了相关的部分。MAINTAINERS这个文件列出了所有开发板的维护人员。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 [email protected]. There is also an archive of previous traffic on the mailing list - please search the archive before asking FAQ’s. Please see http://lists.denx.de/pipermail/u-boot and http://dir.gmane.org/gmane.comp.boot-loaders.u-boot
如果你想为u-boot项目出一份力,以防你在这方面疑问,你可以发送邮件到U-boot邮箱列表
[email protected],在那里有一些以前来往的邮件档案,请你在问问题之前先在这个档案里搜索一下。Where to get source code:
在哪里获得源代码:
The U-Boot source code is maintained in the git repository at git://www.denx.de/git/u-boot.git ; you can browse it online at http://www.denx.de/cgi-bin/gitweb.cgi?p=u-boot.git;a=summary
U-Boot源代码在git代码仓库里被维护:在 git://www.denx.de/git/u-boot.git 其实你也可以在线浏览 :在 http://www.denx.de/cgi-bin/gitweb.cgi?p=u-boot.git;a=summaryThe “snapshot” links on this page allow you to download tarballs of any version you might be interested in. Official releases are also available for FTP download from the ftp://ftp.denx.de/pub/uboot/ directory.
下面这个简短的链接允许你下载你感兴趣u-boot的任何版本。官方也会在FTP站点发布可用的版本 在这个目录: ftp://ftp.denx.de/pub/uboot/ 。Where we come from:
我们来自哪里:
- start from 8xxrom sources
最开始是源于 8xxrom项目的源代码- create PPCBoot project (http://sourceforge.net/projects/ppcboot)
为PowerPC处理器系列的开发板启动创建的项目- clean up code
清除一些不必要的代码- make it easier to add custom boards
使得增加一些常用的开发板变得更加容易- make it possible to add other [PowerPC] CPUs
使得添加一些除PowerPC之外的一些CPU系列成为可能- extend functions, especially:
扩展功能,尤其如下:
- Provide extended interface to Linux boot loader
为Linux启动引导提供扩展接口- S-Record download
支持S-Record 下载- network boot
支持网络启动- PCMCIA / CompactFlash / ATA disk / SCSI … boot
支持 PCMCIA/CompactFlash/ATA disk/SCSI 等方式启动- create ARMBoot project
创建ARMBoot项目- add other CPU families (starting with ARM)
添加其他CPU系列(从ARM系列开始)- create U-Boot project
创建U-Boot 项目- current project
当前的项目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:This is the README file for the U-Boot project.
官方为这个项目起名交 Das U-Boot。U-Boot这样的拼写方式应该被用在所有的文本中。比如:README,这是一个和U-Boot 项目有关的文件。
File names etc. shall be based on the string “u-boot”. Examples:
还用用在文件名的地方,拼写的形式应该是 u-boot 字符串的形式,比如:头文件 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_startVersioning:
版本:
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”.
补丁等级被用来表明 开发的特定阶段 ,官方发布的版本,补丁等级都是0。Directory Hierarchy:
目录层次结构
- api Machine/arch independent API for external apps
特定架构机器扩展应用使用独立的API- board Board dependent files
开发板相关的文件- common Misc architecture independent functions
独立于多种架构的功能模块- cpu CPU specific files
具体类型CPU的文件
- 74xx_7xx Files specific to Freescale MPC74xx and 7xx CPUs
Freescale MPC74xx and 7xx CPUs类型专用的文件- arm720t Files specific to ARM 720 CPUs
ARM 720 CPUs专用的文件- arm920t Files specific to ARM 920 CPUs
ARM 920 CPUs专用的文件- at91rm9200 Files specific to Atmel AT91RM9200 CPU
Atmel AT91RM9200 CPU专用的文件- imx Files specific to Freescale MC9328 i.MX CPUs
Freescale MC9328 i.MX CPUs专用的文件- s3c24x0 Files specific to Samsung S3C24X0 CPUs
Samsung S3C24X0 CPUs专用的文件- arm925t Files specific to ARM 925 CPUs
ARM 925 CPUs专用的文件- arm926ejs Files specific to ARM 926 CPUs
ARM 926 CPUs专用的文件- arm1136 Files specific to ARM 1136 CPUs
ARM 1136 CPUs专用的文件- at32ap Files specific to Atmel AVR32 AP CPUs
Atmel AVR32 AP CPUs专用的文件- blackfin Files specific to Analog Devices Blackfin CPUs
Analog Devices Blackfin CPUs专用的文件- i386 Files specific to i386 CPUs
i386 CPUs专用的文件- ixp Files specific to Intel XScale IXP CPUs
Intel XScale IXP CPUs专用的文件- leon2 Files specific to Gaisler LEON2 SPARC CPU
Gaisler LEON2 SPARC CPU 专用的文件- leon3 Files specific to Gaisler LEON3 SPARC CPU
Gaisler LEON3 SPARC CPU 专用的文件- mcf52x2 Files specific to Freescale ColdFire MCF52x2 CPUs
Freescale ColdFire MCF52x2 CPUs 专用的文件- mcf5227x Files specific to Freescale ColdFire MCF5227x CPUs
Freescale ColdFire MCF5227x CPUs 专用的文件- mcf532x Files specific to Freescale ColdFire MCF5329 CPUs
Freescale ColdFire MCF5329 CPUs 专用的文件- mcf5445x Files specific to Freescale ColdFire MCF5445x CPUs
Freescale ColdFire MCF5445x CPUs 专用的文件- mcf547x_8x Files specific to Freescale ColdFire MCF547x_8x CPUs
Freescale ColdFire MCF547x_8x CPUs 专用的文件- mips Files specific to MIPS CPUs
MIPS CPUs 专用的文件- mpc5xx Files specific to Freescale MPC5xx CPUs
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
通用的设备驱动程序- examples Example code for standalone applications, etc.
一些单独的应用程序代码- fs Filesystem code (cramfs, ext2, jffs2, etc.)
文件系统代码(cramfs,ext2,jffs2,etc.)- include Header Files
头文件- lib_arm Files generic to ARM architecture
ARM架构类的文件- lib_avr32 Files generic to AVR32 architecture
- lib_blackfin Files generic to Blackfin architecture
- lib_generic Files generic to all architectures
- lib_i386 Files generic to i386 architecture
- lib_m68k Files generic to m68k architecture
- lib_microblaze Files generic to microblaze architecture
- lib_mips Files generic to MIPS architecture
- lib_nios Files generic to NIOS architecture
- lib_nios2 Files generic to NIOS2 architecture
- lib_ppc Files generic to PowerPC architecture
- lib_sh Files generic to SH architecture
- lib_sparc Files generic to SPARC architecture
- libfdt Library files to support flattened device trees
- net Networking code
网络相关代码post Power On Self Test
rtc Real Time Clock drivers
实时时钟驱动- tools Tools to build S-Record or U-Boot images, etc.
构建uboot的工具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_”.
配置 OPTIONS: 它是可用被用户选择,以 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 “CONFIG_SYS_”.
配置 SETTINGS:这些是硬件依赖的,如果你不知道自己在干什么,最好不要修改他。 以CONFIG_SYS_开头命名。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.
以后我们会添加一些配置工具,尽可能地和配置配置内核相似甚至相同。但是现在,我们不得不手动配置,这意味着会创建一些新的符号链接以及编辑一些配置文件。在这里,我们以TQM8xxL开发板为例:
Selection of Processor Architecture and Board Type:选择处理器架构和开发板类型:
For all supported boards there are ready-to-use default configurations available; just type
“make _config”.
所有支持的开发板都一个默认的配置变量:make _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.
对于一些大众平台,你需要具体说明cpu的类型,比如:make cogent_mpc8xxx_config. 你需要根据cogent/README文件里面的说明来配置 cogent 目录。Configuration Options:
配置选项:
Configuration depends on the combination of board and CPU type; all such information is kept in a configuration file “include/configs/.h”.
所有的配置选项都依赖于开发板和CPU所关联的模块,所有的配置信息都保存在 /include/configs/.h 中。
Example: For a TQM823L module, all configuration settings are in “include/configs/TQM823L.h”.
比如:对于 TQM823L 开发板模块,所有配置设置都在 “include/configs/TQM823L.h”.Many of the options are named exactly as the corresponding Linux kernel configuration options. The intention is to make it easier to build a config tool - later.
大部分u-boot配置选项的命名和Linux 内核配置严格上是相对应的。这样做的目的是为以后使得构建配置工具变得更加容易。接下去的内容待续………