Skip to content

Commit 23dd197

Browse files
dhalberttannewt
authored andcommitted
Wait 2 secs before creating new filesystem in case power is jittery
1 parent 22bbb6a commit 23dd197

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

atmel-samd/main.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,11 @@ void init_flash_fs(bool create_allowed) {
122122
if (res == FR_NO_FILESYSTEM && create_allowed) {
123123
// no filesystem so create a fresh one
124124

125+
// Wait two seconds before creating. Jittery power might
126+
// fail before we're ready. This can happen if someone
127+
// is bobbling a bit when plugging in a battery.
128+
mp_hal_delay_ms(2000);
129+
125130
uint8_t working_buf[_MAX_SS];
126131
res = f_mkfs(&vfs_fat->fatfs, FM_FAT, 0, working_buf, sizeof(working_buf));
127132
// Flush the new file system to make sure its repaired immediately.

0 commit comments

Comments
 (0)