5.9 U-Boot 指令介紹


這一節將介紹 U-Boot 中最重要的指令。U-Boot 可配置性非常強,所以并不


是所有的指令都已經在你的硬體平台上裝載,此外可能也有這兒沒提到的指令。


你可以使用help 指令來察看根據你的配置所有可用的指令清單。


對于大多數指令,你不必打全這些指令,只需匯入一些字元足以。比如,help


可以簡寫為h


一些指令的執行依賴于 U-Boot 的配置以及U-Boot 中一些環境變數的定義。


所有的 U-Boot 指令都把匯入的數字當作十六進位的格式。


不要使用除了退格鍵之外的其他編輯鍵,因為在諸如環境變數中隱藏的字元


是很難被發現的。


5.9.1 資訊類指令


5.9.1.1 bdinfo – 察看開發板資訊


=> help bdinfo


bdinfo - No help available.


=>


bdinfo 指令(簡寫為bdi)將在終端機察看諸如記憶體位址和大小、時鐘頻率、


MAC 位址等資訊。這些資訊在傳遞給Linux 核心一些參數時會用到。


=> bdi


memstart = 0x00000000


memsize = 0x04000000


flashstart = 0x40000000


flashsize = 0x00800000


flashoffset = 0x00030000


sramstart = 0x00000000


sramsize = 0x00000000


immr_base = 0xFFF00000


bootflags = 0x00000001


intfreq = 50 MHz


busfreq = 50 MHz


ethaddr = 00:D0:93:00:28:81


IP addr = 10.0.0.99


baudrate = 115200 bps


=>


5.9.1.2 coninfo – 察看主控台裝置和資訊


=> help conin


coninfo


=>


coninfo 指令 (簡寫為conin) 察看可用的控制I/O 裝置資訊。


=> conin


List of available devices:


serial 80000003 SIO stdin stdout stderr


=>


匯出包括了裝置名、識別和目前使用情況。以此為例:


serial 80000003 SIO stdin stdout stderr


這個匯出結果意為序列埠裝置是一個系統裝置(旗標‘S),它提供匯入(旗標


I’)和匯出(旗標‘O’)功能,而且目前已經指派給3 個標准I/O 流:tdin


stdout stderr


5.9.1.3 flinfo – 察看Flash 儲存資訊


=> help flinfo


flinfo


- print information for all FLASH memory banks


flinfo N


- print information for FLASH memory bank # N


=>


flinfo 指令 (簡寫為fli) 用于抓取可用的flash 儲存資訊(參見后面的Flash


儲存指令)。


=> fli


Bank # 1: FUJITSU AM29LV160B (16 Mbit, bottom boot sect)


Size: 4 MB in 35 Sectors


Sector Start Addresses:


40000000 (RO) 40008000 (RO) 4000C000 (RO) 40010000 (RO) 40020000 (RO)


40040000 40060000 40080000 400A0000 400C0000


400E0000 40100000 40120000 40140000 40160000


40180000 401A0000 401C0000 401E0000 40200000


40220000 40240000 40260000 40280000 402A0000


402C0000 402E0000 40300000 40320000 40340000


40360000 40380000 403A0000 403C0000 403E0000


Bank # 2: FUJITSU AM29LV160B (16 Mbit, bottom boot sect)


Size: 4 MB in 35 Sectors


Sector Start Addresses:


40400000 40408000 4040C000 40410000 40420000


40440000 40460000 40480000 404A0000 404C0000


404E0000 40500000 40520000 40540000 40560000


40580000 405A0000 405C0000 405E0000 40600000


40620000 40640000 40660000 40680000 406A0000


406C0000 406E0000 40700000 40720000 40740000


40760000 40780000 407A0000 407C0000 407E0000


=>


5.9.1.4 iminfo – 察看映像檔頭部資訊


=> 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 (簡寫為imi) 用于察看像Linux 核心或者ramdisk 之類的映像檔案的


頭部資訊。它察看映像名、類別、大小以及 CRC32 校驗和以驗證檔案沒問題。


=> imi 100000


## Checking Image at 00100000 ...


Image Name: Linux-2.4.4


Created: 2002-04-07 21:31:59 UTC


Image Type: PowerPC Linux Kernel Image (gzip compressed)


Data Size: 605429 Bytes = 591 kB = 0 MB


Load Address: 00000000


Entry Point: 00000000


Verifying Checksum ... OK


=>


跟其他很多指令一樣,imi 指令的精確作業可由U-Boot 的一些環境變數控制


(這兒的是變數verify)。參見后面的詳細介紹。


5.9.1.5 help – 察看在線輔助說明


=> help help


help [command ...]


- show help information (for ''''command'''')


''''help'''' prints online help for the monitor commands.


Without arguments, it prints a short usage message for all commands.


To get detailed help information for specific commands you can type


''''help'''' with one or more command names as arguments.


=>


help 指令(簡寫為h 或者?)察看在線輔助說明。如果不加任何參數,它會列印


出所有目前U-Boot 可用指令清單。你可以把某一指令名作為help 的參數來獲得


這一指令的具體資訊。比如:


=> 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


=>


5.9.2 儲存類指令


5.9.2.1 base – 察看或者設定位址偏移


=> help base


base


- print address offset for memory commands


base off


- set address offset for memory commands to ''''off''''


=>


你可以使用 base 指令(簡寫為ba)來察看或者設定一個“基位址”作為所有


儲存類指令的位址偏移值。預設的基址是0,所以你匯入的所有位址都是實位址。


但是,當你重複存取某一特定儲存區域(如一些內嵌式PowerPc 處理器的記憶體)


時,如果設定此區域的開始位址作為基址,只需使用偏移位址,這將非常簡便:


=> base


Base Address: 0x00000000


=> md 0 c


00000000: feffffff 00000000 7cbd2b78 7cdc3378 ........|.+x|.3x


00000010: 3cfb3b78 3b000000 7c0002e4 39000000 <.;x;...|...9...


00000020: 7d1043a6 3d000400 7918c3a6 3d00c000 }.C.=...y...=...


=> base 40000000


Base Address: 0x40000000


=> md 0 c


40000000: 27051956 50504342 6f6f7420 312e312e ''''..VPPCBoot 1.1.


40000010: 3520284d 61722032 31203230 3032202d 5 (Mar 21 2002 -


40000020: 2031393a 35353a30 34290000 00000000 19:55:04)......


=>


5.9.2.2 crc32 – 校驗和計算


crc32(簡寫為crc)用來計算在某一範圍記憶體儲區域的CRC32 校驗和。


=> crc 100004 3FC


CRC32 for 00100004 ... 001003ff ==> d433b05b


=>


當后面加了 3 個參數時,此指令會把計算結果儲存在給定儲存位址內。


=> crc 100004 3FC 100000


CRC32 for 00100004 ... 001003ff ==> d433b05b


=> md 100000 4


00100000: d433b05b ec3827e4 3cb0bacf 00093cf5 .3.[.8''''.<.....<.


=>


可以看到,CRC32 的校驗和不僅察看出來了,還儲存在位址為0x10000000


的儲存單元裡。


5.9.2.3 cmp – 儲存單元比對


=> help cmp


cmp [.b, .w, .l] addr1 addr2 count


- compare memory


=>


使用 cmp 指令你可以比對兩個儲存區域的內容是否一致。這個指令不僅可


以測試由第3 個參數確定的整個區域,還可以在第一個不同的地方停下來。


=> cmp 100000 40000000 400


word at 0x00100004 (0x50ff4342) != word at 0x40000004 (0x50504342)


Total of 1 word were the same


=> md 100000 C


00100000: 27051956 50ff4342 6f6f7420 312e312e ''''..VP.CBoot 1.1.


00100010: 3520284d 61722032 31203230 3032202d 5 (Mar 21 2002 -


00100020: 2031393a 35353a30 34290000 00000000 19:55:04)......


=> md 40000000 C


40000000: 27051956 50504342 6f6f7420 312e312e ''''..VPPCBoot 1.1.


40000010: 3520284d 61722032 31203230 3032202d 5 (Mar 21 2002 -


40000020: 2031393a 35353a30 34290000 00000000 19:55:04)......


=>


跟很多的儲存類指令一樣,cmp 可以釆用不同的長度存取記憶體:可以是


