check twice for bad filesystem

This commit is contained in:
Dan Halbert 2017-11-29 22:23:13 -05:00 committed by Scott Shawcroft
parent 23dd19757a
commit ec1d29f4ae

View File

@ -127,16 +127,20 @@ void init_flash_fs(bool create_allowed) {
// is bobbling a bit when plugging in a battery. // is bobbling a bit when plugging in a battery.
mp_hal_delay_ms(2000); mp_hal_delay_ms(2000);
uint8_t working_buf[_MAX_SS]; // Then try one more time to mount the flash in case it was late coming up.
res = f_mkfs(&vfs_fat->fatfs, FM_FAT, 0, working_buf, sizeof(working_buf)); res = f_mount(&vfs_fat->fatfs);
// Flush the new file system to make sure its repaired immediately. if (res == FR_NO_FILESYSTEM) {
flash_flush(); uint8_t working_buf[_MAX_SS];
if (res != FR_OK) { res = f_mkfs(&vfs_fat->fatfs, FM_FAT, 0, working_buf, sizeof(working_buf));
return; // Flush the new file system to make sure its repaired immediately.
} flash_flush();
if (res != FR_OK) {
return;
}
// set label // set label
f_setlabel(&vfs_fat->fatfs, "CIRCUITPY"); f_setlabel(&vfs_fat->fatfs, "CIRCUITPY");
}
} else if (res != FR_OK) { } else if (res != FR_OK) {
return; return;
} }