blob: 40d22d82cc5a77e841336870b8076067f8db3716 [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 Pietrasiewicz4dfcec82014-12-16 14:56:38 +01001714. SERIAL function
Andrzej Pietrasiewicz480a9122014-12-16 14:56:39 +01001815. SOURCESINK function
Andrzej Pietrasiewiczdae03582014-12-16 14:56:40 +01001916. UAC1 function
Andrzej Pietrasiewicze38eb2c2014-12-16 14:56:25 +010020
21
221. ACM function
23===============
24
25The function is provided by usb_f_acm.ko module.
26
27Function-specific configfs interface
28------------------------------------
29
30The function name to use when creating the function directory is "acm".
31The ACM function provides just one attribute in its function directory:
32
33 port_num
34
35The attribute is read-only.
36
37There can be at most 4 ACM/generic serial/OBEX ports in the system.
38
39
40Testing the ACM function
41------------------------
42
43On the host: cat > /dev/ttyACM<X>
44On the device : cat /dev/ttyGS<Y>
45
46then the other way round
47
48On the device: cat > /dev/ttyGS<Y>
49On the host: cat /dev/ttyACM<X>
Andrzej Pietrasiewiczd5862ca2014-12-16 14:56:26 +010050
512. ECM function
52===============
53
54The function is provided by usb_f_ecm.ko module.
55
56Function-specific configfs interface
57------------------------------------
58
59The function name to use when creating the function directory is "ecm".
60The ECM function provides these attributes in its function directory:
61
62 ifname - network device interface name associated with this
63 function instance
64 qmult - queue length multiplier for high and super speed
65 host_addr - MAC address of host's end of this
66 Ethernet over USB link
67 dev_addr - MAC address of device's end of this
68 Ethernet over USB link
69
70and after creating the functions/ecm.<instance name> they contain default
71values: qmult is 5, dev_addr and host_addr are randomly selected.
72Except for ifname they can be written to until the function is linked to a
73configuration. The ifname is read-only and contains the name of the interface
74which was assigned by the net core, e. g. usb0.
75
76Testing the ECM function
77------------------------
78
79Configure IP addresses of the device and the host. Then:
80
81On the device: ping <host's IP>
82On the host: ping <device's IP>
Andrzej Pietrasiewicz7bfbc6e2014-12-16 14:56:27 +010083
843. ECM subset function
85======================
86
87The function is provided by usb_f_ecm_subset.ko module.
88
89Function-specific configfs interface
90------------------------------------
91
92The function name to use when creating the function directory is "geth".
93The ECM subset function provides these attributes in its function directory:
94
95 ifname - network device interface name associated with this
96 function instance
97 qmult - queue length multiplier for high and super speed
98 host_addr - MAC address of host's end of this
99 Ethernet over USB link
100 dev_addr - MAC address of device's end of this
101 Ethernet over USB link
102
103and after creating the functions/ecm.<instance name> they contain default
104values: qmult is 5, dev_addr and host_addr are randomly selected.
105Except for ifname they can be written to until the function is linked to a
106configuration. The ifname is read-only and contains the name of the interface
107which was assigned by the net core, e. g. usb0.
108
109Testing the ECM subset function
110-------------------------------
111
112Configure IP addresses of the device and the host. Then:
113
114On the device: ping <host's IP>
115On the host: ping <device's IP>
Andrzej Pietrasiewicz4ca560a2014-12-16 14:56:28 +0100116
1174. EEM function
118===============
119
120The function is provided by usb_f_eem.ko module.
121
122Function-specific configfs interface
123------------------------------------
124
125The function name to use when creating the function directory is "eem".
126The EEM function provides these attributes in its function directory:
127
128 ifname - network device interface name associated with this
129 function instance
130 qmult - queue length multiplier for high and super speed
131 host_addr - MAC address of host's end of this
132 Ethernet over USB link
133 dev_addr - MAC address of device's end of this
134 Ethernet over USB link
135
136and after creating the functions/eem.<instance name> they contain default
137values: qmult is 5, dev_addr and host_addr are randomly selected.
138Except for ifname they can be written to until the function is linked to a
139configuration. The ifname is read-only and contains the name of the interface
140which was assigned by the net core, e. g. usb0.
141
142Testing the EEM function
143------------------------
144
145Configure IP addresses of the device and the host. Then:
146
147On the device: ping <host's IP>
148On the host: ping <device's IP>
Andrzej Pietrasiewicz2c0f62f2014-12-16 14:56:29 +0100149
1505. FFS function
151===============
152
153The function is provided by usb_f_fs.ko module.
154
155Function-specific configfs interface
156------------------------------------
157
158The function name to use when creating the function directory is "ffs".
159The function directory is intentionally empty and not modifiable.
160
161After creating the directory there is a new instance (a "device") of FunctionFS
162available in the system. Once a "device" is available, the user should follow
163the standard procedure for using FunctionFS (mount it, run the userspace
164process which implements the function proper). The gadget should be enabled
165by writing a suitable string to usb_gadget/<gadget>/UDC.
166
167Testing the FFS function
168------------------------
169
170On the device: start the function's userspace daemon, enable the gadget
171On the host: use the USB function provided by the device
Andrzej Pietrasiewiczf7e3c3c2014-12-16 14:56:30 +0100172
1736. HID function
174===============
175
176The function is provided by usb_f_hid.ko module.
177
178Function-specific configfs interface
179------------------------------------
180
181The function name to use when creating the function directory is "hid".
182The HID function provides these attributes in its function directory:
183
184 protocol - HID protocol to use
185 report_desc - data to be used in HID reports, except data
186 passed with /dev/hidg<X>
187 report_length - HID report length
188 subclass - HID subclass to use
189
190For a keyboard the protocol and the subclass are 1, the report_length is 8,
191while the report_desc is:
192
193$ hd my_report_desc
19400000000 05 01 09 06 a1 01 05 07 19 e0 29 e7 15 00 25 01 |..........)...%.|
19500000010 75 01 95 08 81 02 95 01 75 08 81 03 95 05 75 01 |u.......u.....u.|
19600000020 05 08 19 01 29 05 91 02 95 01 75 03 91 03 95 06 |....).....u.....|
19700000030 75 08 15 00 25 65 05 07 19 00 29 65 81 00 c0 |u...%e....)e...|
1980000003f
199
200Such a sequence of bytes can be stored to the attribute with echo:
201
202$ echo -ne \\x05\\x01\\x09\\x06\\xa1.....
203
204Testing the HID function
205------------------------
206
207Device:
208- create the gadget
209- connect the gadget to a host, preferably not the one used
210to control the gadget
211- run a program which writes to /dev/hidg<N>, e.g.
212a userspace program found in Documentation/usb/gadget_hid.txt:
213
214$ ./hid_gadget_test /dev/hidg0 keyboard
215
216Host:
217- observe the keystrokes from the gadget
Andrzej Pietrasiewiczec91aff2014-12-16 14:56:31 +0100218
2197. LOOPBACK function
220====================
221
222The function is provided by usb_f_ss_lb.ko module.
223
224Function-specific configfs interface
225------------------------------------
226
227The function name to use when creating the function directory is "Loopback".
228The LOOPBACK function provides these attributes in its function directory:
229
230 qlen - depth of loopback queue
231 bulk_buflen - buffer length
232
233Testing the LOOPBACK function
234-----------------------------
235
236device: run the gadget
237host: test-usb
238
239http://www.linux-usb.org/usbtest/testusb.c
Andrzej Pietrasiewiczcdbe2872014-12-16 14:56:32 +0100240
2418. MASS STORAGE function
242========================
243
244The function is provided by usb_f_mass_storage.ko module.
245
246Function-specific configfs interface
247------------------------------------
248
249The function name to use when creating the function directory is "mass_storage".
250The MASS STORAGE function provides these attributes in its directory:
251files:
252
253 stall - Set to permit function to halt bulk endpoints.
254 Disabled on some USB devices known not to work
255 correctly. You should set it to true.
256 num_buffers - Number of pipeline buffers. Valid numbers
257 are 2..4. Available only if
258 CONFIG_USB_GADGET_DEBUG_FILES is set.
259
260and a default lun.0 directory corresponding to SCSI LUN #0.
261
262A new lun can be added with mkdir:
263
264$ mkdir functions/mass_storage.0/partition.5
265
266Lun numbering does not have to be continuous, except for lun #0 which is
267created by default. A maximum of 8 luns can be specified and they all must be
268named following the <name>.<number> scheme. The numbers can be 0..8.
269Probably a good convention is to name the luns "lun.<number>",
270although it is not mandatory.
271
272In each lun directory there are the following attribute files:
273
274 file - The path to the backing file for the LUN.
275 Required if LUN is not marked as removable.
276 ro - Flag specifying access to the LUN shall be
277 read-only. This is implied if CD-ROM emulation
278 is enabled as well as when it was impossible
279 to open "filename" in R/W mode.
280 removable - Flag specifying that LUN shall be indicated as
281 being removable.
282 cdrom - Flag specifying that LUN shall be reported as
283 being a CD-ROM.
284 nofua - Flag specifying that FUA flag
285 in SCSI WRITE(10,12)
286
287Testing the MASS STORAGE function
288---------------------------------
289
290device: connect the gadget, enable it
291host: dmesg, see the USB drives appear (if system configured to automatically
292mount)
Andrzej Pietrasiewicz0d6be592014-12-16 14:56:33 +0100293
2949. MIDI function
295================
296
297The function is provided by usb_f_midi.ko module.
298
299Function-specific configfs interface
300------------------------------------
301
302The function name to use when creating the function directory is "midi".
303The MIDI function provides these attributes in its function directory:
304
305 buflen - MIDI buffer length
306 id - ID string for the USB MIDI adapter
307 in_ports - number of MIDI input ports
308 index - index value for the USB MIDI adapter
309 out_ports - number of MIDI output ports
310 qlen - USB read request queue length
311
312Testing the MIDI function
313-------------------------
314
315There are two cases: playing a mid from the gadget to
316the host and playing a mid from the host to the gadget.
317
3181) Playing a mid from the gadget to the host
319host)
320
321$ arecordmidi -l
322 Port Client name Port name
323 14:0 Midi Through Midi Through Port-0
324 24:0 MIDI Gadget MIDI Gadget MIDI 1
325$ arecordmidi -p 24:0 from_gadget.mid
326
327gadget)
328
329$ aplaymidi -l
330 Port Client name Port name
331 20:0 f_midi f_midi
332
333$ aplaymidi -p 20:0 to_host.mid
334
3352) Playing a mid from the host to the gadget
336gadget)
337
338$ arecordmidi -l
339 Port Client name Port name
340 20:0 f_midi f_midi
341
342$ arecordmidi -p 20:0 from_host.mid
343
344host)
345
346$ aplaymidi -l
347 Port Client name Port name
348 14:0 Midi Through Midi Through Port-0
349 24:0 MIDI Gadget MIDI Gadget MIDI 1
350
351$ aplaymidi -p24:0 to_gadget.mid
352
353The from_gadget.mid should sound identical to the to_host.mid.
354The from_host.id should sound identical to the to_gadget.mid.
355
356MIDI files can be played to speakers/headphones with e.g. timidity installed
357
358$ aplaymidi -l
359 Port Client name Port name
360 14:0 Midi Through Midi Through Port-0
361 24:0 MIDI Gadget MIDI Gadget MIDI 1
362128:0 TiMidity TiMidity port 0
363128:1 TiMidity TiMidity port 1
364128:2 TiMidity TiMidity port 2
365128:3 TiMidity TiMidity port 3
366
367$ aplaymidi -p 128:0 file.mid
368
369MIDI ports can be logically connected using the aconnect utility, e.g.:
370
371$ aconnect 24:0 128:0 # try it on the host
372
373After the gadget's MIDI port is connected to timidity's MIDI port,
374whatever is played at the gadget side with aplaymidi -l is audible
375in host's speakers/headphones.
Andrzej Pietrasiewicz4d0fa792014-12-16 14:56:34 +0100376
37710. NCM function
378================
379
380The function is provided by usb_f_ncm.ko module.
381
382Function-specific configfs interface
383------------------------------------
384
385The function name to use when creating the function directory is "ncm".
386The NCM function provides these attributes in its function directory:
387
388 ifname - network device interface name associated with this
389 function instance
390 qmult - queue length multiplier for high and super speed
391 host_addr - MAC address of host's end of this
392 Ethernet over USB link
393 dev_addr - MAC address of device's end of this
394 Ethernet over USB link
395
396and after creating the functions/ncm.<instance name> they contain default
397values: qmult is 5, dev_addr and host_addr are randomly selected.
398Except for ifname they can be written to until the function is linked to a
399configuration. The ifname is read-only and contains the name of the interface
400which was assigned by the net core, e. g. usb0.
401
402Testing the NCM function
403------------------------
404
405Configure IP addresses of the device and the host. Then:
406
407On the device: ping <host's IP>
408On the host: ping <device's IP>
Andrzej Pietrasiewiczd81b85d2014-12-16 14:56:35 +0100409
41011. OBEX function
411=================
412
413The function is provided by usb_f_obex.ko module.
414
415Function-specific configfs interface
416------------------------------------
417
418The function name to use when creating the function directory is "obex".
419The OBEX function provides just one attribute in its function directory:
420
421 port_num
422
423The attribute is read-only.
424
425There can be at most 4 ACM/generic serial/OBEX ports in the system.
426
427Testing the OBEX function
428-------------------------
429
430On device: seriald -f /dev/ttyGS<Y> -s 1024
431On host: serialc -v <vendorID> -p <productID> -i<interface#> -a1 -s1024 \
432 -t<out endpoint addr> -r<in endpoint addr>
433
434where seriald and serialc are Felipe's utilities found here:
435
436https://git.gitorious.org/usb/usb-tools.git master
Andrzej Pietrasiewiczda2907d2014-12-16 14:56:36 +0100437
43812. PHONET function
439===================
440
441The function is provided by usb_f_phonet.ko module.
442
443Function-specific configfs interface
444------------------------------------
445
446The function name to use when creating the function directory is "phonet".
447The PHONET function provides just one attribute in its function directory:
448
449 ifname - network device interface name associated with this
450 function instance
451
452Testing the PHONET function
453---------------------------
454
455It is not possible to test the SOCK_STREAM protocol without a specific piece
456of hardware, so only SOCK_DGRAM has been tested. For the latter to work,
457in the past I had to apply the patch mentioned here:
458
459http://www.spinics.net/lists/linux-usb/msg85689.html
460
461These tools are required:
462
463git://git.gitorious.org/meego-cellular/phonet-utils.git
464
465On the host:
466
467$ ./phonet -a 0x10 -i usbpn0
468$ ./pnroute add 0x6c usbpn0
469$./pnroute add 0x10 usbpn0
470$ ifconfig usbpn0 up
471
472On the device:
473
474$ ./phonet -a 0x6c -i upnlink0
475$ ./pnroute add 0x10 upnlink0
476$ ifconfig upnlink0 up
477
478Then a test program can be used:
479
480http://www.spinics.net/lists/linux-usb/msg85690.html
481
482On the device:
483
484$ ./pnxmit -a 0x6c -r
485
486On the host:
487
488$ ./pnxmit -a 0x10 -s 0x6c
489
490As a result some data should be sent from host to device.
491Then the other way round:
492
493On the host:
494
495$ ./pnxmit -a 0x10 -r
496
497On the device:
498
499$ ./pnxmit -a 0x6c -s 0x10
Andrzej Pietrasiewiczddb72242014-12-16 14:56:37 +0100500
50113. RNDIS function
502==================
503
504The function is provided by usb_f_rndis.ko module.
505
506Function-specific configfs interface
507------------------------------------
508
509The function name to use when creating the function directory is "rndis".
510The RNDIS function provides these attributes in its function directory:
511
512 ifname - network device interface name associated with this
513 function instance
514 qmult - queue length multiplier for high and super speed
515 host_addr - MAC address of host's end of this
516 Ethernet over USB link
517 dev_addr - MAC address of device's end of this
518 Ethernet over USB link
519
520and after creating the functions/rndis.<instance name> they contain default
521values: qmult is 5, dev_addr and host_addr are randomly selected.
522Except for ifname they can be written to until the function is linked to a
523configuration. The ifname is read-only and contains the name of the interface
524which was assigned by the net core, e. g. usb0.
525
526By default there can be only 1 RNDIS interface in the system.
527
528Testing the RNDIS function
529--------------------------
530
531Configure IP addresses of the device and the host. Then:
532
533On the device: ping <host's IP>
534On the host: ping <device's IP>
Andrzej Pietrasiewicz4dfcec82014-12-16 14:56:38 +0100535
53614. SERIAL function
537===================
538
539The function is provided by usb_f_gser.ko module.
540
541Function-specific configfs interface
542------------------------------------
543
544The function name to use when creating the function directory is "gser".
545The SERIAL function provides just one attribute in its function directory:
546
547 port_num
548
549The attribute is read-only.
550
551There can be at most 4 ACM/generic serial/OBEX ports in the system.
552
553Testing the SERIAL function
554---------------------------
555
556On host: insmod usbserial
557 echo VID PID >/sys/bus/usb-serial/drivers/generic/new_id
558On host: cat > /dev/ttyUSB<X>
559On target: cat /dev/ttyGS<Y>
560
561then the other way round
562
563On target: cat > /dev/ttyGS<Y>
564On host: cat /dev/ttyUSB<X>
Andrzej Pietrasiewicz480a9122014-12-16 14:56:39 +0100565
56615. SOURCESINK function
567=======================
568
569The function is provided by usb_f_ss_lb.ko module.
570
571Function-specific configfs interface
572------------------------------------
573
574The function name to use when creating the function directory is "SourceSink".
575The SOURCESINK function provides these attributes in its function directory:
576
577 pattern - 0 (all zeros), 1 (mod63), 2 (none)
578 isoc_interval - 1..16
579 isoc_maxpacket - 0 - 1023 (fs), 0 - 1024 (hs/ss)
580 isoc_mult - 0..2 (hs/ss only)
581 isoc_maxburst - 0..15 (ss only)
582 bulk_buflen - buffer length
583
584Testing the SOURCESINK function
585-------------------------------
586
587device: run the gadget
588host: test-usb
589
590http://www.linux-usb.org/usbtest/testusb.c
Andrzej Pietrasiewiczdae03582014-12-16 14:56:40 +0100591
59216. UAC1 function
593=================
594
595The function is provided by usb_f_uac1.ko module.
596
597Function-specific configfs interface
598------------------------------------
599
600The function name to use when creating the function directory is "uac1".
601The uac1 function provides these attributes in its function directory:
602
603 audio_buf_size - audio buffer size
604 fn_cap - capture pcm device file name
605 fn_cntl - control device file name
606 fn_play - playback pcm device file name
607 req_buf_size - ISO OUT endpoint request buffer size
608 req_count - ISO OUT endpoint request count
609
610The attributes have sane default values.
611
612Testing the UAC1 function
613-------------------------
614
615device: run the gadget
616host: aplay -l # should list our USB Audio Gadget