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