Documentation: usb: OBEX function testing
[GitHub/moto-9609/android_kernel_motorola_exynos9610.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
cdbe287d 118. MASS STORAGE function
0d6be59a 129. MIDI function
4d0fa79e 1310. NCM function
d81b85dc 1411. OBEX function
e38eb2c8
AP
15
16
171. ACM function
18===============
19
20The function is provided by usb_f_acm.ko module.
21
22Function-specific configfs interface
23------------------------------------
24
25The function name to use when creating the function directory is "acm".
26The ACM function provides just one attribute in its function directory:
27
28 port_num
29
30The attribute is read-only.
31
32There can be at most 4 ACM/generic serial/OBEX ports in the system.
33
34
35Testing the ACM function
36------------------------
37
38On the host: cat > /dev/ttyACM<X>
39On the device : cat /dev/ttyGS<Y>
40
41then the other way round
42
43On the device: cat > /dev/ttyGS<Y>
44On the host: cat /dev/ttyACM<X>
d5862ca6
AP
45
462. ECM function
47===============
48
49The function is provided by usb_f_ecm.ko module.
50
51Function-specific configfs interface
52------------------------------------
53
54The function name to use when creating the function directory is "ecm".
55The ECM function provides these attributes in its function directory:
56
57 ifname - network device interface name associated with this
58 function instance
59 qmult - queue length multiplier for high and super speed
60 host_addr - MAC address of host's end of this
61 Ethernet over USB link
62 dev_addr - MAC address of device's end of this
63 Ethernet over USB link
64
65and after creating the functions/ecm.<instance name> they contain default
66values: qmult is 5, dev_addr and host_addr are randomly selected.
67Except for ifname they can be written to until the function is linked to a
68configuration. The ifname is read-only and contains the name of the interface
69which was assigned by the net core, e. g. usb0.
70
71Testing the ECM function
72------------------------
73
74Configure IP addresses of the device and the host. Then:
75
76On the device: ping <host's IP>
77On the host: ping <device's IP>
7bfbc6e3
AP
78
793. ECM subset function
80======================
81
82The function is provided by usb_f_ecm_subset.ko module.
83
84Function-specific configfs interface
85------------------------------------
86
87The function name to use when creating the function directory is "geth".
88The ECM subset function provides these attributes in its function directory:
89
90 ifname - network device interface name associated with this
91 function instance
92 qmult - queue length multiplier for high and super speed
93 host_addr - MAC address of host's end of this
94 Ethernet over USB link
95 dev_addr - MAC address of device's end of this
96 Ethernet over USB link
97
98and after creating the functions/ecm.<instance name> they contain default
99values: qmult is 5, dev_addr and host_addr are randomly selected.
100Except for ifname they can be written to until the function is linked to a
101configuration. The ifname is read-only and contains the name of the interface
102which was assigned by the net core, e. g. usb0.
103
104Testing the ECM subset function
105-------------------------------
106
107Configure IP addresses of the device and the host. Then:
108
109On the device: ping <host's IP>
110On the host: ping <device's IP>
4ca560a6
AP
111
1124. EEM function
113===============
114
115The function is provided by usb_f_eem.ko module.
116
117Function-specific configfs interface
118------------------------------------
119
120The function name to use when creating the function directory is "eem".
121The EEM function provides these attributes in its function directory:
122
123 ifname - network device interface name associated with this
124 function instance
125 qmult - queue length multiplier for high and super speed
126 host_addr - MAC address of host's end of this
127 Ethernet over USB link
128 dev_addr - MAC address of device's end of this
129 Ethernet over USB link
130
131and after creating the functions/eem.<instance name> they contain default
132values: qmult is 5, dev_addr and host_addr are randomly selected.
133Except for ifname they can be written to until the function is linked to a
134configuration. The ifname is read-only and contains the name of the interface
135which was assigned by the net core, e. g. usb0.
136
137Testing the EEM function
138------------------------
139
140Configure IP addresses of the device and the host. Then:
141
142On the device: ping <host's IP>
143On the host: ping <device's IP>
2c0f62f9
AP
144
1455. FFS function
146===============
147
148The function is provided by usb_f_fs.ko module.
149
150Function-specific configfs interface
151------------------------------------
152
153The function name to use when creating the function directory is "ffs".
154The function directory is intentionally empty and not modifiable.
155
156After creating the directory there is a new instance (a "device") of FunctionFS
157available in the system. Once a "device" is available, the user should follow
158the standard procedure for using FunctionFS (mount it, run the userspace
159process which implements the function proper). The gadget should be enabled
160by writing a suitable string to usb_gadget/<gadget>/UDC.
161
162Testing the FFS function
163------------------------
164
165On the device: start the function's userspace daemon, enable the gadget
166On the host: use the USB function provided by the device
f7e3c3cd
AP
167
1686. HID function
169===============
170
171The function is provided by usb_f_hid.ko module.
172
173Function-specific configfs interface
174------------------------------------
175
176The function name to use when creating the function directory is "hid".
177The HID function provides these attributes in its function directory:
178
179 protocol - HID protocol to use
180 report_desc - data to be used in HID reports, except data
181 passed with /dev/hidg<X>
182 report_length - HID report length
183 subclass - HID subclass to use
184
185For a keyboard the protocol and the subclass are 1, the report_length is 8,
186while the report_desc is:
187
188$ hd my_report_desc
18900000000 05 01 09 06 a1 01 05 07 19 e0 29 e7 15 00 25 01 |..........)...%.|
19000000010 75 01 95 08 81 02 95 01 75 08 81 03 95 05 75 01 |u.......u.....u.|
19100000020 05 08 19 01 29 05 91 02 95 01 75 03 91 03 95 06 |....).....u.....|
19200000030 75 08 15 00 25 65 05 07 19 00 29 65 81 00 c0 |u...%e....)e...|
1930000003f
194
195Such a sequence of bytes can be stored to the attribute with echo:
196
197$ echo -ne \\x05\\x01\\x09\\x06\\xa1.....
198
199Testing the HID function
200------------------------
201
202Device:
203- create the gadget
204- connect the gadget to a host, preferably not the one used
205to control the gadget
206- run a program which writes to /dev/hidg<N>, e.g.
207a userspace program found in Documentation/usb/gadget_hid.txt:
208
209$ ./hid_gadget_test /dev/hidg0 keyboard
210
211Host:
212- observe the keystrokes from the gadget
ec91aff7
AP
213
2147. LOOPBACK function
215====================
216
217The function is provided by usb_f_ss_lb.ko module.
218
219Function-specific configfs interface
220------------------------------------
221
222The function name to use when creating the function directory is "Loopback".
223The LOOPBACK function provides these attributes in its function directory:
224
225 qlen - depth of loopback queue
226 bulk_buflen - buffer length
227
228Testing the LOOPBACK function
229-----------------------------
230
231device: run the gadget
232host: test-usb
233
234http://www.linux-usb.org/usbtest/testusb.c
cdbe287d
AP
235
2368. MASS STORAGE function
237========================
238
239The function is provided by usb_f_mass_storage.ko module.
240
241Function-specific configfs interface
242------------------------------------
243
244The function name to use when creating the function directory is "mass_storage".
245The MASS STORAGE function provides these attributes in its directory:
246files:
247
248 stall - Set to permit function to halt bulk endpoints.
249 Disabled on some USB devices known not to work
250 correctly. You should set it to true.
251 num_buffers - Number of pipeline buffers. Valid numbers
252 are 2..4. Available only if
253 CONFIG_USB_GADGET_DEBUG_FILES is set.
254
255and a default lun.0 directory corresponding to SCSI LUN #0.
256
257A new lun can be added with mkdir:
258
259$ mkdir functions/mass_storage.0/partition.5
260
261Lun numbering does not have to be continuous, except for lun #0 which is
262created by default. A maximum of 8 luns can be specified and they all must be
263named following the <name>.<number> scheme. The numbers can be 0..8.
264Probably a good convention is to name the luns "lun.<number>",
265although it is not mandatory.
266
267In each lun directory there are the following attribute files:
268
269 file - The path to the backing file for the LUN.
270 Required if LUN is not marked as removable.
271 ro - Flag specifying access to the LUN shall be
272 read-only. This is implied if CD-ROM emulation
273 is enabled as well as when it was impossible
274 to open "filename" in R/W mode.
275 removable - Flag specifying that LUN shall be indicated as
276 being removable.
277 cdrom - Flag specifying that LUN shall be reported as
278 being a CD-ROM.
279 nofua - Flag specifying that FUA flag
280 in SCSI WRITE(10,12)
281
282Testing the MASS STORAGE function
283---------------------------------
284
285device: connect the gadget, enable it
286host: dmesg, see the USB drives appear (if system configured to automatically
287mount)
0d6be59a
AP
288
2899. MIDI function
290================
291
292The function is provided by usb_f_midi.ko module.
293
294Function-specific configfs interface
295------------------------------------
296
297The function name to use when creating the function directory is "midi".
298The MIDI function provides these attributes in its function directory:
299
300 buflen - MIDI buffer length
301 id - ID string for the USB MIDI adapter
302 in_ports - number of MIDI input ports
303 index - index value for the USB MIDI adapter
304 out_ports - number of MIDI output ports
305 qlen - USB read request queue length
306
307Testing the MIDI function
308-------------------------
309
310There are two cases: playing a mid from the gadget to
311the host and playing a mid from the host to the gadget.
312
3131) Playing a mid from the gadget to the host
314host)
315
316$ arecordmidi -l
317 Port Client name Port name
318 14:0 Midi Through Midi Through Port-0
319 24:0 MIDI Gadget MIDI Gadget MIDI 1
320$ arecordmidi -p 24:0 from_gadget.mid
321
322gadget)
323
324$ aplaymidi -l
325 Port Client name Port name
326 20:0 f_midi f_midi
327
328$ aplaymidi -p 20:0 to_host.mid
329
3302) Playing a mid from the host to the gadget
331gadget)
332
333$ arecordmidi -l
334 Port Client name Port name
335 20:0 f_midi f_midi
336
337$ arecordmidi -p 20:0 from_host.mid
338
339host)
340
341$ aplaymidi -l
342 Port Client name Port name
343 14:0 Midi Through Midi Through Port-0
344 24:0 MIDI Gadget MIDI Gadget MIDI 1
345
346$ aplaymidi -p24:0 to_gadget.mid
347
348The from_gadget.mid should sound identical to the to_host.mid.
349The from_host.id should sound identical to the to_gadget.mid.
350
351MIDI files can be played to speakers/headphones with e.g. timidity installed
352
353$ aplaymidi -l
354 Port Client name Port name
355 14:0 Midi Through Midi Through Port-0
356 24:0 MIDI Gadget MIDI Gadget MIDI 1
357128:0 TiMidity TiMidity port 0
358128:1 TiMidity TiMidity port 1
359128:2 TiMidity TiMidity port 2
360128:3 TiMidity TiMidity port 3
361
362$ aplaymidi -p 128:0 file.mid
363
364MIDI ports can be logically connected using the aconnect utility, e.g.:
365
366$ aconnect 24:0 128:0 # try it on the host
367
368After the gadget's MIDI port is connected to timidity's MIDI port,
369whatever is played at the gadget side with aplaymidi -l is audible
370in host's speakers/headphones.
4d0fa79e
AP
371
37210. NCM function
373================
374
375The function is provided by usb_f_ncm.ko module.
376
377Function-specific configfs interface
378------------------------------------
379
380The function name to use when creating the function directory is "ncm".
381The NCM function provides these attributes in its function directory:
382
383 ifname - network device interface name associated with this
384 function instance
385 qmult - queue length multiplier for high and super speed
386 host_addr - MAC address of host's end of this
387 Ethernet over USB link
388 dev_addr - MAC address of device's end of this
389 Ethernet over USB link
390
391and after creating the functions/ncm.<instance name> they contain default
392values: qmult is 5, dev_addr and host_addr are randomly selected.
393Except for ifname they can be written to until the function is linked to a
394configuration. The ifname is read-only and contains the name of the interface
395which was assigned by the net core, e. g. usb0.
396
397Testing the NCM function
398------------------------
399
400Configure IP addresses of the device and the host. Then:
401
402On the device: ping <host's IP>
403On the host: ping <device's IP>
d81b85dc
AP
404
40511. OBEX function
406=================
407
408The function is provided by usb_f_obex.ko module.
409
410Function-specific configfs interface
411------------------------------------
412
413The function name to use when creating the function directory is "obex".
414The OBEX function provides just one attribute in its function directory:
415
416 port_num
417
418The attribute is read-only.
419
420There can be at most 4 ACM/generic serial/OBEX ports in the system.
421
422Testing the OBEX function
423-------------------------
424
425On device: seriald -f /dev/ttyGS<Y> -s 1024
426On host: serialc -v <vendorID> -p <productID> -i<interface#> -a1 -s1024 \
427 -t<out endpoint addr> -r<in endpoint addr>
428
429where seriald and serialc are Felipe's utilities found here:
430
431https://git.gitorious.org/usb/usb-tools.git master