stm32/main: Support SD cards without a partition table.
Signed-off-by: Damien George <damien@micropython.org>
This commit is contained in:
parent
75d2bfcccf
commit
63c7593df6
@ -233,7 +233,7 @@ MP_NOINLINE STATIC bool init_flash_fs(uint reset_mode) {
|
|||||||
#if MICROPY_HW_SDCARD_MOUNT_AT_BOOT
|
#if MICROPY_HW_SDCARD_MOUNT_AT_BOOT
|
||||||
STATIC bool init_sdcard_fs(void) {
|
STATIC bool init_sdcard_fs(void) {
|
||||||
bool first_part = true;
|
bool first_part = true;
|
||||||
for (int part_num = 1; part_num <= 4; ++part_num) {
|
for (int part_num = 1; part_num <= 5; ++part_num) {
|
||||||
// create vfs object
|
// create vfs object
|
||||||
fs_user_mount_t *vfs_fat = m_new_obj_maybe(fs_user_mount_t);
|
fs_user_mount_t *vfs_fat = m_new_obj_maybe(fs_user_mount_t);
|
||||||
mp_vfs_mount_t *vfs = m_new_obj_maybe(mp_vfs_mount_t);
|
mp_vfs_mount_t *vfs = m_new_obj_maybe(mp_vfs_mount_t);
|
||||||
@ -241,7 +241,16 @@ STATIC bool init_sdcard_fs(void) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
vfs_fat->blockdev.flags = MP_BLOCKDEV_FLAG_FREE_OBJ;
|
vfs_fat->blockdev.flags = MP_BLOCKDEV_FLAG_FREE_OBJ;
|
||||||
|
if (part_num == 5) {
|
||||||
|
if (!first_part) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
// partitions 1-4 couldn't be mounted, so try FATFS auto-detect mode
|
||||||
|
// which will work if there is no partition table, just a filesystem
|
||||||
|
sdcard_init_vfs(vfs_fat, 0);
|
||||||
|
} else {
|
||||||
sdcard_init_vfs(vfs_fat, part_num);
|
sdcard_init_vfs(vfs_fat, part_num);
|
||||||
|
}
|
||||||
|
|
||||||
// try to mount the partition
|
// try to mount the partition
|
||||||
FRESULT res = f_mount(&vfs_fat->fatfs);
|
FRESULT res = f_mount(&vfs_fat->fatfs);
|
||||||
|
Loading…
Reference in New Issue
Block a user