U-Boot命令详解

来源:互联网 发布:淘宝上极有家能保真吗 编辑:程序博客网 时间:2024/06/05 09:10

 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是要比较的数目,单位按照字节、字或长字。

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

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

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

8flinfo
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个可选参数是传递给程式的参数,能够不用。

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

11loadb
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是要读出并且修改的内存地址。

16printenv
printenv
      - print values of all environment variables
printenv name ...
      - print value of environment variable ’name’

printenv命令打印环境变量。
能够打印全部环境变量,也能够只打印参数中列出的环境变量。

17protect
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写保护操作范围,跟擦除的方式相同。

18、rarpboot
rarpboot [loadAddress] [bootfilename]

rarboot命令能够使用TFTP协议通过网络启动映像。也就是把指定的文档下载到指定地址,然后执行。
1个参数是映像文档下载到的内存地址。
2个参数是要下载执行的映像文档。

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

20setenv
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为十进制数。

22tftpboot
tftpboot [loadAddress] [bootfilename]
tftpboot命令能够使用TFTP协议通过网络下载文档。按照二进制文档格式下载。另外使用这个命令,必须配置好相关的环境变量。例如serveripipaddr
1个参数loadAddress是下载到的内存地址。
2个参数是要下载的文档名称,必须放在TFTP服务器相应的目录下。
这些U-Boot命令为嵌入式系统提供了丰富的研发和调试功能。在Linux内核启动和调试过程中,都能够用到U-Boot的命令。但是一般情况下,无需使用全部命令。比如已支持以太网接口,能够通过tftpboot命令来下载文档,那么更有必要使用串口下载的loadb吗?反过来,假如研发板需要特别的调试功能,也能够添加新的命令。


原创粉丝点击