U-Boot上电启动后,进入命令行。在命令行提示符下,能够输入U-Boot的命令并执行。U-Boot能够支持几十个常用命令,通过这些命令能够对研发板进行调试,例如能够引导Linux内核,擦写Flash完成系统部署等功能。掌控这些命令的使用有助于进行嵌入式系统的研发。
首先在命令行下输入help或者?命令,能够得到当前U-Boot所有命令列表:
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'
bootelf - Boot from an ELF image in memory
bootm - boot application image from memory
bootp - boot image via network using BootP/TFTP protocol
bootvx - boot vxWorks from an ELF image
cmp - memory compare
coninfo - print console devices and information
cp - memory copy
crc32 - checksum calculation
date - get/set/reset date & time
dcache - enable or disable data cache
echo - echo args to console
erase - erase FLASH memory
flinfo - print FLASH memory information
go - start application at address 'addr'
help - print online help
icache - enable or disable instruction cache
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
loady - load binary file over serial line (ymodem mode)
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
通过help命令还能够具体查看每个命令的说明。例如help autoscr命令,就可以查看autoscr命令的具体说明。以下是根据每一条命令的帮助信息,简单说明一下这些命令的功能和参数:
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环境变量给内核)。
bootp [loadAddress] [bootfilename]
bootp命令通过bootp请求,需要DHCP服务器分配IP地址,然后通过TFTP协议下载指定的文档到内存。第1个参数是下载文档存放的内存地址;第2个参数是要下载的文档名称,这个文档应该在研发主机上准备好。
cmp [.b, .w, .l] addr1 addr2 count
- compare memory
cmp命令能够比较2块内存中的内容。.b以字节为单位;.w以字为单位;.l以长字为单位。注意:cmp.b中间不能保留空格,需要连续敲入命令。第1个参数addr1是第一块内存的起始地址;第2个参数addr2是第二块内存的起始地址;第3个参数count是要比较的数目,单位按照字节、字或长字。
cp [.b, .w, .l] source target count
- copy memory
cp命令能够在内存中复制数据块,包括对Flash的读写操作。第1个参数source是要复制的数据块起始地址;第2个参数target是数据块要复制到的地址。这个地址假如在Flash中,那么会直接调用写Flash的函数操作。所以U-Boot写Flash就使用这个命令,当然需要先把对应Flash区域擦干净;第3个参数count是要复制的数目,根据cp.b cp.w cp.l分别以字节、字、长字为单位。
crc32 address count [addr]
- compute CRC32 checksum [save at addr]
crc32命令能够计算存储数据的校验和;第1个参数address是需要校验的数据起始地址;第2个参数count是要校验的数据字节数;第3个参数addr用来指定保存结果的地址。
echo [args..]
- echo args to console; \c suppresses newline
echo命令回显参数。
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的参数即可。
flinfo
- print information for all FLASH memory banks
flinfo N
- print information for FLASH memory bank # N
flinfo命令打印全部Flash组的信息,也能够只打印其中某个组。一般嵌入式系统的Flash只有一个组。
go addr [arg ...]
- start application at address 'addr'
passing 'arg' as arguments
go命令能够执行应用程式。第1个参数是要执行程式的入口地址;第2个可选参数是传递给程式的参数,能够不用。
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个参数指定映像的起始地址。可选的参数是指定更多的映像地址。
loadb [ off ] [ baud ]
- load binary file over serial line with offset 'off' and baudrate 'baud'
loadb命令能够通过串口线下载二进制格式文档。
loads [ off ]
- load S-Record file over serial line with offset 'off'
loads命令能够通过串口线下载S-Record格式文档。
mw [.b, .w, .l] address value [count]
- write memory
mw命令能够按照字节、字、长字写内存,.b .w .l的用法和cp命令相同。第1个参数address是要写的内存地址;第2个参数value是要写的值;第3个可选参数count是要写单位值的数目。
nfs [loadAddress] [host ip addr:bootfilename]
nfs命令能够使用NFS网络协议通过网络启动映像。
nm [.b, .w, .l] address
- memory modify, read and keep address
nm命令能够修改内存,能够按照字节、字、长字操作。参数address是要读出并且修改的内存地址。
printenv
- print values of all environment variables
printenv name ...
- print value of environment variable 'name'
printenv命令打印环境变量。能够打印全部环境变量,也能够只打印参数中列出的环境变量。
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代表解除写保护;第2、3参数是指定Flash写保护操作范围,跟擦除的方式相同。
rarpboot [loadAddress] [bootfilename]
rarboot命令能够使用TFTP协议通过网络启动映像。也就是把指定的文档下载到指定地址,然后执行。第1个参数是映像文档下载到的内存地址,第2个参数是要下载执行的映像文档。
run var [...]
- run the commands in the environment variable(s) 'var'
run命令能够执行环境变量中的命令,后面参数能够跟几个环境变量名。
setenv name value ...
- set environment variable 'name' to 'value ...'
setenv name
- delete environment variable 'name'
setenv命令能够配置环境变量。第1个参数是环境变量的名称;第2个参数是要配置的值,假如没有第2个参数,表示删除这个环境变量。
sleep N
- delay execution for N seconds (N is _decimal_ !!!)
sleep命令能够延迟N秒钟执行,N为十进制数。
tftpboot [loadAddress] [bootfilename]
tftpboot命令能够使用TFTP协议通过网络下载文档。按照二进制文档格式下载。另外使用这个命令,必须配置好相关的环境变量。例如serverip和ipaddr。第1个参数loadAddress是下载到的内存地址;第2个参数是要下载的文档名称,必须放在TFTP服务器相应的目录下。
在嵌入式Linux内核启动和调试过程中,可以充分地使用U-Boot的命令。但是一般情况下,无需使用全部命令。假如研发板需要特别的调试功能,也能够通过程序添加新的命令。
以上命令只是本人在U-Boot-1.1.6版本上所作的总结,对于其他版本可能略有差别,有疑问可以留言或者发邮箱联系。
Tags:U-Boot常用命令分析
http://www.19mp3.com/trackback.asp?tbID=209
http://www.19mp3.com/trackback.asp?tbID=209&CP=GBK
用户登陆
站点日历
站点统计
最新评论
日志搜索
U-Boot常用命令分析 [ 日期:2009-07-13 ] [ 来自: