Skip to content

Commit

Permalink
esp32: Add MICROPY_HW_ENABLE_UART_REPL and enable on generic S2/S3.
Browse files Browse the repository at this point in the history
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 <damien@micropython.org>
  • Loading branch information
dpgeorge committed Apr 13, 2022
1 parent d242a9b commit 79cbc53
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 2 deletions.
3 changes: 3 additions & 0 deletions ports/esp32/boards/GENERIC_S2/mpconfigboard.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,6 @@

#define MICROPY_PY_BLUETOOTH (0)
#define MICROPY_HW_ENABLE_SDCARD (0)

// Enable UART REPL for modules that have an external USB-UART and don't use native USB.
#define MICROPY_HW_ENABLE_UART_REPL (1)
3 changes: 3 additions & 0 deletions ports/esp32/boards/GENERIC_S3/mpconfigboard.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,8 @@

#define MICROPY_PY_MACHINE_DAC (0)

// Enable UART REPL for modules that have an external USB-UART and don't use native USB.
#define MICROPY_HW_ENABLE_UART_REPL (1)

#define MICROPY_HW_I2C0_SCL (9)
#define MICROPY_HW_I2C0_SDA (8)
3 changes: 3 additions & 0 deletions ports/esp32/boards/GENERIC_S3_SPIRAM/mpconfigboard.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,8 @@
#define MICROPY_PY_BLUETOOTH (0)
#define MICROPY_PY_MACHINE_DAC (0)

// Enable UART REPL for modules that have an external USB-UART and don't use native USB.
#define MICROPY_HW_ENABLE_UART_REPL (1)

#define MICROPY_HW_I2C0_SCL (9)
#define MICROPY_HW_I2C0_SDA (8)
3 changes: 2 additions & 1 deletion ports/esp32/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,8 @@ void mp_task(void *pvParameter) {
usb_init();
#elif CONFIG_ESP_CONSOLE_USB_SERIAL_JTAG
usb_serial_jtag_init();
#else
#endif
#if MICROPY_HW_ENABLE_UART_REPL
uart_stdout_init();
#endif
machine_init();
Expand Down
3 changes: 2 additions & 1 deletion ports/esp32/mphalport.c
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,8 @@ void mp_hal_stdout_tx_strn(const char *str, size_t len) {
usb_tx_strn(str, len);
#elif CONFIG_ESP_CONSOLE_USB_SERIAL_JTAG
usb_serial_jtag_tx_strn(str, len);
#else
#endif
#if MICROPY_HW_ENABLE_UART_REPL
uart_stdout_tx_strn(str, len);
#endif
if (release_gil) {
Expand Down
5 changes: 5 additions & 0 deletions ports/esp32/uart.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@
#ifndef MICROPY_INCLUDED_ESP32_UART_H
#define MICROPY_INCLUDED_ESP32_UART_H

// Whether to enable the REPL on a UART.
#ifndef MICROPY_HW_ENABLE_UART_REPL
#define MICROPY_HW_ENABLE_UART_REPL (!CONFIG_USB_ENABLED && !CONFIG_ESP_CONSOLE_USB_SERIAL_JTAG)
#endif

#ifndef MICROPY_HW_UART_REPL
#define MICROPY_HW_UART_REPL (UART_NUM_0)
#endif
Expand Down

0 comments on commit 79cbc53

Please sign in to comment.