常用u-boot命令详解(全)


(1)获取帮助

命令:help 或 ?


功能:查看当前U-boot版本中支持的所有命令。



[u-boot@MINI2440]# help
? - alias for 'help'
askenv - get environment variables from stdin
base - print or set address offset
bdinfo - print Board Info structure
bmp - manipulate BMP p_w_picpath data
boot - boot default, i.e., run 'bootcmd'
bootd - boot default, i.e., run 'bootcmd'
bootelf - Boot from an ELF p_w_picpath in memory
bootm - boot application p_w_picpath from memory
bootp - boot p_w_picpath via network using BOOTP/TFTP protocol
bootvx - Boot vxWorks from an ELF p_w_picpath
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
dhcp - boot p_w_picpath via network using DHCP/TFTP protocol
echo - echo args to console
editenv - edit environment variable
eeprom - EEPROM sub-system
erase - erase FLASH memory
exit - exit script
fatinfo - print information about filesystem
fatload - load binary file from a dos filesystem
fatls - list files in a directory (default /)
flinfo - print FLASH memory information
fsinfo - print information about filesystems
fsload - load binary file from a filesystem p_w_picpath
go - start application at address 'addr'
help - print online help
i2c - I2C sub-system
icache - enable or disable instruction cache
iminfo - print header information for application p_w_picpath
imls - list all p_w_picpaths found in flash
imxtract- extract a part of a multi-p_w_picpath
itest - return true/false on integer compare
loadb - load binary file over serial line (kermit mode)
loads - load S-Record file over serial line
loadx - load binary file over serial line (xmodem mode)
loady - load binary file over serial line (ymodem mode)
loop - infinite loop on address range
ls - list files in a directory (default /)
md - memory display
mm - memory modify (auto-incrementing address)
mmc - MMC sub-system
mtest - simple RAM read/write test
mw - memory write (fill)
nand - NAND sub-system
nboot - boot from NAND device
nfs - boot p_w_picpath via network using NFS protocol
nm - memory modify (constant address)
ping - send ICMP ECHO_REQUEST to network host
printenv- print environment variables
protect - enable or disable FLASH write protection
rarpboot- boot p_w_picpath via network using RARP/TFTP protocol
reginfo - print register information
reset - Perform RESET of the CPU
run - run commands in an environment variable
saveenv - save environment variables to persistent storage
setenv - set environment variables
showvar - print local hushshell variables
sleep - delay execution for some time
source - run script from memory
test - minimal test like /bin/sh
tftpboot- boot p_w_picpath via network using TFTP protocol
unzip - unzip a memory region
usb - USB sub-system
usbboot - boot from USB device
version - print monitor version

如果你想获取某条命令的更详细的帮助,可以使用:


help <你想要查的指令>
或者 ? <你想要查的指令> ,
甚至 h <你想要查的指令缩写>

以bmp指令为例:



[u-boot@MINI2440]# help bmp
bmp - manipulate BMP p_w_picpath data

Usage:
bmp info <p_w_picpathAddr> - display p_w_picpath info
bmp display <p_w_picpathAddr> [x y] - display p_w_picpath at x,y
[u-boot@MINI2440]# ? bmp
bmp - manipulate BMP p_w_picpath data

Usage:
bmp info <p_w_picpathAddr> - display p_w_picpath info
bmp display <p_w_picpathAddr> [x y] - display p_w_picpath at x,y
[u-boot@MINI2440]# h bm
bmp - manipulate BMP p_w_picpath data

Usage:
bmp info <p_w_picpathAddr> - display p_w_picpath info
bmp display <p_w_picpathAddr> [x y] - display p_w_picpath at x,y


(2)环境变量(environment variables,简称ENV)与相关指令
和shell类似,U-Boot也有环境变量。一些U-boot默认的环境变量如下:


 

   

 

 

   

 

bootdelay 执行自动启动(bootcmd中的命令)的等候秒数
baudrate 串口控制台的波特率
netmask 以太网的网络掩码
ethaddr 以太网的MAC地址
bootfile 默认的下载文件名
bootargs 传递给Linux内核的启动参数
bootcmd 自动启动时执行命令
serverip TFTP服务器端的IP地址
ipaddr 本地的IP地址
stdin 标准输入设备,一般是串口
stdout 标准输出,一般是串口,也可是LCDVGA
stderr 标准出错,一般是串口,也可是LCDVGA

       ENV可以放在许多固体存储器中,对于mini2440来说Nor Flash、Nand Flash或EEPROM都可以,就看你如何配置了(include/configs下的配置文件)。例如:


  

    Nor Flash


