Skip to content

Commit

Permalink
Disallow format file system if brownout, allow otherwise
Browse files Browse the repository at this point in the history
  • Loading branch information
tyeth committed Nov 8, 2024
1 parent 4b911bf commit b18fcf8
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/provisioning/tinyusb/Wippersnapper_FS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit b18fcf8

Please sign in to comment.