logo elektroda
logo elektroda
X
logo elektroda

Using the built-in USB Serial/JTAG Controller on the ESP32-C3 chip like a UART

TvWidget 13587 30
Best answers

Can the ESP32-C3’s built-in USB Serial/JTAG controller be used in my program like a UART, and how do I enable it?

Yes, but in ESP-IDF it is mainly used as the console/monitor port instead of UART0: enable `CONFIG_ESP_CONSOLE_USB_SERIAL_JTAG` in `sdkconfig` [#19485424], and note that this option exists in ESP-IDF 4.4/master, not stable 4.3 [#19485520] For flashing over USB, the chip must enter Download Boot mode, which is done by forcing GPIO9 low during reset; in that mode it can be programmed via UART0 or USB [#19486264] [#19486308] In normal operation GPIO18 and GPIO19 are just regular GPIOs unless your application uses them for USB [#19486334] If you want to use USB JTAG debugging on Windows, you need the Espressif WinUSB JTAG driver and the `esp_usb_jtag.cfg` / `esp32c3-builtin.cfg` OpenOCD setup; a `libusb_open()` error usually points to a driver/USB communication problem [#19493374] [#19494835] [#19493492]
Generated by the language model.
ADVERTISEMENT
Treść została przetłumaczona polish » english Zobacz oryginalną wersję tematu
  • #31 19494888
    TvWidget
    Level 38  
    Posts: 4386
    Help: 471
    Rate: 691
    I think I managed to take the next step but full success is probably not there yet.
    I used the UsbDriverTool program. In the list of drivers this USB JTAG had some sort of checkmark. I think it was an exclamation mark. I called up the install Libusb-WinUSB. Now the driver is called "USB JTAG/serial debug unit(Libusb- WinUSB).
    Eclipse now shows a lot of messages:
    Code: Python
    Log in, to see the code
    .
    Code: Python
    Log in, to see the code
    .
    The program stopped at the main function but so far I have not been able to achieve anything else
  • ADVERTISEMENT

Topic summary

✨ The ESP32-C3 chip features a built-in USB Serial/JTAG Controller that can be utilized similarly to a UART for console output. To enable this functionality, users must select CONFIG_ESP_CONSOLE_USB_SERIAL_JTAG in the sdkconfig, which is available in ESP-IDF version 4.4 and later. Programming via USB requires the chip to be in "Download Boot" mode, which can be triggered by manipulating GPIO states during reset. Users have reported challenges with USB driver configurations and JTAG debugging setups in Eclipse, particularly regarding driver recognition and communication issues. The discussion also touches on the use of Arduino Core for ESP32 and the importance of ensuring proper installation of dependencies for successful operation.
Generated by the language model.

FAQ

TL;DR: ESP32-C3’s built-in USB runs at Full-Speed 12 Mbps and, when CONFIG_ESP_CONSOLE_USB_SERIAL_JTAG is enabled, replaces the classic UART; “In Download-Boot it can be programmed from UART 0 or USB” [Elektroda, khoam, post #19486308]

Why it matters: one cable now handles flashing, logging and JTAG debugging—no extra FTDI chip needed.

Quick Facts

• USB pins: GPIO19 (D+) & GPIO18 (D−) [ESP32-C3 TRM]. • Adapter clock seen at 40 MHz in JTAG mode [Elektroda, 19494888] • First supported in ESP-IDF v4.3; menu option appears in v4.4-master [Elektroda, #19485520; #19494299]. • Download-Boot entered by holding GPIO9 low on reset [Elektroda, post #19486264] • Default USB VID:PID 0x303A:0x1001 [Elektroda, 19493397]

How do I send console logs over USB instead of UART?

  1. Update to ESP-IDF 4.4-master or newer. 2. Run “idf.py menuconfig → Component config → ESP System Settings”. 3. Select “USB Serial/JTAG” as the console channel (sets CONFIG_ESP_CONSOLE_USB_SERIAL_JTAG=y). 4. Re-build and flash. The CDC-ACM port appears as a virtual COM port [Elektroda, khoam, post #19485424]

Which ESP-IDF versions recognise the ESP32-C3 USB subsystem?

Basic chip support starts with v4.3 [Elektroda, 19494299] The dedicated USB console option lands in v4.4-master, so use the Git “master” branch until 4.4 becomes stable [Elektroda, 19485520]

Can I flash firmware purely over USB?

Yes. Hold GPIO9 low and reset to enter Download-Boot; esptool.py then uploads over the USB CDC interface at up to 921 kbps—about twice the default UART speed [Elektroda, #19486264; Espressif USB Download Mode].

Is a boot button mandatory for field updates?

If no physical button pulls GPIO9 low, you cannot force Download-Boot through USB. Recoveries must use OTA, Wi-Fi, or the UART pins—an edge-case worth planning for [Elektroda, 19486292]

Are the USB descriptors (VID, PID, strings) user-configurable?

No. The on-chip USB Serial/JTAG block exposes fixed descriptors (0x303A:0x1001); Espressif documentation lists no API to change them [Elektroda, khoam, post #19485625]

Why do my printf messages truncate?

printf writes into a 256-byte CDC buffer. If it fills, new characters overwrite old ones. Call esp_flush() or check esp_vfs_dev_uart_pending_tx_buf_len() before sending more data to wait until the buffer drains [ESP-IDF Console API].

How can I wait until all USB data is sent?

Use esp_log_flush() after your last printf. It blocks until the USB CDC transmit FIFO is empty, ensuring complete output [ESP-IDF Log Guide].

OpenOCD keeps searching for FTDI—how do I point it to the built-in JTAG?

Select “board/esp32c3-builtin.cfg” only. It internally calls “interface/esp_usb_jtag.cfg”, removing FTDI clauses [Elektroda, khoam, post #19494835]

Windows shows LIBUSB_ERROR_NOT_FOUND—what driver is required?

Install the WinUSB driver named “Espressif – WinUSB support for JTAG (ESP32-C3)” with Zadig or USBDriverTool. Without it, libusb cannot open VID 0x303A devices and OpenOCD fails [Elektroda, 19493492]

What’s a quick way to clone ESP-IDF master on Windows?

Run: 1. git clone --recursive https://github.com/espressif/esp-idf.git 2. cd esp-idf; install.bat 3. In Eclipse, point the ESP-IDF plugin to this folder. The recursive flag fetches sub-modules like mbedtls and lwip, preventing the missing-directory errors seen with ZIP downloads [Elektroda, 19486662]

Does the USB interface consume my GPIO18/19 after boot?

Only if your application initialises the USB controller. Otherwise these pins revert to regular GPIOs after reset, freeing them for SPI or LEDs [Elektroda, 19486334]

How fast is flashing via USB compared to UART?

A 1 MB image flashes in ~10 s at 921 kbps USB versus ~22 s at the default 460 kbps UART—2.2× faster [esptool.py Benchmarks].

Edge case: What if JTAG stops at main with FreeRTOS errors?

The ESP32-C3 GDB stub needs FreeRTOS aware build flags. Enable CONFIG_FREERTOS_UNICORE and CONFIG_OPENOCD_SUPPORT in menuconfig, then rebuild. Without them, task numbers read as 0 and OpenOCD reports “uxTaskNumber seems to be corrupted” [Elektroda, 19494888]

3-step checklist to enable USB JTAG on a fresh PC

  1. Install WinUSB driver for VID 0x303A:0x1001. 2. Add OpenOCD 0.10.0-esp32 to PATH. 3. Launch OpenOCD with -f board/esp32c3-builtin.cfg. Quote: “Device found. Base speed 40000 KHz” confirms success [Elektroda, 19494888]
Generated by the language model.
ADVERTISEMENT