Description
Board
ESP32 Dev Board
Device Description
ESP32 Dev kit.
Micro SD card breakout board (3.3V).
Hardware Configuration
GPIO 5 connected to CS
GPIO 23 connected to MOSI
GPIO 18 connected to CLK
GPIO 19 connected to MISO
Version
v2.0.6
IDE Name
PlatformIO (VS Code)
Operating System
Ubuntu
Flash frequency
40Mhz
PSRAM enabled
no
Upload speed
921600
Description
Most SD cards will not connect. The sketch compiles and runs, but when trying to mount SD cards produces an error.
Using the SD library communicating by SPI most SD cards do not mount. I have five identical (same size, type, brand etc.) micro SD cards, one of them always connects and runs perfectly. The other four do not mount at all.
They all mount to my computer and have all been formatted as FAT32.
I have tried directly wiring up the SD cards and I get the same behaviour (four don't work and one does).
I have tried powering off a power supply to ensure that isn't the issue but the behaviour remains the same.
The error message that I get is:
ff_sd_initialize(): APP_OP_COND failed: 1
This is different to the error that I get when the SD cards are not connected which is:
ff_sd_initialize(): GO_IDLE_STATE failed
Sketch
#include "FS.h"
#include "SD.h"
#include "SPI.h"
void setup()
{
Serial.begin(115200);
}
void loop()
{
if (!SD.begin())
{
Serial.println("Card Mount Failed");
}
else
{
Serial.println("Worked");
}
delay(2000);
}
Debug Message
[ 72613][W][sd_diskio.cpp:550] ff_sd_initialize(): APP_OP_COND failed: 1
[ 72613][E][sd_diskio.cpp:805] sdcard_mount(): f_mount failed: (3) The physical drive cannot work
Other Steps to Reproduce
I have also reproduced this soldering the pins of a micro SD card adaptor to the ESP32 with the correct pull-ups. The behaviour is identical.
I have tried two different dev boards and the behaviour persists.
I have checked existing issues, online documentation and the Troubleshooting Guide
- I confirm I have checked existing issues, online documentation and Troubleshooting guide.
Activity
VojtechBartoska commentedon Jan 12, 2023
@P-R-O-C-H-Y can you please help with triage? Thanks
everslick commentedon Jan 23, 2023
I don't have this particular issue, that SD cards fail to mount, but I see other SD related problems like writes to files returning 0 (and no data was written), but also data that silently gets dropped. I cannot say more ATM, unfortunately. Just wanted to raise my suspicion, that something is off with SD card support in the current core, in case someone else sees similar issues.
Catzy44 commentedon Jan 25, 2023
Im experiencing this issue too.
Code uploaded via arduino IDE 1.8.19 works perfectly but via PlatformIO downloaded today not working at all, same error.
Is there any temporary fix?
<3
[ 1166][E][sd_diskio.cpp:199] sdCommand(): Card Failed! cmd: 0x00
[ 1167][E][sd_diskio.cpp:802] sdcard_mount(): f_mount failed: (3) The physical drive cannot work
[ 1471][E][sd_diskio.cpp:199] sdCommand(): Card Failed! cmd: 0x00
nsieg commentedon Jan 29, 2023
I can confirm this behavior in my setup:
An older SanDisk Extreme 16GB will mount without errors, while a new SanDisk Ultra 32GB leads to:
There is no difference in my case regarding the version used: it fails with 2.0.6 as well as 1.0.6 using Arduino IDE 1.8.19
P-R-O-C-H-Y commentedon Jan 29, 2023
@nsieg If I understand correctly, the issues with the new Sanddisk SD card accurs even using Arduino IDE? So it's not related to platformIO? Thanks
nsieg commentedon Jan 30, 2023
Yes, I am primarily using PlatformIO. I have tried different versions here (manually specifying
platform
andplatform-packages
), all leading to the error. To make sure, I tried the same using Arduino IDE (current and 1.8.19) but it remains the same with both IDEs.Catzy44 commentedon Jan 30, 2023
Okay so i resolved my problem by manually specifying SPI pins, like this:
int SD_CS_PIN = 19;
SPI.begin(18, 36, 26, SD_CS_PIN);
SPI.setDataMode(SPI_MODE0);
SD.begin(SD_CS_PIN);
But It's still unclear to me why I need to manually specify SPI pins only on PlatformIO.
(I'm using M5-STAMP-PICO module)
Skywalkerf34 commentedon Apr 23, 2023
Same problem here, the card mount correctly 2 or 3 times then give this error message. If I remove the SD card then pull back the problem dissapear for 2 or 3 run then back again with same error
using 4G TF card formated with fat32
sivar2311 commentedon Apr 30, 2023
I am also experiencing the same problem. Whether I try a purchased SD card module or a simple self-soldered adapter.
The used SD card is a SanDisk Ultra Plus 32GB (the smallest card I could find). The card was of course formatted with Fat32 @ 32kb.
lbernstone commentedon May 1, 2023
The M5stack-stamp-s3 (?) does not have spi pins defined in the variant file. You can submit a PR if you would like to fix it.
https://github.com/espressif/arduino-esp32/blob/master/variants/m5stack_stamp_s3/pins_arduino.h
See https://github.com/espressif/arduino-esp32/blob/master/variants/esp32/pins_arduino.h#L20-L23 for the template
28 remaining items