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