Skip to content

Don't create a new filesystem if we restart in safe mode. #319

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 12, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions atmel-samd/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ void do_str(const char *src, mp_parse_input_kind_t input_kind) {

// we don't make this function static because it needs a lot of stack and we
// want it to be executed without using stack within main() function
void init_flash_fs(void) {
void init_flash_fs(bool create_allowed) {
// init the vfs object
fs_user_mount_t *vfs_fat = &fs_user_mount_flash;
vfs_fat->flags = 0;
Expand All @@ -116,7 +116,7 @@ void init_flash_fs(void) {
// try to mount the flash
FRESULT res = f_mount(&vfs_fat->fatfs);

if (res == FR_NO_FILESYSTEM) {
if (res == FR_NO_FILESYSTEM && create_allowed) {
// no filesystem so create a fresh one

uint8_t working_buf[_MAX_SS];
Expand Down Expand Up @@ -653,7 +653,10 @@ int main(void) {
mp_stack_fill_with_sentinel();
#endif

init_flash_fs();
// Create a new filesystem only if we're not in a safe mode.
// A power brownout here could make it appear as if there's
// no SPI flash filesystem, and we might erase the existing one.
init_flash_fs(safe_mode == NO_SAFE_MODE);

// Reset everything and prep MicroPython to run boot.py.
reset_samd21();
Expand Down