Documentation: usb: MASS STORAGE function testing
[deliverable/linux.git] / Documentation / usb / gadget-testing.txt
CommitLineData
e38eb2c8
AP
1This file summarizes information on basic testing of USB functions
2provided by gadgets.
3
41. ACM function
d5862ca6 52. ECM function
7bfbc6e3 63. ECM subset function
4ca560a6 74. EEM function
2c0f62f9 85. FFS function
f7e3c3cd 96. HID function
ec91aff7 107. LOOPBACK function
cdbe287d 118. MASS STORAGE function
e38eb2c8
AP
12
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>
d5862ca6
AP
42
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>
7bfbc6e3
AP
75
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>
4ca560a6
AP
108
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>
2c0f62f9
AP
141
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
f7e3c3cd
AP
164
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
ec91aff7
AP
210
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
cdbe287d
AP
232
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)
This page took 0.045556 seconds and 5 git commands to generate.