greiman / SdFat

Arduino FAT16/FAT32 exFAT Library
MIT License
1.05k stars 496 forks source link

Initialization fails with ESP32 #488

Open Calypso514 opened 3 weeks ago

Calypso514 commented 3 weeks ago

Hi everyone,

I'm using an ESP32 board (Firebeetle ESP32) and I can't make this lib work on it. The wiring is correct since SD lib works perfectly. I've tried the lib and the SD card on two other boards (Arduino Uno and Arduino Zero) and it works. Yet, no example sketch works with the ESP32 board except "SdInfo". The initialization always fails and I get the following error :

begin() failed
Do not reformat the SD.
SdError: 0X19,0X0

Does someone know why it fails ?

Thanks in advance

greiman commented 3 weeks ago

The error occurs here.

This is could be a SPI problem. The SD driver was expecting a DATA_START_SECTOR token which is 0XFE but received 0X0.

The wiring is correct since SD lib works perfectly.

The wiring may be correct but ESP32 often has problems with SdFat since the default SPI speed is much higher than with the SD library. This can be due to the ESP32 driver, the SD socket, wiring that does not support max speed, or another device on the SPI bus.

Try the QuickStart example which runs at a slow clock.