【uboot】uboot环境下usb命令

文章目录

  • uboot usb 命令
    • 0.环境及编译
      • 1 env
      • 2 compile
    • 1.命令使用
      • cmd 0.帮助
      • cmd 1.开始、结束、重置
      • cmd 2.info、tree、storage
      • cmd 3.读取usb设备
      • cmd 4.数据写入usb设备
      • cmd 5.
      • cmd 6.
    • 2.具体应用
      • 1.读取u盘数据
      • 2.数据写入U盘

uboot usb 命令

0.环境及编译

1 env

# env:
openwrt, u-boot-2016 
# usb设备:
FAT , 

2 compile

# compile:

1.命令使用

cmd 0.帮助

# cmd : 
help usb

# src : help部分的说明源码如下:
/*
823 U_BOOT_CMD(
  1     usb,    5,  1,  do_usb,
  2     "USB sub-system",
  3     "start - start (scan) USB controller\n"
  4     "usb reset - reset (rescan) USB controller\n"
  5     "usb stop [f] - stop USB [f]=force stop\n"
  6     "usb tree - show USB device tree\n"
  7     "usb info [dev] - show available USB devices\n"
  8     "usb test [dev] [port] [mode] - set USB 2.0 test mode\n"
  9     "    (specify port 0 to indicate the device's upstream port)\n"
 10     "    Available modes: J, K, S[E0_NAK], P[acket], F[orce_Enable]\n"
 11 #ifdef CONFIG_USB_STORAGE
 12     "usb storage - show details of USB storage devices\n"
 13     "usb dev [dev] - show or set current USB storage device\n"
 14     "usb part [dev] - print partition table of one or all USB storage"
 15     "    devices\n"
 16     "usb read addr blk# cnt - read `cnt' blocks starting at block `blk#'\n"
 17     "    to memory address `addr'\n"
 18     "usb write addr blk# cnt - write `cnt' blocks starting at block `blk#'\n"
 19     "    from memory address `addr'"
 20 #endif /* CONFIG_USB_STORAGE */
 21 ); 
 */

cmd 1.开始、结束、重置

# cmd :
usb start	//开始检索usb设备,注册低速总线,搜索总线设备等。
usb stop    //停止usb设备,关闭一些clock\bus\clock之类的。
usb reset   //类似start

# log :
/*
IPQ6018# usb start
starting USB...
USB0:   Register 2000140 NbrPorts 2
Starting the controller
USB XHCI 1.10
scanning bus 0 for devices... 1 USB Device(s) found
USB1:   Register 1000140 NbrPorts 1
Starting the controller
USB XHCI 1.10
scanning bus 1 for devices... 2 USB Device(s) found
IPQ6018#  
IPQ6018# 
IPQ6018# usb stop
stopping USB..
IPQ6018#  
IPQ6018# usb reset
resetting USB...
USB0:   Register 2000140 NbrPorts 2
Starting the controller
USB XHCI 1.10
scanning bus 0 for devices... 1 USB Device(s) found
USB1:   Register 1000140 NbrPorts 1
Starting the controller
USB XHCI 1.10
scanning bus 1 for devices... 2 USB Device(s) found
IPQ6018# 
*/

cmd 2.info、tree、storage

# cmd :
usb tree 
usb info 
usb storage
# log :
/*
IPQ6018# usb tree
USB device tree:
  1  Hub (5 Gb/s, 0mA)
     U-Boot XHCI Host Controller 
   
  1  Hub (5 Gb/s, 0mA)
  |  U-Boot XHCI Host Controller 
  |
  +-2  Mass Storage (480 Mb/s, 224mA)
       SanDisk Ultra USB 3.0 4C530000021024102591
     
IPQ6018# usb info 1
config for device 1
2: Mass Storage,  USB Revision 2.10
 - SanDisk Ultra USB 3.0 4C530000021024102591
 - Class: (from Interface) Mass Storage
 - PacketSize: 64  Configurations: 1
 - Vendor: 0x0781  Product 0x5591 Version 1.0
   Configuration: 1
   - Interfaces: 1 Bus Powered 224mA
     Interface: 0
     - Alternate Setting 0, Endpoints: 2
     - Class Mass Storage, Transp. SCSI, Bulk only
     - Endpoint 1 In Bulk MaxPacket 512
     - Endpoint 2 Out Bulk MaxPacket 512

IPQ6018#  
IPQ6018# usb info
1: Hub,  USB Revision 3.0
 - U-Boot XHCI Host Controller 
 - Class: Hub
 - PacketSize: 9  Configurations: 1
 - Vendor: 0x0000  Product 0x0000 Version 1.0
   Configuration: 1
   - Interfaces: 1 Self Powered 0mA
     Interface: 0
     - Alternate Setting 0, Endpoints: 1
     - Class Hub
     - Endpoint 1 In Interrupt MaxPacket 8 Interval 255ms

1: Hub,  USB Revision 3.0
 - U-Boot XHCI Host Controller 
 - Class: Hub
 - PacketSize: 9  Configurations: 1
 - Vendor: 0x0000  Product 0x0000 Version 1.0
   Configuration: 1
   - Interfaces: 1 Self Powered 0mA
     Interface: 0
     - Alternate Setting 0, Endpoints: 1
     - Class Hub
     - Endpoint 1 In Interrupt MaxPacket 8 Interval 255ms

2: Mass Storage,  USB Revision 2.10
 - SanDisk Ultra USB 3.0 4C530000021024102591
 - Class: (from Interface) Mass Storage
 - PacketSize: 64  Configurations: 1
 - Vendor: 0x0781  Product 0x5591 Version 1.0
   Configuration: 1
   - Interfaces: 1 Bus Powered 224mA
     Interface: 0
     - Alternate Setting 0, Endpoints: 2
     - Class Mass Storage, Transp. SCSI, Bulk only
     - Endpoint 1 In Bulk MaxPacket 512
     - Endpoint 2 Out Bulk MaxPacket 512

IPQ6018#  
IPQ6018# usb storage
  Device 0: Vendor: SanDisk Rev: 1.00 Prod: Ultra USB 3.0
            Type: Removable Hard Disk
            Capacity: 14664.0 MB = 14.3 GB (30031872 x 512)
IPQ6018# 
*/

cmd 3.读取usb设备

# cmd :

# log :

cmd 4.数据写入usb设备

# cmd :

# log :

cmd 5.

# cmd :

# log :

cmd 6.

# cmd :

# log :

2.具体应用

1.读取u盘数据

# cmd :

# log :

2.数据写入U盘

# cmd :

# log :

你可能感兴趣的:(#,uboot,u-boot,usb)