天天看點

【uboot】uboot環境下usb指令uboot usb 指令

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 :