NOTICE: The Processors Wiki will End-of-Life on January 15, 2021. It is recommended to download any files or other content you may need that are hosted on processors.wiki.ti.com. The site is now set to read only.

Usbtest

From Texas Instruments Wiki
Jump to: navigation, search

About[edit]

The usbtest is an open source utility for testing end point transfers. It tests the control, bulk and iso end points by generating variety of transfer patterns. Supports -

  • ioctls to perform the tests implemented by the kernel driver.
  • Generate a variety of transfer patterns. Make sure to test both regular streaming and mixes of transfer sizes (including short transfers).
  • Read/write data of different sizes n number of times (Bulk tranfers).
  • Control traffic tests
  • Back-to-back control transfers, inducing faults such as protocol stalls. This exposes races, fault handling bugs, and various annoying combinations of the two.
  • Scatterlist tests have been good at doing the same thing as mentioned in previous bullet for bulk transfers.
  • control-OUT type transfer tests that are essential for supporting RNDIS connections to MS-Windows.

Visit USB test wepage for more information.


Source Download Location[edit]


Cross compiling[edit]

Building kernel image (Dependancy to use testusb)

  • Enable USB testing driver as module(The exact option in menuconfig is- USB Testing driver(DEVELOPMENT or EXPERIMENTAL) - Make this as module)
  • Disable MSC class driver(The exact option that appears in menuconfig is - USB Mass storage Support - Make this option as a module or disable it). This is to make sure that the slave device plugged in registers with usb test driver.
  • Build the image and usbtest.ko module(menuconfig to build usbtest module already done as part of step 1).


Compiling testusb.c

  • Compilation command - $(TOOL_CHAIN_PREFIX) -Wall -g -lpthread -o testusb testusb.c
The TOOL_CHAIN_PREFIX corresponds to the tool chain in use. Set this based on your tool chain. Also make path to toolchain is exported as part of $PATH

Test setup[edit]

  • EVM booted up with NFS configuration.


Execution[edit]

  • Boot the EVM with the uImage built as part of section Building kernel image above.
  • mount -t usbfs usbfs /proc/bus/usb
  • connect the MSC slave device to the hub
  • check vendor id and product id of the connected device by : "cat /proc/bus/usb/devices"

device file will contain something like this:

T:  Bus=01 Lev=00 Prnt=00 Port=00 Cnt=00 Dev#=  1 Spd=480 MxCh= 1
B:  Alloc=  0/800 us ( 0%), #Int=  0, #Iso=  0
D:  Ver= 2.00 Cls=09(hub  ) Sub=00 Prot=01 MxPS=64 #Cfgs=  1
P:  Vendor=0000 ProdID=0000 Rev= 2.06
S:  Manufacturer=Linux 2.6.22.18-omap3 musb-hcd
S:  Product=MUSB HDRC host driver
S:  SerialNumber=musb_hdrc.0
C:* #Ifs= 1 Cfg#= 1 Atr=e0 MxPwr=  0mA
I:* If#= 0 Alt= 0 #EPs= 1 Cls=09(hub  ) Sub=00 Prot=00 Driver=hub
E:  Ad=81(I) Atr=03(Int.) MxPS=   4 Ivl=256ms

T:  Bus=01 Lev=01 Prnt=01 Port=00 Cnt=01 Dev#=  7 Spd=480 MxCh= 7
D:  Ver= 2.00 Cls=09(hub  ) Sub=00 Prot=01 MxPS=64 #Cfgs=  1
P:  Vendor=2001 ProdID=f103 Rev= 1.00
C:* #Ifs= 1 Cfg#= 1 Atr=e0 MxPwr=  0mA
I:* If#= 0 Alt= 0 #EPs= 1 Cls=09(hub  ) Sub=00 Prot=00 Driver=hub
E:  Ad=81(I) Atr=03(Int.) MxPS=   1 Ivl=256ms

