diff --git a/libraries/AP_Filesystem/AP_Filesystem_ESP32.cpp b/libraries/AP_Filesystem/AP_Filesystem_ESP32.cpp index fb36c9b1da035e..cc930fb73a3a2c 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; } /*