@@ -97,6 +97,7 @@ Wippersnapper_FS::Wippersnapper_FS() {
97
97
WS_DEBUG_PRINTLN (project_dependencies);
98
98
WS_DEBUG_PRINTLN (" *********************" );
99
99
WS_PRINTER.flush ();
100
+ delay (50 ); // give host a chance to finish reading serial buffer
100
101
#endif
101
102
// Detach USB device during init.
102
103
TinyUSBDevice.detach ();
@@ -159,17 +160,12 @@ bool Wippersnapper_FS::initFilesystem(bool force_format) {
159
160
if (!wipperFatFs.begin (&flash))
160
161
return false ;
161
162
162
- if (false ) { // TODO: reinstate after discussion over utility. Restest a full fs.
163
-
164
163
// TODO: Don't do this unless we need the space and createSecrets fails
165
164
// If CircuitPython was previously installed - erase CPY FS
166
165
eraseCPFS ();
167
166
// Also, should probably relabel drive to WIPPER if CIRCUITPY was there
168
167
// using setVolumeLabel(), but note the FS must be unmounted first
169
- }
170
-
171
168
172
- // TODO: don't do this every time, only if missing (less power usage? less block wear)
173
169
// No file indexing on macOS
174
170
if (!wipperFatFs.exists (" /.fseventsd/no_log" ))
175
171
{
@@ -196,7 +192,7 @@ if (false) { //TODO: reinstate after discussion over utility. Restest a full fs.
196
192
}
197
193
198
194
// Create wippersnapper_boot_out.txt file
199
- if (!createBootFile ())
195
+ if (!createBootFile () && !WS. brownOutCausedReset )
200
196
return false ;
201
197
202
198
// Check if secrets.json file already exists
@@ -253,6 +249,9 @@ bool Wippersnapper_FS::configFileExists() {
253
249
*/
254
250
/* *************************************************************************/
255
251
void 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
+ }
256
255
if (wipperFatFs.exists (" /boot_out.txt" )) {
257
256
wipperFatFs.remove (" /boot_out.txt" );
258
257
wipperFatFs.remove (" /code.py" );
@@ -326,8 +325,9 @@ bool Wippersnapper_FS::createBootFile() {
326
325
" Creating new file..." );
327
326
}
328
327
329
- // We probably don't need to erase first!
330
- eraseBootFile ();
328
+ if (WS.brownOutCausedReset ){
329
+ return false ;
330
+ }
331
331
332
332
// Overwrite the file with new content
333
333
bootFile = wipperFatFs.open (" /wipper_boot_out.txt" , FILE_WRITE);
0 commit comments