Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions libraries/FFat/src/FFat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand All @@ -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()
Expand Down