Documentation: usb: LOOPBACK function testing
[deliverable/linux.git] / Documentation / usb / gadget-testing.txt
CommitLineData
e38eb2c8
AP
1This file summarizes information on basic testing of USB functions
2provided by gadgets.
3
41. ACM function
d5862ca6 52. ECM function
7bfbc6e3 63. ECM subset function
4ca560a6 74. EEM function
2c0f62f9 85. FFS function
f7e3c3cd 96. HID function
ec91aff7 107. LOOPBACK function
e38eb2c8
AP
11
12
131. ACM function
14===============
15
16The function is provided by usb_f_acm.ko module.
17
18Function-specific configfs interface
19------------------------------------
20
21The function name to use when creating the function directory is "acm".
22The ACM function provides just one attribute in its function directory:
23
24 port_num
25
26The attribute is read-only.
27
28There can be at most 4 ACM/generic serial/OBEX ports in the system.
29
30
31Testing the ACM function
32------------------------
33
34On the host: cat > /dev/ttyACM<X>
35On the device : cat /dev/ttyGS<Y>
36
37then the other way round
38
39On the device: cat > /dev/ttyGS<Y>
40On the host: cat /dev/ttyACM<X>
d5862ca6
AP
41
422. ECM function
43===============
44
45The function is provided by usb_f_ecm.ko module.
46
47Function-specific configfs interface
48------------------------------------
49
50The function name to use when creating the function directory is "ecm".
51The ECM function provides these attributes in its function directory:
52
53 ifname - network device interface name associated with this
54 function instance
55 qmult - queue length multiplier for high and super speed
56 host_addr - MAC address of host's end of this
57 Ethernet over USB link
58 dev_addr - MAC address of device's end of this
59 Ethernet over USB link
60
61and after creating the functions/ecm.<instance name> they contain default
62values: qmult is 5, dev_addr and host_addr are randomly selected.
63Except for ifname they can be written to until the function is linked to a
64configuration. The ifname is read-only and contains the name of the interface
65which was assigned by the net core, e. g. usb0.
66
67Testing the ECM function
68------------------------
69
70Configure IP addresses of the device and the host. Then:
71
72On the device: ping <host's IP>
73On the host: ping <device's IP>
7bfbc6e3
AP
74
753. ECM subset function
76======================
77
78The function is provided by usb_f_ecm_subset.ko module.
79
80Function-specific configfs interface
81------------------------------------
82
83The function name to use when creating the function directory is "geth".
84The ECM subset function provides these attributes in its function directory:
85
86 ifname - network device interface name associated with this
87 function instance
88 qmult - queue length multiplier for high and super speed
89 host_addr - MAC address of host's end of this
90 Ethernet over USB link
91 dev_addr - MAC address of device's end of this
92 Ethernet over USB link
93
94and after creating the functions/ecm.<instance name> they contain default
95values: qmult is 5, dev_addr and host_addr are randomly selected.
96Except for ifname they can be written to until the function is linked to a
97configuration. The ifname is read-only and contains the name of the interface
98which was assigned by the net core, e. g. usb0.
99
100Testing the ECM subset function
101-------------------------------
102
103Configure IP addresses of the device and the host. Then:
104
105On the device: ping <host's IP>
106On the host: ping <device's IP>
4ca560a6
AP
107
1084. EEM function
109===============
110
111The function is provided by usb_f_eem.ko module.
112
113Function-specific configfs interface
114------------------------------------
115
116The function name to use when creating the function directory is "eem".
117The EEM function provides these attributes in its function directory:
118
119 ifname - network device interface name associated with this
120 function instance
121 qmult - queue length multiplier for high and super speed
122 host_addr - MAC address of host's end of this
123 Ethernet over USB link
124 dev_addr - MAC address of device's end of this
125 Ethernet over USB link
126
127and after creating the functions/eem.<instance name> they contain default
128values: qmult is 5, dev_addr and host_addr are randomly selected.
129Except for ifname they can be written to until the function is linked to a
130configuration. The ifname is read-only and contains the name of the interface
131which was assigned by the net core, e. g. usb0.
132
133Testing the EEM function
134------------------------
135
136Configure IP addresses of the device and the host. Then:
137
138On the device: ping <host's IP>
139On the host: ping <device's IP>
2c0f62f9
AP
140
1415. FFS function
142===============
143
144The function is provided by usb_f_fs.ko module.
145
146Function-specific configfs interface
147------------------------------------
148
149The function name to use when creating the function directory is "ffs".
150The function directory is intentionally empty and not modifiable.
151
152After creating the directory there is a new instance (a "device") of FunctionFS
153available in the system. Once a "device" is available, the user should follow
154the standard procedure for using FunctionFS (mount it, run the userspace
155process which implements the function proper). The gadget should be enabled
156by writing a suitable string to usb_gadget/<gadget>/UDC.
157
158Testing the FFS function
159------------------------
160
161On the device: start the function's userspace daemon, enable the gadget
162On the host: use the USB function provided by the device
f7e3c3cd
AP
163
1646. HID function
165===============
166
167The function is provided by usb_f_hid.ko module.
168
169Function-specific configfs interface
170------------------------------------
171
172The function name to use when creating the function directory is "hid".
173The HID function provides these attributes in its function directory:
174
175 protocol - HID protocol to use
176 report_desc - data to be used in HID reports, except data
177 passed with /dev/hidg<X>
178 report_length - HID report length
179 subclass - HID subclass to use
180
181For a keyboard the protocol and the subclass are 1, the report_length is 8,
182while the report_desc is:
183
184$ hd my_report_desc
18500000000 05 01 09 06 a1 01 05 07 19 e0 29 e7 15 00 25 01 |..........)...%.|
18600000010 75 01 95 08 81 02 95 01 75 08 81 03 95 05 75 01 |u.......u.....u.|
18700000020 05 08 19 01 29 05 91 02 95 01 75 03 91 03 95 06 |....).....u.....|
18800000030 75 08 15 00 25 65 05 07 19 00 29 65 81 00 c0 |u...%e....)e...|
1890000003f
190
191Such a sequence of bytes can be stored to the attribute with echo:
192
193$ echo -ne \\x05\\x01\\x09\\x06\\xa1.....
194
195Testing the HID function
196------------------------
197
198Device:
199- create the gadget
200- connect the gadget to a host, preferably not the one used
201to control the gadget
202- run a program which writes to /dev/hidg<N>, e.g.
203a userspace program found in Documentation/usb/gadget_hid.txt:
204
205$ ./hid_gadget_test /dev/hidg0 keyboard
206
207Host:
208- observe the keystrokes from the gadget
ec91aff7
AP
209
2107. LOOPBACK function
211====================
212
213The function is provided by usb_f_ss_lb.ko module.
214
215Function-specific configfs interface
216------------------------------------
217
218The function name to use when creating the function directory is "Loopback".
219The LOOPBACK function provides these attributes in its function directory:
220
221 qlen - depth of loopback queue
222 bulk_buflen - buffer length
223
224Testing the LOOPBACK function
225-----------------------------
226
227device: run the gadget
228host: test-usb
229
230http://www.linux-usb.org/usbtest/testusb.c
This page took 0.033137 seconds and 5 git commands to generate.