四、U-boot的使用(二)

(3)串口傳輸命令
命令:
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


(4)網絡命令

    只要你的網卡驅動沒問題,那麼你就可以通過網絡來傳輸文件到開發板,這可比串口快多了。你可以直接用交叉網線連接開發板和電腦,也可以用普通直連網線連接路由器,再連到電腦,不過記得配置好網絡,關閉防火牆哦。
   先測試網絡是否通了,現在開發板使用ping 命令,看看是否可以ping通電腦:

[u-boot@MINI2440]# ping 192.168.1.100 
dm9000 i/o: 0x20000300, id: 0x90000a46
DM9000: running in 16 bit mode
MAC: 08:08:11:18:12:27
operating at 100M full duplex mode
Using dm9000 device
host 192.168.1.100 is alive

如果出現:

[u-boot@MINI2440]# ping 192.168.1.100
dm9000 i/o: 0x20000300, id: 0x90000a46
DM9000: running in 16 bit mode
MAC: 08:08:11:18:12:27
operating at 100M full duplex mode
Using dm9000 device
ping failed; host 192.168.1.100 is not alive

這樣無法ping通的事,可能是:
1、U-boot網卡驅動有問題
2、U-boot網絡協議延時配置有問題
3、網絡參數配置問題,比如IP等,Host和Target都有可能有問題。Host最好關閉IPv6。
實在找不到原因,用Wireshark抓包看看。

如果網絡暢通,下面就可以使用下面的命令從tftp目錄或者nfs目錄下載文件到SDRAM了。
命令:
dhcp    - boot image via network using DHCP/TFTP protocol
rarpboot- boot image via network using RARP/TFTP protocol
nfs     - boot image via network using NFS protocol
tftpboot- boot image via network using TFTP protocol
bootp   - boot image via network using BOOTP/TFTP protocol
這幾個命令的格式都是:<指令> [目的SDRAM地址] [[主機IP:]文件名]

注意:
要使用dhcp、rarpboot或 bootp 等功能要路由器或Host的支持。
如果沒有輸入[目的SDRAM地址],系統就是用編譯時定義的CONFIG_SYS_LOAD_ADDR作爲目的SDRAM地址
如果tftpboot和nfs命令沒有定義[主機IP:],則使用ENV中的serverip
其它命令必需定義[主機IP:],否則會使用提供動態IP服務的主機IP作爲[主機IP:]。

使用範例:

[u-boot@MINI2440]# nfs 0x30008000 192.168.1.100:/home/tekkaman/development/share/u-boot.bin
dm9000 i/o: 0x20000300, id: 0x90000a46
DM9000: running in 16 bit mode
MAC: 08:08:11:18:12:27
operating at 100M full duplex mode
Using dm9000 device
File transfer via NFS from server 192.168.1.100; our IP address is 192.168.1.101
Filename '/home/tekkaman/development/share/u-boot.bin'.
Load address: 0x30008000
Loading: ###################################################
done
Bytes transferred = 256220 (3e8dc hex)
[u-boot@MINI2440]# tftp u-boot.bin
dm9000 i/o: 0x20000300, id: 0x90000a46
DM9000: running in 16 bit mode
MAC: 08:08:11:18:12:27
operating at 100M full duplex mode
Using dm9000 device
TFTP from server 192.168.1.100; our IP address is 192.168.1.101
Filename 'u-boot.bin'.
Load address: 0x30008000
Loading: T ##################
done
Bytes transferred = 256220 (3e8dc hex)
[u-boot@MINI2440]# dhcp 192.168.1.100:u-boot.bin
dm9000 i/o: 0x20000300, id: 0x90000a46
DM9000: running in 16 bit mode
MAC: 08:08:11:18:12:27
operating at 100M full duplex mode
BOOTP broadcast 1
BOOTP broadcast 2
DHCP client bound to address 192.168.1.101
Using dm9000 device
TFTP from server 192.168.1.100; our IP address is 192.168.1.101
Filename 'u-boot.bin'.
Load address: 0x30008000
Loading: ##################
done
Bytes transferred = 256220 (3e8dc hex)
[u-boot@MINI2440]# bootp 192.168.1.100:u-boot.bin
dm9000 i/o: 0x20000300, id: 0x90000a46
DM9000: running in 16 bit mode
MAC: 08:08:11:18:12:27
operating at 100M full duplex mode
BOOTP broadcast 1
BOOTP broadcast 2
DHCP client bound to address 192.168.1.101
Using dm9000 device
TFTP from server 192.168.1.100; our IP address is 192.168.1.101
Filename 'u-boot.bin'.
Load address: 0x30008000
Loading: ##################
done
Bytes transferred = 256220 (3e8dc hex)
[u-boot@MINI2440]# rarpboot 192.168.1.100:u-boot.bin

