Skip to content

Commit b311a32

Browse files
committed
esp32: Make default SDMMC slot configurable.
Resolves part of micropython#18984. On ESP32-P4, SDMMC slot 0 supports SDIO 3.0, and is liekly the default for most boards. MICROPY_HW_SDMMC_DEFAULT_SLOT can be set in mpconfigboard.h to change default slot. Signed-off-by: Dryw Wade <dryw.wade@sparkfun.com>
1 parent 2dc2e30 commit b311a32

2 files changed

Lines changed: 8 additions & 1 deletion

File tree

ports/esp32/machine_sdcard.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ static mp_obj_t machine_sdcard_make_new(const mp_obj_type_t *type, size_t n_args
214214
ARG_freq,
215215
};
216216
#if SOC_SDMMC_HOST_SUPPORTED
217-
static const int DEFAULT_SLOT = 1;
217+
static const int DEFAULT_SLOT = MICROPY_HW_SDMMC_DEFAULT_SLOT;
218218
#else
219219
static const int DEFAULT_SLOT = SD_SLOT_MAX;
220220
#endif

ports/esp32/mpconfigport.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,13 @@
195195
#ifndef MICROPY_HW_ENABLE_SDCARD
196196
#define MICROPY_HW_ENABLE_SDCARD (1)
197197
#endif
198+
#ifndef MICROPY_HW_SDMMC_DEFAULT_SLOT
199+
#if CONFIG_IDF_TARGET_ESP32P4
200+
#define MICROPY_HW_SDMMC_DEFAULT_SLOT (0)
201+
#else
202+
#define MICROPY_HW_SDMMC_DEFAULT_SLOT (1)
203+
#endif
204+
#endif
198205
#define MICROPY_HW_SOFTSPI_MIN_DELAY (0)
199206
#define MICROPY_HW_SOFTSPI_MAX_BAUDRATE (esp_rom_get_cpu_ticks_per_us() * 1000000 / 200) // roughly
200207
#ifndef MICROPY_HW_ESP_NEW_I2C_DRIVER

0 commit comments

Comments
 (0)