mirror of
https://github.com/MarekZegare4/MeshCore-Solo.git
synced 2026-10-18 19:42:09 +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)
|
#if defined(ESP32)
|
||||||
#include <SPIFFS.h>
|
#include <helpers/esp32/InternalFS.h>
|
||||||
#include <nvs_flash.h>
|
#include <nvs_flash.h>
|
||||||
#elif defined(RP2040_PLATFORM)
|
#elif defined(RP2040_PLATFORM)
|
||||||
#include <LittleFS.h>
|
#include <LittleFS.h>
|
||||||
@@ -119,7 +119,7 @@ lfs_ssize_t _getLfsUsedBlockCount(FILESYSTEM* fs) {
|
|||||||
|
|
||||||
uint32_t DataStore::getStorageUsedKb() const {
|
uint32_t DataStore::getStorageUsedKb() const {
|
||||||
#if defined(ESP32)
|
#if defined(ESP32)
|
||||||
return SPIFFS.usedBytes() / 1024;
|
return ESP32_FS.usedBytes() / 1024;
|
||||||
#elif defined(RP2040_PLATFORM)
|
#elif defined(RP2040_PLATFORM)
|
||||||
FSInfo info;
|
FSInfo info;
|
||||||
info.usedBytes = 0;
|
info.usedBytes = 0;
|
||||||
@@ -137,7 +137,7 @@ uint32_t DataStore::getStorageUsedKb() const {
|
|||||||
|
|
||||||
uint32_t DataStore::getStorageTotalKb() const {
|
uint32_t DataStore::getStorageTotalKb() const {
|
||||||
#if defined(ESP32)
|
#if defined(ESP32)
|
||||||
return SPIFFS.totalBytes() / 1024;
|
return ESP32_FS.totalBytes() / 1024;
|
||||||
#elif defined(RP2040_PLATFORM)
|
#elif defined(RP2040_PLATFORM)
|
||||||
FSInfo info;
|
FSInfo info;
|
||||||
info.totalBytes = 0;
|
info.totalBytes = 0;
|
||||||
@@ -198,7 +198,7 @@ bool DataStore::formatFileSystem() {
|
|||||||
#elif defined(RP2040_PLATFORM)
|
#elif defined(RP2040_PLATFORM)
|
||||||
return LittleFS.format();
|
return LittleFS.format();
|
||||||
#elif defined(ESP32)
|
#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
|
esp_err_t nvs_err = nvs_flash_erase(); // no need to reinit, will be done by reboot
|
||||||
return fs_success && (nvs_err == ESP_OK);
|
return fs_success && (nvs_err == ESP_OK);
|
||||||
#elif defined(SIM_PLATFORM)
|
#elif defined(SIM_PLATFORM)
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ class UITask;
|
|||||||
#elif defined(RP2040_PLATFORM)
|
#elif defined(RP2040_PLATFORM)
|
||||||
#include <LittleFS.h>
|
#include <LittleFS.h>
|
||||||
#elif defined(ESP32)
|
#elif defined(ESP32)
|
||||||
#include <SPIFFS.h>
|
#include <helpers/esp32/InternalFS.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "DataStore.h"
|
#include "DataStore.h"
|
||||||
|
|||||||
@@ -54,8 +54,8 @@ static uint32_t _atoi(const char* sp) {
|
|||||||
#include <LittleFS.h>
|
#include <LittleFS.h>
|
||||||
DataStore store(LittleFS, rtc_clock);
|
DataStore store(LittleFS, rtc_clock);
|
||||||
#elif defined(ESP32)
|
#elif defined(ESP32)
|
||||||
#include <SPIFFS.h>
|
#include <helpers/esp32/InternalFS.h>
|
||||||
DataStore store(SPIFFS, rtc_clock);
|
DataStore store(ESP32_FS, rtc_clock);
|
||||||
#elif defined(SIM_PLATFORM)
|
#elif defined(SIM_PLATFORM)
|
||||||
#include <SimFS.h>
|
#include <SimFS.h>
|
||||||
// Real files under ./sim_data/ (relative to the process's cwd) so
|
// Real files under ./sim_data/ (relative to the process's cwd) so
|
||||||
@@ -271,7 +271,7 @@ void setup() {
|
|||||||
#endif
|
#endif
|
||||||
the_mesh.startInterface(serial_interface);
|
the_mesh.startInterface(serial_interface);
|
||||||
#elif defined(ESP32)
|
#elif defined(ESP32)
|
||||||
SPIFFS.begin(true);
|
ESP32_FS.begin(true);
|
||||||
store.begin();
|
store.begin();
|
||||||
the_mesh.begin();
|
the_mesh.begin();
|
||||||
resolveBLEPin(
|
resolveBLEPin(
|
||||||
|
|||||||
@@ -12,7 +12,7 @@
|
|||||||
#include <HTTPClient.h>
|
#include <HTTPClient.h>
|
||||||
#include <WiFiClientSecure.h>
|
#include <WiFiClientSecure.h>
|
||||||
#include <Preferences.h>
|
#include <Preferences.h>
|
||||||
#include <SPIFFS.h>
|
#include <helpers/esp32/InternalFS.h>
|
||||||
#include <esp_heap_caps.h>
|
#include <esp_heap_caps.h>
|
||||||
#include <esp_system.h>
|
#include <esp_system.h>
|
||||||
#include <esp_core_dump.h>
|
#include <esp_core_dump.h>
|
||||||
@@ -262,10 +262,14 @@ static bool crashSummary(char* out, size_t n) {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
// The internal flash file system (contacts, channels, settings, trail...).
|
// 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";
|
static const char* const FLASH_ROOT = "/spiffs";
|
||||||
|
#endif
|
||||||
static bool flashInfo(uint64_t& total, uint64_t& used) {
|
static bool flashInfo(uint64_t& total, uint64_t& used) {
|
||||||
total = SPIFFS.totalBytes();
|
total = ESP32_FS.totalBytes();
|
||||||
used = SPIFFS.usedBytes();
|
used = ESP32_FS.usedBytes();
|
||||||
return total > 0;
|
return total > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -70,6 +70,7 @@ build_flags =
|
|||||||
-D NEARBY_MAX=64
|
-D NEARBY_MAX=64
|
||||||
-D HIST_ARCHIVE ; message history also on the SD card (ui-lvgl/HistoryStore.h)
|
-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 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}
|
build_src_filter = ${Wio_Tracker_L2.build_src_filter}
|
||||||
+<helpers/esp32/*.cpp>
|
+<helpers/esp32/*.cpp>
|
||||||
+<helpers/ui/LGFXDisplay.cpp>
|
+<helpers/ui/LGFXDisplay.cpp>
|
||||||
@@ -89,6 +90,7 @@ lib_deps =
|
|||||||
NetworkClientSecure ; 3.x name of WiFiClientSecure (the header is still there)
|
NetworkClientSecure ; 3.x name of WiFiClientSecure (the header is still there)
|
||||||
Preferences
|
Preferences
|
||||||
Update ; Settings > Firmware update
|
Update ; Settings > Firmware update
|
||||||
|
LittleFS
|
||||||
|
|
||||||
; The same firmware on the old Arduino-ESP32 2.0.17 (ESP-IDF 4.4), kept for
|
; 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
|
; comparison while the 3.x one settles. Not published (the name doesn't end in
|
||||||
@@ -106,4 +108,5 @@ lib_deps =
|
|||||||
HTTPClient
|
HTTPClient
|
||||||
WiFiClientSecure
|
WiFiClientSecure
|
||||||
Preferences
|
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