我的路由器沒有開rarp協議,所以rarpboot 無法使用,要使用dhcp或 bootp 也是要路由或Host支持的。


(5)Nand Flash操作指令

常用的Nand Flash指令如下:

指令

功能

nand info

顯示可使用的Nand Flash

nand device [dev]

顯示或設定當前使用的Nand Flash

nand read  addr off  size

Nand Flash讀取命令,從Nand off 偏移地址處讀取size 字節的數據到SDRAM addr地址。

nand write   addr off  size

Nand Flash燒寫命令,將SDRAM addr地址處的size 字節的數據燒寫到Nand off 偏移地址。

nand write[.yaffs[1]]    addr off size

燒寫yaffs 映像專用的命令,.yaffs1 for 512+16 NAND

nand erase [clean] [off size]

Nand Flash檫除命令,擦除Nand Flash off 偏移地址處的size 字節的數據

nand bad

顯示Nand Flash的壞塊

nand dump[.oob] off

顯示Nand Flash中的數據(16進制)

nand scrub

徹底擦除整塊Nand Flash中的數據,包括OOB。可以擦除軟件壞塊標誌。

nand markbad off

標示 Nand off 偏移地址處的塊爲壞塊

 使用範例:

 

[u-boot@MINI2440]# nand info

Device 0: NAND 128MiB 3,3V 8-bit, sector size 128 KiB
[u-boot@MINI2440]# nand device 0
Device 0: NAND 128MiB 3,3V 8-bit... is now current device
[u-boot@MINI2440]# nand read 0x30008000 0x60000 200000

NAND read: device 0 offset 0x60000, size 0x200000
 2097152 bytes read: OK
[u-boot@MINI2440]# nand bad

Device 0 bad blocks:
  030a0000
  030c0000
  030e0000
  07ee0000
[u-boot@MINI2440]# nand markbad 0x500000
block 0x00500000 successfully marked as bad
[u-boot@MINI2440]# nand bad 

Device 0 bad blocks:
  00500000
  030a0000
  030c0000
  030e0000
  07ee0000
[u-boot@MINI2440]# nand scrub

NAND scrub: device 0 whole chip
Warning: scrub option will erase all factory set bad 
         There is no reliable way to recover them.
         Use this command only for testing purposes if you
         are sure of what you are 

Really scrub this NAND flash? <y/N>
Erasing at 0x2f4000008000000 -- 0% complete.
NAND 128MiB 3,3V 8-bit: MTD Erase failure: -5

NAND 128MiB 3,3V 8-bit: MTD Erase failure: -5

NAND 128MiB 3,3V 8-bit: MTD Erase failure: -5
Erasing at 0x7ea000008000000 -- 0% complete.
NAND 128MiB 3,3V 8-bit: MTD Erase failure: -5
Erasing at 0x7fe000008000000 -- 0% complete.
OK
[u-boot@MINI2440]# nand bad

Device 0 bad blocks:
  030a0000
  030c0000
  030e0000
  07ee0000
[u-boot@MINI2440]# nand dump 0x8000
Page 00008000 dump:
    ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
         ()
OOB:
    ff ff ff ff ff ff ff ff
    ff ff ff ff ff ff ff ff
    ff ff ff ff ff ff ff ff
    ff ff ff ff ff ff ff ff
    ff ff ff ff ff ff ff ff
    ff ff ff ff ff ff ff ff
    ff ff ff ff ff ff ff ff
    ff ff ff ff ff ff ff ff
