Skip to content

Commit fe9eaf1

Browse files
committed
esp32: Add MICROPY_HW_ENABLE_UART_REPL and enable on generic S2/S3.
Some S2/S3 modules don't use the native USB interface but instead have an external USB-UART. To make the GENERIC_S3/S3 firmware work on these boards the UART REPL is enabled in addition to the native USB CDC REPL. Fixes issues micropython#8418 and micropython#8524. Signed-off-by: Damien George <[email protected]>
1 parent be25e33 commit fe9eaf1

File tree

6 files changed

+18
-2
lines changed

6 files changed

+18
-2
lines changed

ports/esp32/boards/GENERIC_S2/mpconfigboard.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,6 @@
33

44
#define MICROPY_PY_BLUETOOTH (0)
55
#define MICROPY_HW_ENABLE_SDCARD (0)
6+
7+
// Enable UART REPL for modules that have an external USB-UART and don't use native USB.
8+
#define MICROPY_HW_ENABLE_UART_REPL (1)

ports/esp32/boards/GENERIC_S3/mpconfigboard.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,8 @@
33

44
#define MICROPY_PY_MACHINE_DAC (0)
55

6+
// Enable UART REPL for modules that have an external USB-UART and don't use native USB.
7+
#define MICROPY_HW_ENABLE_UART_REPL (1)
8+
69
#define MICROPY_HW_I2C0_SCL (9)
710
#define MICROPY_HW_I2C0_SDA (8)

ports/esp32/boards/GENERIC_S3_SPIRAM/mpconfigboard.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,8 @@
44
#define MICROPY_PY_BLUETOOTH (0)
55
#define MICROPY_PY_MACHINE_DAC (0)
66

7+
// Enable UART REPL for modules that have an external USB-UART and don't use native USB.
8+
#define MICROPY_HW_ENABLE_UART_REPL (1)
9+
710
#define MICROPY_HW_I2C0_SCL (9)
811
#define MICROPY_HW_I2C0_SDA (8)

ports/esp32/main.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,8 @@ void mp_task(void *pvParameter) {
9292
usb_init();
9393
#elif CONFIG_ESP_CONSOLE_USB_SERIAL_JTAG
9494
usb_serial_jtag_init();
95-
#else
95+
#endif
96+
#if MICROPY_HW_ENABLE_UART_REPL
9697
uart_stdout_init();
9798
#endif
9899
machine_init();

ports/esp32/mphalport.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,8 @@ void mp_hal_stdout_tx_strn(const char *str, size_t len) {
111111
usb_tx_strn(str, len);
112112
#elif CONFIG_ESP_CONSOLE_USB_SERIAL_JTAG
113113
usb_serial_jtag_tx_strn(str, len);
114-
#else
114+
#endif
115+
#if MICROPY_HW_ENABLE_UART_REPL
115116
uart_stdout_tx_strn(str, len);
116117
#endif
117118
if (release_gil) {

ports/esp32/uart.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,11 @@
2828
#ifndef MICROPY_INCLUDED_ESP32_UART_H
2929
#define MICROPY_INCLUDED_ESP32_UART_H
3030

31+
// Whether to enable the REPL on a UART.
32+
#ifndef MICROPY_HW_ENABLE_UART_REPL
33+
#define MICROPY_HW_ENABLE_UART_REPL (!CONFIG_USB_ENABLED && !CONFIG_ESP_CONSOLE_USB_SERIAL_JTAG)
34+
#endif
35+
3136
#ifndef MICROPY_HW_UART_REPL
3237
#define MICROPY_HW_UART_REPL (UART_NUM_0)
3338
#endif

0 commit comments

Comments
 (0)