ESP32 SD Mount Failed

OstapStad
Posts: 2
Joined: Mon Jan 02, 2023 9:52 am

ESP32 SD Mount Failed

Postby OstapStad » Mon Jan 02, 2023 11:31 am

Hey there! Recently, I ran into a problem with sd mounting. It always says "SD mount failed", even when SD is not inserted. SD module is wired to standard VSPI pins.
here's a sketch:

Code: Select all

#include <Arduino.h>
//#include <WiFi.h>
//#include <AsyncTCP.h>
//#include <ESPAsyncWebServer.h>
//#include "FS.h"
#include "SD.h"
#include "TFT_eSPI.h"
#include "SPI.h"

void initTFT(){
  TFT_eSPI tft=TFT_eSPI();
  tft.init();
  tft.fillScreen(TFT_BLACK);
  tft.drawString("Hello World! I'm OstapStad", 2, 2);
}

void initSDCard(){
  if(!SD.begin()){
    Serial.println("Card Mount Failed");
    return;
  }
  uint8_t cardType = SD.cardType();

  if(cardType == CARD_NONE){
    Serial.println("No SD card attached");
    return;
  }

  Serial.print("SD Card Type: ");
  if(cardType == CARD_MMC){
    Serial.println("MMC");
  } else if(cardType == CARD_SD){
    Serial.println("SDSC");
  } else if(cardType == CARD_SDHC){
    Serial.println("SDHC");
  } else {
    Serial.println("UNKNOWN");
  }
  uint64_t cardSize = SD.cardSize() / (1024 * 1024);
  Serial.printf("SD Card Size: %lluMB\n", cardSize);
}

void setup() {
    // put your setup code here, to run once:
  Serial.begin(115200);
  Serial.print("MOSI: ");
  Serial.println(MOSI);
  Serial.print("MISO: ");
  Serial.println(MISO);
  Serial.print("SCK: ");
  Serial.println(SCK);
  Serial.print("SS: ");
  Serial.println(SS);
  Serial.begin(115200);
  initTFT();
  initSDCard();
}

void loop() {
  
}
And here's a serial response:

Code: Select all

clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:1
load:0x3fff0030,len:1344
load:0x40078000,len:13836
load:0x40080400,len:3608
entry 0x400805f0
MOSI: 23
MISO: 19
SCK: 18
SS: 5
Card Mount Failed
Maybe someone can help? Thank you!

bidrohini
Posts: 202
Joined: Thu Oct 27, 2022 12:55 pm

Re: ESP32 SD Mount Failed

Postby bidrohini » Mon Jan 02, 2023 2:36 pm

Have you tried the 'Cardinfo' example of the Arduino IDE?

OstapStad
Posts: 2
Joined: Mon Jan 02, 2023 9:52 am

Re: ESP32 SD Mount Failed

Postby OstapStad » Thu Jan 05, 2023 7:22 pm

Just gives a lot of compilation errors(

Who is online

Users browsing this forum: No registered users and 127 guests