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