File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree 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) {
107107
108108// we don't make this function static because it needs a lot of stack and we
109109// 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 ) {
111111 // init the vfs object
112112 fs_user_mount_t * vfs_fat = & fs_user_mount_flash ;
113113 vfs_fat -> flags = 0 ;
@@ -116,7 +116,7 @@ void init_flash_fs(void) {
116116 // try to mount the flash
117117 FRESULT res = f_mount (& vfs_fat -> fatfs );
118118
119- if (res == FR_NO_FILESYSTEM ) {
119+ if (res == FR_NO_FILESYSTEM && create_allowed ) {
120120 // no filesystem so create a fresh one
121121
122122 uint8_t working_buf [_MAX_SS ];
@@ -653,7 +653,10 @@ int main(void) {
653653 mp_stack_fill_with_sentinel ();
654654#endif
655655
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 );
657660
658661 // Reset everything and prep MicroPython to run boot.py.
659662 reset_samd21 ();
You can’t perform that action at this time.
0 commit comments