You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: doc/src/programmers-guide.md
+32Lines changed: 32 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1985,6 +1985,38 @@ ok = uart:close(UART)
1985
1985
1986
1986
Once the UART driver is closed, any calls to `uart` functions using a reference to the UART driver instance should return with the value `{error, noproc}`.
1987
1987
1988
+
### USB CDC
1989
+
1990
+
On platforms with a USB device controller, AtomVM can expose a USB CDC (Communications Device Class) ACM interface, which appears on the host as a virtual serial port (`/dev/ttyACMx` on Linux, `/dev/cu.usbmodemXXXX` on macOS, a COM port on Windows). The same byte-stream interface can be used as a UART replacement (logs, REPLs, custom serial protocols) or as the transport for [distribution over USB CDC](./distributed-erlang.md#usb-distribution).
1991
+
1992
+
The Erlang-side API is the platform-specific `usb_cdc` module ([`libs/avm_esp32/src/usb_cdc.erl`](https://github.com/atomvm/AtomVM/blob/main/libs/avm_esp32/src/usb_cdc.erl), [`libs/avm_rp2/src/usb_cdc.erl`](https://github.com/atomvm/AtomVM/blob/main/libs/avm_rp2/src/usb_cdc.erl), [`libs/avm_stm32/src/usb_cdc.erl`](https://github.com/atomvm/AtomVM/blob/main/libs/avm_stm32/src/usb_cdc.erl)). It mirrors the `uart` API: `open/1,2`, `read/1,2`, `write/2`, `close/1`.
1993
+
1994
+
#### Platform support and build configuration
1995
+
1996
+
| Platform | Notes |
1997
+
|----------|-------|
1998
+
| ESP32 | Enable `CONFIG_USE_USB_SERIAL` and `CONFIG_AVM_ENABLE_USB_CDC_PORT_DRIVER` in `menuconfig`. The ESP-IDF `esp_tinyusb` component must be installed. |
1999
+
| RP2040/RP2350 | Set `-DAVM_USB_CDC_PORT_DRIVER_ENABLED=ON` in CMake. You must also disable stdio over USB (`pico_enable_stdio_usb(AtomVM 0)`) so that the CDC interface is available for the port driver. |
2000
+
| STM32 | Set `-DAVM_USB_CDC_PORT_DRIVER_ENABLED=ON` in CMake. TinyUSB is fetched automatically by default; set the `TINYUSB_PATH` environment variable to use a local checkout. |
2001
+
2002
+
#### USB VID/PID and string descriptors
2003
+
2004
+
USB CDC ACM is a standard device class, so on chip vendors that ship their own VID with a blessed "standard CDC" PID arrangement, AtomVM uses that pair by default and no override is required for the device class to be correctly identified by the host:
2005
+
2006
+
- **RP2**: `0x2E8A:0x0009` Raspberry Pi'sregistered"Pico SDK CDC UART"PID, chip-agnostic (coversRP2040andRP2350), perthe [raspberrypi/usb-pidregistry](https://github.com/raspberrypi/usb-pid). Thesamepairisusedbypico-sdk's `stdio_usb` and by any other firmware exposing standard CDC under Pi'sVID, sohost-sidetoolingcannotdistinguishAtomVM-PicofromotherCDCfirmwaresonthispair. NotethatbootromPIDs (`0x0003` onRP2040, `0x000F` onRP2350) mustNOTbereused.
2007
+
-**ESP32**: `0x303A` (EspressifVID) +TinyUSB-derivedclass-encodedPID, viathe `esp_tinyusb` defaults (`CONFIG_TINYUSB_DESC_USE_ESPRESSIF_VID=y`, `CONFIG_TINYUSB_DESC_USE_DEFAULT_PID=y`). [Espressif's USB VID/PID guidance](https://docs.espressif.com/projects/esp-iot-solution/en/latest/usb/usb_overview/usb_vid_pid.html) explicitly states that USB standard-class devices built on TinyUSB do not need a separate PID under Espressif'sVID.
-**RP2/STM32**: `-DAVM_USB_CDC_VID=0xXXXX-DAVM_USB_CDC_PID=0xXXXX` inCMake. RP2buildsmayregisteraproject-specificPIDforfreeunderPi's VID via the [usb-pid registry](https://github.com/raspberrypi/usb-pid).
2013
+
- **ESP32**: set `CONFIG_TINYUSB_DESC_USE_ESPRESSIF_VID=n` / `CONFIG_TINYUSB_DESC_USE_DEFAULT_PID=n` and provide `CONFIG_TINYUSB_DESC_CUSTOM_VID` / `CONFIG_TINYUSB_DESC_CUSTOM_PID` in `menuconfig`.
2014
+
2015
+
The string descriptors can be overridden the same way:
0 commit comments