From b893257696208b503aeb99e2fff7cf36527d31fe Mon Sep 17 00:00:00 2001 From: Thomas Basler Date: Wed, 15 Jun 2022 22:07:30 +0200 Subject: [PATCH] Format config partition if mount failed --- src/main.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 75b7ecd..cfdbfb0 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -20,8 +20,13 @@ void setup() // Initialize file system Serial.print(F("Initialize FS... ")); - if (!LittleFS.begin()) { - Serial.println(F("failed")); + if (!LittleFS.begin(false)) { // Do not format if mount failed + Serial.print(F("failed... trying to format...")); + if (!LittleFS.begin(true)) { + Serial.print("success"); + } else { + Serial.print("failed"); + } } else { Serial.println(F("done")); }