mirror of
https://github.com/MarekZegare4/MeshCore-Solo.git
synced 2026-10-09 03:06:39 +00:00
feat(wio-tracker-l2): internal flash as LittleFS instead of SPIFFS
helpers/esp32/InternalFS.h picks the filesystem: -D ESP32_LITTLEFS mounts LittleFS on the same "spiffs" partition, otherwise SPIFFS as before. Only the L2 LVGL envs set it; every other ESP32 board is unchanged. A settings save drops from ~0.5 s to ~80 ms and the files survive power loss mid-write. No migration: the first boot formats the partition (fresh identity). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -81,7 +81,7 @@ void DataStore::begin() {
|
||||
}
|
||||
|
||||
#if defined(ESP32)
|
||||
#include <SPIFFS.h>
|
||||
#include <helpers/esp32/InternalFS.h>
|
||||
#include <nvs_flash.h>
|
||||
#elif defined(RP2040_PLATFORM)
|
||||
#include <LittleFS.h>
|
||||
@@ -119,7 +119,7 @@ lfs_ssize_t _getLfsUsedBlockCount(FILESYSTEM* fs) {
|
||||
|
||||
uint32_t DataStore::getStorageUsedKb() const {
|
||||
#if defined(ESP32)
|
||||
return SPIFFS.usedBytes() / 1024;
|
||||
return ESP32_FS.usedBytes() / 1024;
|
||||
#elif defined(RP2040_PLATFORM)
|
||||
FSInfo info;
|
||||
info.usedBytes = 0;
|
||||
@@ -137,7 +137,7 @@ uint32_t DataStore::getStorageUsedKb() const {
|
||||
|
||||
uint32_t DataStore::getStorageTotalKb() const {
|
||||
#if defined(ESP32)
|
||||
return SPIFFS.totalBytes() / 1024;
|
||||
return ESP32_FS.totalBytes() / 1024;
|
||||
#elif defined(RP2040_PLATFORM)
|
||||
FSInfo info;
|
||||
info.totalBytes = 0;
|
||||
@@ -198,7 +198,7 @@ bool DataStore::formatFileSystem() {
|
||||
#elif defined(RP2040_PLATFORM)
|
||||
return LittleFS.format();
|
||||
#elif defined(ESP32)
|
||||
bool fs_success = ((fs::SPIFFSFS *)_fs)->format();
|
||||
bool fs_success = ((ESP32_FS_CLASS *)_fs)->format();
|
||||
esp_err_t nvs_err = nvs_flash_erase(); // no need to reinit, will be done by reboot
|
||||
return fs_success && (nvs_err == ESP_OK);
|
||||
#elif defined(SIM_PLATFORM)
|
||||
|
||||
@@ -37,7 +37,7 @@ class UITask;
|
||||
#elif defined(RP2040_PLATFORM)
|
||||
#include <LittleFS.h>
|
||||
#elif defined(ESP32)
|
||||
#include <SPIFFS.h>
|
||||
#include <helpers/esp32/InternalFS.h>
|
||||
#endif
|
||||
|
||||
#include "DataStore.h"
|
||||
|
||||
@@ -54,8 +54,8 @@ static uint32_t _atoi(const char* sp) {
|
||||
#include <LittleFS.h>
|
||||
DataStore store(LittleFS, rtc_clock);
|
||||
#elif defined(ESP32)
|
||||
#include <SPIFFS.h>
|
||||
DataStore store(SPIFFS, rtc_clock);
|
||||
#include <helpers/esp32/InternalFS.h>
|
||||
DataStore store(ESP32_FS, rtc_clock);
|
||||
#elif defined(SIM_PLATFORM)
|
||||
#include <SimFS.h>
|
||||
// Real files under ./sim_data/ (relative to the process's cwd) so
|
||||
@@ -271,7 +271,7 @@ void setup() {
|
||||
#endif
|
||||
the_mesh.startInterface(serial_interface);
|
||||
#elif defined(ESP32)
|
||||
SPIFFS.begin(true);
|
||||
ESP32_FS.begin(true);
|
||||
store.begin();
|
||||
the_mesh.begin();
|
||||
resolveBLEPin(
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
#include <HTTPClient.h>
|
||||
#include <WiFiClientSecure.h>
|
||||
#include <Preferences.h>
|
||||
#include <SPIFFS.h>
|
||||
#include <helpers/esp32/InternalFS.h>
|
||||
#include <esp_heap_caps.h>
|
||||
#include <esp_system.h>
|
||||
#include <esp_core_dump.h>
|
||||
@@ -262,10 +262,14 @@ static bool crashSummary(char* out, size_t n) {
|
||||
#endif
|
||||
}
|
||||
// The internal flash file system (contacts, channels, settings, trail...).
|
||||
#ifdef ESP32_LITTLEFS
|
||||
static const char* const FLASH_ROOT = "/littlefs";
|
||||
#else
|
||||
static const char* const FLASH_ROOT = "/spiffs";
|
||||
#endif
|
||||
static bool flashInfo(uint64_t& total, uint64_t& used) {
|
||||
total = SPIFFS.totalBytes();
|
||||
used = SPIFFS.usedBytes();
|
||||
total = ESP32_FS.totalBytes();
|
||||
used = ESP32_FS.usedBytes();
|
||||
return total > 0;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user