blob: c8ae54022ec878d68db63137b2798c6ead5f1f78 [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 Pietrasiewicze38eb2c2014-12-16 14:56:25 +010015
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>
Andrzej Pietrasiewiczd5862ca2014-12-16 14:56:26 +010045
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>
Andrzej Pietrasiewicz7bfbc6e2014-12-16 14:56:27 +010078
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>
Andrzej Pietrasiewicz4ca560a2014-12-16 14:56:28 +0100111
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>
Andrzej Pietrasiewicz2c0f62f2014-12-16 14:56:29 +0100144
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
Andrzej Pietrasiewiczf7e3c3c2014-12-16 14:56:30 +0100167
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
Andrzej Pietrasiewiczec91aff2014-12-16 14:56:31 +0100213
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
Andrzej Pietrasiewiczcdbe2872014-12-16 14:56:32 +0100235
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)
Andrzej Pietrasiewicz0d6be592014-12-16 14:56:33 +0100288
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.
Andrzej Pietrasiewicz4d0fa792014-12-16 14:56:34 +0100371
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>
Andrzej Pietrasiewiczd81b85d2014-12-16 14:56:35 +0100404
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