Skip to content
Permalink
Browse files

Fix F_Fat::format return false when succeed (#3220)

this is due to ussage of esp_err_t result; instead of boolean, ESP_OK =0 so it is false
  • Loading branch information...
luc-github authored and me-no-dev committed Sep 20, 2019
1 parent 06a399b commit 56fe2dbaff1ac8fb61b4722972e9ac8373e081b5
Showing with 13 additions and 2 deletions.
  1. +13 −2 libraries/FFat/src/FFat.cpp
@@ -76,21 +76,28 @@ void F_Fat::end()
bool F_Fat::format(bool full_wipe, char* partitionLabel)
{
esp_err_t result;
bool res = true;
if(_wl_handle){
log_w("Already Mounted!");
return false;
}
wl_handle_t temp_handle;
// Attempt to mount to see if there is already data
const esp_partition_t *ffat_partition = check_ffat_partition(partitionLabel);
if (!ffat_partition) return false;
if (!ffat_partition){
log_w("No partition!");
return false;
}
result = wl_mount(ffat_partition, &temp_handle);

if (result == ESP_OK) {
// Wipe disk- quick just wipes the FAT. Full zeroes the whole disk
uint32_t wipe_size = full_wipe ? wl_size(temp_handle) : 16384;
wl_erase_range(temp_handle, 0, wipe_size);
wl_unmount(temp_handle);
} else {
res = false;
log_w("wl_mount failed!");
}
// Now do a mount with format_if_fail (which it will)
esp_vfs_fat_mount_config_t conf = {
@@ -99,7 +106,11 @@ bool F_Fat::format(bool full_wipe, char* partitionLabel)
};
result = esp_vfs_fat_spiflash_mount("/format_ffat", partitionLabel, &conf, &temp_handle);
esp_vfs_fat_spiflash_unmount("/format_ffat", temp_handle);
return result;
if (result != ESP_OK){
res = false;
log_w("esp_vfs_fat_spiflash_mount failed!");
}
return res;
}

size_t F_Fat::totalBytes()

0 comments on commit 56fe2db

Please sign in to comment.
You can’t perform that action at this time.