← Documents Documentation/usb/gadget_serial.rst GitHub 원문 ↗

Linux 6.18.37 · USB

Linux Gadget Serial 드라이버 v2.0

g_serial의 CDC ACM·vendor-specific bulk mode, gadget/host TTY node와 Windows·Linux host driver 설치 및 terminal 시험 절차를 설명합니다.

Source pathDocumentation/usb/gadget_serial.rst
Source versionLinux v6.18.37
TranslationDUJINLABS 전문 번역 + 해설

요약·해설과 원문, 전문 번역을 서로 분리했습니다. API 이름, symbol, source path는 원문 표기를 사용합니다.

1. 요약·해설

원문의 핵심 논리와 kernel programming 관점의 보충 설명입니다. 아래의 전문 번역과는 별도로 작성했습니다.

요약·해설

gadget_serial.rst:1-289

`g_serial`은 device-side Linux를 USB serial 장치로 노출합니다. 기본 CDC ACM mode는 Linux `acm`과 Windows `usbser.sys`에 연결되며, `use_acm=0` mode는 bulk IN/OUT vendor-specific interface를 Linux generic `usbserial`에 연결합니다.

Gadget에는 `/dev/ttyGS0`, Linux ACM host에는 `/dev/ttyACM0`, generic host에는 `/dev/ttyUSB0`이 생성됩니다. mdev·udev와 sysfs가 node를 관리하므로 major/minor number를 고정해서는 안 됩니다.

이 드라이버는 serial cable과 비슷한 단순 데이터 통신을 제공하지만 flow control 등 완전한 serial 기능은 보장하지 않습니다. 실제 node 이름과 VID/PID를 확인한 뒤 minicom 또는 Windows terminal로 양방향 전송을 시험합니다.

2. 영어 원문 전체

번역 기준이 된 Linux v6.18.37 원문입니다. 줄 번호는 이 버전의 파일 좌표입니다.

원문 전체 펼치기
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.
290

3. 한국어 전문 번역

영어 원문의 문단 순서와 의미를 유지한 전체 번역입니다. 코드, 함수명, symbol과 URL은 원문 표기를 유지합니다.

문서 version과 날짜

1-9

이 문서는 Linux Gadget Serial Driver v2.0을 설명하며 최초 날짜는 2004년 11월 20일입니다.

2008년 5월 8일에 gadget serial driver v2.3에 맞게 갱신되었습니다.

===============================
Linux Gadget Serial Driver v2.0
===============================

11/20/2004

(updated 8-May-2008 for v2.3)

라이선스와 면책

10-33

이 프로그램은 Free Software Foundation이 공표한 GNU General Public License version 2 또는 사용자가 선택하는 이후 version의 조건에 따라 재배포하고 수정할 수 있는 자유 소프트웨어입니다.

프로그램은 유용하리라는 기대 아래 배포되지만 상품성이나 특정 목적 적합성에 대한 묵시적 보증을 포함해 어떠한 보증도 제공하지 않습니다.

GPL 사본을 프로그램과 함께 받지 못했다면 원문에 적힌 Free Software Foundation 주소로 요청할 수 있습니다.

문서와 gadget serial driver의 저작권은 2004년 Al Borchers에게 있습니다.

드라이버에 대한 질문, 문제 또는 제안은 원문에 기재된 Al Borchers 이메일로 연락합니다.

문서의 법적 정보
항목내용
LicenseGPL version 2 or later
Warranty보증 없음
CopyrightCopyright (C) 2004 Al Borchers
Contactalborchers@steinerpoint.com

라이선스, 보증과 저작권 정보를 구분했습니다.

License and Disclaimer
----------------------
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of
the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public
License along with this program; if not, write to the Free
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
MA 02111-1307 USA.

This document and the gadget serial driver itself are
Copyright (C) 2004 by Al Borchers (alborchers@steinerpoint.com).

If you have questions, problems, or suggestions for this driver
please contact Al Borchers at alborchers@steinerpoint.com.

사전 요구 사항

34-53

gadget serial driver는 Linux 2.4 kernel용 version도 있지만, 이 문서는 Linux 2.6 kernel에서 driver version 2.3 이상을 사용한다고 가정합니다.

독자는 Linux와 Windows 사용, Linux kernel 구성·빌드, 표준 utility 실행, minicom과 HyperTerminal 사용, USB·serial 장치 작업에 익숙해야 합니다.

