Commit 74d07469 authored by Andrew Leech's avatar Andrew Leech Committed by Damien George

extmod/vfs_fat: Fallback to FAT32 if standard FAT16/SFD format fails.

This allows formatting SD cards, larger flash etc which do not support the
default FAT16/SFD format mode.
parent d396a7e1
......@@ -113,6 +113,9 @@ STATIC mp_obj_t fat_vfs_mkfs(mp_obj_t bdev_in) {
// make the filesystem
uint8_t working_buf[FF_MAX_SS];
FRESULT res = f_mkfs(&vfs->fatfs, FM_FAT | FM_SFD, 0, working_buf, sizeof(working_buf));
if (res == FR_MKFS_ABORTED) { // Probably doesn't support FAT16
res = f_mkfs(&vfs->fatfs, FM_FAT32, 0, working_buf, sizeof(working_buf));
}
if (res != FR_OK) {
mp_raise_OSError(fresult_to_errno_table[res]);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment