Fix several SD card issues (#4876)

- File might not eval to false if opened with write/append and SD is gone
- Allow card to be formatted if FAT partition was not found
- Mark card as gone in certain situations
- Fix several logic errors in low level SD API
This commit is contained in:
Me No Dev
2021-03-01 23:52:57 +02:00
committed by GitHub
parent 3fe7c2e8cd
commit 1cf1c8eb79
7 changed files with 90 additions and 40 deletions

View File

@ -35,7 +35,7 @@ SDMMCFS::SDMMCFS(FSImplPtr impl)
: FS(impl), _card(NULL)
{}
bool SDMMCFS::begin(const char * mountpoint, bool mode1bit)
bool SDMMCFS::begin(const char * mountpoint, bool mode1bit, bool format_if_mount_failed)
{
if(_card) {
return true;
@ -68,7 +68,7 @@ bool SDMMCFS::begin(const char * mountpoint, bool mode1bit)
}
esp_vfs_fat_sdmmc_mount_config_t mount_config = {
.format_if_mount_failed = false,
.format_if_mount_failed = format_if_mount_failed,
.max_files = 5,
.allocation_unit_size = 0
};