~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/Documentation/usb/gadget_serial.rst

Version: ~ [ linux-6.11.5 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.58 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.114 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.169 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.228 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.284 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.322 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

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

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php