唐吉诃德

  C++博客 :: 首页 :: 联系 :: 聚合  :: 管理
  5 Posts :: 75 Stories :: 3 Comments :: 0 Trackbacks

常用链接

留言簿(2)

我参与的团队

搜索

  •  

最新评论

阅读排行榜

评论排行榜

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 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-Boot写Flash就使用这个命令,当然需要先把对应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代表解除写保护。
第2、3参数是指定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协议通过网络下载文档。按照二进制文档格式下载。另外使用这个命令,必须配置好相关的环境变量。例如serverip和ipaddr。
第1个参数loadAddress是下载到的内存地址。
第2个参数是要下载的文档名称,必须放在TFTP服务器相应的目录下。
这 些U-Boot命令为嵌入式系统提供了丰富的研发和调试功能。在Linux内核启动和调试过程中,都能够用到U-Boot的命令。但是一般情况下,无需使 用全部命令。比如已支持以太网接口,能够通过tftpboot命令来下载文档,那么更有必要使用串口下载的loadb吗?反过来,假如研发板需要特别的调 试功能,也能够添加新的命令。
在建立交叉研发环境和调试Linux内核等章节时,在ARM平台上移植了U-Boot,并且提供了具体U-Boot的操作步骤。
posted on 2011-05-21 16:58 心羽 阅读(288) 评论(0)  编辑 收藏 引用 所属分类: Ubuntu

只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理