ESP32-C6, ESP32-S3, etc.: MICROPY_HW_ENABLE_UART_REPL should be disabled for boards that have both direct USB and UART connectors
Description
On many ESP32 boards, there are two USB connectors: one connected directly to the MCU and the other connected via a USB/UART bridge chip.
The default ESP32 build for these boards puts the REPL on both ports, making it impossible to use the USB/UART connector as an independent UART for other purposes.
See discussion at #17633 .
Code Size
No response
Implementation
I hope the MicroPython maintainers or community will implement this feature
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.