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

<!-- @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 交叉编译工具,而没有使用native environment, 这种情况下,你必须在shell 中设置环境变量CROSS_COMPILE 。注意不要对Makefile 或其它需要的源文件进行修改。例如在4xx CPU 上使用ELDK ,请输入:

  $ CROSS_COMPILE=ppc_4xx-

  $ export CROSS_COMPILE

 

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

$ make HOSTCC=i586-mingw32msvc-gcc HOSTSTRIP=i586-mingw32msvc-strip tools

 

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

 

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

   make NAME_config

 

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

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

   make TQM823L_config  // 此配置无LCD 支持

 

make TQM823L_LCD_config // LCD 支持

 

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

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

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

-”u-boot.srec” motorola S-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 脚本在<source dir >/LOG 目录下保存了两个日志文件(<target>.ERR<target>.MAKEALL) ,此log 目录路径可以通过设置环境变量MAKEALL_LOGDIR 来设置。如:

  export BUILD_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 available for image processing in the bootm

command can be restricted. This variable is given as

a hexadecimal 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 available for image processing in the bootm

command can be restricted . This variable is given as

a hexadecimal number and defines the size of the region

allowed for use by the bootm command . See also "bootm_low"

environment variable.

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

by the automatic software update feature. Please refer to

documentation in doc/README.update for 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

be automatically started (by internally calling

"bootm")

If set to "no ", a standalone 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)

if set to 'y' configures Linux I2C driver for fast

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

initialization code. So, for changes to be effective

it must be saved and board must be reset.

initrd_high - restrict positioning of initrd images :

If this variable is not set, initrd images will be

copied to the highest possible address in RAM; this

is usually 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

If you 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 through all

available network interfaces.

It just 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,

we use 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

be retransmitted. 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

as type 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 '/',

for example:

setenv bootcmd bootm /${address}

- You can also escape text by enclosing in single apostrophes, for example:

setenv addip 'setenv bootargs $bootargs ip=$ipaddr:$serverip:$gatewayip:$netmask:$hostname::off'

Hush shell:

- 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)

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

 

Linux 支持:

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

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

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

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

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

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

Configuring the Linux kernel:

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

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

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

Building a Linux Image:

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

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

not used. 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,

which was introduced for our predecessor project PPCBoot and uses a

100% compatible format.

Example:

make TQM850L_config

make oldconfig

make dep

make uImage

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

encapsulate a compressed Linux kernel image with header information,

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

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

* 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 /

-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 one file. "mkimage" encapsulates the images with a 64

byte header containing information about target architecture,

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

stamp, CRC32 checksums, etc.

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

print the header information, or to build new images.

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

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

checksum verification:

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 "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'

Right now, all Linux kernels for PowerPC systems use the same load

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

kernel version:

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

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

So a 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

Image Name: 2.4.4 kernel for TQM850L

Created: Wed Jul 19 02:34:59 2000

Image Type: PowerPC Linux Kernel Image (gzip compressed)

Data Size: 335725 Bytes = 327.86 kB = 0.32 MB

Load Address: 0x00000000

Entry Point: 0x00000000

To verify the contents of the image (or check for corruption):

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

Image Name: 2.4.4 kernel for TQM850L

Created: Wed Jul 19 02:34:59 2000

Image Type: PowerPC Linux Kernel Image (gzip compressed)

Data Size: 335725 Bytes = 327.86 kB = 0.32 MB

Load Address: 0x00000000

Entry Point: 0x00000000

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

speed for memory and install an UNCOMPRESSED image instead: this

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

need to 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

Image Name: 2.4.4 kernel for TQM850L

Created: Wed Jul 19 02:34:59 2000

Image Type: PowerPC Linux Kernel Image (uncompressed)

Data Size: 792160 Bytes = 773.59 kB = 0.76 MB

Load Address: 0x00000000

Entry Point: 0x00000000

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

when your 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

Image Name: Simple Ramdisk Image

Created: Wed Jan 12 14:01:50 2000

Image Type: PowerPC Linux RAMDisk Image (gzip compressed)

Data Size: 566530 Bytes = 553.25 kB = 0.54 MB

Load Address: 0x00000000

Entry Point: 0x00000000

 

 

安装linux image:

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

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

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

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

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

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

=> erase 40100000 401FFFFF

.......... done

Erased 8 sectors

 

=> loads 40100000

## Ready for S-Record download ...

~>examples/image.srec

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

...

15989 15990 15991 15992

[file transfer 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 rw nfsroot=10.0.0.2:/LinuxPPC nfsaddrs=10.0.0.99:10.0.0.2

=> printenv bootargs

bootargs=root=/dev/nfs rw 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

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

Boot arguments: root=/dev/nfs rw nfsroot=10.0.0.2:/LinuxPPC nfsaddrs=10.0.0.99:10.0.0.2

time_init: decrementer frequency = 187500000/60

Calibrating delay 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

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

Boot arguments: root=/dev/ram

time_init: decrementer frequency = 187500000/60

Calibrating delay loop... 49.77 BogoMIPS

...

RAMDISK: Compressed image found at block 0

VFS: Mounted root (ext2 filesystem).

bash#

 

启动linux 与传递flat device tree:

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

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

=> print oftaddr

oftaddr=0x300000

=> print oft

oft=oftrees/mpc8540ads.dtb

=> tftp $oftaddr $oft

Speed: 1000, full duplex

Using TSEC0 device

TFTP from server 192.168.1.1; our IP address is 192.168.1.101

Filename 'oftrees/mpc8540ads.dtb'.

Load address: 0x300000

Loading: #

done

Bytes transferred = 4106 (100a hex)

=> tftp $loadaddr $bootfile

Speed: 1000, full duplex

Using TSEC0 device

TFTP from server 192.168.1.1; our IP address is 192.168.1.2

Filename 'uImage'.

Load address: 0x200000

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

done

Bytes transferred = 1029407 (fb51f hex)

=> print loadaddr

loadaddr=200000

=> print oftaddr

oftaddr=0x300000

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

## Booting image at 00200000 ...

Image Name: Linux-2.6.17-dirty

Image Type: PowerPC Linux Kernel Image (gzip compressed)

Data Size: 1029343 Bytes = 1005.2 kB

Load Address: 00000000

Entry Point: 00000000

Verifying Checksum ... OK

Uncompressing Kernel Image ... OK

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

Using MPC85xx ADS machine description

Memory CAM mapping: CAM0=256Mb, CAM1=256Mb, CAM2=0Mb residual: 0Mb

[snip]

 

更多关于Uboot 的镜像类型:

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

uboot 支持以下镜像类型:

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

 

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

 

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

 

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

 

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

 

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

 

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

 

 

 

Standalone HOWTO:

 

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

 

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

Hello World” Demo:

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

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

=> loads

## Ready for S-Record download ...

~>examples/hello_world.srec

1 2 3 4 5 6 7 8 9 10 11 ...

[file transfer complete]

[connected]

## Start Addr = 0x00040004

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

## Starting application at 0x00040004 ...

Hello World

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>"

Hit any 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

1 2 3 4 5 6 7 8 9 10 11 ...

[file transfer complete]

[connected]

## Start Addr = 0x00040004

=> go 40004

## Starting application at 0x00040004 ...

TIMERS=0xfff00980

Using timer 1

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

Hit 'b':

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

Enabling timer

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

 

 


 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值