Linux gadget과 USB driver는 module로 구성한다고 가정합니다.

driver v2.3부터 major와 minor device number가 정적으로 정의되지 않습니다. gadget Linux 시스템은 `/sys`에 sysfs를 mount해야 합니다.

BusyBox의 `mdev` 또는 `udev`가 `/sys/class/tty`의 항목을 따라 `/dev` device node를 생성해야 합니다.

사전 준비 체크
영역요구 사항
Kernel/driverLinux 2.6, gadget serial v2.3 이상
Kernel 구성Gadget·USB driver를 module로 구성
Filesystemsysfs를 /sys에 mount
Device managermdev 또는 udev
도구 지식minicom·HyperTerminal·USB·serial

gadget serial 설치 전에 필요한 환경입니다.

Prerequisites
-------------
Versions of the gadget serial driver are available for the
2.4 Linux kernels, but this document assumes you are using
version 2.3 or later of the gadget serial driver in a 2.6
Linux kernel.

This document assumes that you are familiar with Linux and
Windows and know how to configure and build Linux kernels, run
standard utilities, use minicom and HyperTerminal, and work with
USB and serial devices.  It also assumes you configure the Linux
gadget and usb drivers as modules.

With version 2.3 of the driver, major and minor device nodes are
no longer statically defined.  Your Linux based system should mount
sysfs in /sys, and use "mdev" (in Busybox) or "udev" to make the
/dev nodes matching the sysfs /sys/class/tty files.


동작 개요와 구조

54-107

gadget serial driver는 USB device-side Linux gadget driver입니다. PDA, 임베디드 Linux 시스템, USB 개발 card가 장착된 PC처럼 device-side hardware를 가진 시스템에서 실행합니다.

USB 반대편 호스트 PC에서는 CDC ACM driver 또는 generic USB serial driver가 실행됩니다.

원문의 ASCII 구조도는 호스트 운영체제의 serial driver가 host controller driver와 USB stack을 거쳐 USB link로 연결되고, gadget 쪽 peripheral controller driver와 USB stack이 gadget serial driver에 연결되는 계층을 보여 줍니다.

device-side Linux에서는 gadget serial driver가 일반 serial device처럼 보입니다.

호스트에서는 CDC ACM class device 또는 bulk-in·bulk-out endpoint를 가진 단순 vendor-specific device로 보이며 다른 serial 장치와 비슷하게 취급됩니다.

호스트 driver는 ACM 호환 driver 또는 단순 bulk in/out interface와 통신할 수 있는 driver가 될 수 있습니다. 문서 작성 당시 Linux ACM, Windows `usbser.sys` ACM, Linux generic USB serial driver로 시험했습니다.

양쪽 driver가 동작하면 host와 gadget은 serial cable로 연결된 것처럼 데이터를 주고받을 수 있습니다.

다만 이 driver는 단순하고 신뢰성이 보장되지 않는 data communication만 제공하며 flow control과 일반 serial 장치의 여러 기능을 아직 처리하지 않습니다.

Host와 Gadget serial 계층
Host-side Linux 또는 Windows 운영체제CDC ACM 또는 Generic USB Serial driverUSB host controller driver와 host USB stackUSB cable과 bulk/interrupt endpointGadget USB peripheral controller driver와 gadget USB stackGadget Serial driverDevice-side Linux의 serial device interface

원문 ASCII 도식을 동일한 계층과 연결 순서의 흐름으로 재구성했습니다.

g_serial 노출 모드
Gadget 모드호스트 표현권장 host driver
CDC ACMACM compliant class deviceLinux ACM 또는 Windows usbser.sys
Vendor-specificBulk IN/OUT interfaceLinux generic USB serial

호스트가 장치를 인식하는 두 방식입니다.

Overview
--------
The gadget serial driver is a Linux USB gadget driver, a USB device
side driver.  It runs on a Linux system that has USB device side
hardware; for example, a PDA, an embedded Linux system, or a PC
with a USB development card.

