From 56fe2dbaff1ac8fb61b4722972e9ac8373e081b5 Mon Sep 17 00:00:00 2001 From: Luc <8822552+luc-github@users.noreply.github.com> Date: Sat, 21 Sep 2019 07:34:25 +0800 Subject: [PATCH] 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 --- libraries/FFat/src/FFat.cpp | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/libraries/FFat/src/FFat.cpp b/libraries/FFat/src/FFat.cpp index 3dbda110..2c53f3a3 100644 --- a/libraries/FFat/src/FFat.cpp +++ b/libraries/FFat/src/FFat.cpp @@ -76,6 +76,7 @@ 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; @@ -83,7 +84,10 @@ bool F_Fat::format(bool full_wipe, char* partitionLabel) 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) { @@ -91,6 +95,9 @@ bool F_Fat::format(bool full_wipe, char* partitionLabel) 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()