Skip to content

SD_MMC: Incorrect pin settings for ESP32 #10709

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
1 task done
broddo opened this issue Dec 10, 2024 · 4 comments
Closed
1 task done

SD_MMC: Incorrect pin settings for ESP32 #10709

broddo opened this issue Dec 10, 2024 · 4 comments
Assignees
Labels
Status: Awaiting triage Issue is waiting for triage

Comments

@broddo
Copy link

broddo commented Dec 10, 2024

Board

ESP32-DEVKITC-32E

Device Description

SDCARD breakout board wired via breadboard

Hardware Configuration

N/A

Version

v3.1.0-RC2 804ee12
IDF v5.3.1

IDE Name

VSCode

Operating System

macOS 14.5

Flash frequency

40 Mhz

PSRAM enabled

yes

Upload speed

460800

Description

I recently updated one of my old projects that was using IDF v4 to IDF v5 and upgrade to the latest version of the Arduino library too. The hardware for this project includes an eMMC card that was functioning fine on the old libraries.

The eMMC card no longer works when using the latest libraries. The reason is due to several calls to the perimanSetPinBus which result in this error:

[ 177][E][esp32-hal-periman.c:122] perimanSetPinBus(): Invalid pin: 255

These calls fail because _pin_clk, _pin_cmd are indeed set to -1 if you are configuring for an ESP32. The solution is was to just add a #ifndef CONFIG_IDF_TARGET_ESP32 to exclude these calls on ESP32 hardware.

Sketch

#include <Arduino.h>
#include <SD_MMC.h>


void setup() {
  Serial.begin(115200);
  if (!SD_MMC.begin("/sdmmc")) {
    Serial.println("Failed to mount SDMMC module");
  }
}

void loop() { }

Debug Message

[   177][E][esp32-hal-periman.c:122] perimanSetPinBus(): Invalid pin: 255

Other Steps to Reproduce

No response

I have checked existing issues, online documentation and the Troubleshooting Guide

  • I confirm I have checked existing issues, online documentation and Troubleshooting guide.
@broddo broddo added the Status: Awaiting triage Issue is waiting for triage label Dec 10, 2024
@lbernstone
Copy link
Contributor

lbernstone commented Dec 10, 2024

In the constructor, _pin_clk = SDMMC_SLOT1_IOMUX_PIN_NUM_CLK, so it should use the pins as defined in soc/sdmmc_pins.h. What do you get if you print out SDMMC_SLOT1_IOMUX_PIN_NUM_CLK?
Also, please be more precise about what version and IDE you are using. platformio is generally not using the latest release candidate unless you specifically point it there.

@broddo
Copy link
Author

broddo commented Dec 11, 2024

D'oh - I missed the define BOARD_HAS_SDMMC. Sorry - I can't believe I missed that. It guess it wasn't in my project originally as I was using an older version of this library that didn't require it and I'm also running custom hardware. I see that it is defined in some board variants but can you suggest a good place for me to define this? I just added a add_compile_definitions(BOARD_HAS_SDMMC) to the top level CMakeLists.txt rather than try wrestling with making a custom board variant.

(I'm not using platformio - I'm using IDF v5.3.1 with Arduino ESP32 (v 3.1.0-RC2 804ee12) added as a component.)

@me-no-dev
Copy link
Member

It should not require BOARD_HAS_SDMMC to work. @P-R-O-C-H-Y PTAL

@P-R-O-C-H-Y
Copy link
Member

Closing as solved by PR #10713

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Awaiting triage Issue is waiting for triage
Projects
None yet
Development

No branches or pull requests

4 participants