← index #17570PR #15727
Likely Duplicate · medium · value 3.443
QUERY · ISSUE

esp32S3 The USB function is occupied by USB jtag/serial (VID_303A&PID_1001)

openby absn12opened 2025-06-27updated 2026-03-12
bugport-esp32

Port, board and/or hardware

esp32S3

MicroPython version

MicroPython v1.24.1

Reproduction

No, I've provided everything above.

Expected behaviour

Like 1.19, there is no need to plug or unplug the USB cable, and USB related functions can be used normally

Observed behaviour

on win10
After connecting the USB cable and booting up, the pc system will generate a USB jtag port. After entering micropython, all USBs do not work (such as my microPython USB CDC repl), and the USB jtag port will continue to exist (not work,VID_303A&PID_1001). Only by plugging and unplugging the USB cable once can the relevant USB functions work properly
V1.19 does not have this issue (but on 1.19, IDF's bootloder performs some pin detection to enter different OTA apps. detection stays for >200ms, the same issue will also occur)

Additional Information

No, I've provided everything above.

Code of Conduct

Yes, I agree

CANDIDATE · PULL REQUEST

esp32: Fix ESP32-C3 usb serial/jtag on IDF v5.0.4, clean up native USB-CDC

mergedby projectgusopened 2024-08-27updated 2024-09-03
port-esp32

Summary

  • Closes #15701 which is a regression introduced with #15523 when using IDF v5.0.x.
  • Fixes a lower impact regression from the same PR where on ESP-IDF >= 5.1 the ESP32-S3 would come up using the USB Serial/JTAG interface instead of native USB. The obvious fixes for the first regression all made this second regression appear on all ESP-IDF versions.
  • Overall the logic for how the USB function is assigned were a bit hard to follow, and depended on some default ESP-IDF config selections.
  • There are now two new MicroPython config macros, fully independent of ESP-IDF config:
    • MICROPY_HW_USB_CDC for native USB-CDC which defaults to 1 on supported SoCs (currently ESP32-S2,S3).
    • MICROPY_HW_ESP_USB_SERIAL_JTAG to use the serial/JTAG peripheral which defaults to 1 on supported SoCs that don't have native USB-CDC enabled.
  • Combined with the existing MICROPY_HW_ENABLE_UART_REPL this gives full control in the MicroPython board header over which serial options are enabled. This somewhat helps with #14217 although it's not a fix for it.
  • Support in the code for setting CONFIG_ESP_CONSOLE_USB_CDC on S3 has been removed. This already didn't work on master, and no boards used it. Getting both ESP-IDF stdio and MicroPython stdio on the USB-CDC is actually now possible with this PR (didn't work without it), but requires setting both the sdkconfig option and the MicroPython build option independently.

Testing

Build and verified REPL works with ESP-IDF v5.0.4 and v5.2.2 on:

  • ESP32-C3 DevKitC (external USB/serial)
  • Seeed XIAO C3 (internal USB/serial)
  • ESP32-S3 DevKitC (both "UART" and "native USB" ports)

Trade-offs and Alternatives

We could drop ESP-IDF v5.0.4 support now, but nightly builds have only just switched over so good to wait a little while and see if any other issues crop up. There is still the S3 issue to resolve.

There is a weird inconsistency where ESP-IDF stdout (and logs) go to different places than MicroPython stdout. However that's already the case on master and this PR makes it a little easier to reason about (because the ESP-IDF stdio config and the MicroPython stdio config are now fully independent of each other). If necessary then we could add a hook that routes ESP-IDF stdout into MicroPython stdout as part of app_main(), but I think safe to leave for now.

Future Work

  • Disabling both USB config macros doesn't disable the USB port after MicroPython starts (currently, or after this change). PR to follow for this.

This work was funded through GitHub Sponsors.

Keyboard

j / / n
next pair
k / / p
previous pair
1 / / h
show query pane
2 / / l
show candidate pane
c
copy suggested comment
r
toggle reasoning
g i
go to index
?
show this help
esc
close overlays

press ? or esc to close

copied