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