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