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 |
e38eb2c8 AP |
12 | |
13 | ||
14 | 1. ACM function | |
15 | =============== | |
16 | ||
17 | The function is provided by usb_f_acm.ko module. | |
18 | ||
19 | Function-specific configfs interface | |
20 | ------------------------------------ | |
21 | ||
22 | The function name to use when creating the function directory is "acm". | |
23 | The ACM function provides just one attribute in its function directory: | |
24 | ||
25 | port_num | |
26 | ||
27 | The attribute is read-only. | |
28 | ||
29 | There can be at most 4 ACM/generic serial/OBEX ports in the system. | |
30 | ||
31 | ||
32 | Testing the ACM function | |
33 | ------------------------ | |
34 | ||
35 | On the host: cat > /dev/ttyACM<X> | |
36 | On the device : cat /dev/ttyGS<Y> | |
37 | ||
38 | then the other way round | |
39 | ||
40 | On the device: cat > /dev/ttyGS<Y> | |
41 | On the host: cat /dev/ttyACM<X> | |
d5862ca6 AP |
42 | |
43 | 2. ECM function | |
44 | =============== | |
45 | ||
46 | The function is provided by usb_f_ecm.ko module. | |
47 | ||
48 | Function-specific configfs interface | |
49 | ------------------------------------ | |
50 | ||
51 | The function name to use when creating the function directory is "ecm". | |
52 | The 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 | ||
62 | and after creating the functions/ecm.<instance name> they contain default | |
63 | values: qmult is 5, dev_addr and host_addr are randomly selected. | |
64 | Except for ifname they can be written to until the function is linked to a | |
65 | configuration. The ifname is read-only and contains the name of the interface | |
66 | which was assigned by the net core, e. g. usb0. | |
67 | ||
68 | Testing the ECM function | |
69 | ------------------------ | |
70 | ||
71 | Configure IP addresses of the device and the host. Then: | |
72 | ||
73 | On the device: ping <host's IP> | |
74 | On the host: ping <device's IP> | |
7bfbc6e3 AP |
75 | |
76 | 3. ECM subset function | |
77 | ====================== | |
78 | ||
79 | The function is provided by usb_f_ecm_subset.ko module. | |
80 | ||
81 | Function-specific configfs interface | |
82 | ------------------------------------ | |
83 | ||
84 | The function name to use when creating the function directory is "geth". | |
85 | The 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 | ||
95 | and after creating the functions/ecm.<instance name> they contain default | |
96 | values: qmult is 5, dev_addr and host_addr are randomly selected. | |
97 | Except for ifname they can be written to until the function is linked to a | |
98 | configuration. The ifname is read-only and contains the name of the interface | |
99 | which was assigned by the net core, e. g. usb0. | |
100 | ||
101 | Testing the ECM subset function | |
102 | ------------------------------- | |
103 | ||
104 | Configure IP addresses of the device and the host. Then: | |
105 | ||
106 | On the device: ping <host's IP> | |
107 | On the host: ping <device's IP> | |
4ca560a6 AP |
108 | |
109 | 4. EEM function | |
110 | =============== | |
111 | ||
112 | The function is provided by usb_f_eem.ko module. | |
113 | ||
114 | Function-specific configfs interface | |
115 | ------------------------------------ | |
116 | ||
117 | The function name to use when creating the function directory is "eem". | |
118 | The 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 | ||
128 | and after creating the functions/eem.<instance name> they contain default | |
129 | values: qmult is 5, dev_addr and host_addr are randomly selected. | |
130 | Except for ifname they can be written to until the function is linked to a | |
131 | configuration. The ifname is read-only and contains the name of the interface | |
132 | which was assigned by the net core, e. g. usb0. | |
133 | ||
134 | Testing the EEM function | |
135 | ------------------------ | |
136 | ||
137 | Configure IP addresses of the device and the host. Then: | |
138 | ||
139 | On the device: ping <host's IP> | |
140 | On the host: ping <device's IP> | |
2c0f62f9 AP |
141 | |
142 | 5. FFS function | |
143 | =============== | |
144 | ||
145 | The function is provided by usb_f_fs.ko module. | |
146 | ||
147 | Function-specific configfs interface | |
148 | ------------------------------------ | |
149 | ||
150 | The function name to use when creating the function directory is "ffs". | |
151 | The function directory is intentionally empty and not modifiable. | |
152 | ||
153 | After creating the directory there is a new instance (a "device") of FunctionFS | |
154 | available in the system. Once a "device" is available, the user should follow | |
155 | the standard procedure for using FunctionFS (mount it, run the userspace | |
156 | process which implements the function proper). The gadget should be enabled | |
157 | by writing a suitable string to usb_gadget/<gadget>/UDC. | |
158 | ||
159 | Testing the FFS function | |
160 | ------------------------ | |
161 | ||
162 | On the device: start the function's userspace daemon, enable the gadget | |
163 | On the host: use the USB function provided by the device | |
f7e3c3cd AP |
164 | |
165 | 6. HID function | |
166 | =============== | |
167 | ||
168 | The function is provided by usb_f_hid.ko module. | |
169 | ||
170 | Function-specific configfs interface | |
171 | ------------------------------------ | |
172 | ||
173 | The function name to use when creating the function directory is "hid". | |
174 | The 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 | ||
182 | For a keyboard the protocol and the subclass are 1, the report_length is 8, | |
183 | while the report_desc is: | |
184 | ||
185 | $ hd my_report_desc | |
186 | 00000000 05 01 09 06 a1 01 05 07 19 e0 29 e7 15 00 25 01 |..........)...%.| | |
187 | 00000010 75 01 95 08 81 02 95 01 75 08 81 03 95 05 75 01 |u.......u.....u.| | |
188 | 00000020 05 08 19 01 29 05 91 02 95 01 75 03 91 03 95 06 |....).....u.....| | |
189 | 00000030 75 08 15 00 25 65 05 07 19 00 29 65 81 00 c0 |u...%e....)e...| | |
190 | 0000003f | |
191 | ||
192 | Such a sequence of bytes can be stored to the attribute with echo: | |
193 | ||
194 | $ echo -ne \\x05\\x01\\x09\\x06\\xa1..... | |
195 | ||
196 | Testing the HID function | |
197 | ------------------------ | |
198 | ||
199 | Device: | |
200 | - create the gadget | |
201 | - connect the gadget to a host, preferably not the one used | |
202 | to control the gadget | |
203 | - run a program which writes to /dev/hidg<N>, e.g. | |
204 | a userspace program found in Documentation/usb/gadget_hid.txt: | |
205 | ||
206 | $ ./hid_gadget_test /dev/hidg0 keyboard | |
207 | ||
208 | Host: | |
209 | - observe the keystrokes from the gadget | |
ec91aff7 AP |
210 | |
211 | 7. LOOPBACK function | |
212 | ==================== | |
213 | ||
214 | The function is provided by usb_f_ss_lb.ko module. | |
215 | ||
216 | Function-specific configfs interface | |
217 | ------------------------------------ | |
218 | ||
219 | The function name to use when creating the function directory is "Loopback". | |
220 | The LOOPBACK function provides these attributes in its function directory: | |
221 | ||
222 | qlen - depth of loopback queue | |
223 | bulk_buflen - buffer length | |
224 | ||
225 | Testing the LOOPBACK function | |
226 | ----------------------------- | |
227 | ||
228 | device: run the gadget | |
229 | host: test-usb | |
230 | ||
231 | http://www.linux-usb.org/usbtest/testusb.c | |
cdbe287d AP |
232 | |
233 | 8. MASS STORAGE function | |
234 | ======================== | |
235 | ||
236 | The function is provided by usb_f_mass_storage.ko module. | |
237 | ||
238 | Function-specific configfs interface | |
239 | ------------------------------------ | |
240 | ||
241 | The function name to use when creating the function directory is "mass_storage". | |
242 | The MASS STORAGE function provides these attributes in its directory: | |
243 | files: | |
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 | ||
252 | and a default lun.0 directory corresponding to SCSI LUN #0. | |
253 | ||
254 | A new lun can be added with mkdir: | |
255 | ||
256 | $ mkdir functions/mass_storage.0/partition.5 | |
257 | ||
258 | Lun numbering does not have to be continuous, except for lun #0 which is | |
259 | created by default. A maximum of 8 luns can be specified and they all must be | |
260 | named following the <name>.<number> scheme. The numbers can be 0..8. | |
261 | Probably a good convention is to name the luns "lun.<number>", | |
262 | although it is not mandatory. | |
263 | ||
264 | In 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 | ||
279 | Testing the MASS STORAGE function | |
280 | --------------------------------- | |
281 | ||
282 | device: connect the gadget, enable it | |
283 | host: dmesg, see the USB drives appear (if system configured to automatically | |
284 | mount) |