uboot下的命令使用示例

时间:2021-08-05 05:24:11

1.usb 可以使用此命令读取u盘里的内容,此命令加上相关参数可以有以下功能:

1.1usb start 在使用u盘之前必须启动此命令以初始化好fat文件系统环境,笔者的输出如下:

jello # 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设备,笔者的输出如下:

jello # 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的属性,笔者的输出如下:

jello # 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)
jello # 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盘设备信息:

jello # 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 列出设备树:

jello # 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盘的分区表

jello # 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

jello # 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指定要加载的文件名

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

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

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

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

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

4221634 bytes read

4.sf 支持spi/qspi flash的操作,必须先擦除再写

4.1 sf probe 在操作spi flash之前必须进行此操作:

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

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

4.3 sf write 写操作:

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