From 616dd97398ea5661f383022827d4fdb7e6838d9b Mon Sep 17 00:00:00 2001 From: armando Date: Fri, 16 May 2025 11:08:05 +0800 Subject: [PATCH 1/2] fix(sd): fixed slot0 requires all pins to be set when using 1bit iomux mode on p4 --- .../esp_driver_sdmmc/src/sd_host_sdmmc.c | 23 ++++++++++++------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/components/esp_driver_sdmmc/src/sd_host_sdmmc.c b/components/esp_driver_sdmmc/src/sd_host_sdmmc.c index 43c19bd96e..e5ab29b84d 100644 --- a/components/esp_driver_sdmmc/src/sd_host_sdmmc.c +++ b/components/esp_driver_sdmmc/src/sd_host_sdmmc.c @@ -1190,14 +1190,21 @@ static esp_err_t sdmmc_slot_io_config(sd_host_sdmmc_slot_t *slot, const sd_host_ if (slot_id == 0) { #if !SDMMC_LL_SLOT_SUPPORT_GPIO_MATRIX(0) - if (use_gpio_matrix && - SDMMC_SLOT0_IOMUX_PIN_NUM_CLK == io_config->clk_io && - SDMMC_SLOT0_IOMUX_PIN_NUM_CMD == io_config->cmd_io && - SDMMC_SLOT0_IOMUX_PIN_NUM_D0 == io_config->d0_io && - SDMMC_SLOT0_IOMUX_PIN_NUM_D1 == io_config->d1_io && - SDMMC_SLOT0_IOMUX_PIN_NUM_D2 == io_config->d2_io && - SDMMC_SLOT0_IOMUX_PIN_NUM_D3 == io_config->d3_io) { - use_gpio_matrix = false; + if (use_gpio_matrix) { + if (slot_width >= 1) { + if (SDMMC_SLOT0_IOMUX_PIN_NUM_CLK == io_config->clk_io && SDMMC_SLOT0_IOMUX_PIN_NUM_CMD == io_config->cmd_io && SDMMC_SLOT0_IOMUX_PIN_NUM_D0 == io_config->d0_io) { + use_gpio_matrix = false; + } else { + use_gpio_matrix = true; + } + } + if (slot_width >= 4) { + if (SDMMC_SLOT0_IOMUX_PIN_NUM_D1 == io_config->d1_io && SDMMC_SLOT0_IOMUX_PIN_NUM_D2 == io_config->d2_io && SDMMC_SLOT0_IOMUX_PIN_NUM_D3 == io_config->d3_io) { + use_gpio_matrix = false; + } else { + use_gpio_matrix = true; + } + } } else { ESP_RETURN_ON_FALSE(!use_gpio_matrix, ESP_ERR_INVALID_ARG, TAG, "doesn't support routing from GPIO matrix, driver uses dedicated IOs"); } From ad98c1d9a12780b512b866c5e778e3cf2765fdb1 Mon Sep 17 00:00:00 2001 From: armando Date: Fri, 16 May 2025 11:10:10 +0800 Subject: [PATCH 2/2] fix(sd): fixed menuconfig multi pin definitions issue --- .../sd_card/sdmmc/main/Kconfig.projbuild | 102 +++++++----------- 1 file changed, 38 insertions(+), 64 deletions(-) diff --git a/examples/storage/sd_card/sdmmc/main/Kconfig.projbuild b/examples/storage/sd_card/sdmmc/main/Kconfig.projbuild index ab982f7445..66457c226b 100644 --- a/examples/storage/sd_card/sdmmc/main/Kconfig.projbuild +++ b/examples/storage/sd_card/sdmmc/main/Kconfig.projbuild @@ -47,84 +47,58 @@ menu "SD/MMC Example Configuration" depends on SOC_SDMMC_UHS_I_SUPPORTED endchoice - if SOC_SDMMC_USE_GPIO_MATRIX + config EXAMPLE_PIN_CMD + int + prompt "CMD GPIO number" if SOC_SDMMC_USE_GPIO_MATRIX + default 35 if IDF_TARGET_ESP32S3 + default 44 if IDF_TARGET_ESP32P4 + default 15 if IDF_TARGET_ESP32 - config EXAMPLE_PIN_CMD - int "CMD GPIO number" - default 35 if IDF_TARGET_ESP32S3 - default 44 if IDF_TARGET_ESP32P4 + config EXAMPLE_PIN_CLK + int + prompt "CLK GPIO number" if SOC_SDMMC_USE_GPIO_MATRIX + default 36 if IDF_TARGET_ESP32S3 + default 43 if IDF_TARGET_ESP32P4 + default 14 if IDF_TARGET_ESP32 - config EXAMPLE_PIN_CLK - int "CLK GPIO number" - default 36 if IDF_TARGET_ESP32S3 - default 43 if IDF_TARGET_ESP32P4 + config EXAMPLE_PIN_D0 + int + prompt "D0 GPIO number" if SOC_SDMMC_USE_GPIO_MATRIX + default 37 if IDF_TARGET_ESP32S3 + default 39 if IDF_TARGET_ESP32P4 + default 2 if IDF_TARGET_ESP32 - config EXAMPLE_PIN_D0 - int "D0 GPIO number" - default 37 if IDF_TARGET_ESP32S3 - default 39 if IDF_TARGET_ESP32P4 + if EXAMPLE_SDMMC_BUS_WIDTH_4 - if EXAMPLE_SDMMC_BUS_WIDTH_4 + config EXAMPLE_PIN_D1 + int + prompt "D1 GPIO number" if SOC_SDMMC_USE_GPIO_MATRIX + default 38 if IDF_TARGET_ESP32S3 + default 40 if IDF_TARGET_ESP32P4 + default 4 if IDF_TARGET_ESP32 - config EXAMPLE_PIN_D1 - int "D1 GPIO number" - default 38 if IDF_TARGET_ESP32S3 - default 40 if IDF_TARGET_ESP32P4 - config EXAMPLE_PIN_D2 - int "D2 GPIO number" - default 33 if IDF_TARGET_ESP32S3 - default 41 if IDF_TARGET_ESP32P4 + config EXAMPLE_PIN_D2 + int + prompt "D2 GPIO number" if SOC_SDMMC_USE_GPIO_MATRIX + default 33 if IDF_TARGET_ESP32S3 + default 41 if IDF_TARGET_ESP32P4 + default 12 if IDF_TARGET_ESP32 - config EXAMPLE_PIN_D3 - int "D3 GPIO number" - default 34 if IDF_TARGET_ESP32S3 - default 42 if IDF_TARGET_ESP32P4 - endif # EXAMPLE_SDMMC_BUS_WIDTH_4 + config EXAMPLE_PIN_D3 + int + prompt "D3 GPIO number" if SOC_SDMMC_USE_GPIO_MATRIX + default 34 if IDF_TARGET_ESP32S3 + default 42 if IDF_TARGET_ESP32P4 + default 13 if IDF_TARGET_ESP32 - endif # SOC_SDMMC_USE_GPIO_MATRIX + endif # EXAMPLE_SDMMC_BUS_WIDTH_4 config EXAMPLE_DEBUG_PIN_CONNECTIONS bool "Debug sd pin connections and pullup strength" default n - if !SOC_SDMMC_USE_GPIO_MATRIX - config EXAMPLE_PIN_CMD - int - depends on EXAMPLE_DEBUG_PIN_CONNECTIONS - default 15 if IDF_TARGET_ESP32 - - config EXAMPLE_PIN_CLK - int - depends on EXAMPLE_DEBUG_PIN_CONNECTIONS - default 14 if IDF_TARGET_ESP32 - - config EXAMPLE_PIN_D0 - int - depends on EXAMPLE_DEBUG_PIN_CONNECTIONS - default 2 if IDF_TARGET_ESP32 - - if EXAMPLE_SDMMC_BUS_WIDTH_4 - - config EXAMPLE_PIN_D1 - int - depends on EXAMPLE_DEBUG_PIN_CONNECTIONS - default 4 if IDF_TARGET_ESP32 - - config EXAMPLE_PIN_D2 - int - depends on EXAMPLE_DEBUG_PIN_CONNECTIONS - default 12 if IDF_TARGET_ESP32 - - config EXAMPLE_PIN_D3 - int - depends on EXAMPLE_DEBUG_PIN_CONNECTIONS - default 13 if IDF_TARGET_ESP32 - - endif # EXAMPLE_SDMMC_BUS_WIDTH_4 - endif - config EXAMPLE_ENABLE_ADC_FEATURE bool "Enable ADC feature" depends on EXAMPLE_DEBUG_PIN_CONNECTIONS