From 094f0f48018e9849b12ae7cc9e7b1df600cf47c7 Mon Sep 17 00:00:00 2001 From: muramura Date: Sat, 15 Aug 2026 23:41:41 +0900 Subject: [PATCH] AP_Filesystem: use wear levelling sector size for ESP32 FlashFS --- libraries/AP_Filesystem/AP_Filesystem_ESP32.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/libraries/AP_Filesystem/AP_Filesystem_ESP32.cpp b/libraries/AP_Filesystem/AP_Filesystem_ESP32.cpp index fb36c9b1da035..cc930fb73a3a2 100644 --- a/libraries/AP_Filesystem/AP_Filesystem_ESP32.cpp +++ b/libraries/AP_Filesystem/AP_Filesystem_ESP32.cpp @@ -25,6 +25,12 @@ extern const AP_HAL::HAL& hal; +#if defined(HAL_ESP32_FLASHFS) +#define ESP32_FILESYSTEM_SECTOR_SIZE FF_SS_WL +#else +#define ESP32_FILESYSTEM_SECTOR_SIZE FF_SS_SDCARD +#endif + int AP_Filesystem_ESP32::open(const char *fname, int flags, bool allow_absolute_paths) { #if FSDEBUG @@ -170,7 +176,7 @@ int64_t AP_Filesystem_ESP32::disk_free(const char *path) /* Get total sectors and free sectors */ fre_sect = fre_clust * fs->csize; - return (int64_t)fre_sect * FF_SS_SDCARD; + return (int64_t)fre_sect * ESP32_FILESYSTEM_SECTOR_SIZE; } // return total disk space in bytes @@ -191,7 +197,7 @@ int64_t AP_Filesystem_ESP32::disk_space(const char *path) /* Get total sectors and free sectors */ tot_sect = (fs->n_fatent - 2) * fs->csize; - return (int64_t)tot_sect * FF_SS_SDCARD; + return (int64_t)tot_sect * ESP32_FILESYSTEM_SECTOR_SIZE; } /*