SD_MMC not working in pio

Hi pio community,
I have a piece of code with the espressif SD_MMC library that is working perfectly when I upload it from Arduino IDE but when I upload it from PlatformIO the board become irresponsive after the SD_MMC.begin(). Extract of the code:

#include "SD_MMC.h" 

const int pin_temp = 34;

void setup(){
  Serial.println("Starting SD Card");
    Serial.println("SD Card Mount Failed");
  Serial.println("Initalisation complete.");

When compiled and uploaded with PlatformIO it never reaches the Initialization Complete.
In the platformio.ini file I tried to match the same config as in the Arduino IDE:

platform = espressif32
board = esp-wrover-kit
framework = arduino
monitor_speed = 115200
board_build.flash_mode = qio
upload_speed = 115200
board_build.f_cpu = 40000000L 

Any ideas ?

Okay, then let’s make sure that the build options which are pulled in for your board match those of the Arduino IDE.

Please compile & upload the following code in the Arduino IDE and PlatformIO, then post both outputs:

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

void setup(){

  Serial.println("BOARD_HAS_1BIT_SDMMC enabled");
  Serial.println("BOARD_HAS_1BIT_SDMMC disabled");		
  Serial.println("SDMMC_FREQ_DEFAULT: " + String(SDMMC_FREQ_DEFAULT));

void loop() { }

(might need to press reset after upload to see output because it’s in setup())

Because this topic reminds me of Platformio.ini esp32-gateway revision and SD_MMC returned 0x107.

Thanks for your help. I have tried this code and I get the same output:


Looks like I will have to stick with Arduino IDE :frowning:

Can you show an exact screenshot which board settings you chose in the Arduino IDE?

I am using these settings:

Thanks, I have the same board and try to debug this and report back. There’s probably a really sneaky but trivial error somewhere

1 Like

I was able to reproduce the issue and find the cause.

This setting destroys the functionality. Without it it works.

Notice that the Arduino IDE selects

for this variant. It doesn’t let you run the chip on any other setting than 240MHz. Only lets you select flash frequencies of 80MHz or 40MHz; but not the 40MHz CPU speed that you gave PIO.

Also notice that this also doesn’t work in the Arduino IDE. E.g., selecting “ESP32 Dev Module” (which lets you decide the CPU speed) and uploading with CPU Frequency of 240MHz, it works. When selecting 40MHz, it doesn’t. So, PIO has the same behavior as the Arduino IDE.

Working PIO:

Cool, it works. Many thanks Max !

1 Like