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