]>
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 |
ddb72244 | 16 | 13. RNDIS function |
4dfcec8a | 17 | 14. SERIAL function |
480a912b | 18 | 15. SOURCESINK function |
dae03586 | 19 | 16. UAC1 function |
e38eb2c8 AP |
20 | |
21 | ||
22 | 1. ACM function | |
23 | =============== | |
24 | ||
25 | The function is provided by usb_f_acm.ko module. | |
26 | ||
27 | Function-specific configfs interface | |
28 | ------------------------------------ | |
29 | ||
30 | The function name to use when creating the function directory is "acm". | |
31 | The ACM function provides just one attribute in its function directory: | |
32 | ||
33 | port_num | |
34 | ||
35 | The attribute is read-only. | |
36 | ||
37 | There can be at most 4 ACM/generic serial/OBEX ports in the system. | |
38 | ||
39 | ||
40 | Testing the ACM function | |
41 | ------------------------ | |
42 | ||
43 | On the host: cat > /dev/ttyACM<X> | |
44 | On the device : cat /dev/ttyGS<Y> | |
45 | ||
46 | then the other way round | |
47 | ||
48 | On the device: cat > /dev/ttyGS<Y> | |
49 | On the host: cat /dev/ttyACM<X> | |
d5862ca6 AP |
50 | |
51 | 2. ECM function | |
52 | =============== | |
53 | ||
54 | The function is provided by usb_f_ecm.ko module. | |
55 | ||
56 | Function-specific configfs interface | |
57 | ------------------------------------ | |
58 | ||
59 | The function name to use when creating the function directory is "ecm". | |
60 | The 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 | ||
70 | and after creating the functions/ecm.<instance name> they contain default | |
71 | values: qmult is 5, dev_addr and host_addr are randomly selected. | |
72 | Except for ifname they can be written to until the function is linked to a | |
73 | configuration. The ifname is read-only and contains the name of the interface | |
74 | which was assigned by the net core, e. g. usb0. | |
75 | ||
76 | Testing the ECM function | |
77 | ------------------------ | |
78 | ||
79 | Configure IP addresses of the device and the host. Then: | |
80 | ||
81 | On the device: ping <host's IP> | |
82 | On the host: ping <device's IP> | |
7bfbc6e3 AP |
83 | |
84 | 3. ECM subset function | |
85 | ====================== | |
86 | ||
87 | The function is provided by usb_f_ecm_subset.ko module. | |
88 | ||
89 | Function-specific configfs interface | |
90 | ------------------------------------ | |
91 | ||
92 | The function name to use when creating the function directory is "geth". | |
93 | The 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 | ||
103 | and after creating the functions/ecm.<instance name> they contain default | |
104 | values: qmult is 5, dev_addr and host_addr are randomly selected. | |
105 | Except for ifname they can be written to until the function is linked to a | |
106 | configuration. The ifname is read-only and contains the name of the interface | |
107 | which was assigned by the net core, e. g. usb0. | |
108 | ||
109 | Testing the ECM subset function | |
110 | ------------------------------- | |
111 | ||
112 | Configure IP addresses of the device and the host. Then: | |
113 | ||
114 | On the device: ping <host's IP> | |
115 | On the host: ping <device's IP> | |
4ca560a6 AP |
116 | |
117 | 4. EEM function | |
118 | =============== | |
119 | ||
120 | The function is provided by usb_f_eem.ko module. | |
121 | ||
122 | Function-specific configfs interface | |
123 | ------------------------------------ | |
124 | ||
125 | The function name to use when creating the function directory is "eem". | |
126 | The 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 | ||
136 | and after creating the functions/eem.<instance name> they contain default | |
137 | values: qmult is 5, dev_addr and host_addr are randomly selected. | |
138 | Except for ifname they can be written to until the function is linked to a | |
139 | configuration. The ifname is read-only and contains the name of the interface | |
140 | which was assigned by the net core, e. g. usb0. | |
141 | ||
142 | Testing the EEM function | |
143 | ------------------------ | |
144 | ||
145 | Configure IP addresses of the device and the host. Then: | |
146 | ||
147 | On the device: ping <host's IP> | |
148 | On the host: ping <device's IP> | |
2c0f62f9 AP |
149 | |
150 | 5. FFS function | |
151 | =============== | |
152 | ||
153 | The function is provided by usb_f_fs.ko module. | |
154 | ||
155 | Function-specific configfs interface | |
156 | ------------------------------------ | |
157 | ||
158 | The function name to use when creating the function directory is "ffs". | |
159 | The function directory is intentionally empty and not modifiable. | |
160 | ||
161 | After creating the directory there is a new instance (a "device") of FunctionFS | |
162 | available in the system. Once a "device" is available, the user should follow | |
163 | the standard procedure for using FunctionFS (mount it, run the userspace | |
164 | process which implements the function proper). The gadget should be enabled | |
165 | by writing a suitable string to usb_gadget/<gadget>/UDC. | |
166 | ||
167 | Testing the FFS function | |
168 | ------------------------ | |
169 | ||
170 | On the device: start the function's userspace daemon, enable the gadget | |
171 | On the host: use the USB function provided by the device | |
f7e3c3cd AP |
172 | |
173 | 6. HID function | |
174 | =============== | |
175 | ||
176 | The function is provided by usb_f_hid.ko module. | |
177 | ||
178 | Function-specific configfs interface | |
179 | ------------------------------------ | |
180 | ||
181 | The function name to use when creating the function directory is "hid". | |
182 | The 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 | ||
190 | For a keyboard the protocol and the subclass are 1, the report_length is 8, | |
191 | while the report_desc is: | |
192 | ||
193 | $ hd my_report_desc | |
194 | 00000000 05 01 09 06 a1 01 05 07 19 e0 29 e7 15 00 25 01 |..........)...%.| | |
195 | 00000010 75 01 95 08 81 02 95 01 75 08 81 03 95 05 75 01 |u.......u.....u.| | |
196 | 00000020 05 08 19 01 29 05 91 02 95 01 75 03 91 03 95 06 |....).....u.....| | |
197 | 00000030 75 08 15 00 25 65 05 07 19 00 29 65 81 00 c0 |u...%e....)e...| | |
198 | 0000003f | |
199 | ||
200 | Such a sequence of bytes can be stored to the attribute with echo: | |
201 | ||
202 | $ echo -ne \\x05\\x01\\x09\\x06\\xa1..... | |
203 | ||
204 | Testing the HID function | |
205 | ------------------------ | |
206 | ||
207 | Device: | |
208 | - create the gadget | |
209 | - connect the gadget to a host, preferably not the one used | |
210 | to control the gadget | |
211 | - run a program which writes to /dev/hidg<N>, e.g. | |
212 | a userspace program found in Documentation/usb/gadget_hid.txt: | |
213 | ||
214 | $ ./hid_gadget_test /dev/hidg0 keyboard | |
215 | ||
216 | Host: | |
217 | - observe the keystrokes from the gadget | |
ec91aff7 AP |
218 | |
219 | 7. LOOPBACK function | |
220 | ==================== | |
221 | ||
222 | The function is provided by usb_f_ss_lb.ko module. | |
223 | ||
224 | Function-specific configfs interface | |
225 | ------------------------------------ | |
226 | ||
227 | The function name to use when creating the function directory is "Loopback". | |
228 | The LOOPBACK function provides these attributes in its function directory: | |
229 | ||
230 | qlen - depth of loopback queue | |
231 | bulk_buflen - buffer length | |
232 | ||
233 | Testing the LOOPBACK function | |
234 | ----------------------------- | |
235 | ||
236 | device: run the gadget | |
237 | host: test-usb | |
238 | ||
239 | http://www.linux-usb.org/usbtest/testusb.c | |
cdbe287d AP |
240 | |
241 | 8. MASS STORAGE function | |
242 | ======================== | |
243 | ||
244 | The function is provided by usb_f_mass_storage.ko module. | |
245 | ||
246 | Function-specific configfs interface | |
247 | ------------------------------------ | |
248 | ||
249 | The function name to use when creating the function directory is "mass_storage". | |
250 | The MASS STORAGE function provides these attributes in its directory: | |
251 | files: | |
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 | ||
260 | and a default lun.0 directory corresponding to SCSI LUN #0. | |
261 | ||
262 | A new lun can be added with mkdir: | |
263 | ||
264 | $ mkdir functions/mass_storage.0/partition.5 | |
265 | ||
266 | Lun numbering does not have to be continuous, except for lun #0 which is | |
267 | created by default. A maximum of 8 luns can be specified and they all must be | |
268 | named following the <name>.<number> scheme. The numbers can be 0..8. | |
269 | Probably a good convention is to name the luns "lun.<number>", | |
270 | although it is not mandatory. | |
271 | ||
272 | In 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 | ||
287 | Testing the MASS STORAGE function | |
288 | --------------------------------- | |
289 | ||
290 | device: connect the gadget, enable it | |
291 | host: dmesg, see the USB drives appear (if system configured to automatically | |
292 | mount) | |
0d6be59a AP |
293 | |
294 | 9. MIDI function | |
295 | ================ | |
296 | ||
297 | The function is provided by usb_f_midi.ko module. | |
298 | ||
299 | Function-specific configfs interface | |
300 | ------------------------------------ | |
301 | ||
302 | The function name to use when creating the function directory is "midi". | |
303 | The 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 | ||
312 | Testing the MIDI function | |
313 | ------------------------- | |
314 | ||
315 | There are two cases: playing a mid from the gadget to | |
316 | the host and playing a mid from the host to the gadget. | |
317 | ||
318 | 1) Playing a mid from the gadget to the host | |
319 | host) | |
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 | ||
327 | gadget) | |
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 | ||
335 | 2) Playing a mid from the host to the gadget | |
336 | gadget) | |
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 | ||
344 | host) | |
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 | ||
353 | The from_gadget.mid should sound identical to the to_host.mid. | |
354 | The from_host.id should sound identical to the to_gadget.mid. | |
355 | ||
356 | MIDI 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 | |
362 | 128:0 TiMidity TiMidity port 0 | |
363 | 128:1 TiMidity TiMidity port 1 | |
364 | 128:2 TiMidity TiMidity port 2 | |
365 | 128:3 TiMidity TiMidity port 3 | |
366 | ||
367 | $ aplaymidi -p 128:0 file.mid | |
368 | ||
369 | MIDI ports can be logically connected using the aconnect utility, e.g.: | |
370 | ||
371 | $ aconnect 24:0 128:0 # try it on the host | |
372 | ||
373 | After the gadget's MIDI port is connected to timidity's MIDI port, | |
374 | whatever is played at the gadget side with aplaymidi -l is audible | |
375 | in host's speakers/headphones. | |
4d0fa79e AP |
376 | |
377 | 10. NCM function | |
378 | ================ | |
379 | ||
380 | The function is provided by usb_f_ncm.ko module. | |
381 | ||
382 | Function-specific configfs interface | |
383 | ------------------------------------ | |
384 | ||
385 | The function name to use when creating the function directory is "ncm". | |
386 | The 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 | ||
396 | and after creating the functions/ncm.<instance name> they contain default | |
397 | values: qmult is 5, dev_addr and host_addr are randomly selected. | |
398 | Except for ifname they can be written to until the function is linked to a | |
399 | configuration. The ifname is read-only and contains the name of the interface | |
400 | which was assigned by the net core, e. g. usb0. | |
401 | ||
402 | Testing the NCM function | |
403 | ------------------------ | |
404 | ||
405 | Configure IP addresses of the device and the host. Then: | |
406 | ||
407 | On the device: ping <host's IP> | |
408 | On the host: ping <device's IP> | |
d81b85dc AP |
409 | |
410 | 11. OBEX function | |
411 | ================= | |
412 | ||
413 | The function is provided by usb_f_obex.ko module. | |
414 | ||
415 | Function-specific configfs interface | |
416 | ------------------------------------ | |
417 | ||
418 | The function name to use when creating the function directory is "obex". | |
419 | The OBEX function provides just one attribute in its function directory: | |
420 | ||
421 | port_num | |
422 | ||
423 | The attribute is read-only. | |
424 | ||
425 | There can be at most 4 ACM/generic serial/OBEX ports in the system. | |
426 | ||
427 | Testing the OBEX function | |
428 | ------------------------- | |
429 | ||
430 | On device: seriald -f /dev/ttyGS<Y> -s 1024 | |
431 | On host: serialc -v <vendorID> -p <productID> -i<interface#> -a1 -s1024 \ | |
432 | -t<out endpoint addr> -r<in endpoint addr> | |
433 | ||
434 | where seriald and serialc are Felipe's utilities found here: | |
435 | ||
436 | https://git.gitorious.org/usb/usb-tools.git master | |
da2907d2 AP |
437 | |
438 | 12. PHONET function | |
439 | =================== | |
440 | ||
441 | The function is provided by usb_f_phonet.ko module. | |
442 | ||
443 | Function-specific configfs interface | |
444 | ------------------------------------ | |
445 | ||
446 | The function name to use when creating the function directory is "phonet". | |
447 | The PHONET function provides just one attribute in its function directory: | |
448 | ||
449 | ifname - network device interface name associated with this | |
450 | function instance | |
451 | ||
452 | Testing the PHONET function | |
453 | --------------------------- | |
454 | ||
455 | It is not possible to test the SOCK_STREAM protocol without a specific piece | |
456 | of hardware, so only SOCK_DGRAM has been tested. For the latter to work, | |
457 | in the past I had to apply the patch mentioned here: | |
458 | ||
459 | http://www.spinics.net/lists/linux-usb/msg85689.html | |
460 | ||
461 | These tools are required: | |
462 | ||
463 | git://git.gitorious.org/meego-cellular/phonet-utils.git | |
464 | ||
465 | On the host: | |
466 | ||
467 | $ ./phonet -a 0x10 -i usbpn0 | |
468 | $ ./pnroute add 0x6c usbpn0 | |
469 | $./pnroute add 0x10 usbpn0 | |
470 | $ ifconfig usbpn0 up | |
471 | ||
472 | On the device: | |
473 | ||
474 | $ ./phonet -a 0x6c -i upnlink0 | |
475 | $ ./pnroute add 0x10 upnlink0 | |
476 | $ ifconfig upnlink0 up | |
477 | ||
478 | Then a test program can be used: | |
479 | ||
480 | http://www.spinics.net/lists/linux-usb/msg85690.html | |
481 | ||
482 | On the device: | |
483 | ||
484 | $ ./pnxmit -a 0x6c -r | |
485 | ||
486 | On the host: | |
487 | ||
488 | $ ./pnxmit -a 0x10 -s 0x6c | |
489 | ||
490 | As a result some data should be sent from host to device. | |
491 | Then the other way round: | |
492 | ||
493 | On the host: | |
494 | ||
495 | $ ./pnxmit -a 0x10 -r | |
496 | ||
497 | On the device: | |
498 | ||
499 | $ ./pnxmit -a 0x6c -s 0x10 | |
ddb72244 AP |
500 | |
501 | 13. RNDIS function | |
502 | ================== | |
503 | ||
504 | The function is provided by usb_f_rndis.ko module. | |
505 | ||
506 | Function-specific configfs interface | |
507 | ------------------------------------ | |
508 | ||
509 | The function name to use when creating the function directory is "rndis". | |
510 | The 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 | ||
520 | and after creating the functions/rndis.<instance name> they contain default | |
521 | values: qmult is 5, dev_addr and host_addr are randomly selected. | |
522 | Except for ifname they can be written to until the function is linked to a | |
523 | configuration. The ifname is read-only and contains the name of the interface | |
524 | which was assigned by the net core, e. g. usb0. | |
525 | ||
526 | By default there can be only 1 RNDIS interface in the system. | |
527 | ||
528 | Testing the RNDIS function | |
529 | -------------------------- | |
530 | ||
531 | Configure IP addresses of the device and the host. Then: | |
532 | ||
533 | On the device: ping <host's IP> | |
534 | On the host: ping <device's IP> | |
4dfcec8a AP |
535 | |
536 | 14. SERIAL function | |
537 | =================== | |
538 | ||
539 | The function is provided by usb_f_gser.ko module. | |
540 | ||
541 | Function-specific configfs interface | |
542 | ------------------------------------ | |
543 | ||
544 | The function name to use when creating the function directory is "gser". | |
545 | The SERIAL function provides just one attribute in its function directory: | |
546 | ||
547 | port_num | |
548 | ||
549 | The attribute is read-only. | |
550 | ||
551 | There can be at most 4 ACM/generic serial/OBEX ports in the system. | |
552 | ||
553 | Testing the SERIAL function | |
554 | --------------------------- | |
555 | ||
556 | On host: insmod usbserial | |
557 | echo VID PID >/sys/bus/usb-serial/drivers/generic/new_id | |
558 | On host: cat > /dev/ttyUSB<X> | |
559 | On target: cat /dev/ttyGS<Y> | |
560 | ||
561 | then the other way round | |
562 | ||
563 | On target: cat > /dev/ttyGS<Y> | |
564 | On host: cat /dev/ttyUSB<X> | |
480a912b AP |
565 | |
566 | 15. SOURCESINK function | |
567 | ======================= | |
568 | ||
569 | The function is provided by usb_f_ss_lb.ko module. | |
570 | ||
571 | Function-specific configfs interface | |
572 | ------------------------------------ | |
573 | ||
574 | The function name to use when creating the function directory is "SourceSink". | |
575 | The 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 | ||
584 | Testing the SOURCESINK function | |
585 | ------------------------------- | |
586 | ||
587 | device: run the gadget | |
588 | host: test-usb | |
589 | ||
590 | http://www.linux-usb.org/usbtest/testusb.c | |
dae03586 AP |
591 | |
592 | 16. UAC1 function | |
593 | ================= | |
594 | ||
595 | The function is provided by usb_f_uac1.ko module. | |
596 | ||
597 | Function-specific configfs interface | |
598 | ------------------------------------ | |
599 | ||
600 | The function name to use when creating the function directory is "uac1". | |
601 | The 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 | ||
610 | The attributes have sane default values. | |
611 | ||
612 | Testing the UAC1 function | |
613 | ------------------------- | |
614 | ||
615 | device: run the gadget | |
616 | host: aplay -l # should list our USB Audio Gadget |