uboot移植,编译及环境变量,启动等方面---from README

来源:互联网 发布:microsoft fix it官网 编辑:程序博客网 时间:2024/05/21 10:24

<!--@page { margin: 2cm }P { margin-bottom: 0.21cm }A:link { so-language: zxx }-->

编译软件:

-----------------

u-boot已经在各种不同的交叉环境的各种编译环境中进行了测试,由于我们无法支持所有版本的目前所有的交叉开发工具,因此有可能出现一些工具链问题,所以推荐使用ELDK(http://www.denx.de/wiki/DULG?ELDK),  此工具广泛用于编译和测试U-Boot.

 

 假设在你的路径中有可用的GNU交叉编译工具,而没有使用nativeenvironment,这种情况下,你必须在shell中设置环境变量CROSS_COMPILE。注意不要对Makefile或其它需要的源文件进行修改。例如在4xxCPU上使用ELDK,请输入:

  $CROSS_COMPILE=ppc_4xx-

  $export CROSS_COMPILE

 

注意:如果你想产生windows版本的实用程序,你可以使用MinGW工具链中的工具目录。设置MinGW工具链的HOST工具,然后执行“maketools”.如:

$ makeHOSTCC=i586-mingw32msvc-gcc HOSTSTRIP=i586-mingw32msvc-strip tools

 

tools/mkimage.exe将被创建,然后可以在windows中运行。

 

   U-boot的目的是想让编译简单化。在安装完源码后你必须为你指定的开发板类型配置u-boot.这个是通过如下语句完成的:

   makeNAME_config

 

这儿的NAME_config为已存的配置名称。可以查看顶层makefile获取支持的这些名称。

注意:可能对某些板需要进行更特殊的配置。你可以从开发板厂商那儿确认是否有些其它可用的信息。如TQM823L系统是有LCD支持的(标准是没有LCD支持)。当选择配置时,你可以选择这些额外的“features”,如:

   makeTQM823L_config //此配置无LCD支持

 

makeTQM823L_LCD_config //LCD支持

 

最后,输入“makeall”,你可以得到某些uboot镜像,可以将这些镜像下载安装到你的系统上。

-”u-boot.bin”是最原始的二进制镜像

-”u-boot”ELF格式的镜像

-”u-boot.srec”motorolaS-Record格式的镜像

默认此编译是在本地进行的,编译后生成的文件是保存在源码目录中,有两种方法可以改变这种存放路径使其存放在外面的目录中:

1添加O= make命令行后:

make O=/tmp/build distclean

make O=/tmp/build NAME_config

make O=/tmp/build all

2设置环境变量BHUILD_DIR来指向所指定的存储位置:

export BUILD_DIR=/tmp/build

make distclean

make NAME_config

make all

 

注意:命令行O=设置会优先级高于BUILD_DIR环境变量。

 

必须注意一点,那就是Makefile认为你是使用GNU make,因此例如在NetBSD中你可能需要使用”gmake”而不是“make”

 

如果你的开发板不在列表的范围之崩溃,那么你需要给uboot提供你板子的硬件平台的接口。可以按下面步骤进行:

.在顶层的”Makefile”和”MAKEALL”脚本中按照例子中的接口加入你开发板的一些配置项。需要注意这儿及其它地方,开发板和其它的名字都是按字母顺序列出来的。一定要保持这个顺利。

.创建一个新的目录来存放你开发板的代码。你可以在这儿添加你自己所需要的一些文件,在你的开发板目录中,你需要至少这么几个文件:”Makefile”,“<board>.c”,”flash.c”和”u-boot.lds”.

3.为你的开发板创建一个新的配置文件“include/configs/<board>.h”

4.如果你把uboot接口提供给一个新的CPU,那你也要创建一个新的目录来存放你的CPU方面的代码。可以在这个目录中添加你所需要的文件。

5.运行”make<board>_config”<board>为你的新板名称

6.输入”make”,然后你将得到一个“u-boot.srec”文件

7.调试和解决可能会产生的各种问题(可能会很复杂)

 

 

uboot修改测试,如给新硬件提供新接口等:

--------------------

如果你已经修改了uboot源码(如添加了一个新的board或者支持了一个新的设备,如一个新的CPU等等),你需要将此添加的信息反馈给其它开发人员。反馈信息通常是通过”patch”补丁的形式提供,如通过diff得到的内容。

 

但是在你提交这个补丁之前,必须确保你的修改不会破坏当前的代码。至少必须确保所有uboot支持的开发板编译不会出现任何编译警告,要实现这点,可以运行”MAKEALL”脚本,此脚本将为所有支持的系统配置和编译uboot,值得提醒的是,可能需要等待一段时间。你可以通过环境变量CROSS_COMPILE来选择使用什么交叉编译器来编译此脚本,如使用ELDK交叉编译工具的话,输入:

CROSS_COMPILE=ppc_8xx-MAKEALL

或者要在一般的PowerPC系统编译的话,可以输入: 

CROSS_COMPILE='' MAKEALL

 

当使用MAKEALL脚本时,其缺省的行为是想在源码目录中编译uboot。这个编译存放的路径可以通过设置环境变量BUILD_DIR来改变。另外,对于每个目标板的编译,MAKEALL脚本在<sourcedir>/LOG目录下保存了两个日志文件(<target>.ERR<target>.MAKEALL),此log目录路径可以通过设置环境变量MAKEALL_LOGDIR来设置。如:

  exportBUILD_DIR=/tmp/build

export MAKEALL_LOGDIR=/tmp/log

CROSS_COMPILE=ppc_8xx- MAKEALL

 

以上的设置将使编译的目标结果保存在/tmp/build中,日志保存在/tmp/log中,在整个编译过程中源码树依旧不变(即源码树内容没有被改变)。

 

 

下面请查看”uboot接口向导”

-------------------------------

管理命令预览:

-----------

go-start application at address 'addr'

run-run commands in an environment variable

bootm-boot application image from memory

bootp-boot image via network using BootP/TFTP protocol

tftpboot-boot image via network using TFTP protocol

and env variables "ipaddr" and "serverip"

(and eventually "gatewayip")

rarpboot-boot image via network using RARP/TFTP protocol

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

loads-load S-Record file over serial line

loadb-load binary file over serial line (kermit mode)

md-memory display

mm-memory modify (auto-incrementing)

nm-memory modify (constant address)

mw-memory write (fill)

cp-memory copy

cmp-memory compare

crc32-checksum calculation

i2c-I2C sub-system

sspi-SPI utility commands

base-print or set address offset

printenv-print environment variables

setenv-set environment variables

saveenv- save environment variables to persistent storage

protect- enable or disable FLASH write protection

erase-erase FLASH memory

flinfo-print FLASH memory information

bdinfo-print Board Info structure

iminfo-print header information for application image

coninfo- print console devices and informations

ide-IDE sub-system

loop-infinite loop on address range

loopw-infinite write loop on address range

mtest-simple RAM test

icache-enable or disable instruction cache

dcache-enable or disable data cache

reset-Perform RESET of the CPU

echo-echo args to console

version- print monitor version

help-print online help

?-alias for 'help'

 

 

管理命令 - 详细描述

-------------

环境变量:

-------------

Uboot支持用户使用环境变量来进行配置,此环境变量会持久地保存在flash存储器中。

 

环境变量通过setenv”来设置,打印时使用printenv”,保存到flash时使用saveenv”setenv“后若无任何值,可以用来删除一个变量。万一flash中的环境变量不小被删除,系统会提供一个默认的环境变量。

 

  使用环境变量可以对某些配置选项进行设置

下面列出了各种环境变量(可能不是完整的):

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

bootm_low- Memory range availablefor image processing in the bootm

command can be restricted. This variable is given as

ahexadecimal number and defines lowest address allowed

for use by the bootm command. See also "bootm_size"

environment variable. Address defined by "bootm_low" is

also the base of the initial memory mapping for the Linux

kernel -- see the description of CONFIG_SYS_BOOTMAPSZ.

bootm_size- Memory range availablefor image processing in the bootm

command can be restricted. This variable is given as

ahexadecimal number anddefines the size of the region

allowed for use by the bootmcommand. See also "bootm_low"

environment variable.

updatefile- Location of the software updatefile on a TFTP server, used

bythe automatic software update feature. Please refer to

documentation in doc/README.updatefor more details.

autoload- if set to "no" (any string beginning with 'n'),

"bootp" will just load perform a lookup of the

configuration from the BOOTP server, but not try to

load any image using TFTP

autostart - if set to "yes",an image loaded using the "bootp",

"rarpboot", "tftpboot" or "diskboot"commands will

beautomatically started (by internally calling

"bootm")

Ifset to "no", astandalone image passed to the

"bootm" command will be copied to the load address

(and eventually uncompressed), but NOT be started.

This can be used to load and uncompress arbitrary

data.

i2cfast- (PPC405GP|PPC405EP only)

ifset to 'y' configures Linux I2C driver for fast

mode (400kHZ). This environment variable is used in

initialization code. So, for changes to be effective

itmust be saved and board must be reset.

initrd_high- restrict positioningof initrd images:

Ifthis variable is not set, initrd images will be

copied to the highest possibleaddress in RAM; this

isusually what you want since it allows for

maximum initrd size. If for some reason you want to

make sure that the initrd image is loaded below the

CONFIG_SYS_BOOTMAPSZ limit, you can set this environment

variable to a value of "no" or "off" or "0".

Alternatively, you can set it to a maximum upper

address to use (U-Boot will still check that it

does not overwrite the U-Boot stack and data).

For instance, when you have a system with 16 MB

RAM, and want to reserve 4 MB from use by Linux,

you can do this by adding "mem=12M" to the value of

the "bootargs" variable. However, now you must make

sure that the initrd image is placed in the first

12 MB as well - this can be done with

setenv initrd_high 00c00000

Ifyou set initrd_high to 0xFFFFFFFF, this is an

indication to U-Boot that all addresses are legal

for the Linux kernel, including addresses in flash

memory. In this case U-Boot will NOT COPY the

ramdisk at all. This may be useful to reduce the

boot time on your system, but requires that this

feature is supported by your Linux kernel.

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 for tftpboot command

bootretry- see CONFIG_BOOT_RETRY_TIME

bootdelaykey- see CONFIG_AUTOBOOT_DELAY_STR

bootstopkey- see CONFIG_AUTOBOOT_STOP_STR

ethprime- When CONFIG_NET_MULTI is enabled controls which

interface is used first.

ethact- When CONFIG_NET_MULTI is enabled controls which

interface is currently active. For example you

can do the following

=>setenv ethact FEC ETHERNET

=>ping 192.168.0.1 # traffic sent on FEC ETHERNET

=>setenv ethact SCC ETHERNET

=>ping 10.0.0.1 # traffic sent on SCC ETHERNET

ethrotate- When set to "no" U-Boot does not go throughall

available network interfaces.

Itjust stays at the currently selected interface.

netretry- When set to "no" each network operation will

either succeed or fail without retrying.

When set to "once" the network operation will

fail when all the available network interfaces

are tried once without success.

Useful on scripts which control the retry operation

themselves.

npe_ucode- set load address for the NPE microcode

tftpsrcport- If this is set, the value is used for TFTP's

UDP source port.

tftpdstport- If this is set, the value is used for TFTP's UDP

destination port instead of the Well Know Port 69.

tftpblocksize - Block size to use for TFTP transfers; if not set,

weuse the TFTP server's default block size

tftptimeout-Retransmission timeout for TFTP packets (in milli-

seconds, minimum value is 1000 = 1 second). Defines

when a packet is considered to be lost so it has to

beretransmitted. The default is 5000 = 5 seconds.

Lowering this value may make downloads succeed

faster in networks with high packet loss rates or

with unreliable TFTP servers.

vlan- When set to a value < 4095 the traffic over

Ethernet is encapsulated/received over 802.1q

VLAN tagged frames.

 

使用下列环境变量可以通过网络启动命令(bootprarpboot自动更新,这取决于你启动服务器提供的相关信息:

 

bootfile-see above

dnsip-IP address of your Domain Name Server

dnsip2-IP address of your secondary Domain Name Server

gatewayip-IP address of the Gateway (Router) to use

hostname-Target hostname

ipaddr-see above

netmask-Subnet Mask

rootpath-Pathname of the root filesystem on the NFS server

serverip-see above

 

有2种特殊的环境变量:

serial#-contains hardware identification information such

astype string and/or serial number

ethaddr-Ethernet address

上面这两变量只能设置一次(一般是在制造开发板期间设置的),一量已经设置了这两个变量,uboot拒绝删除和覆盖这些变量。

 

还有一个特殊环境变量:

ver -包含uboot版本字符串,可能通过”version”命令打印出来,此变量是只读的(可以

查看CONFIG_VERSION_VARIABLE).

 

注意:某此配置参数的变量是在下次启动后才起作用的.(有点类似于windows)

 

 

命令行解析器:

---------------------------------------------------

uboot有两种不同的命令行解析器:老的“simple”,还有更强大的“hush”shell

老版本的解析器:

-supports environment variables (through setenv / saveenv commands)

-several commands on one line, separated by ';'

-variable substitution using "... ${name} ..." syntax

-special characters ('$', ';') can be escaped by prefixing with '/',

forexample:

setenvbootcmd bootm /${address}

- Youcan also escape text by enclosing in single apostrophes, forexample:

setenvaddip 'setenv bootargs $bootargsip=$ipaddr:$serverip:$gatewayip:$netmask:$hostname::off'

Hushshell:

-similar to Bourne shell, with control structures like

if...then...else...fi,for...do...done; while...do...done,

until...do...done,...

-supports environment ("global") variables (through setenv /saveenv

commands)and local shell variables (through standard shell syntax

"name=value");only environment variables can be used with "run"

command

 

通用规则:

---------------

(1)如果一个命令行包含有多个命令以';'分隔,如果其中一个命令失败了,其它命令也会执行。

(2)如果调用run来执行多个变量(如run后面紧接着一列的变量),错误的命令会引起”run”命令的终止,余下的变量就不会被执行。

 

 

注意多个网络接口:

---------------------------------------------

有些开发板具有多个网络接口。uboot支持这种配置,当需要的时候也能够自动的选择一个有效的接口,MAC的分配如下:

网络接口被命令为eth0,eth1,eht2...相应的MAC地址是存储在环境变量”ethaddr”(eth0)中,”eth1addr”(eth1),“eth2addr”(即eth2)...

如果网络接口存储着有效的MAC地址(例如在SROM)中,如果没有相应的环境变量设置时,它为默认的地址。如果相应的环境变量设置后,会对网卡的地址进行覆盖设置,这意味着:

o SROM有一个有效的MAC地址,环境变量没有设置,SROM的地址就被使用了。

o 无有效的MAC地址,已经定义了一个环境变量,环境变量的值被使用。

o 如果SROM和环境变量都含有一个MAC地址,且此MAC地址相同,则这个MAC被使用

o 如果SROM和环境变量都含有一个MAC地址,但这个地址不同,则使用环境变量的MAC地址,并打印出警告

o 如果SROM和环境变量都无MAC地址,出现错误。

 

如果网址驱动实现了'write_hwaddr'功能,有效的MAC地址可有程序写入硬件作为初始化处理的一部分。也可以通过设置合适的'ethmacskip'环境变量来省略此操作。

"ethmacskip"(=>eth0), "eth1macskip" (=>eth1) etc.

 

 

镜像格式

--------------------------------

uboot可以有两种格式启动镜像。

新镜像格式(FIT)

这是一种基于FITflattenedimageTree)的灵活可靠的镜像,类型于FDT。它可以允许使用多个元素(如,多镜像,多ramdisk),并且这些内容由SHA1MD5或者CRC32校验进行保护。更多的细节请查看doc/uImage.FIT目录

 

Linux支持:

------------------------------

  虽然uboot本应该很容易地支持各种OS或者独立的应用程序,但是当时设计uboot时主要是基于linux

  uboot包含的许多特性目前为止还是linux内核中很特殊的“bootloader”代码中的一部分。任何将被使用的”initrd”镜像不再是整个linux镜像的一部分;相反,内核与”initrd”是独立的内核。这种实现具有各自不同的目的:

-相同的特性可以用于其它OS或独立应用程序(如:使用压缩镜像来减少flash占用空间)

-由于更多底层的,硬件依赖的东西主要由uboot来实现,,因此更加容易给linux内核版本提供接口。

-相同的inux内核可以用于不同的”initrd”镜象,当然这也意味着不同的内核镜像可以用相同的“initrd”来运行。这使得测试更加容易(当你仅仅在“initrd”中改变一个文件时,你不需要再去编译一个新的”zImage.initrd”Linux镜像)。因此,某一领域的软件升级现在也变得更简单。

Configuringthe Linux kernel:

-----------------------------

Nospecific requirements for U-Boot. Make sure you have some root

device(initial ramdisk, NFS) for your target system.

Buildinga Linux Image:

-----------------------

WithU-Boot, "normal" build targets like "zImage" or"bzImage" are

notused. If you use recent kernel source, a new build target

"uImage"will exist which automatically builds an image usable by

U-Boot.Most older kernels also have support for a "pImage"target,

whichwas introduced for our predecessor project PPCBoot and uses a

100%compatible format.

Example:

makeTQM850L_config

makeoldconfig

makedep

makeuImage

The"uImage" build target uses a special tool (in'tools/mkimage') to

encapsulatea compressed Linux kernel image with header information,

CRC32checksum etc. for use with U-Boot. This is what we are doing:

*build a standard "vmlinux" kernel image (in ELF binaryformat):

*convert the kernel into a raw binary image:

${CROSS_COMPILE}-objcopy-O binary /

-R .note -R .comment /

-S vmlinux linux.bin

*compress the binary image:

gzip-9 linux.bin

*package compressed binary image for U-Boot:

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

-a0 -e 0 -n "Linux Kernel Image" /

-dlinux.bin.gz uImage

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

withU-Boot, either separated from the Linux kernel image, or

combinedinto one file. "mkimage" encapsulates the images with a 64

byteheader containing information about target architecture,

operatingsystem, image type, compression method, entry points, time

stamp,CRC32 checksums, etc.

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

printthe header information, or to build new images.

Inthe first form (with "-l" option) mkimage lists theinformation

containedin the header of an existing U-Boot image; this includes

checksumverification:

tools/mkimage-l image

-l ==> list image header information

Thesecond form (with "-d" option) is used to build a U-Bootimage

froma "data file" which is used as image payload:

tools/mkimage-A arch -O os -T type -C comp -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'

Rightnow, all Linux kernels for PowerPC systems use the same load

address(0x00000000), but the entry point address depends on the

kernelversion:

-2.2.x kernels have the entry point at 0x0000000C,

-2.3.x and later kernels have the entry point at 0x00000000.

Soa typical call to build a U-Boot image would read:

->tools/mkimage -n '2.4.4 kernel for TQM850L' /

>-A ppc -O linux -T kernel -C gzip -a 0 -e 0 /

>-d/opt/elsk/ppc_8xx/usr/src/linux-2.4.4/arch/powerpc/coffboot/vmlinux.gz/

>examples/uImage.TQM850L

ImageName: 2.4.4 kernel for TQM850L

Created: Wed Jul 19 02:34:59 2000

ImageType: PowerPC Linux Kernel Image (gzip compressed)

DataSize: 335725 Bytes = 327.86 kB = 0.32 MB

LoadAddress: 0x00000000

EntryPoint: 0x00000000

Toverify the contents of the image (or check for corruption):

->tools/mkimage -l examples/uImage.TQM850L

ImageName: 2.4.4 kernel for TQM850L

Created: Wed Jul 19 02:34:59 2000

ImageType: PowerPC Linux Kernel Image (gzip compressed)

DataSize: 335725 Bytes = 327.86 kB = 0.32 MB

LoadAddress: 0x00000000

EntryPoint: 0x00000000

NOTE:for embedded systems where boot time is critical you can trade

speedfor memory and install an UNCOMPRESSED image instead: this

needsmore space in Flash, but boots much faster since it does not

needto be uncompressed:

->gunzip/opt/elsk/ppc_8xx/usr/src/linux-2.4.4/arch/powerpc/coffboot/vmlinux.gz

->tools/mkimage -n '2.4.4 kernel for TQM850L' /

>-A ppc -O linux -T kernel -C none -a 0 -e 0 /

>-d/opt/elsk/ppc_8xx/usr/src/linux-2.4.4/arch/powerpc/coffboot/vmlinux/

>examples/uImage.TQM850L-uncompressed

ImageName: 2.4.4 kernel for TQM850L

Created: Wed Jul 19 02:34:59 2000

ImageType: PowerPC Linux Kernel Image (uncompressed)

DataSize: 792160 Bytes = 773.59 kB = 0.76 MB

LoadAddress: 0x00000000

EntryPoint: 0x00000000

Similaryou can build U-Boot images from a 'ramdisk.image.gz' file

whenyour kernel is intended to use an initial ramdisk:

->tools/mkimage -n 'Simple Ramdisk Image' /

>-A ppc -O linux -T ramdisk -C gzip /

>-d /LinuxPPC/images/SIMPLE-ramdisk.image.gz examples/simple-initrd

ImageName: Simple Ramdisk Image

Created: Wed Jan 12 14:01:50 2000

ImageType: PowerPC Linux RAMDisk Image (gzip compressed)

DataSize: 566530 Bytes = 553.25 kB = 0.54 MB

LoadAddress: 0x00000000

EntryPoint: 0x00000000

 

 

安装linuximage:

------------------------------------------------------

要通过串口下载uboot镜像,你必须将其转换成S-Record格式:

objcopy-I binary -O srec examples/image examples/image.srec

'objcopy'并不知道uboot镜像头文件的信息,所以S-Record文件默认地址为:

0x00000000,如果要将它装载到指定地址,你需要用'loads'命令以'offset'参数形式指定目标板的地址。

如:安装image到地址0x40100000(此地址在TQM8xxLisin the first bank);

=>erase 40100000 401FFFFF

..........done

Erased8 sectors

 

=>loads 40100000

##Ready for S-Record download ...

~>examples/image.srec

1 2 34 5 6 7 8 9 10 11 12 13 ...

...

1598915990 15991 15992

[filetransfer complete]

[connected]

##Start Addr = 0x00000000

 

你可以使用'iminfo'命令来检验是否下载成功。‘iminfo'此命令含校验和验证,可以确保没有数据发生错误:

=>imi 40100000

##Checking Image at 40100000 ...

Image Name: 2.2.13 for initrd on TQM850L

Image Type: PowerPC Linux Kernel Image (gzip compressed)

Data Size: 335725 Bytes = 327 kB = 0 MB

Load Address: 00000000

Entry Point: 0000000c

Verifying Checksum ... OK

 

 

 

启动linux:

------------------------------------------------

bootm”命令用于启动一个存放在内存(RAMFlash)当中的应用程序。如果是一个linux内核镜像,bootargs的内容被传递到内核中作为参数,你可以使用”printenv”来查看和修改这个bootargs的变量值。

=>printenv bootargs

bootargs=root=/dev/ram

=>setenv bootargs root=/dev/nfs rwnfsroot=10.0.0.2:/LinuxPPC nfsaddrs=10.0.0.99:10.0.0.2

=>printenv bootargs

bootargs=root=/dev/nfsrw nfsroot=10.0.0.2:/LinuxPPC nfsaddrs=10.0.0.99:10.0.0.2

 

=>bootm 40020000

##Booting Linux kernel at 40020000 ...

Image Name: 2.2.13 for NFS on TQM850L

Image Type: PowerPC Linux Kernel Image (gzip compressed)

Data Size: 381681 Bytes = 372 kB = 0 MB

Load Address: 00000000

Entry Point: 0000000c

Verifying Checksum ... OK

Uncompressing Kernel Image ... OK

Linuxversion 2.2.13 (wd@denx.local.net) (gcc version 2.95.2 19991024(release)) #1 Wed Jul 19 02:35:17 MEST 2000

Bootarguments: root=/dev/nfs rw nfsroot=10.0.0.2:/LinuxPPCnfsaddrs=10.0.0.99:10.0.0.2

time_init:decrementer frequency = 187500000/60

Calibratingdelay loop... 49.77 BogoMIPS

Memory:15208k available (700k kernel code, 444k data, 32k init)[c0000000,c1000000]

 

 

 

 

 

<!--@page { margin: 2cm }P { margin-bottom: 0.21cm }-->

如果你要用初始化的RAM来启动linux内核,必须给”bootm”命令传递内核与initrd镜像(PPBCOOT格式)的内存地址:

 

=>imi 40100000 40200000

##Checking Image at 40100000 ...

Image Name: 2.2.13 for initrd on TQM850L

Image Type: PowerPC Linux Kernel Image (gzip compressed)

Data Size: 335725 Bytes = 327 kB = 0 MB

Load Address: 00000000

Entry Point: 0000000c

Verifying Checksum ... OK

##Checking Image at 40200000 ...

Image Name: Simple Ramdisk Image

Image Type: PowerPC Linux RAMDisk Image (gzip compressed)

Data Size: 566530 Bytes = 553 kB = 0 MB

Load Address: 00000000

Entry Point: 00000000

Verifying Checksum ... OK

=>bootm 40100000 40200000

##Booting Linux kernel at 40100000 ...

Image Name: 2.2.13 for initrd on TQM850L

Image Type: PowerPC Linux Kernel Image (gzip compressed)

Data Size: 335725 Bytes = 327 kB = 0 MB

Load Address: 00000000

Entry Point: 0000000c

Verifying Checksum ... OK

Uncompressing Kernel Image ... OK

##Loading RAMDisk Image at 40200000 ...

Image Name: Simple Ramdisk Image

Image Type: PowerPC Linux RAMDisk Image (gzip compressed)

Data Size: 566530 Bytes = 553 kB = 0 MB

Load Address: 00000000

Entry Point: 00000000

Verifying Checksum ... OK

Loading Ramdisk ... OK

Linuxversion 2.2.13 (wd@denx.local.net) (gcc version 2.95.2 19991024(release)) #1 Wed Jul 19 02:32:08 MEST 2000

Bootarguments: root=/dev/ram

time_init:decrementer frequency = 187500000/60

Calibratingdelay loop... 49.77 BogoMIPS

...

RAMDISK:Compressed image found at block 0

VFS:Mounted root (ext2 filesystem).

bash#

 

启动linux与传递flatdevice tree:

首先,uboot必须要用合适的定义来编译。具体查看“LinuxKernel Interface”

以下是关于如何启动linux内核以及传递更新的fdt的一个例子:

=>print oftaddr

oftaddr=0x300000

=>print oft

oft=oftrees/mpc8540ads.dtb

=>tftp $oftaddr $oft

Speed:1000, full duplex

UsingTSEC0 device

TFTPfrom server 192.168.1.1; our IP address is 192.168.1.101

Filename'oftrees/mpc8540ads.dtb'.

Loadaddress: 0x300000

Loading:#

done

Bytestransferred = 4106 (100a hex)

=>tftp $loadaddr $bootfile

Speed:1000, full duplex

UsingTSEC0 device

TFTPfrom server 192.168.1.1; our IP address is 192.168.1.2

Filename'uImage'.

Loadaddress: 0x200000

Loading:############

done

Bytestransferred = 1029407 (fb51f hex)

=>print loadaddr

loadaddr=200000

=>print oftaddr

oftaddr=0x300000

=>bootm $loadaddr -$oftaddr //后面参数是传递给内核的fdt参数

##Booting image at 00200000 ...

ImageName: Linux-2.6.17-dirty

ImageType: PowerPC Linux Kernel Image (gzip compressed)

DataSize: 1029343 Bytes = 1005.2 kB

LoadAddress: 00000000

EntryPoint: 00000000

VerifyingChecksum ... OK

UncompressingKernel Image ... OK

Bootingusing flat device tree at 0x300000 //此地址为fdt地址

UsingMPC85xx ADS machine description

MemoryCAM mapping: CAM0=256Mb, CAM1=256Mb, CAM2=0Mb residual: 0Mb

[snip]

 

更多关于Uboot的镜像类型:

----------------------

uboot支持以下镜像类型:

StandalonePrograms”:这可以在uboot提供的环境下直接运行。可以让StandaloneProgram运行完返回后我们依旧可以在uboot中工作。

 

OSkernelImages”:这是许多嵌入式OS的常用镜像,嵌入式OS将会完全接管所有控制。通常这些程序会安装属于它们自己的一组异常处理,设备驱动,建立MMU等等。这也意味着,除非你重启CPU,你才能重新进入uboot进行操作,否则是进不了uboot的。

 

RAMDISKImages”可以说是一种数据块吧,其参数(地址,大小)被传递到正在启动的OS内核中。

 

Multi-FileImages”包含了许多镜像,典型的如OSlinux)内核镜像和一个或多个的数据镜像如RAMDISKS.当你想使用BOOTP通过网络启动时,这种结构是很有用的。但是这儿的BOOTP启动服务只提供某一个镜像文件,但是你必须具体地给出某一OS内核以及某一个RAMDISK镜像。

 

