Wait 2 secs before creating new filesystem in case power is jittery

This commit is contained in:
Dan Halbert 2017-11-07 21:05:49 -05:00 committed by Scott Shawcroft
parent 22bbb6ab86
commit 23dd19757a
1 changed files with 5 additions and 0 deletions

View File

@ -122,6 +122,11 @@ void init_flash_fs(bool create_allowed) {
if (res == FR_NO_FILESYSTEM && create_allowed) {
// no filesystem so create a fresh one
// Wait two seconds before creating. Jittery power might
// fail before we're ready. This can happen if someone
// is bobbling a bit when plugging in a battery.
mp_hal_delay_ms(2000);
uint8_t working_buf[_MAX_SS];
res = f_mkfs(&vfs_fat->fatfs, FM_FAT, 0, working_buf, sizeof(working_buf));
// Flush the new file system to make sure its repaired immediately.