Documentation: usb: NCM function testing
[GitHub/moto-9609/android_kernel_motorola_exynos9610.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
e38eb2c8
AP
14
15
161. ACM function
17===============
18
19The function is provided by usb_f_acm.ko module.
20
21Function-specific configfs interface
22------------------------------------
23
24The function name to use when creating the function directory is "acm".
25The ACM function provides just one attribute in its function directory:
26
27 port_num
28
29The attribute is read-only.
30
31There can be at most 4 ACM/generic serial/OBEX ports in the system.
32
33
34Testing the ACM function
35------------------------
36
37On the host: cat > /dev/ttyACM<X>
38On the device : cat /dev/ttyGS<Y>
39
40then the other way round
41
42On the device: cat > /dev/ttyGS<Y>
43On the host: cat /dev/ttyACM<X>
d5862ca6
AP
44
452. ECM function
46===============
47
48The function is provided by usb_f_ecm.ko module.
49
50Function-specific configfs interface
51------------------------------------
52
53The function name to use when creating the function directory is "ecm".
54The ECM function provides these attributes in its function directory:
55
56 ifname - network device interface name associated with this
57 function instance
58 qmult - queue length multiplier for high and super speed
59 host_addr - MAC address of host's end of this
60 Ethernet over USB link
61 dev_addr - MAC address of device's end of this
62 Ethernet over USB link
63
64and after creating the functions/ecm.<instance name> they contain default
65values: qmult is 5, dev_addr and host_addr are randomly selected.
66Except for ifname they can be written to until the function is linked to a
67configuration. The ifname is read-only and contains the name of the interface
68which was assigned by the net core, e. g. usb0.
69
70Testing the ECM function
71------------------------
72
73Configure IP addresses of the device and the host. Then:
74
75On the device: ping <host's IP>
76On the host: ping <device's IP>
7bfbc6e3
AP
77
783. ECM subset function
79======================
80
81The function is provided by usb_f_ecm_subset.ko module.
82
83Function-specific configfs interface
84------------------------------------
85
86The function name to use when creating the function directory is "geth".
87The ECM subset function provides these attributes in its function directory:
88
89 ifname - network device interface name associated with this
90 function instance
91 qmult - queue length multiplier for high and super speed
92 host_addr - MAC address of host's end of this
93 Ethernet over USB link
94 dev_addr - MAC address of device's end of this
95 Ethernet over USB link
96
97and after creating the functions/ecm.<instance name> they contain default
98values: qmult is 5, dev_addr and host_addr are randomly selected.
99Except for ifname they can be written to until the function is linked to a
100configuration. The ifname is read-only and contains the name of the interface
101which was assigned by the net core, e. g. usb0.
102
103Testing the ECM subset function
104-------------------------------
105
106Configure IP addresses of the device and the host. Then:
107
108On the device: ping <host's IP>
109On the host: ping <device's IP>
4ca560a6
AP
110
1114. EEM function
112===============
113
114The function is provided by usb_f_eem.ko module.
115
116Function-specific configfs interface
117------------------------------------
118
119The function name to use when creating the function directory is "eem".
120The EEM function provides these attributes in its function directory:
121
122 ifname - network device interface name associated with this
123 function instance
124 qmult - queue length multiplier for high and super speed
125 host_addr - MAC address of host's end of this
126 Ethernet over USB link
127 dev_addr - MAC address of device's end of this
128 Ethernet over USB link
129
130and after creating the functions/eem.<instance name> they contain default
131values: qmult is 5, dev_addr and host_addr are randomly selected.
132Except for ifname they can be written to until the function is linked to a
133configuration. The ifname is read-only and contains the name of the interface
134which was assigned by the net core, e. g. usb0.
135
136Testing the EEM function
137------------------------
138
139Configure IP addresses of the device and the host. Then:
140
141On the device: ping <host's IP>
142On the host: ping <device's IP>
2c0f62f9
AP
143
1445. FFS function
145===============
146
147The function is provided by usb_f_fs.ko module.
148
149Function-specific configfs interface
150------------------------------------
151
152The function name to use when creating the function directory is "ffs".
153The function directory is intentionally empty and not modifiable.
154
155After creating the directory there is a new instance (a "device") of FunctionFS
156available in the system. Once a "device" is available, the user should follow
157the standard procedure for using FunctionFS (mount it, run the userspace
158process which implements the function proper). The gadget should be enabled
159by writing a suitable string to usb_gadget/<gadget>/UDC.
160
161Testing the FFS function
162------------------------
163
164On the device: start the function's userspace daemon, enable the gadget
165On the host: use the USB function provided by the device
f7e3c3cd
AP
166
1676. HID function
168===============
169
170The function is provided by usb_f_hid.ko module.
171
172Function-specific configfs interface
173------------------------------------
174
175The function name to use when creating the function directory is "hid".
176The HID function provides these attributes in its function directory:
177
178 protocol - HID protocol to use
179 report_desc - data to be used in HID reports, except data
180 passed with /dev/hidg<X>
181 report_length - HID report length
182 subclass - HID subclass to use
183
184For a keyboard the protocol and the subclass are 1, the report_length is 8,
185while the report_desc is:
186
187$ hd my_report_desc
18800000000 05 01 09 06 a1 01 05 07 19 e0 29 e7 15 00 25 01 |..........)...%.|
18900000010 75 01 95 08 81 02 95 01 75 08 81 03 95 05 75 01 |u.......u.....u.|
19000000020 05 08 19 01 29 05 91 02 95 01 75 03 91 03 95 06 |....).....u.....|
19100000030 75 08 15 00 25 65 05 07 19 00 29 65 81 00 c0 |u...%e....)e...|
1920000003f
193
194Such a sequence of bytes can be stored to the attribute with echo:
195
196$ echo -ne \\x05\\x01\\x09\\x06\\xa1.....
197
198Testing the HID function
199------------------------
200
201Device:
202- create the gadget
203- connect the gadget to a host, preferably not the one used
204to control the gadget
205- run a program which writes to /dev/hidg<N>, e.g.
206a userspace program found in Documentation/usb/gadget_hid.txt:
207
208$ ./hid_gadget_test /dev/hidg0 keyboard
209
210Host:
211- observe the keystrokes from the gadget
ec91aff7
AP
212
2137. LOOPBACK function
214====================
215
216The function is provided by usb_f_ss_lb.ko module.
217
218Function-specific configfs interface
219------------------------------------
220
221The function name to use when creating the function directory is "Loopback".
222The LOOPBACK function provides these attributes in its function directory:
223
224 qlen - depth of loopback queue
225 bulk_buflen - buffer length
226
227Testing the LOOPBACK function
228-----------------------------
229
230device: run the gadget
231host: test-usb
232
233http://www.linux-usb.org/usbtest/testusb.c
cdbe287d
AP
234
2358. MASS STORAGE function
236========================
237
238The function is provided by usb_f_mass_storage.ko module.
239
240Function-specific configfs interface
241------------------------------------
242
243The function name to use when creating the function directory is "mass_storage".
244The MASS STORAGE function provides these attributes in its directory:
245files:
246
247 stall - Set to permit function to halt bulk endpoints.
248 Disabled on some USB devices known not to work
249 correctly. You should set it to true.
250 num_buffers - Number of pipeline buffers. Valid numbers
251 are 2..4. Available only if
252 CONFIG_USB_GADGET_DEBUG_FILES is set.
253
254and a default lun.0 directory corresponding to SCSI LUN #0.
255
256A new lun can be added with mkdir:
257
258$ mkdir functions/mass_storage.0/partition.5
259
260Lun numbering does not have to be continuous, except for lun #0 which is
261created by default. A maximum of 8 luns can be specified and they all must be
262named following the <name>.<number> scheme. The numbers can be 0..8.
263Probably a good convention is to name the luns "lun.<number>",
264although it is not mandatory.
265
266In each lun directory there are the following attribute files:
267
268 file - The path to the backing file for the LUN.
269 Required if LUN is not marked as removable.
270 ro - Flag specifying access to the LUN shall be
271 read-only. This is implied if CD-ROM emulation
272 is enabled as well as when it was impossible
273 to open "filename" in R/W mode.
274 removable - Flag specifying that LUN shall be indicated as
275 being removable.
276 cdrom - Flag specifying that LUN shall be reported as
277 being a CD-ROM.
278 nofua - Flag specifying that FUA flag
279 in SCSI WRITE(10,12)
280
281Testing the MASS STORAGE function
282---------------------------------
283
284device: connect the gadget, enable it
285host: dmesg, see the USB drives appear (if system configured to automatically
286mount)
0d6be59a
AP
287
2889. MIDI function
289================
290
291The function is provided by usb_f_midi.ko module.
292
293Function-specific configfs interface
294------------------------------------
295
296The function name to use when creating the function directory is "midi".
297The MIDI function provides these attributes in its function directory:
298
299 buflen - MIDI buffer length
300 id - ID string for the USB MIDI adapter
301 in_ports - number of MIDI input ports
302 index - index value for the USB MIDI adapter
303 out_ports - number of MIDI output ports
304 qlen - USB read request queue length
305
306Testing the MIDI function
307-------------------------
308
309There are two cases: playing a mid from the gadget to
310the host and playing a mid from the host to the gadget.
311
3121) Playing a mid from the gadget to the host
313host)
314
315$ arecordmidi -l
316 Port Client name Port name
317 14:0 Midi Through Midi Through Port-0
318 24:0 MIDI Gadget MIDI Gadget MIDI 1
319$ arecordmidi -p 24:0 from_gadget.mid
320
321gadget)
322
323$ aplaymidi -l
324 Port Client name Port name
325 20:0 f_midi f_midi
326
327$ aplaymidi -p 20:0 to_host.mid
328
3292) Playing a mid from the host to the gadget
330gadget)
331
332$ arecordmidi -l
333 Port Client name Port name
334 20:0 f_midi f_midi
335
336$ arecordmidi -p 20:0 from_host.mid
337
338host)
339
340$ aplaymidi -l
341 Port Client name Port name
342 14:0 Midi Through Midi Through Port-0
343 24:0 MIDI Gadget MIDI Gadget MIDI 1
344
345$ aplaymidi -p24:0 to_gadget.mid
346
347The from_gadget.mid should sound identical to the to_host.mid.
348The from_host.id should sound identical to the to_gadget.mid.
349
350MIDI files can be played to speakers/headphones with e.g. timidity installed
351
352$ aplaymidi -l
353 Port Client name Port name
354 14:0 Midi Through Midi Through Port-0
355 24:0 MIDI Gadget MIDI Gadget MIDI 1
356128:0 TiMidity TiMidity port 0
357128:1 TiMidity TiMidity port 1
358128:2 TiMidity TiMidity port 2
359128:3 TiMidity TiMidity port 3
360
361$ aplaymidi -p 128:0 file.mid
362
363MIDI ports can be logically connected using the aconnect utility, e.g.:
364
365$ aconnect 24:0 128:0 # try it on the host
366
367After the gadget's MIDI port is connected to timidity's MIDI port,
368whatever is played at the gadget side with aplaymidi -l is audible
369in host's speakers/headphones.
4d0fa79e
AP
370
37110. NCM function
372================
373
374The function is provided by usb_f_ncm.ko module.
375
376Function-specific configfs interface
377------------------------------------
378
379The function name to use when creating the function directory is "ncm".
380The NCM function provides these attributes in its function directory:
381
382 ifname - network device interface name associated with this
383 function instance
384 qmult - queue length multiplier for high and super speed
385 host_addr - MAC address of host's end of this
386 Ethernet over USB link
387 dev_addr - MAC address of device's end of this
388 Ethernet over USB link
389
390and after creating the functions/ncm.<instance name> they contain default
391values: qmult is 5, dev_addr and host_addr are randomly selected.
392Except for ifname they can be written to until the function is linked to a
393configuration. The ifname is read-only and contains the name of the interface
394which was assigned by the net core, e. g. usb0.
395
396Testing the NCM function
397------------------------
398
399Configure IP addresses of the device and the host. Then:
400
401On the device: ping <host's IP>
402On the host: ping <device's IP>