U-boot-2014.04移植到MINI2440(2) Readme翻译分析

来源:互联网 发布:编程cs是什么意思 编辑:程序博客网 时间:2024/05/24 00:44

为什么要阅读README,我觉得是更加方便我们理解U-BOOT吧,尤其是在整体上的把握,当然,开发人员写了二十多万个字符,一共六千多行的README,里面有很多涉及到具体配置和使用的部分,其实这就是U-BOOT的使用说明书,这里着重关注几个部分部分,按照README的顺序,就当做英文阅读理解吧。

1.     总结(summary)

首先看看开发者对U-BOOT的定义:a boot loader for Embedded boards based onPowerPC, ARM, MIPS and several other processors, which can be installed in aboot ROM and used to initialize and test the hardware or to download and run applicationcode.这段话的意思是:U-BOOT是一个专门为例如PowerPC,ARM,MIPS等嵌入式主板设计的引导加载程序,它可以被安装在rom中被用来初始化和测试硬件或者下载运行应用代码。我像这段话很清晰的说明了U-BOOT的主要功能。

接着说的是U-BOOT的发展和LINUX是密切相关的,并且一些代码是借鉴了LINUX的,U-BOO命令使用相同的接口实现,很容易添加新的命令。

2.状态?(status)

    这部分说的是U-BOOT中已经存在的板级配置选项都被测试可用,使用了值得玩味的“working”这个词,很多已经用于实际生产系统。下一段有一句话很重要:In case of problems see the CHANGELOG and CREDITSfiles to find out

who contributedthe specific port. The boards.cfg file lists board maintainers.是说boards.cfg文件列出了各个板子的维护者,也就是我们配置开发板的时候要在这个文件下。再往下我们可以忽略,讲的命名,版本,源码获得方法等,直接跳过。

3.目录结构(Directoryhierarchy)

在上一篇帖子里有详细介绍,不赘述。

4.软件配置(SoftwareConfiguration)

这部分就是为什么我们在U-BOOT里面总是看到“CONFIG_”“CONFIG_SYS_”这样的宏,是因为防止dead code,采用的这种C语言宏定义预处理。后面说增加了一个配置工具,但是还需要做手工的配置,需要我们自己添加链接和编辑一些配置文件。

5.选择处理器架构和开发板类型(Selectionof Processor Architecture and Board Type)

    顾名思义,这部分解释了为什么我们在make前要执行makemini2440_config这个指令,文档中解释如下:For all supported boards thereare ready-to-use default

configurationsavailable; just type "make <board_name>_config".意思就是你要配置哪个开发板就执行"make<board_name>_config"

 6.配置相关(ConfigurationOptions)

这部分解释如下:配置取决于主板和CPU类型的组合,所有这样的信息都被保存在include/configs/<board_name>.h下面,我们在移植的时候需要修改mini2440.h下的配置,就是这个意思。后面解释了和LINUX内核配置选项命名规则相同,是为了更加容易的建立配置。下面介绍了很多必须的配置项:

cpu类型,板子型号,CPU子板类型,CPU内核类型,例如对应

Active  arm         arm920t        s3c24x0     mini2440         -                     mini2440      

后面还有很多,例如ARMoptions ,时钟配置,与LINUX内核的交互配置,网络,串口,IO,LCD,USB等等,每一项都讲了需要配置的话要注意些什么,我想有时候我们在配置U-BOOT出错的时候,可以再这里找找答案。

这里我们挑选出一些重要的出来解释下:

-ARM options

Select high exception vectors of the ARM core, e.g.,do not clear the V bit of the c1 register of CP15.

选择ARM内核的高位异常向量,不要清除CP15的C1的V位。

- CPU timer options

The frequency of the timer returned by get_timer().get_timer()must operate in milliseconds and this CONFIG option must be set to 1000.

计时器通过get_timer()函数返回值确定,必须以毫秒为单位,且CONFIG操作选项必需设置为1000.

- Boot Delay:     CONFIG_BOOTDELAY- in seconds

Delay before automatically booting the default image;

这就是自动加载内核之前那个延迟时间。

-CONFIG_BOOTARGS

This can be used to pass arguments to the bootmcommand. The value of CONFIG_BOOTARGS goes into the environment value"bootargs".

用于向bootm命令传递参数。CONFIG_BOOTARGS的值将会加入环境变量"bootargs"中。

- IP address:CONFIG_IPADDR

Define a default value for the IP address to use for thedefault Ethernet interface, in case this is not determined through e.g. bootp.

定义一个缺省的以太网IP地址。

在第3839行,有一句话:

BE CAREFUL! Any changes to the flash layout, and somechanges to the

source code willmake it necessary to adapt <board>/u-boot.lds*accordingly!

小心,任何对flash布局的改变以及源代码的改变都要根据u-boot.lds来做出改变。这是因为u-boot.lds是对U-BOOT代码进行的一个组装。

下面4535行往后是重点

Building the Software:

======================

 

Building U-Boot has been tested in several nativebuild environments

