요약·해설과 원문, 전문 번역을 서로 분리했습니다. API 이름, symbol, source path는 원문 표기를 사용합니다.
1. 요약·해설
원문의 핵심 논리와 kernel programming 관점의 보충 설명입니다. 아래의 전문 번역과는 별도로 작성했습니다.
2. 영어 원문 전체
번역 기준이 된 Linux v6.18.37 원문입니다. 줄 번호는 이 버전의 파일 좌표입니다.
원문 전체 펼치기
===============================
Linux Gadget Serial Driver v2.0
===============================
11/20/2004
(updated 8-May-2008 for v2.3)
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.
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.
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.
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.
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.
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".
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.
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".
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.
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 이메일로 연락합니다.
라이선스, 보증과 저작권 정보를 구분했습니다.
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-53gadget 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를 생성해야 합니다.
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-107gadget 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 장치의 여러 기능을 아직 처리하지 않습니다.
원문 ASCII 도식을 동일한 계층과 연결 순서의 흐름으로 재구성했습니다.
호스트가 장치를 인식하는 두 방식입니다.
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-130gadget 쪽 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에 추가합니다.
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-154mdev 또는 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를 사용합니다.
각 위치와 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-184Windows 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을 선택합니다.
문서에 기록된 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-216Linux 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`을 확인할 수 있습니다.
원문 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-255Linux 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`과 비슷한 메시지가 기록됩니다.
vendor-specific bulk mode의 debugfs 핵심 값입니다.
새 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-289gadget 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 창에 나타나는지 확인합니다.
각 쪽에서 선택할 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.
요약·해설
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로 양방향 전송을 시험합니다.