Skip to content

Commit bccf183

Browse files
mathieuchopstmjhedberg
authored andcommitted
samples: subsys: usb: testusb: improve usage instructions
Add some content in the testusb sample's README to provide a few more hints that can be handy for USB newcomers trying to get the sample running along with testusb. Signed-off-by: Mathieu Choplain <[email protected]>
1 parent fe247a9 commit bccf183

File tree

1 file changed

+50
-6
lines changed

1 file changed

+50
-6
lines changed

samples/subsys/usb/testusb/README.rst

Lines changed: 50 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ To run USB tests:
2525
2626
$ sudo modprobe usbtest vendor=0x2fe3 product=0x0009
2727
28-
The ``usbtest`` module should claim the device:
28+
By checking the kernel diagnostic messages, you should see that the ``usbtest``
29+
module has claimed the device:
2930

3031
.. code-block:: console
3132
@@ -39,6 +40,18 @@ To run USB tests:
3940
[21746.306153] usbtest 9-1:1.0: Generic USB device
4041
[21746.306156] usbtest 9-1:1.0: full-speed {control} tests
4142
43+
.. note::
44+
The kernel diagnostic messages can be displayed using a command such as
45+
``journalctl -k -n 20`` or ``dmesg`` (these commands may need to be
46+
executed as root - e.g., ``sudo dmesg``).
47+
48+
The first line of the diagnostic messages above contains two important
49+
pieces of information that will be needed later on:
50+
51+
* The USB bus number: ``9`` in ``usb 9-1: [...]``
52+
53+
* The device under testing (DUT)'s USB device number: ``16`` in ``USB device number 16``
54+
4255
#. Use the ``testusb`` tool in ``linux/tools/usb`` inside Linux kernel source directory
4356
to start the tests.
4457

@@ -49,17 +62,45 @@ To run USB tests:
4962
/dev/bus/usb/009/016 test 9, 4.994475 secs
5063
/dev/bus/usb/009/016 test 10, 11.990054 secs
5164
52-
#. To run all the tests the Zephyr's VID / PID should be inserted to USB
53-
driver id table. The method for loading the ``usbtest`` driver for our
54-
device is described here: https://lwn.net/Articles/160944/.
65+
.. note::
66+
In this command, replace ``009`` and ``016`` with the USB bus number and
67+
DUT's device number, respectively, as found in the debugging messages on
68+
your host. Do not forget to pad with zeros.
5569

56-
Since we use the "Gadget Zero" interface we specify reference device
57-
``0525:a4a0``.
70+
#. The Linux ``usbtest`` driver does not support this Zephyr sample's VID/PID
71+
so we cannot run all the tests by default. To run all the tests, we can use
72+
the feature described in the `"Dynamic USB device IDs" LWN.net article`_ to
73+
write one of the supported VID/PID pair to the ``new_id`` sysfs attribute
74+
of our device. Since the sample implements an interface similar to the
75+
"Gadget Zero" interface, we specify reference device ``0525:a4a0``.
5876

5977
.. code-block:: console
6078
6179
$ sudo sh -c "echo 0x2fe3 0x0009 0 0x0525 0xa4a0 > /sys/bus/usb/drivers/usbtest/new_id"
6280
81+
.. note::
82+
This step can be performed right after loading the ``usbtest`` module instead.
83+
Otherwise, you may have to disconnect and reconnect the DUT in order for the
84+
Gadget Zero interface to become enabled.
85+
86+
Once this step has been performed, the kernel diagnostic messages upon connecting
87+
the DUT should be similar to the following:
88+
89+
.. code-block::
90+
91+
[100458.667241] usb 3-5.3.1: new full-speed USB device number 38 using xhci_hcd
92+
[100458.761743] usb 3-5.3.1: New USB device found, idVendor=2fe3, idProduct=0009, bcdDevice= 4.02
93+
[100458.761750] usb 3-5.3.1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
94+
[100458.761753] usb 3-5.3.1: Product: Zephyr testusb sample
95+
[100458.761755] usb 3-5.3.1: Manufacturer: Zephyr Project
96+
[100458.761757] usb 3-5.3.1: SerialNumber: 2034354E32365007003C001C
97+
[100458.773785] usbtest 3-5.3.1:1.0: Linux gadget zero
98+
[100458.773791] usbtest 3-5.3.1:1.0: full-speed {control in/out bulk-in bulk-out} tests (+alt)
99+
[100458.773858] usbtest 3-5.3.1:1.1: Linux gadget zero
100+
[100458.773859] usbtest 3-5.3.1:1.1: full-speed {control in/out int-in int-out} tests (+alt)
101+
[100458.773914] usbtest 3-5.3.1:1.2: Linux gadget zero
102+
[100458.773916] usbtest 3-5.3.1:1.2: full-speed {control in/out iso-in iso-out} tests (+alt)
103+
63104
#. Use the ``testusb`` tool in ``linux/tools/usb`` inside Linux kernel source directory
64105
to start the tests.
65106

@@ -90,3 +131,6 @@ To run USB tests:
90131
/dev/bus/usb/009/017 test 27, 56.911052 secs
91132
/dev/bus/usb/009/017 test 28, 34.163089 secs
92133
/dev/bus/usb/009/017 test 29, 3.983999 secs
134+
135+
.. _"Dynamic USB device IDs" LWN.net article:
136+
https://lwn.net/Articles/160944/

0 commit comments

Comments
 (0)