esp32/machine_uart: Change default UART(1) pins on ESP32 with SPIRAM.

SPIRAM usually uses GPIO 9 and 10 on ESP32, so don't use them as default
UART pins.

Fixes issue #18544.

Signed-off-by: Damien George <damien@micropython.org>
This commit is contained in:
Damien George
2025-12-11 11:58:42 +11:00
parent b105677ac4
commit 85a15f995c
2 changed files with 9 additions and 0 deletions

View File

@@ -380,6 +380,9 @@ tx 1 10 17
rx 3 9 16
===== ===== ===== =====
On ESP32 with SPIRAM, the default pins for UART1 are ``tx=5`` and ``rx=4``
to avoid possible conflicts with the SPIRAM pins.
PWM (pulse width modulation)
----------------------------

View File

@@ -278,8 +278,14 @@ static void mp_machine_uart_init_helper(machine_uart_obj_t *self, size_t n_args,
self->tx = UART_PIN_NO_CHANGE; // GPIO 1
break;
case UART_NUM_1:
#if CONFIG_IDF_TARGET_ESP32 && CONFIG_SPIRAM
// ESP32 usually uses pins 9 and 10 for SPIRAM bus, so avoid those pins as defaults.
self->rx = 4;
self->tx = 5;
#else
self->rx = 9;
self->tx = 10;
#endif
break;
#if SOC_UART_HP_NUM > 2
case UART_NUM_2: