Chinaunix首页 | 论坛 | 博客
  • 博客访问: 195344
  • 博文数量: 71
  • 博客积分: 3000
  • 博客等级: 中校
  • 技术积分: 450
  • 用 户 组: 普通用户
  • 注册时间: 2007-11-29 21:28
个人简介

思考人生、专注技术

文章分类

全部博文(71)

文章存档

2015年(1)

2009年(2)

2008年(11)

2007年(57)

我的朋友

分类: C/C++

2007-12-05 12:54:50

6.4.2  U-Boot的常用命令

U-Boot上电启动后,敲任意键可以退出自动启动状态,进入命令行。

 

U-Boot 1.1.2 (Apr 26 2005 - 12:27:13)

U-Boot code: 11080000 -> 1109614C  BSS: -> 1109A91C

RAM Configuration:

Bank #0: 10000000 32 MB

Micron StrataFlash MT28F128J3 device initialized

Flash: 32 MB

In:    serial

Out:   serial

Err:   serial

Hit any key to stop autoboot:  0

U-Boot>

 

在命令行提示符下,可以输入U-Boot的命令并执行。U-Boot可以支持几十个常用命令,通过这些命令,可以对开发板进行调试,可以引导Linux内核,还可以擦写Flash完成系统部署等功能。掌握这些命令的使用,才能够顺利地进行嵌入式系统的开发。

输入help命令,可以得到当前U-Boot的所有命令列表。每一条命令后面是简单的命令说明。

 

=> help

?       - alias for 'help'

autoscr - run script from memory

base    - print or set address offset

bdinfo  - print Board Info structure

boot    - boot default, i.e., run 'bootcmd'

bootd   - boot default, i.e., run 'bootcmd'

bootm   - boot application image from memory

bootp   - boot image via network using BootP/TFTP protocol

cmp     - memory compare

coninfo  - print console devices and information

cp      - memory copy

crc32   - checksum calculation

dhcp    - invoke DHCP client to obtain IP/boot params

echo    - echo args to console

erase   - erase FLASH memory

flinfo  - print FLASH memory information

go      - start application at address 'addr'

help    - print online help

iminfo  - print header information for application image

imls    - list all images found in flash

itest    - return true/false on integer compare

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

loads   - load S-Record file over serial line

loop   - infinite loop on address range

md    - memory display

mm    - memory modify (auto-incrementing)

mtest   - simple RAM test

mw      - memory write (fill)

nfs     - boot image via network using NFS protocol

nm      - memory modify (constant address)

printenv - print environment variables

protect - enable or disable FLASH write protection

rarpboot - boot image via network using RARP/TFTP protocol

reset   - Perform RESET of the CPU

run     - run commands in an environment variable

saveenv - save environment variables to persistent storage

setenv  - set environment variables

sleep   - delay execution for some time

tftpboot - boot image via network using TFTP protocol

version - print monitor version

=>

 

U-Boot还提供了更加详细的命令帮助,通过help命令还可以查看每个命令的参数说明。由于开发过程的需要,有必要先把U-Boot命令的用法弄清楚。接下来,根据每一条命令的帮助信息,解释一下这些命令的功能和参数。

 

=> help bootm

bootm [addr [arg ...]]

    - boot application image stored in memory

          passing arguments 'arg ...'; when booting a Linux kernel,

          'arg' can be the address of an initrd image

 

bootm命令可以引导启动存储在内存中的程序映像。这些内存包括RAM和可以永久保存的Flash

1个参数addr是程序映像的地址,这个程序映像必须转换成U-Boot的格式。

2个参数对于引导Linux内核有用,通常作为U-Boot格式的RAMDISK映像存储地址;也可以是传递给Linux内核的参数(缺省情况下传递bootargs环境变量给内核)。

 

=> help bootp

bootp [loadAddress] [bootfilename]

bootp命令通过bootp请求,要求DHCP服务器分配IP地址,然后通过TFTP协议下载指定的文件到内存。

1个参数是下载文件存放的内存地址。

2个参数是要下载的文件名称,这个文件应该在开发主机上准备好。

 

=> help cmp

cmp [.b, .w, .l] addr1 addr2 count

     - compare memory

 

cmp命令可以比较2块内存中的内容。.b以字节为单位;.w以字为单位;.l以长字为单位。注意:cmp.b中间不能保留空格,需要连续敲入命令。

1个参数addr1是第一块内存的起始地址。

2个参数addr2是第二块内存的起始地址。

3个参数count是要比较的数目,单位按照字节、字或者长字。

 

=> help cp

cp [.b, .w, .l] source target count

       - copy memory

 

cp命令可以在内存中复制数据块,包括对Flash的读写操作。

1个参数source是要复制的数据块起始地址。

2个参数target是数据块要复制到的地址。这个地址如果在Flash中,那么会直接调用写Flash的函数操作。所以U-BootFlash就使用这个命令,当然需要先把对应Flash区域擦干净。

3个参数count是要复制的数目,根据cp.b cp.w cp.l分别以字节、字、长字为单位。

 

=> help crc32

crc32 address count [addr]

     - compute CRC32 checksum [save at addr]  

 

crc32命令可以计算存储数据的校验和。

1个参数address是需要校验的数据起始地址。

2个参数count是要校验的数据字节数。

3个参数addr用来指定保存结果的地址。

 

=> help echo

echo [args..]

      - echo args to console; \c suppresses newline

 

echo命令回显参数。

 

=> help erase

