README.rst
1.. zephyr:code-sample:: usb-cdc-acm
2 :name: USB CDC ACM UART sample
3 :relevant-api: usbd_api uart_interface
4
5 Use USB CDC ACM UART driver to implement a serial port echo.
6
7Overview
8********
9
10This sample app demonstrates use of a USB Communication Device Class (CDC)
11Abstract Control Model (ACM) driver provided by the Zephyr project.
12Received data from the serial port is echoed back to the same port
13provided by this driver.
14
15Requirements
16************
17
18This project requires an USB device driver, which is available for multiple
19boards supported in Zephyr.
20
21Building and Running
22********************
23
24Reel Board
25===========
26
27To see the console output of the app, open a serial port emulator and
28attach it to the USB to TTL Serial cable. Build and flash the project:
29
30.. zephyr-app-commands::
31 :zephyr-app: samples/subsys/usb/cdc_acm
32 :board: reel_board
33 :goals: flash
34 :compact:
35
36Running
37=======
38
39Plug the board into a host device, for example, a PC running Linux.
40The board will be detected as shown by the Linux dmesg command:
41
42.. code-block:: console
43
44 usb 9-1: new full-speed USB device number 112 using uhci_hcd
45 usb 9-1: New USB device found, idVendor=8086, idProduct=f8a1
46 usb 9-1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
47 usb 9-1: Product: CDC-ACM
48 usb 9-1: Manufacturer: Intel
49 usb 9-1: SerialNumber: 00.01
50 cdc_acm 9-1:1.0: ttyACM1: USB ACM device
51
52The app prints on serial output (UART1), used for the console:
53
54.. code-block:: console
55
56 Wait for DTR
57
58Open a serial port emulator, for example minicom
59and attach it to detected CDC ACM device:
60
61.. code-block:: console
62
63 minicom --device /dev/ttyACM1
64
65The app should respond on serial output with:
66
67.. code-block:: console
68
69 DTR set, start test
70 Baudrate detected: 115200
71
72And on ttyACM device, provided by zephyr USB device stack:
73
74.. code-block:: console
75
76 Send characters to the UART device
77 Characters read:
78
79The characters entered in serial port emulator will be echoed back.
80
81Troubleshooting
82===============
83
84If the ModemManager runs on your operating system, it will try
85to access the CDC ACM device and maybe you can see several characters
86including "AT" on the terminal attached to the CDC ACM device.
87You can add or extend the udev rule for your board to inform
88ModemManager to skip the CDC ACM device.
89For this example, it would look like this:
90
91.. code-block:: none
92
93 ATTRS{idVendor}=="8086" ATTRS{idProduct}=="f8a1", ENV{ID_MM_DEVICE_IGNORE}="1"
94