Page 1 of 1

Esp32S3 : esp_vfs_fat_sdmmc_mount() function. Is there an error code saying that the external memory is broken ?

Posted: Mon Jul 07, 2025 1:23 pm
by ThomasESP32
Good afternoon,


I am using an Esp32S3 with an external SDCard.
I manage to mount a FileSystem on the SDCard using the esp_vfs_fat_sdmmc_mount() function.

Using the error code, I can know if the FileSystem is mounted or not, but I would like to know if the FileSystem has not been mounted
because there was no SDCard or fi the FileSystem has not been mounted because the SDCard was broken (Or something like that).

Do you know if the error code sent by the function can tell the difference between these two cases ?

Is there an error code saying that the SDCard is broken and another one saying that the SDCard is not present ?

Best regards,

Thomas TRUILHE

Re: Esp32S3 : esp_vfs_fat_sdmmc_mount() function. Is there an error code saying that the external memory is broken ?

Posted: Tue Jul 08, 2025 1:25 am
by Sprite
Function docs say:
ESP_FAIL if partition can not be mounted

other error codes from SDMMC or SPI drivers, SDMMC protocol, or FATFS drivers
I imagine this passes errors from sdmmc_host_do_transaction() back if something happens:
ESP_ERR_TIMEOUT if response or data transfer has timed out
ESP_ERR_INVALID_CRC if response or data transfer CRC check has failed
ESP_ERR_INVALID_RESPONSE if the card has sent an invalid response
or else from FatFS, which has its own error system which is [url=
https://github.com/espressif/esp-idf/bl ... mmc.c#L120]wrapped[/url] by esp_vfs_fat_sdmmc_mount() and that will return ESP_FAIL if something went wrong with the mount.

But also, in general, as the docs state:
The header file fatfs/vfs/esp_vfs_fat.h defines convenience functions esp_vfs_fat_sdmmc_mount(), esp_vfs_fat_sdspi_mount(), and esp_vfs_fat_sdcard_unmount(). These functions perform Steps 1–3 and 7–9 respectively and handle SD card initialization, but provide only limited error handling. Developers are encouraged to check its source code and incorporate more advanced features into production applications.