From 88b3de0138d4a9bb36bce3da393f2ba19055e450 Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Wed, 16 Dec 2020 12:01:10 +0100 Subject: [PATCH] Fix SPIFFS filesystem Fix enabling SPIFFS filesystem (#10121) --- tasmota/support_command.ino | 3 +++ tasmota/support_esp32.ino | 4 ++-- tasmota/support_filesystem.ino | 13 ++++--------- tasmota/tasmota_globals.h | 6 ++++++ 4 files changed, 15 insertions(+), 11 deletions(-) diff --git a/tasmota/support_command.ino b/tasmota/support_command.ino index 4b9e21839..6d127e0bb 100644 --- a/tasmota/support_command.ino +++ b/tasmota/support_command.ino @@ -2068,6 +2068,9 @@ void CmndDriver(void) void CmndInfo(void) { NvsInfo(); +#ifdef USE_TFS + TfsInfo(); +#endif ResponseCmndDone(); } diff --git a/tasmota/support_esp32.ino b/tasmota/support_esp32.ino index 806175505..2f544ba5e 100644 --- a/tasmota/support_esp32.ino +++ b/tasmota/support_esp32.ino @@ -194,8 +194,8 @@ void QPCWrite(const void *pSettings, unsigned nSettingsLen) { void NvsInfo(void) { nvs_stats_t nvs_stats; nvs_get_stats(NULL, &nvs_stats); - AddLog_P(LOG_LEVEL_INFO, PSTR("INF: NVS Used %d, Free %d, Total %d, Namspaces %d"), - nvs_stats.used_entries, nvs_stats.free_entries, nvs_stats.total_entries, nvs_stats.namespace_count); + AddLog_P(LOG_LEVEL_INFO, PSTR("NVS: Used %d/%d entries, NameSpaces %d"), + nvs_stats.used_entries, nvs_stats.total_entries, nvs_stats.namespace_count); } void ZigbeeErase(unsigned nSettingsLen) { diff --git a/tasmota/support_filesystem.ino b/tasmota/support_filesystem.ino index 6eef715f4..94b69fea2 100644 --- a/tasmota/support_filesystem.ino +++ b/tasmota/support_filesystem.ino @@ -23,15 +23,9 @@ #ifdef ESP32 -#define USE_TFS - -#ifdef USE_SCRIPT -#undef USE_TFS -#endif // USE_SCRIPT - #ifdef USE_TFS -//#define USE_LITTLEFS // LittleFS not tested yet +//#define USE_LITTLEFS // LittleFS not tested yet as currently ESP8266 only //#define USE_FFAT // FFat minimal 983k partition (4096 sector size) - tested #define USE_SPIFFS // SPIFFS - tested @@ -64,7 +58,6 @@ bool TfsInit(void) { } } AddLog_P(LOG_LEVEL_INFO, PSTR("TFS: Mounted")); -// TfsInfo(); FsMounted = 2; // true return true; } @@ -130,10 +123,12 @@ bool TfsLoadFile(const char *fname, uint8_t *buf, uint32_t len) { } void TfsInfo(void) { + if (!TfsInit()) { return; } + + uint32_t total_bytes = TASMOTA_FS.totalBytes(); #ifdef USE_SPIFFS uint32_t used_bytes = TASMOTA_FS.usedBytes(); #endif // USE_SPIFFS - uint32_t total_bytes = TASMOTA_FS.totalBytes(); #ifdef USE_FFAT uint32_t used_bytes = total_bytes - TASMOTA_FS.freeBytes(); #endif // USE_FFAT diff --git a/tasmota/tasmota_globals.h b/tasmota/tasmota_globals.h index fc2fbf34d..3ca9923e0 100644 --- a/tasmota/tasmota_globals.h +++ b/tasmota/tasmota_globals.h @@ -107,6 +107,12 @@ String EthernetMacAddress(void); #define ARDUINO_CORE_RELEASE ARDUINO_ESP32_RELEASE #endif // ARDUINO_ESP32_RELEASE +#define USE_TFS + +#ifdef USE_SCRIPT +#undef USE_TFS +#endif // USE_SCRIPT + // Hardware has no ESP32 #undef USE_TUYA_DIMMER #undef USE_PWM_DIMMER