blob: 6b4a88a8c8e34abf7e85e841cf10b1408b97b000 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001
2 Linux Gadget Serial Driver v2.0
3 11/20/2004
David Brownella7707ad2008-06-19 17:52:07 -07004 (updated 8-May-2008 for v2.3)
Linus Torvalds1da177e2005-04-16 15:20:36 -07005
6
7License and Disclaimer
8----------------------
9This program is free software; you can redistribute it and/or
10modify it under the terms of the GNU General Public License as
11published by the Free Software Foundation; either version 2 of
12the License, or (at your option) any later version.
13
14This program is distributed in the hope that it will be useful,
15but WITHOUT ANY WARRANTY; without even the implied warranty of
16MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17GNU General Public License for more details.
18
19You should have received a copy of the GNU General Public
20License along with this program; if not, write to the Free
21Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
22MA 02111-1307 USA.
23
Tobias Klauserd533f672005-09-10 00:26:46 -070024This document and the gadget serial driver itself are
Linus Torvalds1da177e2005-04-16 15:20:36 -070025Copyright (C) 2004 by Al Borchers (alborchers@steinerpoint.com).
26
27If you have questions, problems, or suggestions for this driver
28please contact Al Borchers at alborchers@steinerpoint.com.
29
30
31Prerequisites
32-------------
33Versions of the gadget serial driver are available for the
342.4 Linux kernels, but this document assumes you are using
David Brownella7707ad2008-06-19 17:52:07 -070035version 2.3 or later of the gadget serial driver in a 2.6
Linus Torvalds1da177e2005-04-16 15:20:36 -070036Linux kernel.
37
38This document assumes that you are familiar with Linux and
39Windows and know how to configure and build Linux kernels, run
40standard utilities, use minicom and HyperTerminal, and work with
41USB and serial devices. It also assumes you configure the Linux
42gadget and usb drivers as modules.
43
David Brownella7707ad2008-06-19 17:52:07 -070044With version 2.3 of the driver, major and minor device nodes are
45no longer statically defined. Your Linux based system should mount
46sysfs in /sys, and use "mdev" (in Busybox) or "udev" to make the
47/dev nodes matching the sysfs /sys/class/tty files.
48
49
Linus Torvalds1da177e2005-04-16 15:20:36 -070050
51Overview
52--------
53The gadget serial driver is a Linux USB gadget driver, a USB device
54side driver. It runs on a Linux system that has USB device side
55hardware; for example, a PDA, an embedded Linux system, or a PC
56with a USB development card.
57
58The gadget serial driver talks over USB to either a CDC ACM driver
59or a generic USB serial driver running on a host PC.
60
61 Host
62 --------------------------------------
63 | Host-Side CDC ACM USB Host |
64 | Operating | or | Controller | USB
65 | System | Generic USB | Driver |--------
66 | (Linux or | Serial | and | |
67 | Windows) Driver USB Stack | |
68 -------------------------------------- |
69 |
70 |
71 |
72 Gadget |
73 -------------------------------------- |
74 | Gadget USB Periph. | |
75 | Device-Side | Gadget | Controller | |
76 | Linux | Serial | Driver |--------
77 | Operating | Driver | and |
78 | System USB Stack |
79 --------------------------------------
80
81On the device-side Linux system, the gadget serial driver looks
82like a serial device.
83
84On the host-side system, the gadget serial device looks like a
85CDC ACM compliant class device or a simple vendor specific device
86with bulk in and bulk out endpoints, and it is treated similarly
87to other serial devices.
88
89The host side driver can potentially be any ACM compliant driver
90or any driver that can talk to a device with a simple bulk in/out
91interface. Gadget serial has been tested with the Linux ACM driver,
92the Windows usbser.sys ACM driver, and the Linux USB generic serial
93driver.
94
95With the gadget serial driver and the host side ACM or generic
96serial driver running, you should be able to communicate between
97the host and the gadget side systems as if they were connected by a
98serial cable.
99
100The gadget serial driver only provides simple unreliable data
101communication. It does not yet handle flow control or many other
102features of normal serial devices.
103
104
105Installing the Gadget Serial Driver
106-----------------------------------
107To use the gadget serial driver you must configure the Linux gadget
108side kernel for "Support for USB Gadgets", for a "USB Peripheral
109Controller" (for example, net2280), and for the "Serial Gadget"
110driver. All this are listed under "USB Gadget Support" when
111configuring the kernel. Then rebuild and install the kernel or
112modules.
113
Linus Torvalds1da177e2005-04-16 15:20:36 -0700114Then you must load the gadget serial driver. To load it as an
David Brownella7707ad2008-06-19 17:52:07 -0700115ACM device (recommended for interoperability), do this:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700116
Peter Korsgaardc33ba392008-12-04 16:30:53 +0100117 modprobe g_serial
Linus Torvalds1da177e2005-04-16 15:20:36 -0700118
119To load it as a vendor specific bulk in/out device, do this:
120
Peter Korsgaardc33ba392008-12-04 16:30:53 +0100121 modprobe g_serial use_acm=0
Linus Torvalds1da177e2005-04-16 15:20:36 -0700122
123This will also automatically load the underlying gadget peripheral
124controller driver. This must be done each time you reboot the gadget
125side Linux system. You can add this to the start up scripts, if
126desired.
127
David Brownella7707ad2008-06-19 17:52:07 -0700128Your system should use mdev (from busybox) or udev to make the
129device nodes. After this gadget driver has been set up you should
130then see a /dev/ttyGS0 node:
131
132 # ls -l /dev/ttyGS0 | cat
133 crw-rw---- 1 root root 253, 0 May 8 14:10 /dev/ttyGS0
134 #
135
136Note that the major number (253, above) is system-specific. If
137you need to create /dev nodes by hand, the right numbers to use
138will be in the /sys/class/tty/ttyGS0/dev file.
139
140When you link this gadget driver early, perhaps even statically,
141you may want to set up an /etc/inittab entry to run "getty" on it.
142The /dev/ttyGS0 line should work like most any other serial port.
143
144
Linus Torvalds1da177e2005-04-16 15:20:36 -0700145If gadget serial is loaded as an ACM device you will want to use
146either the Windows or Linux ACM driver on the host side. If gadget
147serial is loaded as a bulk in/out device, you will want to use the
148Linux generic serial driver on the host side. Follow the appropriate
149instructions below to install the host side driver.
150
151
152Installing the Windows Host ACM Driver
153--------------------------------------
Michal Nazarewicze41e1342010-06-21 13:57:06 +0200154To use the Windows ACM driver you must have the "linux-cdc-acm.inf"
155file (provided along this document) which supports all recent versions
156of Windows.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700157
158When the gadget serial driver is loaded and the USB device connected
159to the Windows host with a USB cable, Windows should recognize the
160gadget serial device and ask for a driver. Tell Windows to find the
Michal Nazarewicze41e1342010-06-21 13:57:06 +0200161driver in the folder that contains the "linux-cdc-acm.inf" file.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700162
163For example, on Windows XP, when the gadget serial device is first
164plugged in, the "Found New Hardware Wizard" starts up. Select
Michal Nazarewicze41e1342010-06-21 13:57:06 +0200165"Install from a list or specific location (Advanced)", then on the
166next screen select "Include this location in the search" and enter the
167path or browse to the folder containing the "linux-cdc-acm.inf" file.
168Windows will complain that the Gadget Serial driver has not passed
169Windows Logo testing, but select "Continue anyway" and finish the
170driver installation.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700171
172On Windows XP, in the "Device Manager" (under "Control Panel",
173"System", "Hardware") expand the "Ports (COM & LPT)" entry and you
174should see "Gadget Serial" listed as the driver for one of the COM
175ports.
176
177To uninstall the Windows XP driver for "Gadget Serial", right click
178on the "Gadget Serial" entry in the "Device Manager" and select
179"Uninstall".
180
181
182Installing the Linux Host ACM Driver
183------------------------------------
184To use the Linux ACM driver you must configure the Linux host side
185kernel for "Support for Host-side USB" and for "USB Modem (CDC ACM)
186support".
187
188Once the gadget serial driver is loaded and the USB device connected
189to the Linux host with a USB cable, the host system should recognize
190the gadget serial device. For example, the command
191
192 cat /proc/bus/usb/devices
193
194should show something like this:
195
196T: Bus=01 Lev=01 Prnt=01 Port=01 Cnt=02 Dev#= 5 Spd=480 MxCh= 0
197D: Ver= 2.00 Cls=02(comm.) Sub=00 Prot=00 MxPS=64 #Cfgs= 1
198P: Vendor=0525 ProdID=a4a7 Rev= 2.01
199S: Manufacturer=Linux 2.6.8.1 with net2280
200S: Product=Gadget Serial
201S: SerialNumber=0
202C:* #Ifs= 2 Cfg#= 2 Atr=c0 MxPwr= 2mA
203I: If#= 0 Alt= 0 #EPs= 1 Cls=02(comm.) Sub=02 Prot=01 Driver=acm
204E: Ad=83(I) Atr=03(Int.) MxPS= 8 Ivl=32ms
205I: If#= 1 Alt= 0 #EPs= 2 Cls=0a(data ) Sub=00 Prot=00 Driver=acm
206E: Ad=81(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms
207E: Ad=02(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms
208
209If the host side Linux system is configured properly, the ACM driver
210should be loaded automatically. The command "lsmod" should show the
211"acm" module is loaded.
212
213
214Installing the Linux Host Generic USB Serial Driver
215---------------------------------------------------
216To use the Linux generic USB serial driver you must configure the
217Linux host side kernel for "Support for Host-side USB", for "USB
218Serial Converter support", and for the "USB Generic Serial Driver".
219
220Once the gadget serial driver is loaded and the USB device connected
221to the Linux host with a USB cable, the host system should recognize
222the gadget serial device. For example, the command
223
224 cat /proc/bus/usb/devices
225
226should show something like this:
227
228T: Bus=01 Lev=01 Prnt=01 Port=01 Cnt=02 Dev#= 6 Spd=480 MxCh= 0
229D: Ver= 2.00 Cls=ff(vend.) Sub=00 Prot=00 MxPS=64 #Cfgs= 1
230P: Vendor=0525 ProdID=a4a6 Rev= 2.01
231S: Manufacturer=Linux 2.6.8.1 with net2280
232S: Product=Gadget Serial
233S: SerialNumber=0
234C:* #Ifs= 1 Cfg#= 1 Atr=c0 MxPwr= 2mA
235I: If#= 0 Alt= 0 #EPs= 2 Cls=0a(data ) Sub=00 Prot=00 Driver=serial
236E: Ad=81(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms
237E: Ad=02(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms
238
Andrzej Pietrasiewiczb797ef42014-12-16 14:56:24 +0100239You must load the usbserial driver and explicitly set its parameters
240to configure it to recognize the gadget serial device, like this:
241
242 echo 0x0525 0xA4A6 >/sys/bus/usb-serial/drivers/generic/new_id
243
244The legacy way is to use module parameters:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700245
246 modprobe usbserial vendor=0x0525 product=0xA4A6
247
248If everything is working, usbserial will print a message in the
249system log saying something like "Gadget Serial converter now
250attached to ttyUSB0".
251
252
253Testing with Minicom or HyperTerminal
254-------------------------------------
255Once the gadget serial driver and the host driver are both installed,
256and a USB cable connects the gadget device to the host, you should
257be able to communicate over USB between the gadget and host systems.
258You can use minicom or HyperTerminal to try this out.
259
260On the gadget side run "minicom -s" to configure a new minicom
261session. Under "Serial port setup" set "/dev/ttygserial" as the
262"Serial Device". Set baud rate, data bits, parity, and stop bits,
263to 9600, 8, none, and 1--these settings mostly do not matter.
264Under "Modem and dialing" erase all the modem and dialing strings.
265
266On a Linux host running the ACM driver, configure minicom similarly
267but use "/dev/ttyACM0" as the "Serial Device". (If you have other
268ACM devices connected, change the device name appropriately.)
269
270On a Linux host running the USB generic serial driver, configure
271minicom similarly, but use "/dev/ttyUSB0" as the "Serial Device".
272(If you have other USB serial devices connected, change the device
273name appropriately.)
274
275On a Windows host configure a new HyperTerminal session to use the
276COM port assigned to Gadget Serial. The "Port Settings" will be
277set automatically when HyperTerminal connects to the gadget serial
278device, so you can leave them set to the default values--these
279settings mostly do not matter.
280
281With minicom configured and running on the gadget side and with
282minicom or HyperTerminal configured and running on the host side,
283you should be able to send data back and forth between the gadget
284side and host side systems. Anything you type on the terminal
285window on the gadget side should appear in the terminal window on
286the host side and vice versa.