T:  Bus=01 Lev=02 Prnt=07 Port=05 Cnt=01 Dev#=  8 Spd=480 MxCh= 0
D:  Ver= 2.00 Cls=00(>ifc ) Sub=00 Prot=00 MxPS=64 #Cfgs=  1
P:  Vendor=05dc ProdID=a400 Rev=20.00
S:  Manufacturer=LEXAR MEDIA
S:  Product=JUMPDRIVE PRO
S:  SerialNumber=67CBF808034854150306
C:* #Ifs= 1 Cfg#= 1 Atr=80 MxPwr=100mA
I:* If#= 0 Alt= 0 #EPs= 2 Cls=08(stor.) Sub=06 Prot=50 Driver=none
E:  Ad=81(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms
E:  Ad=02(O) Atr=02(Bulk) MxPS= 512 Ivl=31875us

(see Inventra HDRC USB Controller for details on the MUSB HDRC host/gadget driver)

Here vendor ID is "Vendor=05dc" and Product ID is "ProdID=a400".Since MSC class driver is not enabled so "Driver=none" is displayed.

  • insmod usbtest.ko vendor=0x____ product=0x____
  • insmod usbtest.ko vendor=0x05dc product=0xa400
<6>usbcore: registered new interface driver usbtest
usbcore: registered new interface driver usbtest
[root@beagleboard /tmp]# <6>usb 1-1: USB disconnect, address 2
usb 1-1: USB disconnect, address 2
<6>usb 1-1.6: USB disconnect, address 3
usb 1-1.6: USB disconnect, address 3
<6>usb 1-1: new high speed USB device using musb_hdrc and address 4
usb 1-1: new high speed USB device using musb_hdrc and address 4
<3>usb 1-1: device descriptor read/64, error -19
usb 1-1: device descriptor read/64, error -19
<3>usb 1-1: device descriptor read/64, error -19
usb 1-1: device descriptor read/64, error -19
<6>usb 1-1: new high speed USB device using musb_hdrc and address 5
usb 1-1: new high speed USB device using musb_hdrc and address 5
<3>usb 1-1: device descriptor read/64, error -19
usb 1-1: device descriptor read/64, error -19
<3>usb 1-1: device descriptor read/64, error -19
usb 1-1: device descriptor read/64, error -19
<6>usb 1-1: new high speed USB device using musb_hdrc and address 6
usb 1-1: new high speed USB device using musb_hdrc and address 6
<3>usb 1-1: device not accepting address 6, error -19
usb 1-1: device not accepting address 6, error -19
  • Now disconnect/connect the USB cable to the Hub(Device is connected to a Hub which inturn is directly connected to EVM).

Logs after connecting the cable back-

[root@beagleboard /tmp]# <6>usb 1-1: new high speed USB device using musb_hdrc a
nd address 7
usb 1-1: new high speed USB device using musb_hdrc and address 7
<6>usb 1-1: configuration #1 chosen from 1 choice
usb 1-1: configuration #1 chosen from 1 choice
<6>hub 1-1:1.0: USB hub found
hub 1-1:1.0: USB hub found
<6>hub 1-1:1.0: 7 ports detected
hub 1-1:1.0: 7 ports detected
<6>usb 1-1.6: new high speed USB device using musb_hdrc and address 8
usb 1-1.6: new high speed USB device using musb_hdrc and address 8
<6>usb 1-1.6: configuration #1 chosen from 1 choice
usb 1-1.6: configuration #1 chosen from 1 choice
<6>usbtest 1-1.6:1.0: Generic USB device
usbtest 1-1.6:1.0: Generic USB device
<6>usbtest 1-1.6:1.0: high speed {control} tests
usbtest 1-1.6:1.0: high speed {control} tests
  • After this step issuing "cat /proc/bus/usb/devices" will give "Driver=usbtest"
[root@beagleboard /tmp]# cat /proc/bus/usb/devices

T:  Bus=01 Lev=00 Prnt=00 Port=00 Cnt=00 Dev#=  1 Spd=480 MxCh= 1
B:  Alloc=  0/800 us ( 0%), #Int=  0, #Iso=  0
D:  Ver= 2.00 Cls=09(hub  ) Sub=00 Prot=01 MxPS=64 #Cfgs=  1
P:  Vendor=0000 ProdID=0000 Rev= 2.06
S:  Manufacturer=Linux 2.6.22.18-omap3 musb-hcd
S:  Product=MUSB HDRC host driver
S:  SerialNumber=musb_hdrc.0
C:* #Ifs= 1 Cfg#= 1 Atr=e0 MxPwr=  0mA
I:* If#= 0 Alt= 0 #EPs= 1 Cls=09(hub  ) Sub=00 Prot=00 Driver=hub
E:  Ad=81(I) Atr=03(Int.) MxPS=   4 Ivl=256ms

T:  Bus=01 Lev=01 Prnt=01 Port=00 Cnt=01 Dev#=  7 Spd=480 MxCh= 7
D:  Ver= 2.00 Cls=09(hub  ) Sub=00 Prot=01 MxPS=64 #Cfgs=  1
P:  Vendor=2001 ProdID=f103 Rev= 1.00
C:* #Ifs= 1 Cfg#= 1 Atr=e0 MxPwr=  0mA
I:* If#= 0 Alt= 0 #EPs= 1 Cls=09(hub  ) Sub=00 Prot=00 Driver=hub
E:  Ad=81(I) Atr=03(Int.) MxPS=   1 Ivl=256ms

T:  Bus=01 Lev=02 Prnt=07 Port=05 Cnt=01 Dev#=  8 Spd=480 MxCh= 0
D:  Ver= 2.00 Cls=00(>ifc ) Sub=00 Prot=00 MxPS=64 #Cfgs=  1
P:  Vendor=05dc ProdID=a400 Rev=20.00
S:  Manufacturer=LEXAR MEDIA
S:  Product=JUMPDRIVE PRO
S:  SerialNumber=67CBF808034854150306
C:* #Ifs= 1 Cfg#= 1 Atr=80 MxPwr=100mA
I:* If#= 0 Alt= 0 #EPs= 2 Cls=08(stor.) Sub=06 Prot=50 Driver=usbtest
E:  Ad=81(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms
E:  Ad=02(O) Atr=02(Bulk) MxPS= 512 Ivl=31875us
  • run testusb as: "./testusb -D /proc/bus/usb/001/xyz"
    • Where xyz is the bus number on which device is connected.
    • xyz can be obtained from /proc/bus/usb/devices (Look for Dev# and replace xyz with that number).


Execution logs[edit]

root@beagleboard /tmp]# ./testusb -D /proc/bus/usb/001/008
./testusb: /proc/bus/usb/001/008 may see only control tests
/proc/bus/usb/001/008 test 0,    0.000000 secs
/proc/bus/usb/001/008 test 9,    1.838287 secs
/proc/bus/usb/001/008 test 10,    9.253235 secs
NOTE
---------------
1. Only Control end point tests can be run using a device which is a registered in MSC or HID class.
2. To run both bulk and control end point tests, use a gadget zero device. A Davinci Board can be used for this purpose. 
Building gadget zero
------------------------------
1) Enable gadget support(Exact option in menuconfig - USB gagdget support under device drivers->USB support) statically.
2)Enter inside the USB gadget support. Now enable - "Support for USB gadgets" (statically). This will enable USB gadget Drivers as module.
3) Now enable Gadget Zero(DEVELOPMENT) as module.
4) Now enable Driver mode as USB peripheral(gadget stack). The driver mode option is present under Inventra HDRC option in menuconfig(under USB support). 

