blob: 01b9ffe2eabc58c246afe430fe8d1772aa4246ea [file] [log] [blame]
Andrzej Pietrasiewicze38eb2c2014-12-16 14:56:25 +01001This file summarizes information on basic testing of USB functions
2provided by gadgets.
3
41. ACM function
Andrzej Pietrasiewiczd5862ca2014-12-16 14:56:26 +010052. ECM function
Andrzej Pietrasiewicz7bfbc6e2014-12-16 14:56:27 +010063. ECM subset function
Andrzej Pietrasiewicz4ca560a2014-12-16 14:56:28 +010074. EEM function
Andrzej Pietrasiewicz2c0f62f2014-12-16 14:56:29 +010085. FFS function
Andrzej Pietrasiewiczf7e3c3c2014-12-16 14:56:30 +010096. HID function
Andrzej Pietrasiewiczec91aff2014-12-16 14:56:31 +0100107. LOOPBACK function
Andrzej Pietrasiewiczcdbe2872014-12-16 14:56:32 +0100118. MASS STORAGE function
Andrzej Pietrasiewicze38eb2c2014-12-16 14:56:25 +010012
13
141. ACM function
15===============
16
17The function is provided by usb_f_acm.ko module.
18
19Function-specific configfs interface
20------------------------------------
21
22The function name to use when creating the function directory is "acm".
23The ACM function provides just one attribute in its function directory:
24
25 port_num
26
27The attribute is read-only.
28
29There can be at most 4 ACM/generic serial/OBEX ports in the system.
30
31
32Testing the ACM function
33------------------------
34
35On the host: cat > /dev/ttyACM<X>
36On the device : cat /dev/ttyGS<Y>
37
38then the other way round
39
40On the device: cat > /dev/ttyGS<Y>
41On the host: cat /dev/ttyACM<X>
Andrzej Pietrasiewiczd5862ca2014-12-16 14:56:26 +010042
432. ECM function
44===============
45
46The function is provided by usb_f_ecm.ko module.
47
48Function-specific configfs interface
49------------------------------------
50
51The function name to use when creating the function directory is "ecm".
52The ECM function provides these attributes in its function directory:
53
54 ifname - network device interface name associated with this
55 function instance
56 qmult - queue length multiplier for high and super speed
57 host_addr - MAC address of host's end of this
58 Ethernet over USB link
59 dev_addr - MAC address of device's end of this
60 Ethernet over USB link
61
62and after creating the functions/ecm.<instance name> they contain default
63values: qmult is 5, dev_addr and host_addr are randomly selected.
64Except for ifname they can be written to until the function is linked to a
65configuration. The ifname is read-only and contains the name of the interface
66which was assigned by the net core, e. g. usb0.
67
68Testing the ECM function
69------------------------
70
71Configure IP addresses of the device and the host. Then:
72
73On the device: ping <host's IP>
74On the host: ping <device's IP>
Andrzej Pietrasiewicz7bfbc6e2014-12-16 14:56:27 +010075
763. ECM subset function
77======================
78
79The function is provided by usb_f_ecm_subset.ko module.
80
81Function-specific configfs interface
82------------------------------------
83
84The function name to use when creating the function directory is "geth".
85The ECM subset function provides these attributes in its function directory:
86
87 ifname - network device interface name associated with this
88 function instance
89 qmult - queue length multiplier for high and super speed
90 host_addr - MAC address of host's end of this
91 Ethernet over USB link
92 dev_addr - MAC address of device's end of this
93 Ethernet over USB link
94
95and after creating the functions/ecm.<instance name> they contain default
96values: qmult is 5, dev_addr and host_addr are randomly selected.
97Except for ifname they can be written to until the function is linked to a
98configuration. The ifname is read-only and contains the name of the interface
99which was assigned by the net core, e. g. usb0.
100
101Testing the ECM subset function
102-------------------------------
103
104Configure IP addresses of the device and the host. Then:
105
106On the device: ping <host's IP>
107On the host: ping <device's IP>
Andrzej Pietrasiewicz4ca560a2014-12-16 14:56:28 +0100108
1094. EEM function
110===============
111
112The function is provided by usb_f_eem.ko module.
113
114Function-specific configfs interface
115------------------------------------
116
117The function name to use when creating the function directory is "eem".
118The EEM function provides these attributes in its function directory:
119
120 ifname - network device interface name associated with this
121 function instance
122 qmult - queue length multiplier for high and super speed
123 host_addr - MAC address of host's end of this
124 Ethernet over USB link
125 dev_addr - MAC address of device's end of this
126 Ethernet over USB link
127
128and after creating the functions/eem.<instance name> they contain default
129values: qmult is 5, dev_addr and host_addr are randomly selected.
130Except for ifname they can be written to until the function is linked to a
131configuration. The ifname is read-only and contains the name of the interface
132which was assigned by the net core, e. g. usb0.
133
134Testing the EEM function
135------------------------
136
137Configure IP addresses of the device and the host. Then:
138
139On the device: ping <host's IP>
140On the host: ping <device's IP>
Andrzej Pietrasiewicz2c0f62f2014-12-16 14:56:29 +0100141
1425. FFS function
143===============
144
145The function is provided by usb_f_fs.ko module.
146
147Function-specific configfs interface
148------------------------------------
149
150The function name to use when creating the function directory is "ffs".
151The function directory is intentionally empty and not modifiable.
152
153After creating the directory there is a new instance (a "device") of FunctionFS
154available in the system. Once a "device" is available, the user should follow
155the standard procedure for using FunctionFS (mount it, run the userspace
156process which implements the function proper). The gadget should be enabled
157by writing a suitable string to usb_gadget/<gadget>/UDC.
158
159Testing the FFS function
160------------------------
161
162On the device: start the function's userspace daemon, enable the gadget
163On the host: use the USB function provided by the device
Andrzej Pietrasiewiczf7e3c3c2014-12-16 14:56:30 +0100164
1656. HID function
166===============
167
168The function is provided by usb_f_hid.ko module.
169
170Function-specific configfs interface
171------------------------------------
172
173The function name to use when creating the function directory is "hid".
174The HID function provides these attributes in its function directory:
175
176 protocol - HID protocol to use
177 report_desc - data to be used in HID reports, except data
178 passed with /dev/hidg<X>
179 report_length - HID report length
180 subclass - HID subclass to use
181
182For a keyboard the protocol and the subclass are 1, the report_length is 8,
183while the report_desc is:
184
185$ hd my_report_desc
18600000000 05 01 09 06 a1 01 05 07 19 e0 29 e7 15 00 25 01 |..........)...%.|
18700000010 75 01 95 08 81 02 95 01 75 08 81 03 95 05 75 01 |u.......u.....u.|
18800000020 05 08 19 01 29 05 91 02 95 01 75 03 91 03 95 06 |....).....u.....|
18900000030 75 08 15 00 25 65 05 07 19 00 29 65 81 00 c0 |u...%e....)e...|
1900000003f
191
192Such a sequence of bytes can be stored to the attribute with echo:
193
194$ echo -ne \\x05\\x01\\x09\\x06\\xa1.....
195
196Testing the HID function
197------------------------
198
199Device:
200- create the gadget
201- connect the gadget to a host, preferably not the one used
202to control the gadget
203- run a program which writes to /dev/hidg<N>, e.g.
204a userspace program found in Documentation/usb/gadget_hid.txt:
205
206$ ./hid_gadget_test /dev/hidg0 keyboard
207
208Host:
209- observe the keystrokes from the gadget
Andrzej Pietrasiewiczec91aff2014-12-16 14:56:31 +0100210
2117. LOOPBACK function
212====================
213
214The function is provided by usb_f_ss_lb.ko module.
215
216Function-specific configfs interface
217------------------------------------
218
219The function name to use when creating the function directory is "Loopback".
220The LOOPBACK function provides these attributes in its function directory:
221
222 qlen - depth of loopback queue
223 bulk_buflen - buffer length
224
225Testing the LOOPBACK function
226-----------------------------
227
228device: run the gadget
229host: test-usb
230
231http://www.linux-usb.org/usbtest/testusb.c
Andrzej Pietrasiewiczcdbe2872014-12-16 14:56:32 +0100232
2338. MASS STORAGE function
234========================
235
236The function is provided by usb_f_mass_storage.ko module.
237
238Function-specific configfs interface
239------------------------------------
240
241The function name to use when creating the function directory is "mass_storage".
242The MASS STORAGE function provides these attributes in its directory:
243files:
244
245 stall - Set to permit function to halt bulk endpoints.
246 Disabled on some USB devices known not to work
247 correctly. You should set it to true.
248 num_buffers - Number of pipeline buffers. Valid numbers
249 are 2..4. Available only if
250 CONFIG_USB_GADGET_DEBUG_FILES is set.
251
252and a default lun.0 directory corresponding to SCSI LUN #0.
253
254A new lun can be added with mkdir:
255
256$ mkdir functions/mass_storage.0/partition.5
257
258Lun numbering does not have to be continuous, except for lun #0 which is
259created by default. A maximum of 8 luns can be specified and they all must be
260named following the <name>.<number> scheme. The numbers can be 0..8.
261Probably a good convention is to name the luns "lun.<number>",
262although it is not mandatory.
263
264In each lun directory there are the following attribute files:
265
266 file - The path to the backing file for the LUN.
267 Required if LUN is not marked as removable.
268 ro - Flag specifying access to the LUN shall be
269 read-only. This is implied if CD-ROM emulation
270 is enabled as well as when it was impossible
271 to open "filename" in R/W mode.
272 removable - Flag specifying that LUN shall be indicated as
273 being removable.
274 cdrom - Flag specifying that LUN shall be reported as
275 being a CD-ROM.
276 nofua - Flag specifying that FUA flag
277 in SCSI WRITE(10,12)
278
279Testing the MASS STORAGE function
280---------------------------------
281
282device: connect the gadget, enable it
283host: dmesg, see the USB drives appear (if system configured to automatically
284mount)