[u-boot: v2013.04]
[Author: Bo Shen <[email protected]>]
1. 使用 (帮助信息)
U-Boot >
usb
usb - USB sub-system
Usage:
usb start - start (scan) USB controller
usb reset - reset (rescan) USB controller
usb stop [f] - stop USB [f]=force stop
usb tree - show USB device tree
usb info [dev] - show available USB devices
usb storage - show details of USB storage devices
usb dev [dev] - show or set current USB storage device
usb part [dev] - print partition table of one or all USB storage devices
usb read addr blk# cnt - read `cnt' blocks starting at block `blk#'
to memory address `addr'
usb write addr blk# cnt - write `cnt' blocks starting at block `blk#'
from memory address `addr'
1.1usb start / usb reset
U-Boot> usb start
(Re)start USB...
USB0: scanning bus 0 for devices... 2 USB Device(s) found
scanning usb for storage devices... 1 Storage Device(s) found
1.2
usb tree
U-Boot> usb tree
USB device tree:
1 Hub (12 Mb/s, 0mA)
| OHCI Root Hub
|
+-2 Mass Storage (12 Mb/s, 200mA)
Kingston DataTraveler G3 001372982955EBC0C5AB0019
1.3
usb info
(usb info 1 / usb info 2)
U-Boot> 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: Mass Storage, USB Revision 2.0
- Kingston DataTraveler G3 001372982955EBC0C5AB0019
- Class: (from Interface) Mass Storage
- PacketSize: 64 Configurations: 1
- Vendor: 0x0930 Product 0x6545 Version 1.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
1.4
usb dev
U-Boot> usb dev
USB device 0: Vendor: Kingston Rev: PMAP Prod: DataTraveler G3
Type: Removable Hard Disk
Capacity: 7441.6 MB = 7.2 GB (15240576 x 512)
2. 源代码分析
<common/cmd_usb.c>
2.1 usb start / usb reset 命令代码执行
[ strncmp(argv[1], "start", 5) == 0 ] / [ strncmp(argv[1], "reset", 5) == 0 ] --> usb_stop() --> usb_init() --> usb_stor_scan(1) (CONFIG_USB_STORAGE) --> usb_host_eth_scan(1) (CONFIG_USB_HOST_ETHER) --> drv_usb_kbd_init() (CONFIG_USB_KEYBOARD) --> return 0;
2.2 usb stop 命令代码执行
[ strncmp(argv[1], "stop", 4) == 0 ] --> (CONFIG_USB_KEYBOARD) [ argc == 2 ] --> usb_kbd_deregister() --> usb_stop --> return 0;
[ strncmp(argv[1], "stop", 4) == 0 ] --> (CONFIG_USB_KEYBOARD) [ argc != 2 ] --> console_assign(stdin, "serial") --> usb_kbd_deregister() --> usb_stop --> return 0;