Multi-FileImages”:启动时给出一列的image大小,每个镜像通过”uint32_t”类型指定(以字节形式)其大小,按网络字节格式。这一列image以”(uint32_t)0”终止。后面一个镜像紧接着一个镜像,所有都按”uint32_t”类型为边界排列(如int4字节类型。。。)

 

FirmwareImages”为二进制的镜像,含firmware(固化程序)(ubootFPGA镜像)通常是编程到flash中。

 

Scriptfiles”:是命令序列,通过uboot的命令解析器执行。当你配置uboot来使用一个shellhush)来作为命令解析器时,非常有用。

 

 

 

StandaloneHOWTO:

 

uboot的其中一个特性是你可以动态地调用和运行一个”standalone”应用程序,而且此应用程序可以使用uboot的一些资源,如IO终端,中断服务等。

 

源码中包含有两个简单的应用程序例子:

HelloWorld” Demo:

-------------------------------

'examples/hello_world.c'包含一个小的”HelloWorld”Demo应用程序。当编译uboot时此应用程序会自动编译。可以进行配置后在0x00040004地址处运行,所以你可以按如下地址进行:

=>loads

##Ready for S-Record download ...

~>examples/hello_world.srec

12 3 4 5 6 7 8 9 10 11 ...

[filetransfer complete]

