Skip to content

Commit b18fcf8

Browse files
committed
Disallow format file system if brownout, allow otherwise
1 parent 4b911bf commit b18fcf8

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

src/provisioning/tinyusb/Wippersnapper_FS.cpp

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,18 @@ Wippersnapper_FS::Wippersnapper_FS() {
106106

107107
// If a filesystem does not already exist - attempt to initialize a new
108108
// filesystem
109-
if (!initFilesystem()){ //} && !initFilesystem(true)) {
110-
setStatusLEDColor(RED);
111-
fsHalt("ERROR Initializing Filesystem");
109+
if (!initFilesystem()) {
110+
if (WS.brownOutCausedReset) {
111+
// try once more for good measure
112+
delay(10); // let power stablise after failure
113+
if (!initFilesystem()) {
114+
// no lights, save power as we're probably on a low battery
115+
fsHalt("Brownout detected. Couldn't initialise filesystem.");
116+
}
117+
} else if (!WS.brownOutCausedReset && !initFilesystem(true)) {
118+
setStatusLEDColor(RED);
119+
fsHalt("ERROR Initializing Filesystem");
120+
}
112121
}
113122

114123
// Initialize USB-MSD

0 commit comments

Comments
 (0)