Uboot命令


setenv bootcmd tftp 30800000 uImage ; bootm

setenv bootargs console=ttySAC0,115200 init=/linuxrc root=nfs nfsroot=192.168.7.103:/opt/filesystem ip=192.168.7.163

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


1、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环境变量给内核)。

2、bootp
bootp [loadAddress] [bootfilename]
bootp命令通过bootp请求,要求DHCP服务器分配IP地址,然后通过TFTP协议下载指定的文件到内存。
第1个参数是下载文件存放的内存地址。
第2个参数是要下载的文件名称,这个文件应该在开发主机上准备好。

3、cmp
cmp [.b, .w, .l] addr1 addr2 count
- compare memory
cmp命令可以比较2块内存中的内容。.b以字节为单位;.w以字为单位;.l以长字为单位。注意:cmp.b中间不能保留空格,需要连续敲入命令。
第1个参数addr1是第一块内存的起始地址。
第2个参数addr2是第二块内存的起始地址。
第3个参数count是要比较的数目,单位按照字节、字或者长字。

4、cp
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分别以字节、字、长字为单位。

5、crc32
crc32 address count [addr]
- compute CRC32 checksum [save at addr] 
crc32命令可以计算存储数据的校验和。
第1个参数address是需要校验的数据起始地址。
第2个参数count是要校验的数据字节数。
第3个参数addr用来指定保存结果的地址。

6、echo
echo [args..]
- echo args to console; c suppresses newline
echo命令回显参数。

7、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的参数即可。

8、flinfo
flinfo
- print information for all FLASH memory banks
flinfo N
- print information for FLASH memory bank # N
flinfo命令打印全部Flash组的信息,也可以只打印其中某个组。一般嵌入式系统的Flash只有一个组。

9、go
go addr [arg ...]
- start application at address ''addr''
passing ''arg'' as arguments
go命令可以执行应用程序。
第1个参数是要执行程序的入口地址。
第2个可选参数是传递给程序的参数,可以不用。

10、minfo
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个参数指定映像的起始地址。
可选的参数是指定更多的映像地址。

11、loadb
loadb [ off ] [ baud ]
- load binary file over serial line with offset ''off'' and baudrate ''baud''
loadb命令可以通过串口线下载二进制格式文件。

12、loads
loads [ off ]
- load S-Record file over serial line with offset ''off''
loads命令可以通过串口线下载S-Record格式文件。

13、mw
mw [.b, .w, .l] address value [count]
- write memory
mw命令可以按照字节、字、长字写内存,.b .w .l的用法与cp命令相同。
第1个参数address是要写的内存地址。
第2个参数value是要写的值。
第3个可选参数count是要写单位值的数目。

14、nfs
nfs [loadAddress] [host ip addr:bootfilename]
nfs命令可以使用NFS网络协议通过网络启动映像。

15、nm
nm [.b, .w, .l] address
- memory modify, read and keep address
nm命令可以修改内存,可以按照字节、字、长字操作。

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

16、printenv
printenv
- print values of all environment variables
printenv name ...
- print value of environment variable ''name''
printenv命令打印环境变量。
可以打印全部环境变量,也可以只打印参数中列出的环境变量。

17、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代表解除写保护。
第2、3参数是指定Flash写保护操作范围,跟擦除的方式相同。

18、rarpboot
rarpboot [loadAddress] [bootfilename]
rarboot命令可以使用TFTP协议通过网络启动映像。也就是把指定的文件下载到指定地址,然后执行。
第1个参数是映像文件下载到的内存地址。
第2个参数是要下载执行的映像文件。

19、run
run var [...]
- run the commands in the environment variable(s) ''var''
run命令可以执行环境变量中的命令,后面参数可以跟几个环境变量名。

20、setenv
setenv name value ...
- set environment variable ''name'' to ''value ...''
setenv name
- delete environment variable ''name''
setenv命令可以设置环境变量。
第1个参数是环境变量的名称。
第2个参数是要设置的值,如果没有第2个参数,表示删除这个环境变量。

21、sleep
sleep N
- delay execution for N seconds (N is _decimal_ !!!)
sleep命令可以延迟N秒钟执行,N为十进制数。

22、tftpboot
tftpboot [loadAddress] [bootfilename]
tftpboot命令可以使用TFTP协议通过网络下载文件。按照二进制文件格式下载。另外使用这个命令,必须配置好相关的环境变量。例如serverip和ipaddr。
第1个参数loadAddress是下载到的内存地址。
第2个参数是要下载的文件名称,必须放在TFTP服务器相应的目录下。

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