32bit(長字),16bit()或者8bit(位元組)資料。預設使用32bit,或者使用cmp.l


代替,結果是一樣的。如果你想以16bit 或者字資料存取記憶體,你可以用cmp.w


代替;如果是8bit 或者位元組資料,請用cmp.b


必須注意到計數參數確定了需要被處理的資料的總長度,也就是有多少長


字、字或者位元組需要被比對。


=> cmp.l 100000 40000000 400


word at 0x00100004 (0x50ff4342) != word at 0x40000004 (0x50504342)


Total of 1 word were the same


=> cmp.w 100000 40000000 800


halfword at 0x00100004 (0x50ff) != halfword at 0x40000004 (0x5050)


Total of 2 halfwords were the same


=> cmp.b 100000 40000000 1000


byte at 0x00100005 (0xff) != byte at 0x40000005 (0x50)


Total of 5 bytes were the same


=>


5.9.2.4 cp – 記憶體拷貝


=> help cp


cp [.b, .w, .l] source target count


- copy memory


=>


cp 用來複制儲存單元。


=> cp 40000000 100000 10000


=>


cp 可以使用類別旗標 .l , .w .b


5.9.2.5 md – 察看儲存單元內容


=> help md


md [.b, .w, .l] address [# of objects]


- memory display


=>


md 釆用十六進位和ASCII 碼兩種形式來察看儲存單元的內容。


=> md 100000


00100000: 27051956 50504342 6f6f7420 312e312e ''''..VPPCBoot 1.1.


00100010: 3520284d 61722032 31203230 3032202d 5 (Mar 21 2002 -


00100020: 2031393a 35353a30 34290000 00000000 19:55:04)......


00100030: 00000000 00000000 00000000 00000000 ................


00100040: 00000000 00000000 00000000 00000000 ................


00100050: 00000000 00000000 00000000 00000000 ................


00100060: 00000000 00000000 00000000 00000000 ................


00100070: 00000000 00000000 00000000 00000000 ................


00100080: 00000000 00000000 00000000 00000000 ................


00100090: 00000000 00000000 00000000 00000000 ................


001000a0: 00000000 00000000 00000000 00000000 ................


001000b0: 00000000 00000000 00000000 00000000 ................


001000c0: 00000000 00000000 00000000 00000000 ................


001000d0: 00000000 00000000 00000000 00000000 ................


001000e0: 00000000 00000000 00000000 00000000 ................


001000f0: 00000000 00000000 00000000 00000000 ................


=>


00100100: 3c60fff0 7c7e9ba6 3aa00001 4800000c <`..|~..:...H...


00100110: 3aa00002 48000004 38601002 7c600124 :...H...8`..|`.$


00100120: 7c7b03a6 7c7422a6 7c000278 7c1c23a6 |{..|t".|..x|.#.


00100130: 7c1d23a6 7c1623a6 7c1723a6 7c708aa6 |.#.|.#.|.#.|p..


00100140: 7c788aa6 3c600a00 7c708ba6 7c788ba6 |x..<`..|p..|x..


00100150: 3c600c00 7c708ba6 7c788ba6 3c600400 <`..|p..|x..<`..


00100160: 7c788ba6 3c600200 7c708ba6 7c0002e4 |x..<`..|p..|...


00100170: 4c00012c 3c604000 60630000 38630188 L..,<`@.`c..8c..


00100180: 7c6803a6 4e800020 3c60fff0 60612ec0 |h..N.. <`..`a..


00100190: 9401fffc 9401fffc 38400007 7c5e23a6 ........8@..|^#.


001001a0: 3c400000 60420000 7c5523a6 48000005 <@..`B..|U#.H...


001001b0: 7dc802a6 800e22bc 7dc07214 48019d41 }.....".}.r.H..A


001001c0: 7ea3ab78 4800c05d 00000000 00000000 ~..xH..]........


001001d0: 00000000 00000000 00000000 00000000 ................


001001e0: 00000000 00000000 00000000 00000000 ................


001001f0: 00000000 00000000 00000000 00000000 ................


=>


這條指令同樣可以釆用類別旗標 .l, .w .b


=> md.w 100000


00100000: 2705 1956 5050 4342 6f6f 7420 312e 312e ''''..VPPCBoot 1.1.


00100010: 3520 284d 6172 2032 3120 3230 3032 202d 5 (Mar 21 2002 -


00100020: 2031 393a 3535 3a30 3429 0000 0000 0000 19:55:04)......


00100030: 0000 0000 0000 0000 0000 0000 0000 0000 ................


00100040: 0000 0000 0000 0000 0000 0000 0000 0000 ................


00100050: 0000 0000 0000 0000 0000 0000 0000 0000 ................


00100060: 0000 0000 0000 0000 0000 0000 0000 0000 ................


00100070: 0000 0000 0000 0000 0000 0000 0000 0000 ................


=> md.b 100000


00100000: 27 05 19 56 50 50 43 42 6f 6f 74 20 31 2e 31 2e ''''..VPPCBoot 1.1.


00100010: 35 20 28 4d 61 72 20 32 31 20 32 30 30 32 20 2d 5 (Mar 21 2002 -


00100020: 20 31 39 3a 35 35 3a 30 34 29 00 00 00 00 00 00 19:55:04)......


00100030: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................


=>


上次察看的儲存單元位址和計數參數值會被記憶,所以你可以不加任何參數


僅僅匯入md,它將會自動地察看下一個位址,使用相同的計數參數:


=> md.b 100000 20


00100000: 27 05 19 56 50 50 43 42 6f 6f 74 20 31 2e 31 2e ''''..VPPCBoot 1.1.


00100010: 35 20 28 4d 61 72 20 32 31 20 32 30 30 32 20 2d 5 (Mar 21 2002 -


=> md.w 100000


00100000: 2705 1956 5050 4342 6f6f 7420 312e 312e ''''..VPPCBoot 1.1.


00100010: 3520 284d 6172 2032 3120 3230 3032 202d 5 (Mar 21 2002 -


00100020: 2031 393a 3535 3a30 3429 0000 0000 0000 19:55:04)......


00100030: 0000 0000 0000 0000 0000 0000 0000 0000 ................


=> md 100000


00100000: 27051956 50504342 6f6f7420 312e312e ''''..VPPCBoot 1.1.


00100010: 3520284d 61722032 31203230 3032202d 5 (Mar 21 2002 -


00100020: 2031393a 35353a30 34290000 00000000 19:55:04)......


00100030: 00000000 00000000 00000000 00000000 ................


00100040: 00000000 00000000 00000000 00000000 ................


00100050: 00000000 00000000 00000000 00000000 ................


00100060: 00000000 00000000 00000000 00000000 ................


00100070: 00000000 00000000 00000000 00000000 ................


=>


5.9.2.6 mm – 儲存單元修正(自動增長)


=> help md


md [.b, .w, .l] address [# of objects]


- memory display


=>


mm提供了一種互動修改記憶體內容的方法。它將會察看位址和目前值,然


后輔助說明用戶匯入。如果你匯入了一個合法的十六進位數,這個新的值將會被寫入


該位址。然后輔助說明下一個位址。如果你沒有匯入任何值,只是按了一下轉鍵,那


么該位址的內容保持不變。只要你匯入任意非十六進位的資料(比如說.),此


指令就立刻結束。


=> mm 100000


00100000: 27051956 ? 0


00100004: 50504342 ? AABBCCDD


00100008: 6f6f7420 ? 01234567


0010000c: 312e312e ? .


=> md 100000 10


00100000: 00000000 aabbccdd 01234567 312e312e .........#Eg1.1.


00100010: 3520284d 61722032 31203230 3032202d 5 (Mar 21 2002 -


00100020: 2031393a 35353a30 34290000 00000000 19:55:04)......


00100030: 00000000 00000000 00000000 00000000 ................


=>


同樣,這條指令也可以加上類別旗標.l, .w .b


=> mm.w 100000


00100000: 0000 ? 0101


00100002: 0000 ? 0202


00100004: aabb ? 4321


00100006: ccdd ? 8765


00100008: 0123 ?

arrow
arrow
    全站熱搜

    立你斯 發表在 痞客邦 留言(0) 人氣()