#define CONFIG_ENV_IS_IN_FLASH 1
#define CONFIG_ENV_OFFSET 0X40000
#define CONFIG_ENV_SIZE            0x20000    /* Total Size of Environment Sector */

Nand Flash: 


#define CONFIG_ENV_IS_IN_NAND 1
#define CONFIG_ENV_OFFSET 0X40000
#define CONFIG_ENV_SIZE            0x20000    /* Total Size of Environment Sector */

EEPROM:


#define CONFIG_ENV_IS_IN_EEPROM 1 /* use EEPROM for environment vars */
#define CONFIG_ENV_OFFSET 0x000 /* environment starts at offset 0 */
#define CONFIG_ENV_SIZE     0x400 /* 1KB */


CONFIG_ENV_OFFSET是在整个存储器中的偏移地址;
CONFIG_ENV_SIZE是指其使用的大小。

注意 CONFIG_ENV_OFFSET和 CONFIG_ENV_SIZE 的设置,不要覆盖了其他分区。


四、U-boot的使用(二)

命令:
loadb   - load binary file over serial line (kermit mode)
loadx   - load binary file over serial line (xmodem mode)
loady   - load binary file over serial line (ymodem mode)


功能:以不同的协议从串口获取文件.。
格式基本都为:
load? [ off ] [ baud ]
第1个参数是下载到SDRAM的地址,如果不填,就是用默认配置:CONFIG_SYS_LOAD_ADDR
第2个参数是波特率,一般不填,用默认的115200.


    在windows下的超级终端可以用这些协议发送文件,但是在ubuntu下基本只能用kermit协议。一下使用C-kermit来发送一个文件到mini2440。

 

[u-boot@MINI2440]# loadb
## Ready for binary (kermit) download to 0x30008000 at 115200 bps...

 


    上面已经启动了U-boot的kermit传输协议,这时按下 Ctrl + \ , 再按 c, 切换到C-kermit的命令行模式,输入命令:send  <文件路径>,回车。

 

[u-boot@MINI2440]# loadb
## Ready for binary (kermit) download to 0x30008000 at 115200 bps...

(Back at MAGI-Linux)
----------------------------------------------------
C-Kermit 8.0.211, 10 Apr 2004, for Linux
Copyright (C) 1985, 2004,
  Trustees of Columbia University in the City of New York.
Type ? or HELP for help.
(/home/tekkaman/桌面/) C-Kermit>send/home/tekkaman/development/share/zImage.img

 

C-kermit就开始传送,并且显示一个传送界面,并动态显示传送进度。


C-Kermit 8.0.211, 10 Apr 2004, MAGI-Linux

   Current Directory: /home/tekkaman/&#65533;&#65533;~L&#65533;~]&#65533;
Communication Device: /dev/ttyUSB0
Communication Speed: 115200
              Parity: none
         RTT/Timeout: 01 / 02
             SENDING: /home/tekkaman/development/share/zImage.img => zImage.img
           File Type: BINARY
           File Size: 2277540
        Percent Done: 19 
/////////-

                          ...10...20...30...40...50...60...70...80...90..100
Estimated Time Left: 00:03:35
  Transfer Rate, CPS: 8536
        Window Slots: 1 of 1
         Packet Type: D
        Packet Count: 557
       Packet Length: 1000
         Error Count: 0
          Last Error:
        Last Message:

X to cancel file, Z to cancel group, <CR> to resend last packet,
E to send Error packet, ^C to quit immediately, ^L to refresh screen.

传送完毕后,输入c ,回到U-boot的串口界面。


[u-boot@MINI2440]# loadb
## Ready for binary (kermit) download to 0x30008000 at 115200 bps...

(Back at MAGI-Linux)
----------------------------------------------------
C-Kermit 8.0.211, 10 Apr 2004, for Linux
Copyright (C) 1985, 2004,
  Trustees of Columbia University in the City of New York.
Type ? or HELP for help.
(/home/tekkaman/桌面/) C-Kermit>send/home/tekkaman/development/share/zImage.img
(/home/tekkaman/桌面/) C-Kermit>c
Connecting to /dev/ttyUSB0, speed 115200
Escape character: Ctrl-\ (ASCII 28, FS): enabled
Type the escape character followed by C to get back,
or followed by ? to see other options.
----------------------------------------------------
## Total Size = 0x0022c0a4 = 2277540 Bytes
## Start Addr = 0x30008000