[u-boot@MINI2440]# tftp u-boot.bin
dm9000 i/o: 0x20000300, id: 0x90000a46
DM9000: running in 16 bit mode
MAC: 08:08:11:18:12:27
operating at 100M full duplex mode
Using dm9000 device
TFTP from server 192.168.1.100; our IP address is 192.168.1.101
Filename 'u-boot.bin'.
Load address: 0x30008000
Loading: T ##################
done
Bytes transferred = 256220 (3e8dc hex)
[u-boot@MINI2440]# nand write
 0x30008000 0 40000

NAND write: device 0 offset 0x0, size 0x40000
Writing at 0x2000000020000 -- 100% is complete. 262144 bytes written: OK
[u-boot@MINI2440]# nand dump 0x8000
Page 00008000 dump:
    00 00 53 e1 01 00 00 2a 15 40 e0 e3 19 00 00 ea
         ()
    60 30 97 e5 03 00 54 e1 f6 ff ff ba 00 40 a0 e3
OOB:
    ff ff ff ff ff ff ff ff
    ff ff ff ff ff ff ff ff
    ff ff ff ff ff ff ff ff
    ff ff ff ff ff ff ff ff
    ff ff ff ff ff ff ff ff
    65 a9 6b f3 ff 33 fc 30
    f3 33 cf 33 0f f0 ff 00
    cc 0f 59 55 57 96 a5 5b

    nboot 指令也是一條Nand Flash 讀取指令,它是將Nand Flash 的 offset 偏移地址的內核映像讀取到SDRAM的loadAddr位置。它會自動讀取到內核映像(使用mkimage處理過的)的結束,所以不用給出讀取大小。
格式:nboot  loadAddr  dev  offset
使用範例:

[u-boot@MINI2440]# tftp 192.168.1.100:zImage.img
dm9000 i/o: 0x20000300, id: 0x90000a46
DM9000: running in 16 bit mode
MAC: 08:08:11:18:12:27
operating at 100M full duplex mode
Using dm9000 device
TFTP from server 192.168.1.100; our IP address is 192.168.1.101
Filename 'zImage.img'.
Load address: 0x30008000
Loading: T #################################################################
     #################################################################
     ##########################
done
Bytes transferred = 2277540 (22c0a4 hex)
[u-boot@MINI2440]# nand erase 0x100000 300000

NAND erase: device 0 offset 0x100000, size 0x300000
Erasing at 0x3e000001800000 -- 0% complete.
OK
[u-boot@MINI2440]# nand write
 0x30008000 0x100000 300000

NAND write: device 0 offset 0x100000, size 0x300000
Writing at 0x3e000000020000 -- 100% is complete. 3145728 bytes written: OK
[u-boot@MINI2440]# nand device 0
Device 0: NAND 128MiB 3,3V 8-bit... is now current device
[u-boot@MINI2440]# nboot 30008000 0 0x100000

Loading from NAND 128MiB 3,3V 8-bit, offset 0x100000
   Image Name: tekkaman
   Created: 2010-03-29 12:59:51 UTC
   Image Type: ARM Linux Kernel Image (uncompressed)
   Data Size: 2277476 Bytes = 2.2 MB
   Load Address: 30008000
   Entry Point: 30008040

 [u-boot@MINI2440]# bootm 30008000
## Booting kernel from Legacy Image at 30008000 ...
   Image Name: tekkaman
   Created: 2010-03-29 12:59:51 UTC
   Image Type: ARM Linux Kernel Image (uncompressed)
   Data Size: 2277476 Bytes = 2.2 MB
   Load Address: 30008000
   Entry Point: 30008040
   Verifying Checksum ... OK
   XIP Kernel Image ... OK
OK

Starting kernel ...

Uncompressing Linux... done, booting the kernel.
Linux version 2.6.33.(tekkaman@MAGI-Linux) (gcc version 4.3.(crosstool-NG-1.6.1-tekkaman) ) #5 Mon Mar 29 20:58:50 CST 2010
CPU: ARM920T [41129200] revision 0 (ARMv4T), cr=c0007177
CPU: VIVT data cache, VIVT instruction cache
Machine: MINI2440
(略)

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章