Welcome 微信登录
编程资源 图片资源库 蚂蚁家优选 PDF转换器

首页 / 操作系统 / Linux / u-boot中的usb命令

[u-boot: v2013.04][Author: Bo Shen voice.shen@gmail.com]1. 使用 (帮助信息)U-Boot > usb usb - USB sub-system Usage:usb start - start (scan) USB controllerusb reset - reset (rescan) USB controllerusb stop [f] - stop USB [f]=force stopusb tree - show USB device treeusb info [dev] - show available USB devicesusb storage - show details of USB storage devicesusb dev [dev] - show or set current USB storage deviceusb part [dev] - print partition table of one or all USB storage devicesusb 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 resetU-Boot> usb start(Re)start USB...USB0: scanning bus 0 for devices... 2 USB Device(s) foundscanning usb for storage devices... 1 Storage Device(s) found1.2 usb treeU-Boot> usb treeUSB device tree:1 Hub (12 Mb/s, 0mA)| OHCI Root Hub|+-2 Mass Storage (12 Mb/s, 200mA)Kingston DataTraveler G3 001372982955EBC0C5AB00191.3 usb info (usb info 1 / usb info 2)U-Boot> usb info1: Hub, USB Revision 1.10- OHCI Root Hub- Class: Hub- PacketSize: 8 Configurations: 1- Vendor: 0x0000 Product 0x0000 Version 0.0Configuration: 1- Interfaces: 1 Self Powered 0mAInterface: 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.0Configuration: 1- Interfaces: 1 Bus Powered 200mAInterface: 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 devU-Boot> usb dev USB device 0: Vendor: Kingston Rev: PMAP Prod: DataTraveler G3Type: Removable Hard DiskCapacity: 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;