File tree 1 file changed +6
-3
lines changed 1 file changed +6
-3
lines changed Original file line number Diff line number Diff line change @@ -107,7 +107,7 @@ void do_str(const char *src, mp_parse_input_kind_t input_kind) {
107
107
108
108
// we don't make this function static because it needs a lot of stack and we
109
109
// want it to be executed without using stack within main() function
110
- void init_flash_fs (void ) {
110
+ void init_flash_fs (bool create_allowed ) {
111
111
// init the vfs object
112
112
fs_user_mount_t * vfs_fat = & fs_user_mount_flash ;
113
113
vfs_fat -> flags = 0 ;
@@ -116,7 +116,7 @@ void init_flash_fs(void) {
116
116
// try to mount the flash
117
117
FRESULT res = f_mount (& vfs_fat -> fatfs );
118
118
119
- if (res == FR_NO_FILESYSTEM ) {
119
+ if (res == FR_NO_FILESYSTEM && create_allowed ) {
120
120
// no filesystem so create a fresh one
121
121
122
122
uint8_t working_buf [_MAX_SS ];
@@ -653,7 +653,10 @@ int main(void) {
653
653
mp_stack_fill_with_sentinel ();
654
654
#endif
655
655
656
- init_flash_fs ();
656
+ // Create a new filesystem only if we're not in a safe mode.
657
+ // A power brownout here could make it appear as if there's
658
+ // no SPI flash filesystem, and we might erase the existing one.
659
+ init_flash_fs (safe_mode == NO_SAFE_MODE );
657
660
658
661
// Reset everything and prep MicroPython to run boot.py.
659
662
reset_samd21 ();
You can’t perform that action at this time.
0 commit comments