首頁 > 軟體

uboot下的命令使用範例

2020-06-16 17:05:22

1.usb 可以使用此命令讀取u盤裡的內容,此命令加上相關引數可以有以下功能:

1.1usb start 在使用u盤之前必須啟動此命令以初始化好fat檔案系統環境,筆者的輸出如下:

linuxidc # usb start
(Re)start USB...
USB:  Starting the controller
scanning bus for devices... 5 USB Device(s) found
      scanning bus for storage devices... usb_stor_get_info->1431,blksz:512
Device NOT ready
  Request Sense returned 02 3A 00
2 Storage Device(s) found

 

1.2 usb dev 檢視檢測到的usb裝置,筆者的輸出如下:

linuxidc # usb dev

USB device 0: Vendor: Lexar    Rev: 1100 Prod: USB Flash Drive
            Type: Removable Hard Disk
            Capacity: 3824.0 MB = 3.7 GB (7831552 x 512)

1.3 usb info可列出usb host的屬性,筆者的輸出如下:

linuxidc # usb dev

USB device 0: Vendor: Lexar    Rev: 1100 Prod: USB Flash Drive
            Type: Removable Hard Disk
            Capacity: 3824.0 MB = 3.7 GB (7831552 x 512)
linuxidc # usb info
1: Hub,  USB Revision 1.10
 -  OHCI Root Hub
 - Class: Hub
 - PacketSize: 8  Configurations: 1
 - Vendor: 0x0000  Product 0x0000 Version 0.0
  Configuration: 1
  - Interfaces: 1 Self Powered 0mA
    Interface: 0
    - Alternate Setting 0, Endpoints: 1
    - Class Hub
    - Endpoint 1 In Interrupt MaxPacket 2 Interval 255ms

2: Hub,  USB Revision 2.0
 -  USB2.0 Hub
 - Class: Hub
 - PacketSize: 64  Configurations: 1
 - Vendor: 0x05e3  Product 0x0608 Version 133.54
  Configuration: 1
  - Interfaces: 1 Self Powered Remote Wakeup 100mA
    Interface: 0
    - Alternate Setting 0, Endpoints: 1
    - Class Hub
    - Endpoint 1 In Interrupt MaxPacket 1 Interval 255ms

3: Hub,  USB Revision 2.0
 -  USB2.0 Hub
 - Class: Hub
 - PacketSize: 64  Configurations: 1
 - Vendor: 0x05e3  Product 0x0608 Version 133.54
  Configuration: 1
  - Interfaces: 1 Self Powered Remote Wakeup 100mA
    Interface: 0
    - Alternate Setting 0, Endpoints: 1
    - Class Hub
    - Endpoint 1 In Interrupt MaxPacket 1 Interval 255ms

4: Mass Storage,  USB Revision 2.0
 - Lexar USB Flash Drive AA066NWLMLMLBQPX
 - Class: (from Interface) Mass Storage
 - PacketSize: 64  Configurations: 1
 - Vendor: 0x05dc  Product 0xa813 Version 17.0
  Configuration: 1
  - Interfaces: 1 Bus Powered 200mA
    Interface: 0
    - Alternate Setting 0, Endpoints: 2
    - Class Mass Storage, Transp. SCSI, Bulk only
    - Endpoint 1 In Bulk MaxPacket 64
    - Endpoint 2 Out Bulk MaxPacket 64

5: Mass Storage,  USB Revision 2.0
 - Generic Ultra Fast Media  000000225001
 - Class: (from Interface) Mass Storage
 - PacketSize: 64  Configurations: 1
 - Vendor: 0x0424  Product 0x2240 Version 1.152
  Configuration: 1
  - Interfaces: 1 Bus Powered 96mA
    Interface: 0
    - Alternate Setting 0, Endpoints: 2
    - Class Mass Storage, Transp. SCSI, Bulk only
    - Endpoint 2 Out Bulk MaxPacket 64
    - Endpoint 2 In Bulk MaxPacket 64

1.4 usb storage 可列出u盤裝置資訊:

linuxidc # usb storage
  Device 0: Vendor: Lexar    Rev: 1100 Prod: USB Flash Drive
            Type: Removable Hard Disk
            Capacity: 3824.0 MB = 3.7 GB (7831552 x 512)
  Device 1: Vendor: Generic  Rev: 1.98 Prod: Ultra HS-COMBO
            Type: Removable Hard Disk
            Capacity: not available

1.5 usb tree 列出裝置樹:

linuxidc # usb tree

Device Tree:
  1  Hub (12 Mb/s, 0mA)
  |  OHCI Root Hub
  |
  +-2  Hub (12 Mb/s, 100mA)
    |  USB2.0 Hub
    |
    +-3  Hub (12 Mb/s, 100mA)
    | |  USB2.0 Hub
    | |
    | +-4  Mass Storage (12 Mb/s, 200mA)
    |      Lexar USB Flash Drive AA066NWLMLMLFEPX
    |   
    +-5  Mass Storage (12 Mb/s, 96mA)
        Generic Ultra Fast Media  000000135404

1.6 usb part 列出u盤的分割區表

linuxidc # usb part

Partition Map for USB device 0  --  Partition Type: DOS

Partition    Start Sector    Num Sectors    Type
    1              2048      7829504    83

## Unknown partition table

 

2. fatls 列出fat檔案系統中的內容,i其用法如下:

usage: fatls <interface> <dev[:part]> [directory]  interface是指定哪種型別的裝置,此處筆者用的usb裝置,因此填入usb,dev就是裝置號,筆者從以上命令得知為0

linuxidc # fatls usb 0
  187495  check.png
            system volume information/
  4051616  uimage
            hello/
            .trash-1000/

  2 file(s), 3 dir(s)
3. fatload 從u盤載入檔案到指定記憶體地址處,用法如下:

usage: fatload <interface> <dev[:part]> <addr> <filename> [bytes]  interface和dev不再敘述,addr 指定要載入檔案到記憶體的某個地址,filename指定要載入的檔名

linuxidc # fatload usb 0 0x42000000 uimage
reading uimage
..............................................................................

...............................................................................

................................................................................

...................................................................................

...........................................................................

4221634 bytes read

 

4.sf 支援spi/qspi flash的操作,必須先擦除再寫

4.1 sf probe 在操作spi flash之前必須進行此操作:

linuxidc # sf probe 0
32768 KiB spi_flash at 0:0 is now current device
4.2 sf erase 擦除操作:

linuxidc # sf erase 0x100000 0x400000  (0x100000是要擦除的起始地址,0x400000為指定要擦除的大小)
Erasing at 0x500000 -- 100% complete.

 

4.3 sf write 寫操作:

linuxidc # sf write 0x42000000 0x100000 0x400000
Writing at 0x500000 -- 100% complete.

分析uboot中 make xxx_config過程  http://www.linuxidc.com/Linux/2017-06/145292.htm

U-Boot原始碼下載地址 http://www.linuxidc.com/Linux/2011-07/38897.htm

本文永久更新連結地址http://www.linuxidc.com/Linux/2017-10/147367.htm


IT145.com E-mail:sddin#qq.com