Now boot up an EVM(say OMAP35x) with the above kernel image.
On the OMAP35x EVM, do the following-

root@OMAP3EVM saumya]# insmod g_zero.ko
zero gadget: Gadget Zero, version: St Patrick's Day 2004
zero gadget: using musb_hdrc, OUT ep1out IN ep1in

Logs on beagle
-------------------
[root@OMAP3EVM saumya]# <6>usb 1-1.2: new high speed USB device using musb_hdrc
and address 9
usb 1-1.2: new high speed USB device using musb_hdrc and address 9
<6>usb 1-1.2: configuration #3 chosen from 2 choices
usb 1-1.2: configuration #3 chosen from 2 choices
<6>usbtest 1-1.2:3.0: Linux gadget zero
usbtest 1-1.2:3.0: Linux gadget zero
<6>usbtest 1-1.2:3.0: high speed {control in/out bulk-in bulk-out} tests (+alt)
usbtest 1-1.2:3.0: high speed {control in/out bulk-in bulk-out} tests (+alt)



Now connect the OMAP35x EVM(gadget zero device in our case) to the Beagle board(acting as Host with usbtest built).

Issue cat /proc/bus/usb/devices. You will see OMAP35x device being listed here as below-

T:  Bus=01 Lev=02 Prnt=07 Port=01 Cnt=01 Dev#=  9 Spd=480 MxCh= 0
D:  Ver= 2.00 Cls=ff(vend.) Sub=00 Prot=00 MxPS=64 #Cfgs=  2
P:  Vendor=0525 ProdID=a4a0 Rev= 2.16
S:  Manufacturer=Linux 2.6.22.18-omap3 with musb_hdrc
S:  Product=Gadget Zero
S:  SerialNumber=0123456789.0123456789.0123456789
C:* #Ifs= 1 Cfg#= 3 Atr=c0 MxPwr=  2mA
I:* If#= 0 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=00 Prot=00 Driver=usbtest
E:  Ad=81(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms
E:  Ad=01(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms
C:  #Ifs= 1 Cfg#= 2 Atr=c0 MxPwr=  2mA
I:  If#= 0 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=00 Prot=00 Driver=
E:  Ad=81(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms
E:  Ad=01(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms

Now if the usbtest.ko is alreday inserted, just issue-
./testusb -a

else

insmod usbtest.ko with vendor id and product id of OMAP35x device.

[root@beagleboard /tmp]# insmod usbtest.ko vendor=0x0525 product=0xa4a0

Logs
-------------

[root@beagleboard /tmp]# ./testusb -a
unknown speed   /proc/bus/usb/001/009
/proc/bus/usb/001/009 test 0,    0.000000 secs
/proc/bus/usb/001/009 test 1,    0.165344 secs
/proc/bus/usb/001/009 test 2,    0.097076 secs
/proc/bus/usb/001/009 test 3,    0.165772 secs
/proc/bus/usb/001/009 test 4,    0.096558 secs
/proc/bus/usb/001/009 test 5,    5.316803 secs
/proc/bus/usb/001/009 test 6,    2.473480 secs
/proc/bus/usb/001/009 test 7,    5.313537 secs
/proc/bus/usb/001/009 test 8,    2.474273 secs
/proc/bus/usb/001/009 test 9,    0.577332 secs
/proc/bus/usb/001/009 test 10,    1.202819 secs
<3>musb_host_rx 1615: Rx interrupt with no errors or packet!
musb_host_rx 1615: Rx interrupt with no errors or packet!
<4>musb_rx_reinit 596: rx1, packet/512 ready?
musb_rx_reinit 596: rx1, packet/512 ready?
<3>musb_host_rx 1615: Rx interrupt with no errors or packet!
musb_host_rx 1615: Rx interrupt with no errors or packet!
<4>musb_rx_reinit 596: rx1, packet/0 ready?
musb_rx_reinit 596: rx1, packet/0 ready?
<3>musb_host_rx 1615: Rx interrupt with no errors or packet!
musb_host_rx 1615: Rx interrupt with no errors or packet!
<4>musb_rx_reinit 596: rx1, packet/0 ready?
musb_rx_reinit 596: rx1, packet/0 ready?
<3>musb_host_rx 1615: Rx interrupt with no errors or packet!
musb_host_rx 1615: Rx interrupt with no errors or packet!
<4>musb_rx_reinit 596: rx1, packet/0 ready?
musb_rx_reinit 596: rx1, packet/0 ready?
<3>musb_host_rx 1615: Rx interrupt with no errors or packet!
musb_host_rx 1615: Rx interrupt with no errors or packet!
<3>musb_host_rx 1615: Rx interrupt with no errors or packet!
musb_host_rx 1615: Rx interrupt with no errors or packet!
<4>musb_rx_reinit 596: rx1, packet/0 ready?
musb_rx_reinit 596: rx1, packet/0 ready?
<3>musb_host_rx 1615: Rx interrupt with no errors or packet!
musb_host_rx 1615: Rx interrupt with no errors or packet!
<4>musb_rx_reinit 596: rx1, packet/0 ready?
musb_rx_reinit 596: rx1, packet/0 ready?
<3>musb_host_rx 1615: Rx interrupt with no errors or packet!
musb_host_rx 1615: Rx interrupt with no errors or packet!
<4>musb_rx_reinit 596: rx1, packet/0 ready?
musb_rx_reinit 596: rx1, packet/0 ready?
<3>musb_host_rx 1615: Rx interrupt with no errors or packet!
musb_host_rx 1615: Rx interrupt with no errors or packet!
<4>musb_rx_reinit 596: rx1, packet/0 ready?
musb_rx_reinit 596: rx1, packet/0 ready?
<3>musb_host_rx 1615: Rx interrupt with no errors or packet!
musb_host_rx 1615: Rx interrupt with no errors or packet!
<3>musb_host_rx 1615: Rx interrupt with no errors or packet!
musb_host_rx 1615: Rx interrupt with no errors or packet!
<3>musb_host_rx 1615: Rx interrupt with no errors or packet!
musb_host_rx 1615: Rx interrupt with no errors or packet!
<4>musb_rx_reinit 596: rx1, packet/512 ready?
musb_rx_reinit 596: rx1, packet/512 ready?
<3>musb_host_rx 1615: Rx interrupt with no errors or packet!
musb_host_rx 1615: Rx interrupt with no errors or packet!
<4>musb_rx_reinit 596: rx1, packet/0 ready?
musb_rx_reinit 596: rx1, packet/0 ready?
<3>musb_host_rx 1615: Rx interrupt with no errors or packet!
musb_host_rx 1615: Rx interrupt with no errors or packet!
<3>musb_host_rx 1615: Rx interrupt with no errors or packet!
musb_host_rx 1615: Rx interrupt with no errors or packet!
<4>musb_rx_reinit 596: rx1, packet/0 ready?
musb_rx_reinit 596: rx1, packet/0 ready?
<3>musb_host_rx 1615: Rx interrupt with no errors or packet!
musb_host_rx 1615: Rx interrupt with no errors or packet!
<3>musb_host_rx 1615: Rx interrupt with no errors or packet!
musb_host_rx 1615: Rx interrupt with no errors or packet!
<4>musb_rx_reinit 596: rx1, packet/0 ready?

/proc/bus/usb/001/009 test 11,   31.526245 secs
/proc/bus/usb/001/009 test 12,   31.239166 secs
/proc/bus/usb/001/009 test 13 --> 22 (Invalid argument)
/proc/bus/usb/001/009 test 14 --> 22 (Invalid argument)

Now run Test 13 and 14 manually as below-

[root@beagleboard /tmp]# ./testusb -D /proc/bus/usb/001/009 -t 14 -c 15000 -s 25
6 -v 1
unknown speed   /proc/bus/usb/001/009
/proc/bus/usb/001/009 test 14,    3.014953 secs

[root@beagleboard /tmp]# ./testusb -D /proc/bus/usb/001/009 -t 13
unknown speed   /proc/bus/usb/001/009
/proc/bus/usb/001/009 test 13 --> 22 (Invalid argument)
E2e.jpg {{
  1. switchcategory:MultiCore=
  • For technical support on MultiCore devices, please post your questions in the C6000 MultiCore Forum
  • For questions related to the BIOS MultiCore SDK (MCSDK), please use the BIOS Forum

Please post only comments related to the article Usbtest here.

Keystone=
  • For technical support on MultiCore devices, please post your questions in the C6000 MultiCore Forum
  • For questions related to the BIOS MultiCore SDK (MCSDK), please use the BIOS Forum

Please post only comments related to the article Usbtest here.

C2000=For technical support on the C2000 please post your questions on The C2000 Forum. Please post only comments about the article Usbtest here. DaVinci=For technical support on DaVincoplease post your questions on The DaVinci Forum. Please post only comments about the article Usbtest here. MSP430=For technical support on MSP430 please post your questions on The MSP430 Forum. Please post only comments about the article Usbtest here. OMAP35x=For technical support on OMAP please post your questions on The OMAP Forum. Please post only comments about the article Usbtest here. OMAPL1=For technical support on OMAP please post your questions on The OMAP Forum. Please post only comments about the article Usbtest here. MAVRK=For technical support on MAVRK please post your questions on The MAVRK Toolbox Forum. Please post only comments about the article Usbtest here. For technical support please post your questions at http://e2e.ti.com. Please post only comments about the article Usbtest here.

}}

Hyperlink blue.png Links

Amplifiers & Linear
Audio
Broadband RF/IF & Digital Radio
Clocks & Timers
Data Converters

DLP & MEMS
High-Reliability
Interface
Logic
Power Management

Processors

Switches & Multiplexers
Temperature Sensors & Control ICs
Wireless Connectivity