The gadget serial driver talks over USB to either a CDC ACM driver
or a generic USB serial driver running on a host PC::

   Host
   --------------------------------------
  | Host-Side   CDC ACM       USB Host   |
  | Operating |   or        | Controller |   USB
  | System    | Generic USB | Driver     |--------
  | (Linux or | Serial      | and        |        |
  | Windows)    Driver        USB Stack  |        |
   --------------------------------------         |
                                                  |
                                                  |
                                                  |
   Gadget                                         |
   --------------------------------------         |
  | Gadget                   USB Periph. |        |
  | Device-Side |  Gadget  | Controller  |        |
  | Linux       |  Serial  | Driver      |--------
  | Operating   |  Driver  | and         |
  | System                   USB Stack   |
   --------------------------------------

On the device-side Linux system, the gadget serial driver looks
like a serial device.

On the host-side system, the gadget serial device looks like a
CDC ACM compliant class device or a simple vendor specific device
with bulk in and bulk out endpoints, and it is treated similarly
to other serial devices.

The host side driver can potentially be any ACM compliant driver
or any driver that can talk to a device with a simple bulk in/out
interface.  Gadget serial has been tested with the Linux ACM driver,
the Windows usbser.sys ACM driver, and the Linux USB generic serial
driver.

With the gadget serial driver and the host side ACM or generic
serial driver running, you should be able to communicate between
the host and the gadget side systems as if they were connected by a
serial cable.

The gadget serial driver only provides simple unreliable data
communication.  It does not yet handle flow control or many other
features of normal serial devices.

Gadget 쪽 드라이버 설치

108-130

gadget 쪽 kernel에서 `Support for USB Gadgets`, 사용할 `USB Peripheral Controller` 예를 들어 net2280, 그리고 `Serial Gadget` driver를 활성화해야 합니다.

이 항목들은 kernel 설정의 `USB Gadget Support` 아래에 있으며 설정 후 kernel 또는 module을 다시 빌드해 설치합니다.

상호 운용성이 좋은 ACM 장치로 적재하려면 `modprobe g_serial`을 실행합니다.

vendor-specific bulk in/out 장치로 적재하려면 `modprobe g_serial use_acm=0`을 실행합니다.

g_serial 적재는 하위 gadget peripheral controller driver도 자동으로 적재합니다.

gadget Linux 시스템을 재부팅할 때마다 이 작업이 필요하므로 원하는 경우 startup script에 추가합니다.

Gadget serial 설치 순서
USB Gadget Support 활성화대상 USB Peripheral Controller 선택Serial Gadget driver 활성화Kernel/module 빌드와 설치modprobe g_serial 또는 use_acm=0 실행UDC driver 자동 적재와 USB 열거

Kernel 구성부터 module 적재까지의 절차입니다.

Installing the Gadget Serial Driver
-----------------------------------
To use the gadget serial driver you must configure the Linux gadget
side kernel for "Support for USB Gadgets", for a "USB Peripheral
Controller" (for example, net2280), and for the "Serial Gadget"
driver.  All this are listed under "USB Gadget Support" when
configuring the kernel.  Then rebuild and install the kernel or
modules.

Then you must load the gadget serial driver.  To load it as an
ACM device (recommended for interoperability), do this::

  modprobe g_serial

To load it as a vendor specific bulk in/out device, do this::

  modprobe g_serial use_acm=0

This will also automatically load the underlying gadget peripheral
controller driver.  This must be done each time you reboot the gadget
side Linux system.  You can add this to the start up scripts, if
desired.

Device node와 host mode 선택

131-154

mdev 또는 udev가 device node를 만들면 gadget 쪽에 `/dev/ttyGS0`가 나타납니다.

예제의 major number 253은 시스템마다 다릅니다. node를 수동으로 만들 때는 `/sys/class/tty/ttyGS0/dev`에서 정확한 major와 minor number를 읽어야 합니다.

driver를 boot 초기에 또는 kernel에 정적으로 연결한다면 `/etc/inittab`에서 `/dev/ttyGS0`에 `getty`를 실행하도록 구성할 수 있습니다.

`/dev/ttyGS0`는 대부분의 일반 serial port처럼 동작합니다.

ACM 모드에서는 Windows 또는 Linux ACM driver를 사용하고, bulk in/out 모드에서는 Linux generic serial driver를 사용합니다.

Gadget·host TTY node
위치·모드Device node담당 driver
Gadget side/dev/ttyGS0g_serial
Linux host ACM/dev/ttyACM0acm
Linux host generic/dev/ttyUSB0usbserial
Windows host ACM할당된 COM portusbser.sys