erase start end

      - erase FLASH from addr 'start' to addr 'end'

erase N:SF[-SL]

      - erase sectors SF-SL in FLASH bank # N

erase bank N

      - erase FLASH bank # N

erase all

      - erase all FLASH banks

 

erase命令可以擦Flash

参数必须指定Flash擦除的范围。

按照起始地址和结束地址,start必须是擦除块的起始地址;end必须是擦除末尾块的结束地址。这种方式最常用。举例说明:擦除0x20000 – 0x3ffff区域命令为erase 20000 3ffff

按照组和扇区,N表示Flash的组号,SF表示擦除起始扇区号,SL表示擦除结束扇区号。另外,还可以擦除整个组,擦除组号为N的整个Flash组。擦除全部Flash只要给出一个all的参数即可。

 

=> help flinfo

flinfo

       - print information for all FLASH memory banks

flinfo N

       - print information for FLASH memory bank # N

 

flinfo命令打印全部Flash组的信息,也可以只打印其中某个组。一般嵌入式系统的Flash只有一个组。

 

=> help go

go addr [arg ...]

      - start application at address 'addr'

        passing 'arg' as arguments

 

go命令可以执行应用程序。

1个参数是要执行程序的入口地址。

2个可选参数是传递给程序的参数,可以不用。

 

=> help iminfo

iminfo addr [addr ...]

      - print header information for application image starting at

         address 'addr' in memory; this includes verification of the

         image contents (magic number, header and payload checksums)

 

iminfo可以打印程序映像的开头信息,包含了映像内容的校验(序列号、头和校验和)。

1个参数指定映像的起始地址。

可选的参数是指定更多的映像地址。

 

=> help loadb

loadb [ off ] [ baud ]

     - load binary file over serial line with offset 'off' and baudrate 'baud'

 

loadb命令可以通过串口线下载二进制格式文件。

 

=> help loads

loads [ off ]

    - load S-Record file over serial line with offset 'off'

 

loads命令可以通过串口线下载S-Record格式文件。

 

=> help mw

mw [.b, .w, .l] address value [count]

     - write memory

 

mw命令可以按照字节、字、长字写内存,.b .w .l的用法与cp命令相同。

1个参数address是要写的内存地址。

2个参数value是要写的值。

3个可选参数count是要写单位值的数目。

 

=> help nfs

nfs [loadAddress] [host ip addr:bootfilename]

 

nfs命令可以使用NFS网络协议通过网络启动映像。

 

=> help nm

nm [.b, .w, .l] address

     - memory modify, read and keep address

 

nm命令可以修改内存,可以按照字节、字、长字操作。

参数address是要读出并且修改的内存地址。

 

=> help printenv

printenv

      - print values of all environment variables

printenv name ...

      - print value of environment variable 'name'

 

printenv命令打印环境变量。

可以打印全部环境变量,也可以只打印参数中列出的环境变量。

 

=> help protect

protect on  start end

      - protect Flash from addr 'start' to addr 'end'

protect on  N:SF[-SL]

      - protect sectors SF-SL in Flash bank # N

protect on  bank N

      - protect Flash bank # N

protect on  all

      - protect all Flash banks

protect off start end

      - make Flash from addr 'start' to addr 'end' writable

protect off N:SF[-SL]

     - make sectors SF-SL writable in Flash bank # N

protect off bank N

     - make Flash bank # N writable

protect off all

     - make all Flash banks writable

 

protect命令是对Flash写保护的操作,可以使能和解除写保护。

1个参数on代表使能写保护;off代表解除写保护。

23参数是指定Flash写保护操作范围,跟擦除的方式相同。

 

=> help rarpboot

rarpboot [loadAddress] [bootfilename]

 

rarboot命令可以使用TFTP协议通过网络启动映像。也就是把指定的文件下载到指定地址,然后执行。

1个参数是映像文件下载到的内存地址。

2个参数是要下载执行的映像文件。

 

=> help run

run var [...]

      - run the commands in the environment variable(s) 'var'

 

run命令可以执行环境变量中的命令,后面参数可以跟几个环境变量名。

 

=> help setenv

setenv name value ...

      - set environment variable 'name' to 'value ...'

setenv name

      - delete environment variable 'name'

 

setenv命令可以设置环境变量。

1个参数是环境变量的名称。

2个参数是要设置的值,如果没有第2个参数,表示删除这个环境变量。

 

 

=> help sleep

sleep N

      - delay execution for N seconds (N is _decimal_ !!!)

 

sleep命令可以延迟N秒钟执行,N为十进制数。

 

=> help tftpboot

tftpboot [loadAddress] [bootfilename]

 

tftpboot命令可以使用TFTP协议通过网络下载文件。按照二进制文件格式下载。另外使用这个命令,必须配置好相关的环境变量。例如serveripipaddr

1个参数loadAddress是下载到的内存地址。

2个参数是要下载的文件名称,必须放在TFTP服务器相应的目录下。

这些U-Boot命令为嵌入式系统提供了丰富的开发和调试功能。在Linux内核启动和调试过程中,都可以用到U-Boot的命令。但是一般情况下,不需要使用全部命令。比如已经支持以太网接口,可以通过tftpboot命令来下载文件,那么还有必要使用串口下载的loadb吗?反过来,如果开发板需要特殊的调试功能,也可以添加新的命令。

在建立交叉开发环境和调试Linux内核等章节时,在ARM平台上移植了U-Boot,并且提供了具体U-Boot的操作步骤。
阅读(1122) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~