From 8cff7a4f1c533721581aac82285e1c094124fc00 Mon Sep 17 00:00:00 2001 From: "Adrian A. Baumann" Date: Mon, 29 Jun 2026 01:03:08 +0200 Subject: [PATCH] Explicitly set LittleFS for uploadfs; log filesystem contents on boot --- platformio.ini | 3 ++- src/main.cpp | 10 +++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/platformio.ini b/platformio.ini index 82d3a0d..27cc672 100644 --- a/platformio.ini +++ b/platformio.ini @@ -25,7 +25,8 @@ board = esp32dev framework = arduino platform = espressif32 monitor_speed = 115200 -lib_deps = +board_build.filesystem = littlefs +lib_deps = tzapu/WiFiManager @ ^2.0.17 bblanchon/ArduinoJson @ ^7.4.3 knolleary/PubSubClient @ ^2.8 diff --git a/src/main.cpp b/src/main.cpp index 8756481..7b1a817 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -461,7 +461,15 @@ static void applyFactoryResetIfNeeded(int count) { void setup() { Serial.begin(115200); Serial.println("\n\n=== ESP32 Device boot ==="); - LittleFS.begin(true); + if (!LittleFS.begin(false)) { + Serial.println("[FS] mount failed, formatting..."); + LittleFS.begin(true); + } else { + Serial.println("[FS] mounted OK"); + File root = LittleFS.open("/"); + File f = root.openNextFile(); + while (f) { Serial.printf("[FS] %s (%u bytes)\n", f.name(), f.size()); f = root.openNextFile(); } + } loadConfig(); hostnameParam.setValue(hostname, sizeof(hostname) - 1);