esp32S3 The USB function is occupied by USB jtag/serial (VID_303A&PID_1001)
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
ports/esp32/usb.c: Allow serial/jtag to be enabled.
Summary
I was having an issue getting USB serial going on an ESP32S3 LilyGO T-Deck, the flavor that is called "Serial/JTAG mode" in Micropython (not the one where there's an explicit serial -> USB chip onboard.)
The REPL appears fine on the UART chip models. But on the T-Deck (and presumably other boards with no explicit UART chip) I cannot see or type into the REPL from the serial monitor.
If i set in mpconfigport.h:
#define MICROPY_HW_USB_CDC (1)
#define MICROPY_HW_ESP_USB_SERIAL_JTAG (1)
I get a compiler error: #error "Invalid build config: Can't enable both native USB and USB Serial/JTAG peripheral". OK, so for the T-Deck I turn off HW_USB_CDC:
#ifdef TDECK
#define MICROPY_HW_USB_CDC (0)
#else
#define MICROPY_HW_USB_CDC (1)
#endif
But then ports/esp32/usb.c has a #ifdef for MICROPY_HW_USB_CDC bracketed around the entire code, including usb_usj_mode which is required in the bootloader. So, if i'm understanding it right -- we can't have both USB_CDC and USB_SERIAL_JTAG on at once. Makes sense. But usb_usj_mode requires USB_CDC to be enabled to switch the PHY back to Serial/JTAG mode. That doesn't make sense to me. So this PR moves the #ifdef out of the way of usb_usj_mode.
Testing
With this, everything compiles fine and I'm able to use mpremote etc to control the T-Deck over Serial/JTAG.