mirror of
https://github.com/MarekZegare4/MeshCore-Solo.git
synced 2026-10-09 11:16: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;
|
||||
}
|
||||
|
||||
|
||||
@@ -70,6 +70,7 @@ build_flags =
|
||||
-D NEARBY_MAX=64
|
||||
-D HIST_ARCHIVE ; message history also on the SD card (ui-lvgl/HistoryStore.h)
|
||||
-D GPS_SKYVIEW ; satellites / signal / DOPs for the GPS screen (helpers/sensors/GpsSky.h)
|
||||
-D ESP32_LITTLEFS ; internal flash as LittleFS, not SPIFFS (helpers/esp32/InternalFS.h)
|
||||
build_src_filter = ${Wio_Tracker_L2.build_src_filter}
|
||||
+<helpers/esp32/*.cpp>
|
||||
+<helpers/ui/LGFXDisplay.cpp>
|
||||
@@ -89,6 +90,7 @@ lib_deps =
|
||||
NetworkClientSecure ; 3.x name of WiFiClientSecure (the header is still there)
|
||||
Preferences
|
||||
Update ; Settings > Firmware update
|
||||
LittleFS
|
||||
|
||||
; The same firmware on the old Arduino-ESP32 2.0.17 (ESP-IDF 4.4), kept for
|
||||
; comparison while the 3.x one settles. Not published (the name doesn't end in
|
||||
@@ -106,4 +108,5 @@ lib_deps =
|
||||
HTTPClient
|
||||
WiFiClientSecure
|
||||
Preferences
|
||||
LittleFS
|
||||
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
#pragma once
|
||||
|
||||
// The ESP32's internal filesystem, on the "spiffs" partition: SPIFFS, or with
|
||||
// -D ESP32_LITTLEFS LittleFS -- far faster for the small files MeshCore keeps
|
||||
// (a settings save: ~0.5 s on SPIFFS), and safe against power loss. The two
|
||||
// formats don't mix: switching a board formats the partition on first boot.
|
||||
#ifdef ESP32_LITTLEFS
|
||||
#include <LittleFS.h>
|
||||
#define ESP32_FS LittleFS
|
||||
#define ESP32_FS_CLASS fs::LittleFSFS
|
||||
#else
|
||||
#include <SPIFFS.h>
|
||||
#define ESP32_FS SPIFFS
|
||||
#define ESP32_FS_CLASS fs::SPIFFSFS
|
||||
#endif
|
||||
Reference in New Issue
Block a user