각 위치와 mode에서 사용하는 대표 device node입니다.

Your system should use mdev (from busybox) or udev to make the
device nodes.  After this gadget driver has been set up you should
then see a /dev/ttyGS0 node::

  # ls -l /dev/ttyGS0 | cat
  crw-rw----    1 root     root     253,   0 May  8 14:10 /dev/ttyGS0
  #

Note that the major number (253, above) is system-specific.  If
you need to create /dev nodes by hand, the right numbers to use
will be in the /sys/class/tty/ttyGS0/dev file.

When you link this gadget driver early, perhaps even statically,
you may want to set up an /etc/inittab entry to run "getty" on it.
The /dev/ttyGS0 line should work like most any other serial port.


If gadget serial is loaded as an ACM device you will want to use
either the Windows or Linux ACM driver on the host side.  If gadget
serial is loaded as a bulk in/out device, you will want to use the
Linux generic serial driver on the host side.  Follow the appropriate
instructions below to install the host side driver.

Windows host ACM driver 설치

155-184

Windows ACM driver를 사용하려면 문서와 함께 제공되는 `linux-cdc-acm.inf`가 필요하며 이 파일은 당시의 최근 Windows version을 지원합니다.

gadget serial driver를 적재하고 USB cable을 연결하면 Windows가 장치를 인식하고 driver 위치를 묻습니다. `linux-cdc-acm.inf`가 있는 folder를 지정합니다.

Windows XP의 Found New Hardware Wizard에서는 `Install from a list or specific location (Advanced)`를 선택하고 다음 화면에서 INF folder를 검색 위치로 포함합니다.

Windows Logo testing 경고가 나오면 원문 절차에서는 `Continue anyway`를 선택해 설치를 마칩니다.

설치 후 Device Manager의 `Ports (COM & LPT)` 아래에서 `Gadget Serial`이 COM port 하나에 연결된 것을 확인할 수 있습니다.

제거하려면 Device Manager의 Gadget Serial 항목을 마우스 오른쪽 단추로 눌러 Uninstall을 선택합니다.

Windows XP ACM 설치
Gadget에 g_serial ACM mode 적재USB cable로 Windows host 연결Found New Hardware Wizard 실행linux-cdc-acm.inf folder 지정Logo testing 경고에서 Continue anywayDevice Manager의 COM port에서 Gadget Serial 확인

문서에 기록된 INF 설치 흐름입니다.

Installing the Windows Host ACM Driver
--------------------------------------
To use the Windows ACM driver you must have the "linux-cdc-acm.inf"
file (provided along this document) which supports all recent versions
of Windows.

When the gadget serial driver is loaded and the USB device connected
to the Windows host with a USB cable, Windows should recognize the
gadget serial device and ask for a driver.  Tell Windows to find the
driver in the folder that contains the "linux-cdc-acm.inf" file.

For example, on Windows XP, when the gadget serial device is first
plugged in, the "Found New Hardware Wizard" starts up.  Select
"Install from a list or specific location (Advanced)", then on the
next screen select "Include this location in the search" and enter the
path or browse to the folder containing the "linux-cdc-acm.inf" file.
Windows will complain that the Gadget Serial driver has not passed
Windows Logo testing, but select "Continue anyway" and finish the
driver installation.

On Windows XP, in the "Device Manager" (under "Control Panel",
"System", "Hardware") expand the "Ports (COM & LPT)" entry and you
should see "Gadget Serial" listed as the driver for one of the COM
ports.

To uninstall the Windows XP driver for "Gadget Serial", right click
on the "Gadget Serial" entry in the "Device Manager" and select
"Uninstall".

Linux host ACM driver 설치

185-216

Linux host kernel에서 `Support for Host-side USB`와 `USB Modem (CDC ACM) support`를 활성화해야 합니다.

g_serial ACM mode 장치를 연결하면 host가 composite communication device를 인식합니다.

`cat /sys/kernel/debug/usb/devices` 출력 예는 class 02 communication device, communication과 data 두 interface, interrupt endpoint 하나와 bulk IN/OUT endpoint를 보여 줍니다.

interface 0은 ACM communication control, interface 1은 data이며 둘 다 `Driver=acm`으로 연결됩니다.

