Skip to content

Commit 85a15f9

Browse files
committed
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>
1 parent b105677 commit 85a15f9

2 files changed

Lines changed: 9 additions & 0 deletions

File tree

docs/esp32/quickref.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -380,6 +380,9 @@ tx 1 10 17
380380
rx 3 9 16
381381
===== ===== ===== =====
382382

383+
On ESP32 with SPIRAM, the default pins for UART1 are ``tx=5`` and ``rx=4``
384+
to avoid possible conflicts with the SPIRAM pins.
385+
383386
PWM (pulse width modulation)
384387
----------------------------
385388

ports/esp32/machine_uart.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,8 +278,14 @@ static void mp_machine_uart_init_helper(machine_uart_obj_t *self, size_t n_args,
278278
self->tx = UART_PIN_NO_CHANGE; // GPIO 1
279279
break;
280280
case UART_NUM_1:
281+
#if CONFIG_IDF_TARGET_ESP32 && CONFIG_SPIRAM
282+
// ESP32 usually uses pins 9 and 10 for SPIRAM bus, so avoid those pins as defaults.
283+
self->rx = 4;
284+
self->tx = 5;
285+
#else
281286
self->rx = 9;
282287
self->tx = 10;
288+
#endif
283289
break;
284290
#if SOC_UART_HP_NUM > 2
285291
case UART_NUM_2:

0 commit comments

Comments
 (0)