fix: resolve SD card mount error by routing schematic pins CLK=38, CMD=21, D0=39, D3=17 and disabling internal pull-up on CLK

This commit is contained in:
Adolfo Reyna
2026-07-10 12:19:32 -04:00
parent bd8fea0436
commit 9ffd2051fe
2 changed files with 29 additions and 8 deletions
@@ -45,11 +45,13 @@
sdmmc0 {
compatible = "espressif,esp32-sdmmc";
pin-clk = <&gpio0 2 GPIO_FLAG_NONE>;
pin-cmd = <&gpio0 1 GPIO_FLAG_NONE>;
pin-d0 = <&gpio0 3 GPIO_FLAG_NONE>;
pin-clk = <&gpio0 38 GPIO_FLAG_NONE>;
pin-cmd = <&gpio0 21 GPIO_FLAG_NONE>;
pin-d0 = <&gpio0 39 GPIO_FLAG_NONE>;
pin-d3 = <&gpio0 17 GPIO_FLAG_NONE>;
slot = <SDMMC_HOST_SLOT_1>;
bus-width = <1>;
pullups;
};
uart0 {
@@ -9,6 +9,7 @@
#include <tactility/log.h>
#include <driver/sdmmc_host.h>
#include <driver/gpio.h>
#include <esp_vfs_fat.h>
#include <freertos/FreeRTOS.h>
#include <freertos/task.h>
@@ -108,15 +109,33 @@ static error_t mount(void* data) {
uint32_t slot_config_flags = 0;
if (config->enable_uhs) slot_config_flags |= SDMMC_SLOT_FLAG_UHS1;
if (config->wp_active_high) slot_config_flags |= SDMMC_SLOT_FLAG_WP_ACTIVE_HIGH;
if (config->pullups) slot_config_flags |= SDMMC_SLOT_FLAG_INTERNAL_PULLUP;
gpio_num_t clk_pin = to_native_pin(config->pin_clk);
gpio_num_t cmd_pin = to_native_pin(config->pin_cmd);
gpio_num_t d0_pin = to_native_pin(config->pin_d0);
gpio_num_t d3_pin = to_native_pin(config->pin_d3);
// Manually enable pull-ups on CMD, D0, and D3 if pullups configuration is true
// This avoids pulling up the CLK line which can cause clock signal distortion
if (config->pullups) {
if (cmd_pin != GPIO_NUM_NC) {
gpio_pullup_en(cmd_pin);
}
if (d0_pin != GPIO_NUM_NC) {
gpio_pullup_en(d0_pin);
}
if (d3_pin != GPIO_NUM_NC) {
gpio_pullup_en(d3_pin);
}
}
sdmmc_slot_config_t slot_config = {
.clk = to_native_pin(config->pin_clk),
.cmd = to_native_pin(config->pin_cmd),
.d0 = to_native_pin(config->pin_d0),
.clk = clk_pin,
.cmd = cmd_pin,
.d0 = d0_pin,
.d1 = to_native_pin(config->pin_d1),
.d2 = to_native_pin(config->pin_d2),
.d3 = to_native_pin(config->pin_d3),
.d3 = d3_pin,
.d4 = to_native_pin(config->pin_d4),
.d5 = to_native_pin(config->pin_d5),
.d6 = to_native_pin(config->pin_d6),