@@ -97,6 +97,7 @@ Wippersnapper_FS::Wippersnapper_FS() {
9797 WS_DEBUG_PRINTLN (project_dependencies);
9898 WS_DEBUG_PRINTLN (" *********************" );
9999 WS_PRINTER.flush ();
100+ delay (50 ); // give host a chance to finish reading serial buffer
100101#endif
101102 // Detach USB device during init.
102103 TinyUSBDevice.detach ();
@@ -159,17 +160,12 @@ bool Wippersnapper_FS::initFilesystem(bool force_format) {
159160 if (!wipperFatFs.begin (&flash))
160161 return false ;
161162
162- if (false ) { // TODO: reinstate after discussion over utility. Restest a full fs.
163-
164163 // TODO: Don't do this unless we need the space and createSecrets fails
165164 // If CircuitPython was previously installed - erase CPY FS
166165 eraseCPFS ();
167166 // Also, should probably relabel drive to WIPPER if CIRCUITPY was there
168167 // using setVolumeLabel(), but note the FS must be unmounted first
169- }
170-
171168
172- // TODO: don't do this every time, only if missing (less power usage? less block wear)
173169 // No file indexing on macOS
174170 if (!wipperFatFs.exists (" /.fseventsd/no_log" ))
175171 {
@@ -196,7 +192,7 @@ if (false) { //TODO: reinstate after discussion over utility. Restest a full fs.
196192 }
197193
198194 // Create wippersnapper_boot_out.txt file
199- if (!createBootFile ())
195+ if (!createBootFile () && !WS. brownOutCausedReset )
200196 return false ;
201197
202198 // Check if secrets.json file already exists
@@ -253,6 +249,9 @@ bool Wippersnapper_FS::configFileExists() {
253249*/
254250/* *************************************************************************/
255251void Wippersnapper_FS::eraseCPFS () {
252+ if (WS.brownOutCausedReset ){
253+ return ; // Can't serial print here, in next PR check we're not out of space
254+ }
256255 if (wipperFatFs.exists (" /boot_out.txt" )) {
257256 wipperFatFs.remove (" /boot_out.txt" );
258257 wipperFatFs.remove (" /code.py" );
@@ -326,8 +325,9 @@ bool Wippersnapper_FS::createBootFile() {
326325 " Creating new file..." );
327326 }
328327
329- // We probably don't need to erase first!
330- eraseBootFile ();
328+ if (WS.brownOutCausedReset ){
329+ return false ;
330+ }
331331
332332 // Overwrite the file with new content
333333 bootFile = wipperFatFs.open (" /wipper_boot_out.txt" , FILE_WRITE);
0 commit comments