ESP32-S2 2nd usb-serial port
HI
At micropython for ESP32-S2, I'd like to have
secondary USB-serial port (like /dev/ttyACM1 on linux)
which directly maps to board's hardware serial port
RX/TX pins and if possible, few RS232 signaling lines.
Can this (easily) be done?
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.