u-boot命令解釋

http://blog.21ic.com/user1/5165/archives/2008/50377.html

 

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的操作步驟。

發佈了6 篇原創文章 · 獲贊 0 · 訪問量 6萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章