host kernel 구성이 올바르면 ACM module은 자동 적재되며 `lsmod`에서 `acm`을 확인할 수 있습니다.

ACM descriptor 예의 interface
InterfaceClass·driverEndpoint
If# 0Cls=02 comm., Driver=acmInterrupt IN 8 bytes
If# 1Cls=0a data, Driver=acmBulk IN/OUT 512 bytes

원문 debugfs 출력의 핵심 interface와 endpoint입니다.

Installing the Linux Host ACM Driver
------------------------------------
To use the Linux ACM driver you must configure the Linux host side
kernel for "Support for Host-side USB" and for "USB Modem (CDC ACM)
support".

Once the gadget serial driver is loaded and the USB device connected
to the Linux host with a USB cable, the host system should recognize
the gadget serial device.  For example, the command::

  cat /sys/kernel/debug/usb/devices

should show something like this:::

  T:  Bus=01 Lev=01 Prnt=01 Port=01 Cnt=02 Dev#=  5 Spd=480 MxCh= 0
  D:  Ver= 2.00 Cls=02(comm.) Sub=00 Prot=00 MxPS=64 #Cfgs=  1
  P:  Vendor=0525 ProdID=a4a7 Rev= 2.01
  S:  Manufacturer=Linux 2.6.8.1 with net2280
  S:  Product=Gadget Serial
  S:  SerialNumber=0
  C:* #Ifs= 2 Cfg#= 2 Atr=c0 MxPwr=  2mA
  I:  If#= 0 Alt= 0 #EPs= 1 Cls=02(comm.) Sub=02 Prot=01 Driver=acm
  E:  Ad=83(I) Atr=03(Int.) MxPS=   8 Ivl=32ms
  I:  If#= 1 Alt= 0 #EPs= 2 Cls=0a(data ) Sub=00 Prot=00 Driver=acm
  E:  Ad=81(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms
  E:  Ad=02(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms

If the host side Linux system is configured properly, the ACM driver
should be loaded automatically.  The command "lsmod" should show the
"acm" module is loaded.

Linux host Generic USB Serial 설치

217-255

Linux generic USB serial driver를 사용하려면 host kernel에서 Host-side USB, USB Serial Converter support, USB Generic Serial Driver를 활성화해야 합니다.

`use_acm=0` 장치를 연결하면 debugfs 출력에서 vendor-specific device class와 bulk IN/OUT endpoint를 가진 단일 data interface로 보입니다.

generic driver가 gadget serial 장치를 인식하도록 VID `0x0525`와 PID `0xA4A6`을 명시적으로 등록해야 합니다.

현재 방식은 `echo 0x0525 0xA4A6 > /sys/bus/usb-serial/drivers/generic/new_id`로 dynamic ID를 추가하는 것입니다.

구형 방식은 `modprobe usbserial vendor=0x0525 product=0xA4A6` module parameter를 사용합니다.

정상 연결되면 system log에 `Gadget Serial converter now attached to ttyUSB0`과 비슷한 메시지가 기록됩니다.

Generic serial descriptor 예
항목예제 값
Device classff (vendor-specific)
Vendor/Product0525:a4a6
Interfaces1 data interface
EndpointsBulk IN 81, Bulk OUT 02
Host driverserial / usbserial generic
TTY nodettyUSB0

vendor-specific bulk mode의 debugfs 핵심 값입니다.

Generic driver에 VID/PID 등록
g_serial을 use_acm=0으로 적재Host에 vendor-specific USB 장치 연결generic/new_id에 0x0525 0xA4A6 기록usbserial generic driver가 interface probeSystem log에 converter attachment 기록/dev/ttyUSB0 생성

새 ID 등록에서 ttyUSB0 연결까지의 흐름입니다.

Installing the Linux Host Generic USB Serial Driver
---------------------------------------------------
To use the Linux generic USB serial driver you must configure the
Linux host side kernel for "Support for Host-side USB", for "USB
Serial Converter support", and for the "USB Generic Serial Driver".

Once the gadget serial driver is loaded and the USB device connected
to the Linux host with a USB cable, the host system should recognize
the gadget serial device.  For example, the command::

  cat /sys/kernel/debug/usb/devices

should show something like this:::

  T:  Bus=01 Lev=01 Prnt=01 Port=01 Cnt=02 Dev#=  6 Spd=480 MxCh= 0
  D:  Ver= 2.00 Cls=ff(vend.) Sub=00 Prot=00 MxPS=64 #Cfgs=  1
  P:  Vendor=0525 ProdID=a4a6 Rev= 2.01
  S:  Manufacturer=Linux 2.6.8.1 with net2280
  S:  Product=Gadget Serial
  S:  SerialNumber=0
  C:* #Ifs= 1 Cfg#= 1 Atr=c0 MxPwr=  2mA
  I:  If#= 0 Alt= 0 #EPs= 2 Cls=0a(data ) Sub=00 Prot=00 Driver=serial
  E:  Ad=81(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms
  E:  Ad=02(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms

You must load the usbserial driver and explicitly set its parameters
to configure it to recognize the gadget serial device, like this::

  echo 0x0525 0xA4A6 >/sys/bus/usb-serial/drivers/generic/new_id

The legacy way is to use module parameters::

  modprobe usbserial vendor=0x0525 product=0xA4A6

If everything is working, usbserial will print a message in the
system log saying something like "Gadget Serial converter now
attached to ttyUSB0".

Minicom 또는 HyperTerminal 시험

256-289

gadget driver와 host driver를 모두 설치하고 USB cable을 연결하면 두 시스템 사이에서 serial communication을 시험할 수 있습니다.

gadget 쪽에서는 `minicom -s`를 실행하고 Serial Device를 문서의 `/dev/ttygserial`로 설정합니다. 현재 설명 앞부분의 실제 node는 `/dev/ttyGS0`이므로 환경에서 생성된 node 이름을 확인해야 합니다.

baud rate 9600, data bit 8, parity none, stop bit 1로 설정하지만 USB gadget serial에서는 이 값들이 대부분 중요하지 않습니다. Modem and dialing의 modem·dialing string은 모두 지웁니다.

Linux ACM host는 `/dev/ttyACM0`, Linux generic serial host는 `/dev/ttyUSB0`을 사용합니다. 같은 종류의 장치가 이미 있으면 번호가 달라질 수 있습니다.

Windows host는 Gadget Serial에 할당된 COM port로 새 HyperTerminal session을 만듭니다. Port Settings는 연결할 때 자동 설정되므로 기본값을 유지할 수 있습니다.

양쪽 terminal을 실행한 뒤 gadget 쪽에 입력한 문자가 host 창에 나타나고 host 쪽 입력도 gadget 창에 나타나는지 확인합니다.

운영체제별 terminal 설정
위치프로그램Serial device
Gadget Linuxminicom/dev/ttyGS0 또는 환경의 gadget TTY
Linux host ACMminicom/dev/ttyACM0
Linux host genericminicom/dev/ttyUSB0
Windows host ACMHyperTerminalGadget Serial COM port

각 쪽에서 선택할 serial device와 프로그램입니다.

Testing with Minicom or HyperTerminal
-------------------------------------
Once the gadget serial driver and the host driver are both installed,
and a USB cable connects the gadget device to the host, you should
be able to communicate over USB between the gadget and host systems.
You can use minicom or HyperTerminal to try this out.

On the gadget side run "minicom -s" to configure a new minicom
session.  Under "Serial port setup" set "/dev/ttygserial" as the
"Serial Device".  Set baud rate, data bits, parity, and stop bits,
to 9600, 8, none, and 1--these settings mostly do not matter.
Under "Modem and dialing" erase all the modem and dialing strings.

On a Linux host running the ACM driver, configure minicom similarly
but use "/dev/ttyACM0" as the "Serial Device".  (If you have other
ACM devices connected, change the device name appropriately.)

On a Linux host running the USB generic serial driver, configure
minicom similarly, but use "/dev/ttyUSB0" as the "Serial Device".
(If you have other USB serial devices connected, change the device
name appropriately.)

On a Windows host configure a new HyperTerminal session to use the
COM port assigned to Gadget Serial.  The "Port Settings" will be
set automatically when HyperTerminal connects to the gadget serial
device, so you can leave them set to the default values--these
settings mostly do not matter.

With minicom configured and running on the gadget side and with
minicom or HyperTerminal configured and running on the host side,
you should be able to send data back and forth between the gadget
side and host side systems.  Anything you type on the terminal
window on the gadget side should appear in the terminal window on
the host side and vice versa.