samples/subsys/usb/cdc_acm/README.html · samples/subsys/usb/cdc_acm/README.rst 공식 원문 ↗

Zephyr 3.7.0 · Samples · USB CDC-ACM

USB CDC-ACM

Linux ttyACM device를 열어 serial echo를 확인하고 udev rule로 자동 probing을 막습니다.

Official pathsamples/subsys/usb/cdc_acm/README.html
Source filesamples/subsys/usb/cdc_acm/README.rst
Source versionZephyr 3.7.0
TranslationFull · reviewed

본문 기준: Zephyr 3.7.0 LTS3 · 이후 유지보수 패치는 별도입니다.

Part 1

요약·해설

Reel Board build, dmesg 탐지, baud rate와 echo path를 단계별로 설명합니다.

Class

CDC Abstract Control Model

Device

ttyACM1

Behavior

Same-port echo

Part 2

접을 수 있는 영어 원문 전체

영어 원문 전체 펼치기
원문 SHA-256 DC4EEAD5F2E333A3EBF906EAD6E16D6B3900D6BF58AD606572C64684D3D59BE1
.. zephyr:code-sample:: usb-cdc-acm
   :name: USB CDC-ACM
   :relevant-api: usbd_api _usb_device_core_api uart_interface

   Use USB CDC-ACM driver to implement a serial port echo.

Overview
********

This sample app demonstrates use of a USB Communication Device Class (CDC)
Abstract Control Model (ACM) driver provided by the Zephyr project.
Received data from the serial port is echoed back to the same port
provided by this driver.
This sample can be found under :zephyr_file:`samples/subsys/usb/cdc_acm` in the
Zephyr project tree.

Requirements
************

This project requires an USB device driver, which is available for multiple
boards supported in Zephyr.

Building and Running
********************

Reel Board
===========

To see the console output of the app, open a serial port emulator and
attach it to the USB to TTL Serial cable. Build and flash the project:

.. zephyr-app-commands::
   :zephyr-app: samples/subsys/usb/cdc_acm
   :board: reel_board
   :goals: flash
   :compact:

Running
=======

Plug the board into a host device, for example, a PC running Linux.
The board will be detected as shown by the Linux dmesg command:

.. code-block:: console

   usb 9-1: new full-speed USB device number 112 using uhci_hcd
   usb 9-1: New USB device found, idVendor=8086, idProduct=f8a1
   usb 9-1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
   usb 9-1: Product: CDC-ACM
   usb 9-1: Manufacturer: Intel
   usb 9-1: SerialNumber: 00.01
   cdc_acm 9-1:1.0: ttyACM1: USB ACM device

The app prints on serial output (UART1), used for the console:

.. code-block:: console

   Wait for DTR

Open a serial port emulator, for example minicom
and attach it to detected CDC ACM device:

.. code-block:: console

   minicom --device /dev/ttyACM1

The app should respond on serial output with:

.. code-block:: console

   DTR set, start test
   Baudrate detected: 115200

And on ttyACM device, provided by zephyr USB device stack:

.. code-block:: console

   Send characters to the UART device
   Characters read:

The characters entered in serial port emulator will be echoed back.

Troubleshooting
===============

If the ModemManager runs on your operating system, it will try
to access the CDC ACM device and maybe you can see several characters
including "AT" on the terminal attached to the CDC ACM device.
You can add or extend the udev rule for your board to inform
ModemManager to skip the CDC ACM device.
For this example, it would look like this:

.. code-block:: none

   ATTRS{idVendor}=="8086" ATTRS{idProduct}=="f8a1", ENV{ID_MM_DEVICE_IGNORE}="1"

You can use
``/lib/udev/rules.d/77-mm-usb-device-blacklist.rules`` as reference.

Part 3

한국어 전문 번역

개요

이 sample application은 Zephyr project가 제공하는 USB Communication Device Class(CDC) Abstract Control Model(ACM) driver 사용법을 보여 줍니다. Driver가 제공하는 serial port로 수신한 data를 같은 port로 다시 보내는 echo 장치를 구현합니다.

Sample source는 Zephyr project tree의 samples/subsys/usb/cdc_acm에서 찾을 수 있습니다.

요구 사항

이 project에는 USB device driver가 필요합니다. Zephyr가 지원하는 여러 board에서 해당 driver를 사용할 수 있습니다.

빌드 및 실행

Reel Board

Application의 console output을 보려면 serial port emulator를 열어 USB-to-TTL serial cable에 연결합니다. 이어서 다음 command로 project를 build하고 flash합니다.

west build -b reel_board samples/subsys/usb/cdc_acm
west flash

실행

Board를 Linux PC 같은 host device에 연결합니다. Linux의 dmesg에는 다음과 같이 CDC-ACM USB device와 ttyACM1이 감지됩니다.

usb 9-1: new full-speed USB device number 112 using uhci_hcd
usb 9-1: New USB device found, idVendor=8086, idProduct=f8a1
usb 9-1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
usb 9-1: Product: CDC-ACM
usb 9-1: Manufacturer: Intel
usb 9-1: SerialNumber: 00.01
cdc_acm 9-1:1.0: ttyACM1: USB ACM device

Console로 사용하는 UART1 serial output에는 application이 DTR(Data Terminal Ready) 신호를 기다린다는 message가 나타납니다.

Wait for DTR

Minicom 같은 serial port emulator를 열어 감지된 CDC ACM device에 연결합니다.

minicom --device /dev/ttyACM1

DTR이 설정되면 application의 serial output에는 test 시작과 감지된 baud rate가 표시됩니다.

DTR set, start test
Baudrate detected: 115200

Zephyr USB device stack이 제공하는 ttyACM device에는 다음 prompt가 표시됩니다.

Send characters to the UART device
Characters read:

Serial port emulator에 입력한 문자는 같은 port로 echo되어 되돌아옵니다.

문제 해결

Operating system에서 ModemManager가 실행 중이면 CDC ACM device에 자동으로 접근합니다. 그 결과 terminal에 AT를 포함한 여러 문자가 보일 수 있습니다.

Board용 udev rule을 추가하거나 확장해 ModemManager가 이 CDC ACM device를 건너뛰도록 지정할 수 있습니다. 이 example에는 다음 rule을 사용합니다.

ATTRS{idVendor}=="8086" ATTRS{idProduct}=="f8a1", ENV{ID_MM_DEVICE_IGNORE}="1"

Rule 작성 형식은 /lib/udev/rules.d/77-mm-usb-device-blacklist.rules를 참고할 수 있습니다.

Source

출처

영어 원문에는 문단, 문서 지시문, 표, 코드, 코드 심벌, 경로를 그대로 보존했습니다.