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.
This commit is contained in:
Andrew Leech 2019-03-25 11:20:54 +11:00 committed by Damien George
parent d396a7e10d
commit 74d07469f2
1 changed files with 3 additions and 0 deletions

View File

@ -113,6 +113,9 @@ STATIC mp_obj_t fat_vfs_mkfs(mp_obj_t bdev_in) {
// make the filesystem // make the filesystem
uint8_t working_buf[FF_MAX_SS]; uint8_t working_buf[FF_MAX_SS];
FRESULT res = f_mkfs(&vfs->fatfs, FM_FAT | FM_SFD, 0, working_buf, sizeof(working_buf)); 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) { if (res != FR_OK) {
mp_raise_OSError(fresult_to_errno_table[res]); mp_raise_OSError(fresult_to_errno_table[res]);
} }