summaryrefslogtreecommitdiffstats
path: root/Documentation/usb/gadget-testing.txt
diff options
context:
space:
mode:
Diffstat (limited to 'Documentation/usb/gadget-testing.txt')
-rw-r--r--Documentation/usb/gadget-testing.txt611
1 files changed, 363 insertions, 248 deletions
diff --git a/Documentation/usb/gadget-testing.txt b/Documentation/usb/gadget-testing.txt
index 5908a21fddb6..7d7f2340af42 100644
--- a/Documentation/usb/gadget-testing.txt
+++ b/Documentation/usb/gadget-testing.txt
@@ -1,26 +1,32 @@
1==============
2Gadget Testing
3==============
4
1This file summarizes information on basic testing of USB functions 5This file summarizes information on basic testing of USB functions
2provided by gadgets. 6provided by gadgets.
3 7
41. ACM function 8.. contents
52. ECM function 9
63. ECM subset function 10 1. ACM function
74. EEM function 11 2. ECM function
85. FFS function 12 3. ECM subset function
96. HID function 13 4. EEM function
107. LOOPBACK function 14 5. FFS function
118. MASS STORAGE function 15 6. HID function
129. MIDI function 16 7. LOOPBACK function
1310. NCM function 17 8. MASS STORAGE function
1411. OBEX function 18 9. MIDI function
1512. PHONET function 19 10. NCM function
1613. RNDIS function 20 11. OBEX function
1714. SERIAL function 21 12. PHONET function
1815. SOURCESINK function 22 13. RNDIS function
1916. UAC1 function (legacy implementation) 23 14. SERIAL function
2017. UAC2 function 24 15. SOURCESINK function
2118. UVC function 25 16. UAC1 function (legacy implementation)
2219. PRINTER function 26 17. UAC2 function
2320. UAC1 function (new API) 27 18. UVC function
28 19. PRINTER function
29 20. UAC1 function (new API)
24 30
25 31
261. ACM function 321. ACM function
@@ -44,13 +50,23 @@ There can be at most 4 ACM/generic serial/OBEX ports in the system.
44Testing the ACM function 50Testing the ACM function
45------------------------ 51------------------------
46 52
47On the host: cat > /dev/ttyACM<X> 53On the host::
48On the device : cat /dev/ttyGS<Y> 54
55 cat > /dev/ttyACM<X>
56
57On the device::
58
59 cat /dev/ttyGS<Y>
49 60
50then the other way round 61then the other way round
51 62
52On the device: cat > /dev/ttyGS<Y> 63On the device::
53On the host: cat /dev/ttyACM<X> 64
65 cat > /dev/ttyGS<Y>
66
67On the host::
68
69 cat /dev/ttyACM<X>
54 70
552. ECM function 712. ECM function
56=============== 72===============
@@ -63,13 +79,15 @@ Function-specific configfs interface
63The function name to use when creating the function directory is "ecm". 79The function name to use when creating the function directory is "ecm".
64The ECM function provides these attributes in its function directory: 80The ECM function provides these attributes in its function directory:
65 81
66 ifname - network device interface name associated with this 82 =============== ==================================================
83 ifname network device interface name associated with this
67 function instance 84 function instance
68 qmult - queue length multiplier for high and super speed 85 qmult queue length multiplier for high and super speed
69 host_addr - MAC address of host's end of this 86 host_addr MAC address of host's end of this
70 Ethernet over USB link 87 Ethernet over USB link
71 dev_addr - MAC address of device's end of this 88 dev_addr MAC address of device's end of this
72 Ethernet over USB link 89 Ethernet over USB link
90 =============== ==================================================
73 91
74and after creating the functions/ecm.<instance name> they contain default 92and after creating the functions/ecm.<instance name> they contain default
75values: qmult is 5, dev_addr and host_addr are randomly selected. 93values: qmult is 5, dev_addr and host_addr are randomly selected.
@@ -82,8 +100,13 @@ Testing the ECM function
82 100
83Configure IP addresses of the device and the host. Then: 101Configure IP addresses of the device and the host. Then:
84 102
85On the device: ping <host's IP> 103On the device::
86On the host: ping <device's IP> 104
105 ping <host's IP>
106
107On the host::
108
109 ping <device's IP>
87 110
883. ECM subset function 1113. ECM subset function
89====================== 112======================
@@ -96,13 +119,15 @@ Function-specific configfs interface
96The function name to use when creating the function directory is "geth". 119The function name to use when creating the function directory is "geth".
97The ECM subset function provides these attributes in its function directory: 120The ECM subset function provides these attributes in its function directory:
98 121
99 ifname - network device interface name associated with this 122 =============== ==================================================
123 ifname network device interface name associated with this
100 function instance 124 function instance
101 qmult - queue length multiplier for high and super speed 125 qmult queue length multiplier for high and super speed
102 host_addr - MAC address of host's end of this 126 host_addr MAC address of host's end of this
103 Ethernet over USB link 127 Ethernet over USB link
104 dev_addr - MAC address of device's end of this 128 dev_addr MAC address of device's end of this
105 Ethernet over USB link 129 Ethernet over USB link
130 =============== ==================================================
106 131
107and after creating the functions/ecm.<instance name> they contain default 132and after creating the functions/ecm.<instance name> they contain default
108values: qmult is 5, dev_addr and host_addr are randomly selected. 133values: qmult is 5, dev_addr and host_addr are randomly selected.
@@ -115,8 +140,13 @@ Testing the ECM subset function
115 140
116Configure IP addresses of the device and the host. Then: 141Configure IP addresses of the device and the host. Then:
117 142
118On the device: ping <host's IP> 143On the device::
119On the host: ping <device's IP> 144
145 ping <host's IP>
146
147On the host::
148
149 ping <device's IP>
120 150
1214. EEM function 1514. EEM function
122=============== 152===============
@@ -129,13 +159,15 @@ Function-specific configfs interface
129The function name to use when creating the function directory is "eem". 159The function name to use when creating the function directory is "eem".
130The EEM function provides these attributes in its function directory: 160The EEM function provides these attributes in its function directory:
131 161
132 ifname - network device interface name associated with this 162 =============== ==================================================
163 ifname network device interface name associated with this
133 function instance 164 function instance
134 qmult - queue length multiplier for high and super speed 165 qmult queue length multiplier for high and super speed
135 host_addr - MAC address of host's end of this 166 host_addr MAC address of host's end of this
136 Ethernet over USB link 167 Ethernet over USB link
137 dev_addr - MAC address of device's end of this 168 dev_addr MAC address of device's end of this
138 Ethernet over USB link 169 Ethernet over USB link
170 =============== ==================================================
139 171
140and after creating the functions/eem.<instance name> they contain default 172and after creating the functions/eem.<instance name> they contain default
141values: qmult is 5, dev_addr and host_addr are randomly selected. 173values: qmult is 5, dev_addr and host_addr are randomly selected.
@@ -148,8 +180,13 @@ Testing the EEM function
148 180
149Configure IP addresses of the device and the host. Then: 181Configure IP addresses of the device and the host. Then:
150 182
151On the device: ping <host's IP> 183On the device::
152On the host: ping <device's IP> 184
185 ping <host's IP>
186
187On the host::
188
189 ping <device's IP>
153 190
1545. FFS function 1915. FFS function
155=============== 192===============
@@ -172,6 +209,7 @@ Testing the FFS function
172------------------------ 209------------------------
173 210
174On the device: start the function's userspace daemon, enable the gadget 211On the device: start the function's userspace daemon, enable the gadget
212
175On the host: use the USB function provided by the device 213On the host: use the USB function provided by the device
176 214
1776. HID function 2156. HID function
@@ -185,39 +223,43 @@ Function-specific configfs interface
185The function name to use when creating the function directory is "hid". 223The function name to use when creating the function directory is "hid".
186The HID function provides these attributes in its function directory: 224The HID function provides these attributes in its function directory:
187 225
188 protocol - HID protocol to use 226 =============== ===========================================
189 report_desc - data to be used in HID reports, except data 227 protocol HID protocol to use
228 report_desc data to be used in HID reports, except data
190 passed with /dev/hidg<X> 229 passed with /dev/hidg<X>
191 report_length - HID report length 230 report_length HID report length
192 subclass - HID subclass to use 231 subclass HID subclass to use
232 =============== ===========================================
193 233
194For a keyboard the protocol and the subclass are 1, the report_length is 8, 234For a keyboard the protocol and the subclass are 1, the report_length is 8,
195while the report_desc is: 235while the report_desc is::
196 236
197$ hd my_report_desc 237 $ hd my_report_desc
19800000000 05 01 09 06 a1 01 05 07 19 e0 29 e7 15 00 25 01 |..........)...%.| 238 00000000 05 01 09 06 a1 01 05 07 19 e0 29 e7 15 00 25 01 |..........)...%.|
19900000010 75 01 95 08 81 02 95 01 75 08 81 03 95 05 75 01 |u.......u.....u.| 239 00000010 75 01 95 08 81 02 95 01 75 08 81 03 95 05 75 01 |u.......u.....u.|
20000000020 05 08 19 01 29 05 91 02 95 01 75 03 91 03 95 06 |....).....u.....| 240 00000020 05 08 19 01 29 05 91 02 95 01 75 03 91 03 95 06 |....).....u.....|
20100000030 75 08 15 00 25 65 05 07 19 00 29 65 81 00 c0 |u...%e....)e...| 241 00000030 75 08 15 00 25 65 05 07 19 00 29 65 81 00 c0 |u...%e....)e...|
2020000003f 242 0000003f
203 243
204Such a sequence of bytes can be stored to the attribute with echo: 244Such a sequence of bytes can be stored to the attribute with echo::
205 245
206$ echo -ne \\x05\\x01\\x09\\x06\\xa1..... 246 $ echo -ne \\x05\\x01\\x09\\x06\\xa1.....
207 247
208Testing the HID function 248Testing the HID function
209------------------------ 249------------------------
210 250
211Device: 251Device:
252
212- create the gadget 253- create the gadget
213- connect the gadget to a host, preferably not the one used 254- connect the gadget to a host, preferably not the one used
214to control the gadget 255 to control the gadget
215- run a program which writes to /dev/hidg<N>, e.g. 256- run a program which writes to /dev/hidg<N>, e.g.
216a userspace program found in Documentation/usb/gadget_hid.txt: 257 a userspace program found in Documentation/usb/gadget_hid.txt::
217 258
218$ ./hid_gadget_test /dev/hidg0 keyboard 259 $ ./hid_gadget_test /dev/hidg0 keyboard
219 260
220Host: 261Host:
262
221- observe the keystrokes from the gadget 263- observe the keystrokes from the gadget
222 264
2237. LOOPBACK function 2657. LOOPBACK function
@@ -231,13 +273,16 @@ Function-specific configfs interface
231The function name to use when creating the function directory is "Loopback". 273The function name to use when creating the function directory is "Loopback".
232The LOOPBACK function provides these attributes in its function directory: 274The LOOPBACK function provides these attributes in its function directory:
233 275
234 qlen - depth of loopback queue 276 =============== =======================
235 bulk_buflen - buffer length 277 qlen depth of loopback queue
278 bulk_buflen buffer length
279 =============== =======================
236 280
237Testing the LOOPBACK function 281Testing the LOOPBACK function
238----------------------------- 282-----------------------------
239 283
240device: run the gadget 284device: run the gadget
285
241host: test-usb (tools/usb/testusb.c) 286host: test-usb (tools/usb/testusb.c)
242 287
2438. MASS STORAGE function 2888. MASS STORAGE function
@@ -252,18 +297,20 @@ The function name to use when creating the function directory is "mass_storage".
252The MASS STORAGE function provides these attributes in its directory: 297The MASS STORAGE function provides these attributes in its directory:
253files: 298files:
254 299
255 stall - Set to permit function to halt bulk endpoints. 300 =============== ==============================================
301 stall Set to permit function to halt bulk endpoints.
256 Disabled on some USB devices known not to work 302 Disabled on some USB devices known not to work
257 correctly. You should set it to true. 303 correctly. You should set it to true.
258 num_buffers - Number of pipeline buffers. Valid numbers 304 num_buffers Number of pipeline buffers. Valid numbers
259 are 2..4. Available only if 305 are 2..4. Available only if
260 CONFIG_USB_GADGET_DEBUG_FILES is set. 306 CONFIG_USB_GADGET_DEBUG_FILES is set.
307 =============== ==============================================
261 308
262and a default lun.0 directory corresponding to SCSI LUN #0. 309and a default lun.0 directory corresponding to SCSI LUN #0.
263 310
264A new lun can be added with mkdir: 311A new lun can be added with mkdir::
265 312
266$ mkdir functions/mass_storage.0/partition.5 313 $ mkdir functions/mass_storage.0/partition.5
267 314
268Lun numbering does not have to be continuous, except for lun #0 which is 315Lun numbering does not have to be continuous, except for lun #0 which is
269created by default. A maximum of 8 luns can be specified and they all must be 316created by default. A maximum of 8 luns can be specified and they all must be
@@ -273,18 +320,20 @@ although it is not mandatory.
273 320
274In each lun directory there are the following attribute files: 321In each lun directory there are the following attribute files:
275 322
276 file - The path to the backing file for the LUN. 323 =============== ==============================================
324 file The path to the backing file for the LUN.
277 Required if LUN is not marked as removable. 325 Required if LUN is not marked as removable.
278 ro - Flag specifying access to the LUN shall be 326 ro Flag specifying access to the LUN shall be
279 read-only. This is implied if CD-ROM emulation 327 read-only. This is implied if CD-ROM emulation
280 is enabled as well as when it was impossible 328 is enabled as well as when it was impossible
281 to open "filename" in R/W mode. 329 to open "filename" in R/W mode.
282 removable - Flag specifying that LUN shall be indicated as 330 removable Flag specifying that LUN shall be indicated as
283 being removable. 331 being removable.
284 cdrom - Flag specifying that LUN shall be reported as 332 cdrom Flag specifying that LUN shall be reported as
285 being a CD-ROM. 333 being a CD-ROM.
286 nofua - Flag specifying that FUA flag 334 nofua Flag specifying that FUA flag
287 in SCSI WRITE(10,12) 335 in SCSI WRITE(10,12)
336 =============== ==============================================
288 337
289Testing the MASS STORAGE function 338Testing the MASS STORAGE function
290--------------------------------- 339---------------------------------
@@ -304,12 +353,14 @@ Function-specific configfs interface
304The function name to use when creating the function directory is "midi". 353The function name to use when creating the function directory is "midi".
305The MIDI function provides these attributes in its function directory: 354The MIDI function provides these attributes in its function directory:
306 355
307 buflen - MIDI buffer length 356 =============== ====================================
308 id - ID string for the USB MIDI adapter 357 buflen MIDI buffer length
309 in_ports - number of MIDI input ports 358 id ID string for the USB MIDI adapter
310 index - index value for the USB MIDI adapter 359 in_ports number of MIDI input ports
311 out_ports - number of MIDI output ports 360 index index value for the USB MIDI adapter
312 qlen - USB read request queue length 361 out_ports number of MIDI output ports
362 qlen USB read request queue length
363 =============== ====================================
313 364
314Testing the MIDI function 365Testing the MIDI function
315------------------------- 366-------------------------
@@ -317,60 +368,63 @@ Testing the MIDI function
317There are two cases: playing a mid from the gadget to 368There are two cases: playing a mid from the gadget to
318the host and playing a mid from the host to the gadget. 369the host and playing a mid from the host to the gadget.
319 370
3201) Playing a mid from the gadget to the host 3711) Playing a mid from the gadget to the host:
321host) 372
373host::
322 374
323$ arecordmidi -l 375 $ arecordmidi -l
324 Port Client name Port name 376 Port Client name Port name
325 14:0 Midi Through Midi Through Port-0 377 14:0 Midi Through Midi Through Port-0
326 24:0 MIDI Gadget MIDI Gadget MIDI 1 378 24:0 MIDI Gadget MIDI Gadget MIDI 1
327$ arecordmidi -p 24:0 from_gadget.mid 379 $ arecordmidi -p 24:0 from_gadget.mid
328 380
329gadget) 381gadget::
330 382
331$ aplaymidi -l 383 $ aplaymidi -l
332 Port Client name Port name 384 Port Client name Port name
333 20:0 f_midi f_midi 385 20:0 f_midi f_midi
334 386
335$ aplaymidi -p 20:0 to_host.mid 387 $ aplaymidi -p 20:0 to_host.mid
336 388
3372) Playing a mid from the host to the gadget 3892) Playing a mid from the host to the gadget
338gadget)
339 390
340$ arecordmidi -l 391gadget::
341 Port Client name Port name 392
342 20:0 f_midi f_midi 393 $ arecordmidi -l
394 Port Client name Port name
395 20:0 f_midi f_midi
343 396
344$ arecordmidi -p 20:0 from_host.mid 397 $ arecordmidi -p 20:0 from_host.mid
345 398
346host) 399host::
347 400
348$ aplaymidi -l 401 $ aplaymidi -l
349 Port Client name Port name 402 Port Client name Port name
350 14:0 Midi Through Midi Through Port-0 403 14:0 Midi Through Midi Through Port-0
351 24:0 MIDI Gadget MIDI Gadget MIDI 1 404 24:0 MIDI Gadget MIDI Gadget MIDI 1
352 405
353$ aplaymidi -p24:0 to_gadget.mid 406 $ aplaymidi -p24:0 to_gadget.mid
354 407
355The from_gadget.mid should sound identical to the to_host.mid. 408The from_gadget.mid should sound identical to the to_host.mid.
409
356The from_host.id should sound identical to the to_gadget.mid. 410The from_host.id should sound identical to the to_gadget.mid.
357 411
358MIDI files can be played to speakers/headphones with e.g. timidity installed 412MIDI files can be played to speakers/headphones with e.g. timidity installed::
359 413
360$ aplaymidi -l 414 $ aplaymidi -l
361 Port Client name Port name 415 Port Client name Port name
362 14:0 Midi Through Midi Through Port-0 416 14:0 Midi Through Midi Through Port-0
363 24:0 MIDI Gadget MIDI Gadget MIDI 1 417 24:0 MIDI Gadget MIDI Gadget MIDI 1
364128:0 TiMidity TiMidity port 0 418 128:0 TiMidity TiMidity port 0
365128:1 TiMidity TiMidity port 1 419 128:1 TiMidity TiMidity port 1
366128:2 TiMidity TiMidity port 2 420 128:2 TiMidity TiMidity port 2
367128:3 TiMidity TiMidity port 3 421 128:3 TiMidity TiMidity port 3
368 422
369$ aplaymidi -p 128:0 file.mid 423 $ aplaymidi -p 128:0 file.mid
370 424
371MIDI ports can be logically connected using the aconnect utility, e.g.: 425MIDI ports can be logically connected using the aconnect utility, e.g.::
372 426
373$ aconnect 24:0 128:0 # try it on the host 427 $ aconnect 24:0 128:0 # try it on the host
374 428
375After the gadget's MIDI port is connected to timidity's MIDI port, 429After the gadget's MIDI port is connected to timidity's MIDI port,
376whatever is played at the gadget side with aplaymidi -l is audible 430whatever is played at the gadget side with aplaymidi -l is audible
@@ -387,13 +441,15 @@ Function-specific configfs interface
387The function name to use when creating the function directory is "ncm". 441The function name to use when creating the function directory is "ncm".
388The NCM function provides these attributes in its function directory: 442The NCM function provides these attributes in its function directory:
389 443
390 ifname - network device interface name associated with this 444 =============== ==================================================
445 ifname network device interface name associated with this
391 function instance 446 function instance
392 qmult - queue length multiplier for high and super speed 447 qmult queue length multiplier for high and super speed
393 host_addr - MAC address of host's end of this 448 host_addr MAC address of host's end of this
394 Ethernet over USB link 449 Ethernet over USB link
395 dev_addr - MAC address of device's end of this 450 dev_addr MAC address of device's end of this
396 Ethernet over USB link 451 Ethernet over USB link
452 =============== ==================================================
397 453
398and after creating the functions/ncm.<instance name> they contain default 454and after creating the functions/ncm.<instance name> they contain default
399values: qmult is 5, dev_addr and host_addr are randomly selected. 455values: qmult is 5, dev_addr and host_addr are randomly selected.
@@ -406,8 +462,13 @@ Testing the NCM function
406 462
407Configure IP addresses of the device and the host. Then: 463Configure IP addresses of the device and the host. Then:
408 464
409On the device: ping <host's IP> 465On the device::
410On the host: ping <device's IP> 466
467 ping <host's IP>
468
469On the host::
470
471 ping <device's IP>
411 472
41211. OBEX function 47311. OBEX function
413================= 474=================
@@ -429,13 +490,18 @@ There can be at most 4 ACM/generic serial/OBEX ports in the system.
429Testing the OBEX function 490Testing the OBEX function
430------------------------- 491-------------------------
431 492
432On device: seriald -f /dev/ttyGS<Y> -s 1024 493On device::
433On host: serialc -v <vendorID> -p <productID> -i<interface#> -a1 -s1024 \ 494
434 -t<out endpoint addr> -r<in endpoint addr> 495 seriald -f /dev/ttyGS<Y> -s 1024
496
497On host::
498
499 serialc -v <vendorID> -p <productID> -i<interface#> -a1 -s1024 \
500 -t<out endpoint addr> -r<in endpoint addr>
435 501
436where seriald and serialc are Felipe's utilities found here: 502where seriald and serialc are Felipe's utilities found here:
437 503
438https://github.com/felipebalbi/usb-tools.git master 504 https://github.com/felipebalbi/usb-tools.git master
439 505
44012. PHONET function 50612. PHONET function
441=================== 507===================
@@ -448,8 +514,10 @@ Function-specific configfs interface
448The function name to use when creating the function directory is "phonet". 514The function name to use when creating the function directory is "phonet".
449The PHONET function provides just one attribute in its function directory: 515The PHONET function provides just one attribute in its function directory:
450 516
451 ifname - network device interface name associated with this 517 =============== ==================================================
518 ifname network device interface name associated with this
452 function instance 519 function instance
520 =============== ==================================================
453 521
454Testing the PHONET function 522Testing the PHONET function
455--------------------------- 523---------------------------
@@ -464,41 +532,41 @@ These tools are required:
464 532
465git://git.gitorious.org/meego-cellular/phonet-utils.git 533git://git.gitorious.org/meego-cellular/phonet-utils.git
466 534
467On the host: 535On the host::
468 536
469$ ./phonet -a 0x10 -i usbpn0 537 $ ./phonet -a 0x10 -i usbpn0
470$ ./pnroute add 0x6c usbpn0 538 $ ./pnroute add 0x6c usbpn0
471$./pnroute add 0x10 usbpn0 539 $./pnroute add 0x10 usbpn0
472$ ifconfig usbpn0 up 540 $ ifconfig usbpn0 up
473 541
474On the device: 542On the device::
475 543
476$ ./phonet -a 0x6c -i upnlink0 544 $ ./phonet -a 0x6c -i upnlink0
477$ ./pnroute add 0x10 upnlink0 545 $ ./pnroute add 0x10 upnlink0
478$ ifconfig upnlink0 up 546 $ ifconfig upnlink0 up
479 547
480Then a test program can be used: 548Then a test program can be used::
481 549
482http://www.spinics.net/lists/linux-usb/msg85690.html 550 http://www.spinics.net/lists/linux-usb/msg85690.html
483 551
484On the device: 552On the device::
485 553
486$ ./pnxmit -a 0x6c -r 554 $ ./pnxmit -a 0x6c -r
487 555
488On the host: 556On the host::
489 557
490$ ./pnxmit -a 0x10 -s 0x6c 558 $ ./pnxmit -a 0x10 -s 0x6c
491 559
492As a result some data should be sent from host to device. 560As a result some data should be sent from host to device.
493Then the other way round: 561Then the other way round:
494 562
495On the host: 563On the host::
496 564
497$ ./pnxmit -a 0x10 -r 565 $ ./pnxmit -a 0x10 -r
498 566
499On the device: 567On the device::
500 568
501$ ./pnxmit -a 0x6c -s 0x10 569 $ ./pnxmit -a 0x6c -s 0x10
502 570
50313. RNDIS function 57113. RNDIS function
504================== 572==================
@@ -511,13 +579,15 @@ Function-specific configfs interface
511The function name to use when creating the function directory is "rndis". 579The function name to use when creating the function directory is "rndis".
512The RNDIS function provides these attributes in its function directory: 580The RNDIS function provides these attributes in its function directory:
513 581
514 ifname - network device interface name associated with this 582 =============== ==================================================
583 ifname network device interface name associated with this
515 function instance 584 function instance
516 qmult - queue length multiplier for high and super speed 585 qmult queue length multiplier for high and super speed
517 host_addr - MAC address of host's end of this 586 host_addr MAC address of host's end of this
518 Ethernet over USB link 587 Ethernet over USB link
519 dev_addr - MAC address of device's end of this 588 dev_addr MAC address of device's end of this
520 Ethernet over USB link 589 Ethernet over USB link
590 =============== ==================================================
521 591
522and after creating the functions/rndis.<instance name> they contain default 592and after creating the functions/rndis.<instance name> they contain default
523values: qmult is 5, dev_addr and host_addr are randomly selected. 593values: qmult is 5, dev_addr and host_addr are randomly selected.
@@ -530,8 +600,13 @@ Testing the RNDIS function
530 600
531Configure IP addresses of the device and the host. Then: 601Configure IP addresses of the device and the host. Then:
532 602
533On the device: ping <host's IP> 603On the device::
534On the host: ping <device's IP> 604
605 ping <host's IP>
606
607On the host::
608
609 ping <device's IP>
535 610
53614. SERIAL function 61114. SERIAL function
537=================== 612===================
@@ -553,15 +628,28 @@ There can be at most 4 ACM/generic serial/OBEX ports in the system.
553Testing the SERIAL function 628Testing the SERIAL function
554--------------------------- 629---------------------------
555 630
556On host: insmod usbserial 631On host::
557 echo VID PID >/sys/bus/usb-serial/drivers/generic/new_id 632
558On host: cat > /dev/ttyUSB<X> 633 insmod usbserial
559On target: cat /dev/ttyGS<Y> 634 echo VID PID >/sys/bus/usb-serial/drivers/generic/new_id
635
636On host::
637
638 cat > /dev/ttyUSB<X>
639
640On target::
641
642 cat /dev/ttyGS<Y>
560 643
561then the other way round 644then the other way round
562 645
563On target: cat > /dev/ttyGS<Y> 646On target::
564On host: cat /dev/ttyUSB<X> 647
648 cat > /dev/ttyGS<Y>
649
650On host::
651
652 cat /dev/ttyUSB<X>
565 653
56615. SOURCESINK function 65415. SOURCESINK function
567======================= 655=======================
@@ -574,24 +662,27 @@ Function-specific configfs interface
574The function name to use when creating the function directory is "SourceSink". 662The function name to use when creating the function directory is "SourceSink".
575The SOURCESINK function provides these attributes in its function directory: 663The SOURCESINK function provides these attributes in its function directory:
576 664
577 pattern - 0 (all zeros), 1 (mod63), 2 (none) 665 =============== ==================================
578 isoc_interval - 1..16 666 pattern 0 (all zeros), 1 (mod63), 2 (none)
579 isoc_maxpacket - 0 - 1023 (fs), 0 - 1024 (hs/ss) 667 isoc_interval 1..16
580 isoc_mult - 0..2 (hs/ss only) 668 isoc_maxpacket 0 - 1023 (fs), 0 - 1024 (hs/ss)
581 isoc_maxburst - 0..15 (ss only) 669 isoc_mult 0..2 (hs/ss only)
582 bulk_buflen - buffer length 670 isoc_maxburst 0..15 (ss only)
583 bulk_qlen - depth of queue for bulk 671 bulk_buflen buffer length
584 iso_qlen - depth of queue for iso 672 bulk_qlen depth of queue for bulk
673 iso_qlen depth of queue for iso
674 =============== ==================================
585 675
586Testing the SOURCESINK function 676Testing the SOURCESINK function
587------------------------------- 677-------------------------------
588 678
589device: run the gadget 679device: run the gadget
680
590host: test-usb (tools/usb/testusb.c) 681host: test-usb (tools/usb/testusb.c)
591 682
592 683
59316. UAC1 function (legacy implementation) 68416. UAC1 function (legacy implementation)
594================= 685=========================================
595 686
596The function is provided by usb_f_uac1_legacy.ko module. 687The function is provided by usb_f_uac1_legacy.ko module.
597 688
@@ -602,12 +693,14 @@ The function name to use when creating the function directory
602is "uac1_legacy". 693is "uac1_legacy".
603The uac1 function provides these attributes in its function directory: 694The uac1 function provides these attributes in its function directory:
604 695
605 audio_buf_size - audio buffer size 696 =============== ====================================
606 fn_cap - capture pcm device file name 697 audio_buf_size audio buffer size
607 fn_cntl - control device file name 698 fn_cap capture pcm device file name
608 fn_play - playback pcm device file name 699 fn_cntl control device file name
609 req_buf_size - ISO OUT endpoint request buffer size 700 fn_play playback pcm device file name
610 req_count - ISO OUT endpoint request count 701 req_buf_size ISO OUT endpoint request buffer size
702 req_count ISO OUT endpoint request count
703 =============== ====================================
611 704
612The attributes have sane default values. 705The attributes have sane default values.
613 706
@@ -615,7 +708,10 @@ Testing the UAC1 function
615------------------------- 708-------------------------
616 709
617device: run the gadget 710device: run the gadget
618host: aplay -l # should list our USB Audio Gadget 711
712host::
713
714 aplay -l # should list our USB Audio Gadget
619 715
62017. UAC2 function 71617. UAC2 function
621================= 717=================
@@ -628,14 +724,16 @@ Function-specific configfs interface
628The function name to use when creating the function directory is "uac2". 724The function name to use when creating the function directory is "uac2".
629The uac2 function provides these attributes in its function directory: 725The uac2 function provides these attributes in its function directory:
630 726
631 c_chmask - capture channel mask 727 =============== ====================================================
632 c_srate - capture sampling rate 728 c_chmask capture channel mask
633 c_ssize - capture sample size (bytes) 729 c_srate capture sampling rate
634 p_chmask - playback channel mask 730 c_ssize capture sample size (bytes)
635 p_srate - playback sampling rate 731 p_chmask playback channel mask
636 p_ssize - playback sample size (bytes) 732 p_srate playback sampling rate
637 req_number - the number of pre-allocated request for both capture 733 p_ssize playback sample size (bytes)
638 and playback 734 req_number the number of pre-allocated request for both capture
735 and playback
736 =============== ====================================================
639 737
640The attributes have sane default values. 738The attributes have sane default values.
641 739
@@ -648,14 +746,14 @@ host: aplay -l # should list our USB Audio Gadget
648This function does not require real hardware support, it just 746This function does not require real hardware support, it just
649sends a stream of audio data to/from the host. In order to 747sends a stream of audio data to/from the host. In order to
650actually hear something at the device side, a command similar 748actually hear something at the device side, a command similar
651to this must be used at the device side: 749to this must be used at the device side::
652 750
653$ arecord -f dat -t wav -D hw:2,0 | aplay -D hw:0,0 & 751 $ arecord -f dat -t wav -D hw:2,0 | aplay -D hw:0,0 &
654 752
655e.g.: 753e.g.::
656 754
657$ arecord -f dat -t wav -D hw:CARD=UAC2Gadget,DEV=0 | \ 755 $ arecord -f dat -t wav -D hw:CARD=UAC2Gadget,DEV=0 | \
658aplay -D default:CARD=OdroidU3 756 aplay -D default:CARD=OdroidU3
659 757
66018. UVC function 75818. UVC function
661================ 759================
@@ -668,66 +766,73 @@ Function-specific configfs interface
668The function name to use when creating the function directory is "uvc". 766The function name to use when creating the function directory is "uvc".
669The uvc function provides these attributes in its function directory: 767The uvc function provides these attributes in its function directory:
670 768
671 streaming_interval - interval for polling endpoint for data transfers 769 =================== ================================================
672 streaming_maxburst - bMaxBurst for super speed companion descriptor 770 streaming_interval interval for polling endpoint for data transfers
673 streaming_maxpacket - maximum packet size this endpoint is capable of 771 streaming_maxburst bMaxBurst for super speed companion descriptor
674 sending or receiving when this configuration is 772 streaming_maxpacket maximum packet size this endpoint is capable of
675 selected 773 sending or receiving when this configuration is
774 selected
775 =================== ================================================
676 776
677There are also "control" and "streaming" subdirectories, each of which contain 777There are also "control" and "streaming" subdirectories, each of which contain
678a number of their subdirectories. There are some sane defaults provided, but 778a number of their subdirectories. There are some sane defaults provided, but
679the user must provide the following: 779the user must provide the following:
680 780
681 control header - create in control/header, link from control/class/fs 781 ================== ====================================================
682 and/or control/class/ss 782 control header create in control/header, link from control/class/fs
683 streaming header - create in streaming/header, link from 783 and/or control/class/ss
684 streaming/class/fs and/or streaming/class/hs and/or 784 streaming header create in streaming/header, link from
685 streaming/class/ss 785 streaming/class/fs and/or streaming/class/hs and/or
686 format description - create in streaming/mjpeg and/or 786 streaming/class/ss
687 streaming/uncompressed 787 format description create in streaming/mjpeg and/or
688 frame description - create in streaming/mjpeg/<format> and/or in 788 streaming/uncompressed
689 streaming/uncompressed/<format> 789 frame description create in streaming/mjpeg/<format> and/or in
790 streaming/uncompressed/<format>
791 ================== ====================================================
690 792
691Each frame description contains frame interval specification, and each 793Each frame description contains frame interval specification, and each
692such specification consists of a number of lines with an inverval value 794such specification consists of a number of lines with an inverval value
693in each line. The rules stated above are best illustrated with an example: 795in each line. The rules stated above are best illustrated with an example::
694 796
695# mkdir functions/uvc.usb0/control/header/h 797 # mkdir functions/uvc.usb0/control/header/h
696# cd functions/uvc.usb0/control/ 798 # cd functions/uvc.usb0/control/
697# ln -s header/h class/fs 799 # ln -s header/h class/fs
698# ln -s header/h class/ss 800 # ln -s header/h class/ss
699# mkdir -p functions/uvc.usb0/streaming/uncompressed/u/360p 801 # mkdir -p functions/uvc.usb0/streaming/uncompressed/u/360p
700# cat <<EOF > functions/uvc.usb0/streaming/uncompressed/u/360p/dwFrameInterval 802 # cat <<EOF > functions/uvc.usb0/streaming/uncompressed/u/360p/dwFrameInterval
701666666 803 666666
7021000000 804 1000000
7035000000 805 5000000
704EOF 806 EOF
705# cd $GADGET_CONFIGFS_ROOT 807 # cd $GADGET_CONFIGFS_ROOT
706# mkdir functions/uvc.usb0/streaming/header/h 808 # mkdir functions/uvc.usb0/streaming/header/h
707# cd functions/uvc.usb0/streaming/header/h 809 # cd functions/uvc.usb0/streaming/header/h
708# ln -s ../../uncompressed/u 810 # ln -s ../../uncompressed/u
709# cd ../../class/fs 811 # cd ../../class/fs
710# ln -s ../../header/h 812 # ln -s ../../header/h
711# cd ../../class/hs 813 # cd ../../class/hs
712# ln -s ../../header/h 814 # ln -s ../../header/h
713# cd ../../class/ss 815 # cd ../../class/ss
714# ln -s ../../header/h 816 # ln -s ../../header/h
715 817
716 818
717Testing the UVC function 819Testing the UVC function
718------------------------ 820------------------------
719 821
720device: run the gadget, modprobe vivid 822device: run the gadget, modprobe vivid::
721 823
722# uvc-gadget -u /dev/video<uvc video node #> -v /dev/video<vivid video node #> 824 # uvc-gadget -u /dev/video<uvc video node #> -v /dev/video<vivid video node #>
723 825
724where uvc-gadget is this program: 826where uvc-gadget is this program:
725http://git.ideasonboard.org/uvc-gadget.git 827 http://git.ideasonboard.org/uvc-gadget.git
726 828
727with these patches: 829with these patches:
728http://www.spinics.net/lists/linux-usb/msg99220.html
729 830
730host: luvcview -f yuv 831 http://www.spinics.net/lists/linux-usb/msg99220.html
832
833host::
834
835 luvcview -f yuv
731 836
73219. PRINTER function 83719. PRINTER function
733==================== 838====================
@@ -740,16 +845,19 @@ Function-specific configfs interface
740The function name to use when creating the function directory is "printer". 845The function name to use when creating the function directory is "printer".
741The printer function provides these attributes in its function directory: 846The printer function provides these attributes in its function directory:
742 847
743 pnp_string - Data to be passed to the host in pnp string 848 ========== ===========================================
744 q_len - Number of requests per endpoint 849 pnp_string Data to be passed to the host in pnp string
850 q_len Number of requests per endpoint
851 ========== ===========================================
745 852
746Testing the PRINTER function 853Testing the PRINTER function
747---------------------------- 854----------------------------
748 855
749The most basic testing: 856The most basic testing:
750 857
751device: run the gadget 858device: run the gadget::
752# ls -l /devices/virtual/usb_printer_gadget/ 859
860 # ls -l /devices/virtual/usb_printer_gadget/
753 861
754should show g_printer<number>. 862should show g_printer<number>.
755 863
@@ -761,23 +869,28 @@ If udev is active, then e.g. /dev/usb/lp0 should appear.
761 869
762host->device transmission: 870host->device transmission:
763 871
764device: 872device::
765# cat /dev/g_printer<number>
766host:
767# cat > /dev/usb/lp0
768 873
769device->host transmission: 874 # cat /dev/g_printer<number>
770 875
771# cat > /dev/g_printer<number> 876host::
772host: 877
773# cat /dev/usb/lp0 878 # cat > /dev/usb/lp0
879
880device->host transmission::
881
882 # cat > /dev/g_printer<number>
883
884host::
885
886 # cat /dev/usb/lp0
774 887
775More advanced testing can be done with the prn_example 888More advanced testing can be done with the prn_example
776described in Documentation/usb/gadget_printer.txt. 889described in Documentation/usb/gadget_printer.txt.
777 890
778 891
77920. UAC1 function (virtual ALSA card, using u_audio API) 89220. UAC1 function (virtual ALSA card, using u_audio API)
780================= 893========================================================
781 894
782The function is provided by usb_f_uac1.ko module. 895The function is provided by usb_f_uac1.ko module.
783It will create a virtual ALSA card and the audio streams are simply 896It will create a virtual ALSA card and the audio streams are simply
@@ -789,14 +902,16 @@ Function-specific configfs interface
789The function name to use when creating the function directory is "uac1". 902The function name to use when creating the function directory is "uac1".
790The uac1 function provides these attributes in its function directory: 903The uac1 function provides these attributes in its function directory:
791 904
792 c_chmask - capture channel mask 905 ========== ====================================================
793 c_srate - capture sampling rate 906 c_chmask capture channel mask
794 c_ssize - capture sample size (bytes) 907 c_srate capture sampling rate
795 p_chmask - playback channel mask 908 c_ssize capture sample size (bytes)
796 p_srate - playback sampling rate 909 p_chmask playback channel mask
797 p_ssize - playback sample size (bytes) 910 p_srate playback sampling rate
798 req_number - the number of pre-allocated request for both capture 911 p_ssize playback sample size (bytes)
799 and playback 912 req_number the number of pre-allocated request for both capture
913 and playback
914 ========== ====================================================
800 915
801The attributes have sane default values. 916The attributes have sane default values.
802 917
@@ -809,11 +924,11 @@ host: aplay -l # should list our USB Audio Gadget
809This function does not require real hardware support, it just 924This function does not require real hardware support, it just
810sends a stream of audio data to/from the host. In order to 925sends a stream of audio data to/from the host. In order to
811actually hear something at the device side, a command similar 926actually hear something at the device side, a command similar
812to this must be used at the device side: 927to this must be used at the device side::
813 928
814$ arecord -f dat -t wav -D hw:2,0 | aplay -D hw:0,0 & 929 $ arecord -f dat -t wav -D hw:2,0 | aplay -D hw:0,0 &
815 930
816e.g.: 931e.g.::
817 932
818$ arecord -f dat -t wav -D hw:CARD=UAC1Gadget,DEV=0 | \ 933 $ arecord -f dat -t wav -D hw:CARD=UAC1Gadget,DEV=0 | \
819aplay -D default:CARD=OdroidU3 934 aplay -D default:CARD=OdroidU3