Card Mount failed

Hello,

I am currently working on an ESP32 CAM. I had a code writting on a micro SD but my cam broke. I bought a new one but I can no more write on the micro SD even with basic code like this one:

#include "FS.h"
#include "SD_MMC.h"

void setup() {
  Serial.begin(115200);
  Serial.println("Initialisation de la carte SD...");

  if (!SD_MMC.begin()) {
    Serial.println("Erreur initialisation carte SD");
    Serial.println("Vérifiez les connexions et le formatage de la carte SD");
    return;
  }
  Serial.println("Carte SD initialisée avec succès.");

  // Créez un fichier et écrivez dedans
  File file = SD_MMC.open("/test.txt", FILE_WRITE);
  if (!file) {
    Serial.println("Erreur ouverture fichier");
    return;
  }
  file.println("Test de la carte SD");
  file.close();
  Serial.println("Fichier créé et écrit.");

  // Lisez le fichier
  file = SD_MMC.open("/test.txt");
  if (!file) {
    Serial.println("Erreur ouverture fichier pour lecture");
    return;
  }
  while (file.available()) {
    Serial.write(file.read());
  }
  file.close();
}

void loop() {
  // Rien à faire dans la boucle
}

I get some error that I don't understand.
Initialisation de la carte SD...

E (514) sdmmc_sd: sdmmc_init_sd_ssr: sdmmc_send_cmd returned 0xffffffff

E (514) vfs_fat_sdmmc: sdmmc_card_init failed (0xffffffff).

Erreur initialisation carte SD

Vérifiez les connexions et le formatage de la carte SD

(sorry for the french logs)
I tried to format the micro sd with the "slow way"

But at the end I get an message telling me " windows failed format".
I am really lost. Can someone help me please? By the way I don't have anoother sd to test :frowning:

Does the SD card show on your file explorer?
Can you navigate to it? What does a directory list show?

The card may be worn out or damaged in some other way. I haven't used windows in a few years but there should be a disk analyze and repair tool to check the card.

I tried this command ( chkdsk D: /f /r /x ) with the name of the sd card (D:)
Windows said there was no problem.
I don't understand if the sd card is damaged because when i plug it into my laptop I can open it and copy files into it.
About disk analyzer I didn't find one :frowning:

I moved your topic to a more appropriate forum category @lorenzo_froment14.

The Nano ESP32 category you chose is only used for discussions directly related to the Arduino Nano ESP32 board.

In the future, please take the time to pick the forum category that best suits the subject of your question. There is an "About the _____ category" topic at the top of each category that explains its purpose.

Thanks in advance for your cooperation.

2 Likes

I bought a new micro sd card to see if it resolved the problem but still not working at the line "SD.begin()"

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.