[connected]

##Start Addr = 0x00040004

=>go 40004 Hello World! This is a test.

##Starting application at 0x00040004 ...

HelloWorld

argc= 7

argv[0]= "40004"

argv[1]= "Hello"

argv[2]= "World!"

argv[3]= "This"

argv[4]= "is"

argv[5]= "a"

argv[6]= "test."

argv[7]= "<NULL>"

Hitany key to exit ...

##Application terminated, rc = 0x0

 

另外一个例子演示了如何用uboot代码注册一个CPM中断服务处理函数,可以在'examples/timer.c'找到源码。这儿的CPM定时器设置成每秒产生一次中断。此中断服务子程序没有处理什么特别的任务,只是打印一个‘.'的字符,这仅仅只是一个demo.程序可以通过下述关键字进行控制:

?- print current values og the CPM Timer registers

b- enable interrupts and start timer

e- stop timer and disable interrupts

q- quit application

=>loads

##Ready for S-Record download ...

~>examples/timer.srec

12 3 4 5 6 7 8 9 10 11 ...

[filetransfer complete]

[connected]

##Start Addr = 0x00040004

=>go 40004

##Starting application at 0x00040004 ...

TIMERS=0xfff00980

Usingtimer 1

tgcr @ 0xfff00980, tmr @ 0xfff00990, trr @ 0xfff00994, tcr @0xfff00998, tcn @ 0xfff0099c, ter @ 0xfff009b0

Hit'b':

[q,b, e, ?] Set interval 1000000 us

Enablingtimer

Hit'?':

[q,b, e, ?] ........

tgcr=0x1,tmr=0xff1c, trr=0x3d09, tcr=0x0, tcn=0xef6, ter=0x0

Hit'?':

[q,b, e, ?] .

tgcr=0x1,tmr=0xff1c, trr=0x3d09, tcr=0x0, tcn=0x2ad4, ter=0x0

Hit'?':

[q,b, e, ?] .

tgcr=0x1,tmr=0xff1c, trr=0x3d09, tcr=0x0, tcn=0x1efc, ter=0x0

Hit'?':

[q,b, e, ?] .

tgcr=0x1,tmr=0xff1c, trr=0x3d09, tcr=0x0, tcn=0x169d, ter=0x0

Hit'e':

[q,b, e, ?] ...Stopping timer

Hit'q':

[q,b, e, ?] ## Application terminated, rc = 0x0

 

 


 

原创粉丝点击