Andrzej Pietrasiewicz | e38eb2c | 2014-12-16 14:56:25 +0100 | [diff] [blame] | 1 | This file summarizes information on basic testing of USB functions |
| 2 | provided by gadgets. |
| 3 | |
| 4 | 1. ACM function |
Andrzej Pietrasiewicz | d5862ca | 2014-12-16 14:56:26 +0100 | [diff] [blame] | 5 | 2. ECM function |
Andrzej Pietrasiewicz | 7bfbc6e | 2014-12-16 14:56:27 +0100 | [diff] [blame] | 6 | 3. ECM subset function |
Andrzej Pietrasiewicz | 4ca560a | 2014-12-16 14:56:28 +0100 | [diff] [blame] | 7 | 4. EEM function |
Andrzej Pietrasiewicz | 2c0f62f | 2014-12-16 14:56:29 +0100 | [diff] [blame] | 8 | 5. FFS function |
Andrzej Pietrasiewicz | f7e3c3c | 2014-12-16 14:56:30 +0100 | [diff] [blame] | 9 | 6. HID function |
Andrzej Pietrasiewicz | ec91aff | 2014-12-16 14:56:31 +0100 | [diff] [blame] | 10 | 7. LOOPBACK function |
Andrzej Pietrasiewicz | cdbe287 | 2014-12-16 14:56:32 +0100 | [diff] [blame] | 11 | 8. MASS STORAGE function |
Andrzej Pietrasiewicz | 0d6be59 | 2014-12-16 14:56:33 +0100 | [diff] [blame] | 12 | 9. MIDI function |
Andrzej Pietrasiewicz | 4d0fa79 | 2014-12-16 14:56:34 +0100 | [diff] [blame] | 13 | 10. NCM function |
Andrzej Pietrasiewicz | d81b85d | 2014-12-16 14:56:35 +0100 | [diff] [blame] | 14 | 11. OBEX function |
Andrzej Pietrasiewicz | da2907d | 2014-12-16 14:56:36 +0100 | [diff] [blame] | 15 | 12. PHONET function |
Andrzej Pietrasiewicz | ddb7224 | 2014-12-16 14:56:37 +0100 | [diff] [blame] | 16 | 13. RNDIS function |
Andrzej Pietrasiewicz | 4dfcec8 | 2014-12-16 14:56:38 +0100 | [diff] [blame] | 17 | 14. SERIAL function |
Andrzej Pietrasiewicz | 480a912 | 2014-12-16 14:56:39 +0100 | [diff] [blame] | 18 | 15. SOURCESINK function |
Ruslan Bilovol | d355339 | 2017-06-18 16:23:53 +0300 | [diff] [blame] | 19 | 16. UAC1 function (legacy implementation) |
Andrzej Pietrasiewicz | 020c6f9 | 2014-12-16 14:56:41 +0100 | [diff] [blame] | 20 | 17. UAC2 function |
Andrzej Pietrasiewicz | 9c4f538 | 2014-12-16 14:56:42 +0100 | [diff] [blame] | 21 | 18. UVC function |
Andrzej Pietrasiewicz | ee1cd51 | 2015-03-03 10:52:32 +0100 | [diff] [blame] | 22 | 19. PRINTER function |
Ruslan Bilovol | 0591bc2 | 2017-06-18 16:23:54 +0300 | [diff] [blame] | 23 | 20. UAC1 function (new API) |
Andrzej Pietrasiewicz | e38eb2c | 2014-12-16 14:56:25 +0100 | [diff] [blame] | 24 | |
| 25 | |
| 26 | 1. ACM function |
| 27 | =============== |
| 28 | |
| 29 | The function is provided by usb_f_acm.ko module. |
| 30 | |
| 31 | Function-specific configfs interface |
| 32 | ------------------------------------ |
| 33 | |
| 34 | The function name to use when creating the function directory is "acm". |
| 35 | The ACM function provides just one attribute in its function directory: |
| 36 | |
| 37 | port_num |
| 38 | |
| 39 | The attribute is read-only. |
| 40 | |
| 41 | There can be at most 4 ACM/generic serial/OBEX ports in the system. |
| 42 | |
| 43 | |
| 44 | Testing the ACM function |
| 45 | ------------------------ |
| 46 | |
| 47 | On the host: cat > /dev/ttyACM<X> |
| 48 | On the device : cat /dev/ttyGS<Y> |
| 49 | |
| 50 | then the other way round |
| 51 | |
| 52 | On the device: cat > /dev/ttyGS<Y> |
| 53 | On the host: cat /dev/ttyACM<X> |
Andrzej Pietrasiewicz | d5862ca | 2014-12-16 14:56:26 +0100 | [diff] [blame] | 54 | |
| 55 | 2. ECM function |
| 56 | =============== |
| 57 | |
| 58 | The function is provided by usb_f_ecm.ko module. |
| 59 | |
| 60 | Function-specific configfs interface |
| 61 | ------------------------------------ |
| 62 | |
| 63 | The function name to use when creating the function directory is "ecm". |
| 64 | The ECM function provides these attributes in its function directory: |
| 65 | |
| 66 | ifname - network device interface name associated with this |
| 67 | function instance |
| 68 | qmult - queue length multiplier for high and super speed |
| 69 | host_addr - MAC address of host's end of this |
| 70 | Ethernet over USB link |
| 71 | dev_addr - MAC address of device's end of this |
| 72 | Ethernet over USB link |
| 73 | |
| 74 | and after creating the functions/ecm.<instance name> they contain default |
| 75 | values: qmult is 5, dev_addr and host_addr are randomly selected. |
| 76 | Except for ifname they can be written to until the function is linked to a |
| 77 | configuration. The ifname is read-only and contains the name of the interface |
| 78 | which was assigned by the net core, e. g. usb0. |
| 79 | |
| 80 | Testing the ECM function |
| 81 | ------------------------ |
| 82 | |
| 83 | Configure IP addresses of the device and the host. Then: |
| 84 | |
| 85 | On the device: ping <host's IP> |
| 86 | On the host: ping <device's IP> |
Andrzej Pietrasiewicz | 7bfbc6e | 2014-12-16 14:56:27 +0100 | [diff] [blame] | 87 | |
| 88 | 3. ECM subset function |
| 89 | ====================== |
| 90 | |
| 91 | The function is provided by usb_f_ecm_subset.ko module. |
| 92 | |
| 93 | Function-specific configfs interface |
| 94 | ------------------------------------ |
| 95 | |
| 96 | The function name to use when creating the function directory is "geth". |
| 97 | The ECM subset function provides these attributes in its function directory: |
| 98 | |
| 99 | ifname - network device interface name associated with this |
| 100 | function instance |
| 101 | qmult - queue length multiplier for high and super speed |
| 102 | host_addr - MAC address of host's end of this |
| 103 | Ethernet over USB link |
| 104 | dev_addr - MAC address of device's end of this |
| 105 | Ethernet over USB link |
| 106 | |
| 107 | and after creating the functions/ecm.<instance name> they contain default |
| 108 | values: qmult is 5, dev_addr and host_addr are randomly selected. |
| 109 | Except for ifname they can be written to until the function is linked to a |
| 110 | configuration. The ifname is read-only and contains the name of the interface |
| 111 | which was assigned by the net core, e. g. usb0. |
| 112 | |
| 113 | Testing the ECM subset function |
| 114 | ------------------------------- |
| 115 | |
| 116 | Configure IP addresses of the device and the host. Then: |
| 117 | |
| 118 | On the device: ping <host's IP> |
| 119 | On the host: ping <device's IP> |
Andrzej Pietrasiewicz | 4ca560a | 2014-12-16 14:56:28 +0100 | [diff] [blame] | 120 | |
| 121 | 4. EEM function |
| 122 | =============== |
| 123 | |
| 124 | The function is provided by usb_f_eem.ko module. |
| 125 | |
| 126 | Function-specific configfs interface |
| 127 | ------------------------------------ |
| 128 | |
| 129 | The function name to use when creating the function directory is "eem". |
| 130 | The EEM function provides these attributes in its function directory: |
| 131 | |
| 132 | ifname - network device interface name associated with this |
| 133 | function instance |
| 134 | qmult - queue length multiplier for high and super speed |
| 135 | host_addr - MAC address of host's end of this |
| 136 | Ethernet over USB link |
| 137 | dev_addr - MAC address of device's end of this |
| 138 | Ethernet over USB link |
| 139 | |
| 140 | and after creating the functions/eem.<instance name> they contain default |
| 141 | values: qmult is 5, dev_addr and host_addr are randomly selected. |
| 142 | Except for ifname they can be written to until the function is linked to a |
| 143 | configuration. The ifname is read-only and contains the name of the interface |
| 144 | which was assigned by the net core, e. g. usb0. |
| 145 | |
| 146 | Testing the EEM function |
| 147 | ------------------------ |
| 148 | |
| 149 | Configure IP addresses of the device and the host. Then: |
| 150 | |
| 151 | On the device: ping <host's IP> |
| 152 | On the host: ping <device's IP> |
Andrzej Pietrasiewicz | 2c0f62f | 2014-12-16 14:56:29 +0100 | [diff] [blame] | 153 | |
| 154 | 5. FFS function |
| 155 | =============== |
| 156 | |
| 157 | The function is provided by usb_f_fs.ko module. |
| 158 | |
| 159 | Function-specific configfs interface |
| 160 | ------------------------------------ |
| 161 | |
| 162 | The function name to use when creating the function directory is "ffs". |
| 163 | The function directory is intentionally empty and not modifiable. |
| 164 | |
| 165 | After creating the directory there is a new instance (a "device") of FunctionFS |
| 166 | available in the system. Once a "device" is available, the user should follow |
| 167 | the standard procedure for using FunctionFS (mount it, run the userspace |
| 168 | process which implements the function proper). The gadget should be enabled |
| 169 | by writing a suitable string to usb_gadget/<gadget>/UDC. |
| 170 | |
| 171 | Testing the FFS function |
| 172 | ------------------------ |
| 173 | |
| 174 | On the device: start the function's userspace daemon, enable the gadget |
| 175 | On the host: use the USB function provided by the device |
Andrzej Pietrasiewicz | f7e3c3c | 2014-12-16 14:56:30 +0100 | [diff] [blame] | 176 | |
| 177 | 6. HID function |
| 178 | =============== |
| 179 | |
| 180 | The function is provided by usb_f_hid.ko module. |
| 181 | |
| 182 | Function-specific configfs interface |
| 183 | ------------------------------------ |
| 184 | |
| 185 | The function name to use when creating the function directory is "hid". |
| 186 | The HID function provides these attributes in its function directory: |
| 187 | |
| 188 | protocol - HID protocol to use |
| 189 | report_desc - data to be used in HID reports, except data |
| 190 | passed with /dev/hidg<X> |
| 191 | report_length - HID report length |
| 192 | subclass - HID subclass to use |
| 193 | |
| 194 | For a keyboard the protocol and the subclass are 1, the report_length is 8, |
| 195 | while the report_desc is: |
| 196 | |
| 197 | $ hd my_report_desc |
| 198 | 00000000 05 01 09 06 a1 01 05 07 19 e0 29 e7 15 00 25 01 |..........)...%.| |
| 199 | 00000010 75 01 95 08 81 02 95 01 75 08 81 03 95 05 75 01 |u.......u.....u.| |
| 200 | 00000020 05 08 19 01 29 05 91 02 95 01 75 03 91 03 95 06 |....).....u.....| |
| 201 | 00000030 75 08 15 00 25 65 05 07 19 00 29 65 81 00 c0 |u...%e....)e...| |
| 202 | 0000003f |
| 203 | |
| 204 | Such a sequence of bytes can be stored to the attribute with echo: |
| 205 | |
| 206 | $ echo -ne \\x05\\x01\\x09\\x06\\xa1..... |
| 207 | |
| 208 | Testing the HID function |
| 209 | ------------------------ |
| 210 | |
| 211 | Device: |
| 212 | - create the gadget |
| 213 | - connect the gadget to a host, preferably not the one used |
| 214 | to control the gadget |
| 215 | - run a program which writes to /dev/hidg<N>, e.g. |
| 216 | a userspace program found in Documentation/usb/gadget_hid.txt: |
| 217 | |
| 218 | $ ./hid_gadget_test /dev/hidg0 keyboard |
| 219 | |
| 220 | Host: |
| 221 | - observe the keystrokes from the gadget |
Andrzej Pietrasiewicz | ec91aff | 2014-12-16 14:56:31 +0100 | [diff] [blame] | 222 | |
| 223 | 7. LOOPBACK function |
| 224 | ==================== |
| 225 | |
| 226 | The function is provided by usb_f_ss_lb.ko module. |
| 227 | |
| 228 | Function-specific configfs interface |
| 229 | ------------------------------------ |
| 230 | |
| 231 | The function name to use when creating the function directory is "Loopback". |
| 232 | The LOOPBACK function provides these attributes in its function directory: |
| 233 | |
| 234 | qlen - depth of loopback queue |
| 235 | bulk_buflen - buffer length |
| 236 | |
| 237 | Testing the LOOPBACK function |
| 238 | ----------------------------- |
| 239 | |
| 240 | device: run the gadget |
Peter Chen | f811a38 | 2015-07-31 16:36:30 +0800 | [diff] [blame] | 241 | host: test-usb (tools/usb/testusb.c) |
Andrzej Pietrasiewicz | cdbe287 | 2014-12-16 14:56:32 +0100 | [diff] [blame] | 242 | |
| 243 | 8. MASS STORAGE function |
| 244 | ======================== |
| 245 | |
| 246 | The function is provided by usb_f_mass_storage.ko module. |
| 247 | |
| 248 | Function-specific configfs interface |
| 249 | ------------------------------------ |
| 250 | |
| 251 | The function name to use when creating the function directory is "mass_storage". |
| 252 | The MASS STORAGE function provides these attributes in its directory: |
| 253 | files: |
| 254 | |
| 255 | stall - Set to permit function to halt bulk endpoints. |
| 256 | Disabled on some USB devices known not to work |
| 257 | correctly. You should set it to true. |
| 258 | num_buffers - Number of pipeline buffers. Valid numbers |
| 259 | are 2..4. Available only if |
| 260 | CONFIG_USB_GADGET_DEBUG_FILES is set. |
| 261 | |
| 262 | and a default lun.0 directory corresponding to SCSI LUN #0. |
| 263 | |
| 264 | A new lun can be added with mkdir: |
| 265 | |
| 266 | $ mkdir functions/mass_storage.0/partition.5 |
| 267 | |
| 268 | Lun numbering does not have to be continuous, except for lun #0 which is |
| 269 | created by default. A maximum of 8 luns can be specified and they all must be |
| 270 | named following the <name>.<number> scheme. The numbers can be 0..8. |
| 271 | Probably a good convention is to name the luns "lun.<number>", |
| 272 | although it is not mandatory. |
| 273 | |
| 274 | In each lun directory there are the following attribute files: |
| 275 | |
| 276 | file - The path to the backing file for the LUN. |
| 277 | Required if LUN is not marked as removable. |
| 278 | ro - Flag specifying access to the LUN shall be |
| 279 | read-only. This is implied if CD-ROM emulation |
| 280 | is enabled as well as when it was impossible |
| 281 | to open "filename" in R/W mode. |
| 282 | removable - Flag specifying that LUN shall be indicated as |
| 283 | being removable. |
| 284 | cdrom - Flag specifying that LUN shall be reported as |
| 285 | being a CD-ROM. |
| 286 | nofua - Flag specifying that FUA flag |
| 287 | in SCSI WRITE(10,12) |
| 288 | |
| 289 | Testing the MASS STORAGE function |
| 290 | --------------------------------- |
| 291 | |
| 292 | device: connect the gadget, enable it |
| 293 | host: dmesg, see the USB drives appear (if system configured to automatically |
| 294 | mount) |
Andrzej Pietrasiewicz | 0d6be59 | 2014-12-16 14:56:33 +0100 | [diff] [blame] | 295 | |
| 296 | 9. MIDI function |
| 297 | ================ |
| 298 | |
| 299 | The function is provided by usb_f_midi.ko module. |
| 300 | |
| 301 | Function-specific configfs interface |
| 302 | ------------------------------------ |
| 303 | |
| 304 | The function name to use when creating the function directory is "midi". |
| 305 | The MIDI function provides these attributes in its function directory: |
| 306 | |
| 307 | buflen - MIDI buffer length |
| 308 | id - ID string for the USB MIDI adapter |
| 309 | in_ports - number of MIDI input ports |
| 310 | index - index value for the USB MIDI adapter |
| 311 | out_ports - number of MIDI output ports |
| 312 | qlen - USB read request queue length |
| 313 | |
| 314 | Testing the MIDI function |
| 315 | ------------------------- |
| 316 | |
| 317 | There are two cases: playing a mid from the gadget to |
| 318 | the host and playing a mid from the host to the gadget. |
| 319 | |
| 320 | 1) Playing a mid from the gadget to the host |
| 321 | host) |
| 322 | |
| 323 | $ arecordmidi -l |
| 324 | Port Client name Port name |
| 325 | 14:0 Midi Through Midi Through Port-0 |
| 326 | 24:0 MIDI Gadget MIDI Gadget MIDI 1 |
| 327 | $ arecordmidi -p 24:0 from_gadget.mid |
| 328 | |
| 329 | gadget) |
| 330 | |
| 331 | $ aplaymidi -l |
| 332 | Port Client name Port name |
| 333 | 20:0 f_midi f_midi |
| 334 | |
| 335 | $ aplaymidi -p 20:0 to_host.mid |
| 336 | |
| 337 | 2) Playing a mid from the host to the gadget |
| 338 | gadget) |
| 339 | |
| 340 | $ arecordmidi -l |
| 341 | Port Client name Port name |
| 342 | 20:0 f_midi f_midi |
| 343 | |
| 344 | $ arecordmidi -p 20:0 from_host.mid |
| 345 | |
| 346 | host) |
| 347 | |
| 348 | $ aplaymidi -l |
| 349 | Port Client name Port name |
| 350 | 14:0 Midi Through Midi Through Port-0 |
| 351 | 24:0 MIDI Gadget MIDI Gadget MIDI 1 |
| 352 | |
| 353 | $ aplaymidi -p24:0 to_gadget.mid |
| 354 | |
| 355 | The from_gadget.mid should sound identical to the to_host.mid. |
| 356 | The from_host.id should sound identical to the to_gadget.mid. |
| 357 | |
| 358 | MIDI files can be played to speakers/headphones with e.g. timidity installed |
| 359 | |
| 360 | $ aplaymidi -l |
| 361 | Port Client name Port name |
| 362 | 14:0 Midi Through Midi Through Port-0 |
| 363 | 24:0 MIDI Gadget MIDI Gadget MIDI 1 |
| 364 | 128:0 TiMidity TiMidity port 0 |
| 365 | 128:1 TiMidity TiMidity port 1 |
| 366 | 128:2 TiMidity TiMidity port 2 |
| 367 | 128:3 TiMidity TiMidity port 3 |
| 368 | |
| 369 | $ aplaymidi -p 128:0 file.mid |
| 370 | |
| 371 | MIDI ports can be logically connected using the aconnect utility, e.g.: |
| 372 | |
| 373 | $ aconnect 24:0 128:0 # try it on the host |
| 374 | |
| 375 | After the gadget's MIDI port is connected to timidity's MIDI port, |
| 376 | whatever is played at the gadget side with aplaymidi -l is audible |
| 377 | in host's speakers/headphones. |
Andrzej Pietrasiewicz | 4d0fa79 | 2014-12-16 14:56:34 +0100 | [diff] [blame] | 378 | |
| 379 | 10. NCM function |
| 380 | ================ |
| 381 | |
| 382 | The function is provided by usb_f_ncm.ko module. |
| 383 | |
| 384 | Function-specific configfs interface |
| 385 | ------------------------------------ |
| 386 | |
| 387 | The function name to use when creating the function directory is "ncm". |
| 388 | The NCM function provides these attributes in its function directory: |
| 389 | |
| 390 | ifname - network device interface name associated with this |
| 391 | function instance |
| 392 | qmult - queue length multiplier for high and super speed |
| 393 | host_addr - MAC address of host's end of this |
| 394 | Ethernet over USB link |
| 395 | dev_addr - MAC address of device's end of this |
| 396 | Ethernet over USB link |
| 397 | |
| 398 | and after creating the functions/ncm.<instance name> they contain default |
| 399 | values: qmult is 5, dev_addr and host_addr are randomly selected. |
| 400 | Except for ifname they can be written to until the function is linked to a |
| 401 | configuration. The ifname is read-only and contains the name of the interface |
| 402 | which was assigned by the net core, e. g. usb0. |
| 403 | |
| 404 | Testing the NCM function |
| 405 | ------------------------ |
| 406 | |
| 407 | Configure IP addresses of the device and the host. Then: |
| 408 | |
| 409 | On the device: ping <host's IP> |
| 410 | On the host: ping <device's IP> |
Andrzej Pietrasiewicz | d81b85d | 2014-12-16 14:56:35 +0100 | [diff] [blame] | 411 | |
| 412 | 11. OBEX function |
| 413 | ================= |
| 414 | |
| 415 | The function is provided by usb_f_obex.ko module. |
| 416 | |
| 417 | Function-specific configfs interface |
| 418 | ------------------------------------ |
| 419 | |
| 420 | The function name to use when creating the function directory is "obex". |
| 421 | The OBEX function provides just one attribute in its function directory: |
| 422 | |
| 423 | port_num |
| 424 | |
| 425 | The attribute is read-only. |
| 426 | |
| 427 | There can be at most 4 ACM/generic serial/OBEX ports in the system. |
| 428 | |
| 429 | Testing the OBEX function |
| 430 | ------------------------- |
| 431 | |
| 432 | On device: seriald -f /dev/ttyGS<Y> -s 1024 |
| 433 | On host: serialc -v <vendorID> -p <productID> -i<interface#> -a1 -s1024 \ |
| 434 | -t<out endpoint addr> -r<in endpoint addr> |
| 435 | |
| 436 | where seriald and serialc are Felipe's utilities found here: |
| 437 | |
Robert Baldyga | f310abb | 2015-12-11 12:24:40 +0100 | [diff] [blame] | 438 | https://github.com/felipebalbi/usb-tools.git master |
Andrzej Pietrasiewicz | da2907d | 2014-12-16 14:56:36 +0100 | [diff] [blame] | 439 | |
| 440 | 12. PHONET function |
| 441 | =================== |
| 442 | |
| 443 | The function is provided by usb_f_phonet.ko module. |
| 444 | |
| 445 | Function-specific configfs interface |
| 446 | ------------------------------------ |
| 447 | |
| 448 | The function name to use when creating the function directory is "phonet". |
| 449 | The PHONET function provides just one attribute in its function directory: |
| 450 | |
| 451 | ifname - network device interface name associated with this |
| 452 | function instance |
| 453 | |
| 454 | Testing the PHONET function |
| 455 | --------------------------- |
| 456 | |
| 457 | It is not possible to test the SOCK_STREAM protocol without a specific piece |
| 458 | of hardware, so only SOCK_DGRAM has been tested. For the latter to work, |
| 459 | in the past I had to apply the patch mentioned here: |
| 460 | |
| 461 | http://www.spinics.net/lists/linux-usb/msg85689.html |
| 462 | |
| 463 | These tools are required: |
| 464 | |
| 465 | git://git.gitorious.org/meego-cellular/phonet-utils.git |
| 466 | |
| 467 | On the host: |
| 468 | |
| 469 | $ ./phonet -a 0x10 -i usbpn0 |
| 470 | $ ./pnroute add 0x6c usbpn0 |
| 471 | $./pnroute add 0x10 usbpn0 |
| 472 | $ ifconfig usbpn0 up |
| 473 | |
| 474 | On the device: |
| 475 | |
| 476 | $ ./phonet -a 0x6c -i upnlink0 |
| 477 | $ ./pnroute add 0x10 upnlink0 |
| 478 | $ ifconfig upnlink0 up |
| 479 | |
| 480 | Then a test program can be used: |
| 481 | |
| 482 | http://www.spinics.net/lists/linux-usb/msg85690.html |
| 483 | |
| 484 | On the device: |
| 485 | |
| 486 | $ ./pnxmit -a 0x6c -r |
| 487 | |
| 488 | On the host: |
| 489 | |
| 490 | $ ./pnxmit -a 0x10 -s 0x6c |
| 491 | |
| 492 | As a result some data should be sent from host to device. |
| 493 | Then the other way round: |
| 494 | |
| 495 | On the host: |
| 496 | |
| 497 | $ ./pnxmit -a 0x10 -r |
| 498 | |
| 499 | On the device: |
| 500 | |
| 501 | $ ./pnxmit -a 0x6c -s 0x10 |
Andrzej Pietrasiewicz | ddb7224 | 2014-12-16 14:56:37 +0100 | [diff] [blame] | 502 | |
| 503 | 13. RNDIS function |
| 504 | ================== |
| 505 | |
| 506 | The function is provided by usb_f_rndis.ko module. |
| 507 | |
| 508 | Function-specific configfs interface |
| 509 | ------------------------------------ |
| 510 | |
| 511 | The function name to use when creating the function directory is "rndis". |
| 512 | The RNDIS function provides these attributes in its function directory: |
| 513 | |
| 514 | ifname - network device interface name associated with this |
| 515 | function instance |
| 516 | qmult - queue length multiplier for high and super speed |
| 517 | host_addr - MAC address of host's end of this |
| 518 | Ethernet over USB link |
| 519 | dev_addr - MAC address of device's end of this |
| 520 | Ethernet over USB link |
| 521 | |
| 522 | and after creating the functions/rndis.<instance name> they contain default |
| 523 | values: qmult is 5, dev_addr and host_addr are randomly selected. |
| 524 | Except for ifname they can be written to until the function is linked to a |
| 525 | configuration. The ifname is read-only and contains the name of the interface |
| 526 | which was assigned by the net core, e. g. usb0. |
| 527 | |
Andrzej Pietrasiewicz | ddb7224 | 2014-12-16 14:56:37 +0100 | [diff] [blame] | 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> |
Andrzej Pietrasiewicz | 4dfcec8 | 2014-12-16 14:56:38 +0100 | [diff] [blame] | 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> |
Andrzej Pietrasiewicz | 480a912 | 2014-12-16 14:56:39 +0100 | [diff] [blame] | 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 |
Peter Chen | df00189 | 2015-11-19 15:02:17 +0800 | [diff] [blame] | 583 | bulk_qlen - depth of queue for bulk |
| 584 | iso_qlen - depth of queue for iso |
Andrzej Pietrasiewicz | 480a912 | 2014-12-16 14:56:39 +0100 | [diff] [blame] | 585 | |
| 586 | Testing the SOURCESINK function |
| 587 | ------------------------------- |
| 588 | |
| 589 | device: run the gadget |
Peter Chen | f811a38 | 2015-07-31 16:36:30 +0800 | [diff] [blame] | 590 | host: test-usb (tools/usb/testusb.c) |
Andrzej Pietrasiewicz | 480a912 | 2014-12-16 14:56:39 +0100 | [diff] [blame] | 591 | |
Andrzej Pietrasiewicz | dae0358 | 2014-12-16 14:56:40 +0100 | [diff] [blame] | 592 | |
Ruslan Bilovol | d355339 | 2017-06-18 16:23:53 +0300 | [diff] [blame] | 593 | 16. UAC1 function (legacy implementation) |
Andrzej Pietrasiewicz | dae0358 | 2014-12-16 14:56:40 +0100 | [diff] [blame] | 594 | ================= |
| 595 | |
Ruslan Bilovol | d355339 | 2017-06-18 16:23:53 +0300 | [diff] [blame] | 596 | The function is provided by usb_f_uac1_legacy.ko module. |
Andrzej Pietrasiewicz | dae0358 | 2014-12-16 14:56:40 +0100 | [diff] [blame] | 597 | |
| 598 | Function-specific configfs interface |
| 599 | ------------------------------------ |
| 600 | |
Ruslan Bilovol | d355339 | 2017-06-18 16:23:53 +0300 | [diff] [blame] | 601 | The function name to use when creating the function directory |
| 602 | is "uac1_legacy". |
Andrzej Pietrasiewicz | dae0358 | 2014-12-16 14:56:40 +0100 | [diff] [blame] | 603 | The uac1 function provides these attributes in its function directory: |
| 604 | |
| 605 | audio_buf_size - audio buffer size |
| 606 | fn_cap - capture pcm device file name |
| 607 | fn_cntl - control device file name |
| 608 | fn_play - playback pcm device file name |
| 609 | req_buf_size - ISO OUT endpoint request buffer size |
| 610 | req_count - ISO OUT endpoint request count |
| 611 | |
| 612 | The attributes have sane default values. |
| 613 | |
| 614 | Testing the UAC1 function |
| 615 | ------------------------- |
| 616 | |
| 617 | device: run the gadget |
| 618 | host: aplay -l # should list our USB Audio Gadget |
Andrzej Pietrasiewicz | 020c6f9 | 2014-12-16 14:56:41 +0100 | [diff] [blame] | 619 | |
| 620 | 17. UAC2 function |
| 621 | ================= |
| 622 | |
| 623 | The function is provided by usb_f_uac2.ko module. |
| 624 | |
| 625 | Function-specific configfs interface |
| 626 | ------------------------------------ |
| 627 | |
| 628 | The function name to use when creating the function directory is "uac2". |
| 629 | The uac2 function provides these attributes in its function directory: |
| 630 | |
Peter Chen | 4e39aca | 2015-03-27 16:32:18 +0800 | [diff] [blame] | 631 | c_chmask - capture channel mask |
Andrzej Pietrasiewicz | 020c6f9 | 2014-12-16 14:56:41 +0100 | [diff] [blame] | 632 | c_srate - capture sampling rate |
| 633 | c_ssize - capture sample size (bytes) |
| 634 | p_chmask - playback channel mask |
| 635 | p_srate - playback sampling rate |
| 636 | p_ssize - playback sample size (bytes) |
Peter Chen | e92b9d4 | 2017-01-04 10:19:23 +0800 | [diff] [blame] | 637 | req_number - the number of pre-allocated request for both capture |
| 638 | and playback |
Andrzej Pietrasiewicz | 020c6f9 | 2014-12-16 14:56:41 +0100 | [diff] [blame] | 639 | |
| 640 | The attributes have sane default values. |
| 641 | |
| 642 | Testing the UAC2 function |
| 643 | ------------------------- |
| 644 | |
| 645 | device: run the gadget |
| 646 | host: aplay -l # should list our USB Audio Gadget |
| 647 | |
| 648 | This function does not require real hardware support, it just |
| 649 | sends a stream of audio data to/from the host. In order to |
| 650 | actually hear something at the device side, a command similar |
| 651 | to this must be used at the device side: |
| 652 | |
| 653 | $ arecord -f dat -t wav -D hw:2,0 | aplay -D hw:0,0 & |
| 654 | |
| 655 | e.g.: |
| 656 | |
| 657 | $ arecord -f dat -t wav -D hw:CARD=UAC2Gadget,DEV=0 | \ |
| 658 | aplay -D default:CARD=OdroidU3 |
Andrzej Pietrasiewicz | 9c4f538 | 2014-12-16 14:56:42 +0100 | [diff] [blame] | 659 | |
| 660 | 18. UVC function |
| 661 | ================ |
| 662 | |
| 663 | The function is provided by usb_f_uvc.ko module. |
| 664 | |
| 665 | Function-specific configfs interface |
| 666 | ------------------------------------ |
| 667 | |
| 668 | The function name to use when creating the function directory is "uvc". |
| 669 | The uvc function provides these attributes in its function directory: |
| 670 | |
| 671 | streaming_interval - interval for polling endpoint for data transfers |
| 672 | streaming_maxburst - bMaxBurst for super speed companion descriptor |
| 673 | streaming_maxpacket - maximum packet size this endpoint is capable of |
| 674 | sending or receiving when this configuration is |
| 675 | selected |
| 676 | |
| 677 | There are also "control" and "streaming" subdirectories, each of which contain |
| 678 | a number of their subdirectories. There are some sane defaults provided, but |
| 679 | the user must provide the following: |
| 680 | |
| 681 | control header - create in control/header, link from control/class/fs |
| 682 | and/or control/class/ss |
| 683 | streaming header - create in streaming/header, link from |
| 684 | streaming/class/fs and/or streaming/class/hs and/or |
| 685 | streaming/class/ss |
| 686 | format description - create in streaming/mjpeg and/or |
| 687 | streaming/uncompressed |
| 688 | frame description - create in streaming/mjpeg/<format> and/or in |
| 689 | streaming/uncompressed/<format> |
| 690 | |
| 691 | Each frame description contains frame interval specification, and each |
| 692 | such specification consists of a number of lines with an inverval value |
| 693 | in each line. The rules stated above are best illustrated with an example: |
| 694 | |
| 695 | # mkdir functions/uvc.usb0/control/header/h |
| 696 | # cd functions/uvc.usb0/control/header/h |
| 697 | # ln -s header/h class/fs |
| 698 | # ln -s header/h class/ss |
| 699 | # mkdir -p functions/uvc.usb0/streaming/uncompressed/u/360p |
| 700 | # cat <<EOF > functions/uvc.usb0/streaming/uncompressed/u/360p/dwFrameInterval |
| 701 | 666666 |
| 702 | 1000000 |
| 703 | 5000000 |
| 704 | EOF |
| 705 | # cd $GADGET_CONFIGFS_ROOT |
| 706 | # mkdir functions/uvc.usb0/streaming/header/h |
| 707 | # cd functions/uvc.usb0/streaming/header/h |
| 708 | # ln -s ../../uncompressed/u |
| 709 | # cd ../../class/fs |
| 710 | # ln -s ../../header/h |
| 711 | # cd ../../class/hs |
| 712 | # ln -s ../../header/h |
| 713 | # cd ../../class/ss |
| 714 | # ln -s ../../header/h |
| 715 | |
| 716 | |
| 717 | Testing the UVC function |
| 718 | ------------------------ |
| 719 | |
| 720 | device: run the gadget, modprobe vivid |
| 721 | |
| 722 | # uvc-gadget -u /dev/video<uvc video node #> -v /dev/video<vivid video node #> |
| 723 | |
| 724 | where uvc-gadget is this program: |
| 725 | http://git.ideasonboard.org/uvc-gadget.git |
| 726 | |
| 727 | with these patches: |
| 728 | http://www.spinics.net/lists/linux-usb/msg99220.html |
| 729 | |
| 730 | host: luvcview -f yuv |
Andrzej Pietrasiewicz | ee1cd51 | 2015-03-03 10:52:32 +0100 | [diff] [blame] | 731 | |
| 732 | 19. PRINTER function |
| 733 | ==================== |
| 734 | |
| 735 | The function is provided by usb_f_printer.ko module. |
| 736 | |
| 737 | Function-specific configfs interface |
| 738 | ------------------------------------ |
| 739 | |
| 740 | The function name to use when creating the function directory is "printer". |
| 741 | The printer function provides these attributes in its function directory: |
| 742 | |
| 743 | pnp_string - Data to be passed to the host in pnp string |
| 744 | q_len - Number of requests per endpoint |
| 745 | |
| 746 | Testing the PRINTER function |
| 747 | ---------------------------- |
| 748 | |
| 749 | The most basic testing: |
| 750 | |
| 751 | device: run the gadget |
| 752 | # ls -l /devices/virtual/usb_printer_gadget/ |
| 753 | |
| 754 | should show g_printer<number>. |
| 755 | |
| 756 | If udev is active, then /dev/g_printer<number> should appear automatically. |
| 757 | |
| 758 | host: |
| 759 | |
| 760 | If udev is active, then e.g. /dev/usb/lp0 should appear. |
| 761 | |
| 762 | host->device transmission: |
| 763 | |
| 764 | device: |
| 765 | # cat /dev/g_printer<number> |
| 766 | host: |
| 767 | # cat > /dev/usb/lp0 |
| 768 | |
| 769 | device->host transmission: |
| 770 | |
| 771 | # cat > /dev/g_printer<number> |
| 772 | host: |
| 773 | # cat /dev/usb/lp0 |
| 774 | |
| 775 | More advanced testing can be done with the prn_example |
| 776 | described in Documentation/usb/gadget-printer.txt. |
Ruslan Bilovol | 0591bc2 | 2017-06-18 16:23:54 +0300 | [diff] [blame] | 777 | |
| 778 | |
| 779 | 20. UAC1 function (virtual ALSA card, using u_audio API) |
| 780 | ================= |
| 781 | |
| 782 | The function is provided by usb_f_uac1.ko module. |
| 783 | It will create a virtual ALSA card and the audio streams are simply |
| 784 | sinked to and sourced from it. |
| 785 | |
| 786 | Function-specific configfs interface |
| 787 | ------------------------------------ |
| 788 | |
| 789 | The function name to use when creating the function directory is "uac1". |
| 790 | The uac1 function provides these attributes in its function directory: |
| 791 | |
| 792 | c_chmask - capture channel mask |
| 793 | c_srate - capture sampling rate |
| 794 | c_ssize - capture sample size (bytes) |
| 795 | p_chmask - playback channel mask |
| 796 | p_srate - playback sampling rate |
| 797 | p_ssize - playback sample size (bytes) |
| 798 | req_number - the number of pre-allocated request for both capture |
| 799 | and playback |
| 800 | |
| 801 | The attributes have sane default values. |
| 802 | |
| 803 | Testing the UAC1 function |
| 804 | ------------------------- |
| 805 | |
| 806 | device: run the gadget |
| 807 | host: aplay -l # should list our USB Audio Gadget |
| 808 | |
| 809 | This function does not require real hardware support, it just |
| 810 | sends a stream of audio data to/from the host. In order to |
| 811 | actually hear something at the device side, a command similar |
| 812 | to this must be used at the device side: |
| 813 | |
| 814 | $ arecord -f dat -t wav -D hw:2,0 | aplay -D hw:0,0 & |
| 815 | |
| 816 | e.g.: |
| 817 | |
| 818 | $ arecord -f dat -t wav -D hw:CARD=UAC1Gadget,DEV=0 | \ |
| 819 | aplay -D default:CARD=OdroidU3 |