1 This file summarizes information on basic testing of USB functions
11 8. MASS STORAGE function
18 15. SOURCESINK function
24 The function is provided by usb_f_acm.ko module.
26 Function-specific configfs interface
27 ------------------------------------
29 The function name to use when creating the function directory is "acm".
30 The ACM function provides just one attribute in its function directory:
34 The attribute is read-only.
36 There can be at most 4 ACM/generic serial/OBEX ports in the system.
39 Testing the ACM function
40 ------------------------
42 On the host: cat > /dev/ttyACM<X>
43 On the device : cat /dev/ttyGS<Y>
45 then the other way round
47 On the device: cat > /dev/ttyGS<Y>
48 On the host: cat /dev/ttyACM<X>
53 The function is provided by usb_f_ecm.ko module.
55 Function-specific configfs interface
56 ------------------------------------
58 The function name to use when creating the function directory is "ecm".
59 The ECM function provides these attributes in its function directory:
61 ifname - network device interface name associated with this
63 qmult - queue length multiplier for high and super speed
64 host_addr - MAC address of host's end of this
65 Ethernet over USB link
66 dev_addr - MAC address of device's end of this
67 Ethernet over USB link
69 and after creating the functions/ecm.<instance name> they contain default
70 values: qmult is 5, dev_addr and host_addr are randomly selected.
71 Except for ifname they can be written to until the function is linked to a
72 configuration. The ifname is read-only and contains the name of the interface
73 which was assigned by the net core, e. g. usb0.
75 Testing the ECM function
76 ------------------------
78 Configure IP addresses of the device and the host. Then:
80 On the device: ping <host's IP>
81 On the host: ping <device's IP>
83 3. ECM subset function
84 ======================
86 The function is provided by usb_f_ecm_subset.ko module.
88 Function-specific configfs interface
89 ------------------------------------
91 The function name to use when creating the function directory is "geth".
92 The ECM subset function provides these attributes in its function directory:
94 ifname - network device interface name associated with this
96 qmult - queue length multiplier for high and super speed
97 host_addr - MAC address of host's end of this
98 Ethernet over USB link
99 dev_addr - MAC address of device's end of this
100 Ethernet over USB link
102 and after creating the functions/ecm.<instance name> they contain default
103 values: qmult is 5, dev_addr and host_addr are randomly selected.
104 Except for ifname they can be written to until the function is linked to a
105 configuration. The ifname is read-only and contains the name of the interface
106 which was assigned by the net core, e. g. usb0.
108 Testing the ECM subset function
109 -------------------------------
111 Configure IP addresses of the device and the host. Then:
113 On the device: ping <host's IP>
114 On the host: ping <device's IP>
119 The function is provided by usb_f_eem.ko module.
121 Function-specific configfs interface
122 ------------------------------------
124 The function name to use when creating the function directory is "eem".
125 The EEM function provides these attributes in its function directory:
127 ifname - network device interface name associated with this
129 qmult - queue length multiplier for high and super speed
130 host_addr - MAC address of host's end of this
131 Ethernet over USB link
132 dev_addr - MAC address of device's end of this
133 Ethernet over USB link
135 and after creating the functions/eem.<instance name> they contain default
136 values: qmult is 5, dev_addr and host_addr are randomly selected.
137 Except for ifname they can be written to until the function is linked to a
138 configuration. The ifname is read-only and contains the name of the interface
139 which was assigned by the net core, e. g. usb0.
141 Testing the EEM function
142 ------------------------
144 Configure IP addresses of the device and the host. Then:
146 On the device: ping <host's IP>
147 On the host: ping <device's IP>
152 The function is provided by usb_f_fs.ko module.
154 Function-specific configfs interface
155 ------------------------------------
157 The function name to use when creating the function directory is "ffs".
158 The function directory is intentionally empty and not modifiable.
160 After creating the directory there is a new instance (a "device") of FunctionFS
161 available in the system. Once a "device" is available, the user should follow
162 the standard procedure for using FunctionFS (mount it, run the userspace
163 process which implements the function proper). The gadget should be enabled
164 by writing a suitable string to usb_gadget/<gadget>/UDC.
166 Testing the FFS function
167 ------------------------
169 On the device: start the function's userspace daemon, enable the gadget
170 On the host: use the USB function provided by the device
175 The function is provided by usb_f_hid.ko module.
177 Function-specific configfs interface
178 ------------------------------------
180 The function name to use when creating the function directory is "hid".
181 The HID function provides these attributes in its function directory:
183 protocol - HID protocol to use
184 report_desc - data to be used in HID reports, except data
185 passed with /dev/hidg<X>
186 report_length - HID report length
187 subclass - HID subclass to use
189 For a keyboard the protocol and the subclass are 1, the report_length is 8,
190 while the report_desc is:
193 00000000 05 01 09 06 a1 01 05 07 19 e0 29 e7 15 00 25 01 |..........)...%.|
194 00000010 75 01 95 08 81 02 95 01 75 08 81 03 95 05 75 01 |u.......u.....u.|
195 00000020 05 08 19 01 29 05 91 02 95 01 75 03 91 03 95 06 |....).....u.....|
196 00000030 75 08 15 00 25 65 05 07 19 00 29 65 81 00 c0 |u...%e....)e...|
199 Such a sequence of bytes can be stored to the attribute with echo:
201 $ echo -ne \\x05\\x01\\x09\\x06\\xa1.....
203 Testing the HID function
204 ------------------------
208 - connect the gadget to a host, preferably not the one used
209 to control the gadget
210 - run a program which writes to /dev/hidg<N>, e.g.
211 a userspace program found in Documentation/usb/gadget_hid.txt:
213 $ ./hid_gadget_test /dev/hidg0 keyboard
216 - observe the keystrokes from the gadget
221 The function is provided by usb_f_ss_lb.ko module.
223 Function-specific configfs interface
224 ------------------------------------
226 The function name to use when creating the function directory is "Loopback".
227 The LOOPBACK function provides these attributes in its function directory:
229 qlen - depth of loopback queue
230 bulk_buflen - buffer length
232 Testing the LOOPBACK function
233 -----------------------------
235 device: run the gadget
238 http://www.linux-usb.org/usbtest/testusb.c
240 8. MASS STORAGE function
241 ========================
243 The function is provided by usb_f_mass_storage.ko module.
245 Function-specific configfs interface
246 ------------------------------------
248 The function name to use when creating the function directory is "mass_storage".
249 The MASS STORAGE function provides these attributes in its directory:
252 stall - Set to permit function to halt bulk endpoints.
253 Disabled on some USB devices known not to work
254 correctly. You should set it to true.
255 num_buffers - Number of pipeline buffers. Valid numbers
256 are 2..4. Available only if
257 CONFIG_USB_GADGET_DEBUG_FILES is set.
259 and a default lun.0 directory corresponding to SCSI LUN #0.
261 A new lun can be added with mkdir:
263 $ mkdir functions/mass_storage.0/partition.5
265 Lun numbering does not have to be continuous, except for lun #0 which is
266 created by default. A maximum of 8 luns can be specified and they all must be
267 named following the <name>.<number> scheme. The numbers can be 0..8.
268 Probably a good convention is to name the luns "lun.<number>",
269 although it is not mandatory.
271 In each lun directory there are the following attribute files:
273 file - The path to the backing file for the LUN.
274 Required if LUN is not marked as removable.
275 ro - Flag specifying access to the LUN shall be
276 read-only. This is implied if CD-ROM emulation
277 is enabled as well as when it was impossible
278 to open "filename" in R/W mode.
279 removable - Flag specifying that LUN shall be indicated as
281 cdrom - Flag specifying that LUN shall be reported as
283 nofua - Flag specifying that FUA flag
286 Testing the MASS STORAGE function
287 ---------------------------------
289 device: connect the gadget, enable it
290 host: dmesg, see the USB drives appear (if system configured to automatically
296 The function is provided by usb_f_midi.ko module.
298 Function-specific configfs interface
299 ------------------------------------
301 The function name to use when creating the function directory is "midi".
302 The MIDI function provides these attributes in its function directory:
304 buflen - MIDI buffer length
305 id - ID string for the USB MIDI adapter
306 in_ports - number of MIDI input ports
307 index - index value for the USB MIDI adapter
308 out_ports - number of MIDI output ports
309 qlen - USB read request queue length
311 Testing the MIDI function
312 -------------------------
314 There are two cases: playing a mid from the gadget to
315 the host and playing a mid from the host to the gadget.
317 1) Playing a mid from the gadget to the host
321 Port Client name Port name
322 14:0 Midi Through Midi Through Port-0
323 24:0 MIDI Gadget MIDI Gadget MIDI 1
324 $ arecordmidi -p 24:0 from_gadget.mid
329 Port Client name Port name
332 $ aplaymidi -p 20:0 to_host.mid
334 2) Playing a mid from the host to the gadget
338 Port Client name Port name
341 $ arecordmidi -p 20:0 from_host.mid
346 Port Client name Port name
347 14:0 Midi Through Midi Through Port-0
348 24:0 MIDI Gadget MIDI Gadget MIDI 1
350 $ aplaymidi -p24:0 to_gadget.mid
352 The from_gadget.mid should sound identical to the to_host.mid.
353 The from_host.id should sound identical to the to_gadget.mid.
355 MIDI files can be played to speakers/headphones with e.g. timidity installed
358 Port Client name Port name
359 14:0 Midi Through Midi Through Port-0
360 24:0 MIDI Gadget MIDI Gadget MIDI 1
361 128:0 TiMidity TiMidity port 0
362 128:1 TiMidity TiMidity port 1
363 128:2 TiMidity TiMidity port 2
364 128:3 TiMidity TiMidity port 3
366 $ aplaymidi -p 128:0 file.mid
368 MIDI ports can be logically connected using the aconnect utility, e.g.:
370 $ aconnect 24:0 128:0 # try it on the host
372 After the gadget's MIDI port is connected to timidity's MIDI port,
373 whatever is played at the gadget side with aplaymidi -l is audible
374 in host's speakers/headphones.
379 The function is provided by usb_f_ncm.ko module.
381 Function-specific configfs interface
382 ------------------------------------
384 The function name to use when creating the function directory is "ncm".
385 The NCM function provides these attributes in its function directory:
387 ifname - network device interface name associated with this
389 qmult - queue length multiplier for high and super speed
390 host_addr - MAC address of host's end of this
391 Ethernet over USB link
392 dev_addr - MAC address of device's end of this
393 Ethernet over USB link
395 and after creating the functions/ncm.<instance name> they contain default
396 values: qmult is 5, dev_addr and host_addr are randomly selected.
397 Except for ifname they can be written to until the function is linked to a
398 configuration. The ifname is read-only and contains the name of the interface
399 which was assigned by the net core, e. g. usb0.
401 Testing the NCM function
402 ------------------------
404 Configure IP addresses of the device and the host. Then:
406 On the device: ping <host's IP>
407 On the host: ping <device's IP>
412 The function is provided by usb_f_obex.ko module.
414 Function-specific configfs interface
415 ------------------------------------
417 The function name to use when creating the function directory is "obex".
418 The OBEX function provides just one attribute in its function directory:
422 The attribute is read-only.
424 There can be at most 4 ACM/generic serial/OBEX ports in the system.
426 Testing the OBEX function
427 -------------------------
429 On device: seriald -f /dev/ttyGS<Y> -s 1024
430 On host: serialc -v <vendorID> -p <productID> -i<interface#> -a1 -s1024 \
431 -t<out endpoint addr> -r<in endpoint addr>
433 where seriald and serialc are Felipe's utilities found here:
435 https://git.gitorious.org/usb/usb-tools.git master
440 The function is provided by usb_f_phonet.ko module.
442 Function-specific configfs interface
443 ------------------------------------
445 The function name to use when creating the function directory is "phonet".
446 The PHONET function provides just one attribute in its function directory:
448 ifname - network device interface name associated with this
451 Testing the PHONET function
452 ---------------------------
454 It is not possible to test the SOCK_STREAM protocol without a specific piece
455 of hardware, so only SOCK_DGRAM has been tested. For the latter to work,
456 in the past I had to apply the patch mentioned here:
458 http://www.spinics.net/lists/linux-usb/msg85689.html
460 These tools are required:
462 git://git.gitorious.org/meego-cellular/phonet-utils.git
466 $ ./phonet -a 0x10 -i usbpn0
467 $ ./pnroute add 0x6c usbpn0
468 $./pnroute add 0x10 usbpn0
473 $ ./phonet -a 0x6c -i upnlink0
474 $ ./pnroute add 0x10 upnlink0
475 $ ifconfig upnlink0 up
477 Then a test program can be used:
479 http://www.spinics.net/lists/linux-usb/msg85690.html
483 $ ./pnxmit -a 0x6c -r
487 $ ./pnxmit -a 0x10 -s 0x6c
489 As a result some data should be sent from host to device.
490 Then the other way round:
494 $ ./pnxmit -a 0x10 -r
498 $ ./pnxmit -a 0x6c -s 0x10
503 The function is provided by usb_f_rndis.ko module.
505 Function-specific configfs interface
506 ------------------------------------
508 The function name to use when creating the function directory is "rndis".
509 The RNDIS function provides these attributes in its function directory:
511 ifname - network device interface name associated with this
513 qmult - queue length multiplier for high and super speed
514 host_addr - MAC address of host's end of this
515 Ethernet over USB link
516 dev_addr - MAC address of device's end of this
517 Ethernet over USB link
519 and after creating the functions/rndis.<instance name> they contain default
520 values: qmult is 5, dev_addr and host_addr are randomly selected.
521 Except for ifname they can be written to until the function is linked to a
522 configuration. The ifname is read-only and contains the name of the interface
523 which was assigned by the net core, e. g. usb0.
525 By default there can be only 1 RNDIS interface in the system.
527 Testing the RNDIS function
528 --------------------------
530 Configure IP addresses of the device and the host. Then:
532 On the device: ping <host's IP>
533 On the host: ping <device's IP>
538 The function is provided by usb_f_gser.ko module.
540 Function-specific configfs interface
541 ------------------------------------
543 The function name to use when creating the function directory is "gser".
544 The SERIAL function provides just one attribute in its function directory:
548 The attribute is read-only.
550 There can be at most 4 ACM/generic serial/OBEX ports in the system.
552 Testing the SERIAL function
553 ---------------------------
555 On host: insmod usbserial
556 echo VID PID >/sys/bus/usb-serial/drivers/generic/new_id
557 On host: cat > /dev/ttyUSB<X>
558 On target: cat /dev/ttyGS<Y>
560 then the other way round
562 On target: cat > /dev/ttyGS<Y>
563 On host: cat /dev/ttyUSB<X>
565 15. SOURCESINK function
566 =======================
568 The function is provided by usb_f_ss_lb.ko module.
570 Function-specific configfs interface
571 ------------------------------------
573 The function name to use when creating the function directory is "SourceSink".
574 The SOURCESINK function provides these attributes in its function directory:
576 pattern - 0 (all zeros), 1 (mod63), 2 (none)
577 isoc_interval - 1..16
578 isoc_maxpacket - 0 - 1023 (fs), 0 - 1024 (hs/ss)
579 isoc_mult - 0..2 (hs/ss only)
580 isoc_maxburst - 0..15 (ss only)
581 bulk_buflen - buffer length
583 Testing the SOURCESINK function
584 -------------------------------
586 device: run the gadget
589 http://www.linux-usb.org/usbtest/testusb.c