Based on kernel version 2.6.26. Page generated on 2008-07-16 21:13 EST.
1 2 Linux Gadget Serial Driver v2.0 3 11/20/2004 4 5 6 License and Disclaimer 7 ---------------------- 8 This program is free software; you can redistribute it and/or 9 modify it under the terms of the GNU General Public License as 10 published by the Free Software Foundation; either version 2 of 11 the License, or (at your option) any later version. 12 13 This program is distributed in the hope that it will be useful, 14 but WITHOUT ANY WARRANTY; without even the implied warranty of 15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 GNU General Public License for more details. 17 18 You should have received a copy of the GNU General Public 19 License along with this program; if not, write to the Free 20 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, 21 MA 02111-1307 USA. 22 23 This document and the gadget serial driver itself are 24 Copyright (C) 2004 by Al Borchers (alborchers[AT]steinerpoint.com)[DOT] 25 26 If you have questions, problems, or suggestions for this driver 27 please contact Al Borchers at alborchers[AT]steinerpoint.com[DOT] 28 29 30 Prerequisites 31 ------------- 32 Versions of the gadget serial driver are available for the 33 2.4 Linux kernels, but this document assumes you are using 34 version 2.0 or later of the gadget serial driver in a 2.6 35 Linux kernel. 36 37 This document assumes that you are familiar with Linux and 38 Windows and know how to configure and build Linux kernels, run 39 standard utilities, use minicom and HyperTerminal, and work with 40 USB and serial devices. It also assumes you configure the Linux 41 gadget and usb drivers as modules. 42 43 44 Overview 45 -------- 46 The gadget serial driver is a Linux USB gadget driver, a USB device 47 side driver. It runs on a Linux system that has USB device side 48 hardware; for example, a PDA, an embedded Linux system, or a PC 49 with a USB development card. 50 51 The gadget serial driver talks over USB to either a CDC ACM driver 52 or a generic USB serial driver running on a host PC. 53 54 Host 55 -------------------------------------- 56 | Host-Side CDC ACM USB Host | 57 | Operating | or | Controller | USB 58 | System | Generic USB | Driver |-------- 59 | (Linux or | Serial | and | | 60 | Windows) Driver USB Stack | | 61 -------------------------------------- | 62 | 63 | 64 | 65 Gadget | 66 -------------------------------------- | 67 | Gadget USB Periph. | | 68 | Device-Side | Gadget | Controller | | 69 | Linux | Serial | Driver |-------- 70 | Operating | Driver | and | 71 | System USB Stack | 72 -------------------------------------- 73 74 On the device-side Linux system, the gadget serial driver looks 75 like a serial device. 76 77 On the host-side system, the gadget serial device looks like a 78 CDC ACM compliant class device or a simple vendor specific device 79 with bulk in and bulk out endpoints, and it is treated similarly 80 to other serial devices. 81 82 The host side driver can potentially be any ACM compliant driver 83 or any driver that can talk to a device with a simple bulk in/out 84 interface. Gadget serial has been tested with the Linux ACM driver, 85 the Windows usbser.sys ACM driver, and the Linux USB generic serial 86 driver. 87 88 With the gadget serial driver and the host side ACM or generic 89 serial driver running, you should be able to communicate between 90 the host and the gadget side systems as if they were connected by a 91 serial cable. 92 93 The gadget serial driver only provides simple unreliable data 94 communication. It does not yet handle flow control or many other 95 features of normal serial devices. 96 97 98 Installing the Gadget Serial Driver 99 ----------------------------------- 100 To use the gadget serial driver you must configure the Linux gadget 101 side kernel for "Support for USB Gadgets", for a "USB Peripheral 102 Controller" (for example, net2280), and for the "Serial Gadget" 103 driver. All this are listed under "USB Gadget Support" when 104 configuring the kernel. Then rebuild and install the kernel or 105 modules. 106 107 The gadget serial driver uses major number 127, for now. So you 108 will need to create a device node for it, like this: 109 110 mknod /dev/ttygserial c 127 0 111 112 You only need to do this once. 113 114 Then you must load the gadget serial driver. To load it as an 115 ACM device, do this: 116 117 modprobe g_serial use_acm=1 118 119 To load it as a vendor specific bulk in/out device, do this: 120 121 modprobe g_serial 122 123 This will also automatically load the underlying gadget peripheral 124 controller driver. This must be done each time you reboot the gadget 125 side Linux system. You can add this to the start up scripts, if 126 desired. 127 128 If gadget serial is loaded as an ACM device you will want to use 129 either the Windows or Linux ACM driver on the host side. If gadget 130 serial is loaded as a bulk in/out device, you will want to use the 131 Linux generic serial driver on the host side. Follow the appropriate 132 instructions below to install the host side driver. 133 134 135 Installing the Windows Host ACM Driver 136 -------------------------------------- 137 To use the Windows ACM driver you must have the files "gserial.inf" 138 and "usbser.sys" together in a folder on the Windows machine. 139 140 The "gserial.inf" file is given here. 141 142 -------------------- CUT HERE -------------------- 143 [Version] 144 Signature="$Windows NT$" 145 Class=Ports 146 ClassGuid={4D36E978-E325-11CE-BFC1-08002BE10318} 147 Provider=%LINUX% 148 DriverVer=08/17/2004,0.0.2.0 149 ; Copyright (C) 2004 Al Borchers (alborchers[AT]steinerpoint[DOT]com) 150 151 [Manufacturer] 152 %LINUX%=GSerialDeviceList 153 154 [GSerialDeviceList] 155 %GSERIAL%=GSerialInstall, USB\VID_0525&PID_A4A7 156 157 [DestinationDirs] 158 DefaultDestDir=10,System32\Drivers 159 160 [GSerialInstall] 161 CopyFiles=GSerialCopyFiles 162 AddReg=GSerialAddReg 163 164 [GSerialCopyFiles] 165 usbser.sys 166 167 [GSerialAddReg] 168 HKR,,DevLoader,,*ntkern 169 HKR,,NTMPDriver,,usbser.sys 170 HKR,,EnumPropPages32,,"MsPorts.dll,SerialPortPropPageProvider" 171 172 [GSerialInstall.Services] 173 AddService = usbser,0x0002,GSerialService 174 175 [GSerialService] 176 DisplayName = %GSERIAL_DISPLAY_NAME% 177 ServiceType = 1 ; SERVICE_KERNEL_DRIVER 178 StartType = 3 ; SERVICE_DEMAND_START 179 ErrorControl = 1 ; SERVICE_ERROR_NORMAL 180 ServiceBinary = %10%\System32\Drivers\usbser.sys 181 LoadOrderGroup = Base 182 183 [Strings] 184 LINUX = "Linux" 185 GSERIAL = "Gadget Serial" 186 GSERIAL_DISPLAY_NAME = "USB Gadget Serial Driver" 187 -------------------- CUT HERE -------------------- 188 189 The "usbser.sys" file comes with various versions of Windows. 190 For example, it can be found on Windows XP typically in 191 192 C:\WINDOWS\Driver Cache\i386\driver.cab 193 194 Or it can be found on the Windows 98SE CD in the "win98" folder 195 in the "DRIVER11.CAB" through "DRIVER20.CAB" cab files. You will 196 need the DOS "expand" program, the Cygwin "cabextract" program, or 197 a similar program to unpack these cab files and extract "usbser.sys". 198 199 For example, to extract "usbser.sys" into the current directory 200 on Windows XP, open a DOS window and run a command like 201 202 expand C:\WINDOWS\Driver~1\i386\driver.cab -F:usbser.sys . 203 204 (Thanks to Nishant Kamat for pointing out this DOS command.) 205 206 When the gadget serial driver is loaded and the USB device connected 207 to the Windows host with a USB cable, Windows should recognize the 208 gadget serial device and ask for a driver. Tell Windows to find the 209 driver in the folder that contains "gserial.inf" and "usbser.sys". 210 211 For example, on Windows XP, when the gadget serial device is first 212 plugged in, the "Found New Hardware Wizard" starts up. Select 213 "Install from a list or specific location (Advanced)", then on 214 the next screen select "Include this location in the search" and 215 enter the path or browse to the folder containing "gserial.inf" and 216 "usbser.sys". Windows will complain that the Gadget Serial driver 217 has not passed Windows Logo testing, but select "Continue anyway" 218 and finish the driver installation. 219 220 On Windows XP, in the "Device Manager" (under "Control Panel", 221 "System", "Hardware") expand the "Ports (COM & LPT)" entry and you 222 should see "Gadget Serial" listed as the driver for one of the COM 223 ports. 224 225 To uninstall the Windows XP driver for "Gadget Serial", right click 226 on the "Gadget Serial" entry in the "Device Manager" and select 227 "Uninstall". 228 229 230 Installing the Linux Host ACM Driver 231 ------------------------------------ 232 To use the Linux ACM driver you must configure the Linux host side 233 kernel for "Support for Host-side USB" and for "USB Modem (CDC ACM) 234 support". 235 236 Once the gadget serial driver is loaded and the USB device connected 237 to the Linux host with a USB cable, the host system should recognize 238 the gadget serial device. For example, the command 239 240 cat /proc/bus/usb/devices 241 242 should show something like this: 243 244 T: Bus=01 Lev=01 Prnt=01 Port=01 Cnt=02 Dev#= 5 Spd=480 MxCh= 0 245 D: Ver= 2.00 Cls=02(comm.) Sub=00 Prot=00 MxPS=64 #Cfgs= 1 246 P: Vendor=0525 ProdID=a4a7 Rev= 2.01 247 S: Manufacturer=Linux 2.6.8.1 with net2280 248 S: Product=Gadget Serial 249 S: SerialNumber=0 250 C:* #Ifs= 2 Cfg#= 2 Atr=c0 MxPwr= 2mA 251 I: If#= 0 Alt= 0 #EPs= 1 Cls=02(comm.) Sub=02 Prot=01 Driver=acm 252 E: Ad=83(I) Atr=03(Int.) MxPS= 8 Ivl=32ms 253 I: If#= 1 Alt= 0 #EPs= 2 Cls=0a(data ) Sub=00 Prot=00 Driver=acm 254 E: Ad=81(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms 255 E: Ad=02(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms 256 257 If the host side Linux system is configured properly, the ACM driver 258 should be loaded automatically. The command "lsmod" should show the 259 "acm" module is loaded. 260 261 262 Installing the Linux Host Generic USB Serial Driver 263 --------------------------------------------------- 264 To use the Linux generic USB serial driver you must configure the 265 Linux host side kernel for "Support for Host-side USB", for "USB 266 Serial Converter support", and for the "USB Generic Serial Driver". 267 268 Once the gadget serial driver is loaded and the USB device connected 269 to the Linux host with a USB cable, the host system should recognize 270 the gadget serial device. For example, the command 271 272 cat /proc/bus/usb/devices 273 274 should show something like this: 275 276 T: Bus=01 Lev=01 Prnt=01 Port=01 Cnt=02 Dev#= 6 Spd=480 MxCh= 0 277 D: Ver= 2.00 Cls=ff(vend.) Sub=00 Prot=00 MxPS=64 #Cfgs= 1 278 P: Vendor=0525 ProdID=a4a6 Rev= 2.01 279 S: Manufacturer=Linux 2.6.8.1 with net2280 280 S: Product=Gadget Serial 281 S: SerialNumber=0 282 C:* #Ifs= 1 Cfg#= 1 Atr=c0 MxPwr= 2mA 283 I: If#= 0 Alt= 0 #EPs= 2 Cls=0a(data ) Sub=00 Prot=00 Driver=serial 284 E: Ad=81(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms 285 E: Ad=02(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms 286 287 You must explicitly load the usbserial driver with parameters to 288 configure it to recognize the gadget serial device, like this: 289 290 modprobe usbserial vendor=0x0525 product=0xA4A6 291 292 If everything is working, usbserial will print a message in the 293 system log saying something like "Gadget Serial converter now 294 attached to ttyUSB0". 295 296 297 Testing with Minicom or HyperTerminal 298 ------------------------------------- 299 Once the gadget serial driver and the host driver are both installed, 300 and a USB cable connects the gadget device to the host, you should 301 be able to communicate over USB between the gadget and host systems. 302 You can use minicom or HyperTerminal to try this out. 303 304 On the gadget side run "minicom -s" to configure a new minicom 305 session. Under "Serial port setup" set "/dev/ttygserial" as the 306 "Serial Device". Set baud rate, data bits, parity, and stop bits, 307 to 9600, 8, none, and 1--these settings mostly do not matter. 308 Under "Modem and dialing" erase all the modem and dialing strings. 309 310 On a Linux host running the ACM driver, configure minicom similarly 311 but use "/dev/ttyACM0" as the "Serial Device". (If you have other 312 ACM devices connected, change the device name appropriately.) 313 314 On a Linux host running the USB generic serial driver, configure 315 minicom similarly, but use "/dev/ttyUSB0" as the "Serial Device". 316 (If you have other USB serial devices connected, change the device 317 name appropriately.) 318 319 On a Windows host configure a new HyperTerminal session to use the 320 COM port assigned to Gadget Serial. The "Port Settings" will be 321 set automatically when HyperTerminal connects to the gadget serial 322 device, so you can leave them set to the default values--these 323 settings mostly do not matter. 324 325 With minicom configured and running on the gadget side and with 326 minicom or HyperTerminal configured and running on the host side, 327 you should be able to send data back and forth between the gadget 328 side and host side systems. Anything you type on the terminal 329 window on the gadget side should appear in the terminal window on 330 the host side and vice versa. 331