8000 extmod/vfs_fat: Fallback to FAT32 if standard FAT16/SFD format fails. · rlucia/micropython@74d0746 · GitHub
[go: up one dir, main page]

Skip to content

Commit 74d0746

Browse files
pi-anldpgeorge
authored andcommitted
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.
1 parent d396a7e commit 74d0746

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

extmod/vfs_fat.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,9 @@ STATIC mp_obj_t fat_vfs_mkfs(mp_obj_t bdev_in) {
113113
// make the filesystem
114114
uint8_t working_buf[FF_MAX_SS];
115115
FRESULT res = f_mkfs(&vfs->fatfs, FM_FAT | FM_SFD, 0, working_buf, sizeof(working_buf));
116+
if (res == FR_MKFS_ABORTED) { // Probably doesn't support FAT16
117+
res = f_mkfs(&vfs->fatfs, FM_FAT32, 0, working_buf, sizeof(working_buf));
118+
}
116119
if (res != FR_OK) {
117120
mp_raise_OSError(fresult_to_errno_table[res]);
118121
}

0 commit comments

Comments
 (0)
0