From b18fcf816f7c78e9929c98fbeb90a3f0ff5997fe Mon Sep 17 00:00:00 2001 From: tyeth Date: Fri, 8 Nov 2024 16:59:31 +0000 Subject: [PATCH] Disallow format file system if brownout, allow otherwise --- src/provisioning/tinyusb/Wippersnapper_FS.cpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/provisioning/tinyusb/Wippersnapper_FS.cpp b/src/provisioning/tinyusb/Wippersnapper_FS.cpp index 5083e2c4..061f2880 100644 --- a/src/provisioning/tinyusb/Wippersnapper_FS.cpp +++ b/src/provisioning/tinyusb/Wippersnapper_FS.cpp @@ -106,9 +106,18 @@ Wippersnapper_FS::Wippersnapper_FS() { // If a filesystem does not already exist - attempt to initialize a new // filesystem - if (!initFilesystem()){ //} && !initFilesystem(true)) { - setStatusLEDColor(RED); - fsHalt("ERROR Initializing Filesystem"); + if (!initFilesystem()) { + if (WS.brownOutCausedReset) { + // try once more for good measure + delay(10); // let power stablise after failure + if (!initFilesystem()) { + // no lights, save power as we're probably on a low battery + fsHalt("Brownout detected. Couldn't initialise filesystem."); + } + } else if (!WS.brownOutCausedReset && !initFilesystem(true)) { + setStatusLEDColor(RED); + fsHalt("ERROR Initializing Filesystem"); + } } // Initialize USB-MSD