and in many different cross environments. Of course wecannot support

all possibly existing versions of cross developmenttools in all

(potentially obsolete) versions. In case of tool chainproblems we

recommend to use the ELDK (seehttp://www.denx.de/wiki/DULG/ELDK)

which is extensively used to build and test U-Boot.

 

If you are not using a native environment, it isassumed that you

have GNU cross compiling tools available in your path.In this case,

you must set the environment variable CROSS_COMPILE inyour shell.

Note that no changes to the Makefile or any othersource files are

necessary. For example using the ELDK on a 4xx CPU,please enter:

 

      $CROSS_COMPILE=ppc_4xx-

      $ exportCROSS_COMPILE

   

编译软件

U-BOOT已经被测试在很多“本地环境”和交叉环境下能够进行编译,当然我们并不能支持所有的交叉开发工具版本(指旧版本),如果遇到工具链问题,建议到http://www.denx.de/wiki/DULG/ELDK,他被广泛用于编译和测试U-BOOT。这里U-BOOT官方支持ELDK。

下面一段话是说,如果你要使用交叉编译工具,要在Makefile里面更改,然后它举了个例子,这里就像我们使用arm-linux-gcc编译器的时候一样,

$ CROSS_COMPILE=arm-linux-

 

第4564行:

U-Boot is intended to be simple to build. Afterinstalling the

sources you must configure U-Boot for one specificboard type. This

is done by typing:

 

      makeNAME_config

 

where "NAME_config" is the name of one of theexisting configu-

rations; see boards.cfg for supported names.

 

上面这段话说的是U-BOOT的趋势是支持更加简单的配置过程,例如你要配置一个开发板,就输入make NAME_config,这些具体的板子名称在boards.cfg下,我们打开看到boards里面是已经支持的板子。

第4588行:

Finally, type "make all", and you should getsome working U-Boot

images ready for download to / installation on yoursystem:

 

- "u-boot.bin" is a raw binary image

- "u-boot" is an image in ELF binary format

- "u-boot.srec" is in Motorola S-Recordformat

上面是说U-BOOT的生成的三个可用的image的格式,一个是原始的二进制,一个是ELF二进制的格式,最后一个是摩托罗拉S-RECORD格式,我们下载到开发板里面的是u-boot.bin。

 

4621行,非常重要!

    If the system board that you have is notlisted, then you will need

to port U-Boot toyour hardware platform. To do this, follow these

steps:

 

1.  Add a new configuration option for your boardto the toplevel

    "boards.cfg" file, using theexisting entries as examples.

    Follow the instructions there to keep theboards in order.

2.  Create a new directory to hold your boardspecific code. Add any

    files you need. In your board directory,you will need at least

    the "Makefile", a"<board>.c", "flash.c" and "u-boot.lds".

3.  Create a new configuration file"include/configs/<board>.h" for

    your board

3.  If you're porting U-Boot to a new CPU, thenalso create a new

    directory to hold your CPU specific code.Add any files you need.

4.  Run "make <board>_config"with your new name.

5.  Type "make", and you should get aworking "u-boot.srec" file

    to be installed on your target system.

6.  Debug and solve any problems that mightarise.

    [Of course, this last step is much harderthan it sounds.]

 

如果你的开发板没有在boards.cfg里面,那么你将需要配置U-BOOT来支持你的硬件平台,为此,需要按照以下步骤。其实上一篇帖子,正是按照这个步骤来做的。

第一步:在boards.cfg里面添加自己的开发板,必须按照现有的规则添加。

第二步:为自己的开发板建立一个目录,在目录下添加你需要的文件,这目录下必须要有以下几个文件,Makefile,<board>.c,flash.c和u-boot.lds

第三步:为你的建立一个新的配置文件“include/configs/<board>.h”

第四步:输入“make<board>_config”

第五步:make

第六步:调试并解决出现的问题(当然,这一步远比听起来的难很多)

最后一步官方文档还是挺幽默的,哈哈

 

第4686行:

Monitor Commands - Overview:

============================

 

go  - startapplication at address 'addr'

run - runcommands in an environment variable

bootm   - bootapplication image from memory

bootp    - bootimage via network using BootP/TFTP protocol

bootz   - bootzImage from memory

tftpboot- boot image via network using TFTP protocol

             and env variables "ipaddr" and"serverip"

             (and eventually "gatewayip")

tftpput - upload a file via network using TFTPprotocol

rarpboot- boot image via network using RARP/TFTPprotocol

diskboot- boot from IDE devicebootd   - boot default, i.e., run 'bootcmd'

loads     - loadS-Record file over serial line

loadb    - loadbinary file over serial line (kermit mode)

md - memorydisplay

mm       - memorymodify (auto-incrementing)

nm - memorymodify (constant address)

mw       - memorywrite (fill)

cp  - memory copy

cmp      - memorycompare

crc32    -checksum calculation

i2c - I2Csub-system

sspi       - SPIutility commands

base      - printor set address offset

printenv- print environment variables

setenv   - setenvironment variables

saveenv - save environment variables to persistentstorage

protect - enable or disable FLASH write protection

erase     - eraseFLASH memory

flinfo    - printFLASH memory information

nand     - NANDmemory operations (see doc/README.nand)

bdinfo  - printBoard Info structure

iminfo   - printheader information for application image

coninfo - print console devices and informations

ide - IDEsub-system

loop      -infinite loop on address range

loopw   -infinite write loop on address range

mtest    - simpleRAM test

icache   - enableor disable instruction cache

dcache  - enable ordisable data cache

reset      -Perform RESET of the CPU

echo      - echoargs to console

version - print monitor version

help      - printonline help

?    - alias for'help'

 

上面主要讲的都是U-BOOT的命令以及基本的用法,如果不清楚可以使用help或者?来查看。

   

第4743行:

Environment Variables:

======================

 

U-Boot supports user configuration using EnvironmentVariables which

can be made persistent by saving to Flash memory.

 

U-BOOT支持使用环境变量来配置,并且可以保存在FLASH里面。

 

Environment Variables are set using"setenv", printed using

"printenv", and saved to Flash using"saveenv". Using "setenv"

without a value can be used to delete a variable fromthe

environment. As long as you don't save the environmentyou are

working with an in-memory copy. In case the Flash areacontaining the

environment is erased by accident, a defaultenvironment is provided.

 

上面说的就是我们使用的setenv和saveenv来更改和保存环境变量。

 

Some configuration options can be set usingEnvironment Variables.

 

List of environment variables (most likely notcomplete):

 

  baudrate  - see CONFIG_BAUDRATE

 

  bootdelay       - see CONFIG_BOOTDELAY

 

  bootcmd  - see CONFIG_BOOTCOMMAND

 

  bootargs  - Boot arguments when booting an RTOS image

 

  bootfile    - Name of the image to load with TFTP

 

  ipaddr      - IP address; needed for tftpboot command

 

  loadaddr  - Default load address for commands like"bootp",

               "rarpboot", "tftpboot","loadb" or "diskboot"

 

  loads_echo     - see CONFIG_LOADS_ECHO

 

  serverip    - TFTP server IP address; needed fortftpboot command

 

  bootretry - see CONFIG_BOOT_RETRY_TIME

 

  bootdelaykey - see CONFIG_AUTOBOOT_DELAY_STR

 

  bootstopkey   - see CONFIG_AUTOBOOT_STOP_STR

 

    上面列举了一些环境变量,U-BOOT里面对大部分环境变量都做了解释,这里不一一赘述。

   

第5231行:

* packagecompressed binary image for U-Boot:

 

       mkimage -A ppc -O linux -T kernel -C gzip\

              -a 0 -e 0 -n "Linux Kernel Image"\

              -d linux.bin.gz uImage

 

 

The"mkimage" tool can also be used to create ramdisk images for use

with U-Boot,either separated from the Linux kernel image, or

combined into onefile. "mkimage" encapsulates the images with a 64

byte headercontaining information about target architecture,

operating system,image type, compression method, entry points, time

stamp, CRC32checksums, etc.

 

"mkimage"can be called in two ways: to verify existing images and

print the headerinformation, or to build new images.

 

In the first form(with "-l" option) mkimage lists the information

contained in theheader of an existing U-Boot image; this includes

checksumverification:

 

       tools/mkimage -l image

        -l ==> list image header information

 

The second form(with "-d" option) is used to build a U-Boot image

from a "datafile" which is used as image payload:

 

       tools/mkimage -A arch -O os -T type -Ccomp -a addr -e ep \

                    -n name -d data_file image

        -A ==> set architecture to 'arch'

        -O ==> set operating system to 'os'

        -T ==> set image type to 'type'

        -C ==> set compression type 'comp'

        -a ==> set load address to 'addr' (hex)

        -e ==> set entry point to 'ep' (hex)

        -n ==> set image name to 'name'

        -d ==> use image data from 'datafile'

上面说的上面呢,还记得我们编译LINUX的时候,生成的Image需要用mkimage来加一个头吗?这里介绍的就是这个工具的使用,编译好U-BOOT以后,在tools目录下面。我们使用的时候把它拷贝到Linux下的arch/arm/boot下,然后执行脚本./mkz2image,就会生成可以下载到开发板的uImage.这里面有很多的参数,上面都做了详细的介绍。

 

第5388行:

Boot Linux:

The "bootm" command is used to boot anapplication that is stored in

memory (RAM or Flash). In case of a Linux kernelimage, the contents

of the "bootargs" environment variable ispassed to the kernel as

parameters. You can check and modify this variableusing the

"printenv" and "setenv" commands

 

上面说的是U-BOOT从RAM和FLASH启动时候的操作方法,后面还有一ramdisk启动的方式,基本都是使用printenv来查看环境变量,再用saveenv进行设置。

 

README里面几乎包含了所有关于U-BOOT的内容,有时候遇到问题了,可以再这里找找,感觉读一遍,还是收获很大的,就看到这里吧。

1 0
原创粉丝点击