summaryrefslogtreecommitdiff
path: root/ports/stm32/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'ports/stm32/main.c')
-rw-r--r--ports/stm32/main.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/ports/stm32/main.c b/ports/stm32/main.c
index 3291a8018..875584be8 100644
--- a/ports/stm32/main.c
+++ b/ports/stm32/main.c
@@ -233,7 +233,7 @@ MP_NOINLINE STATIC bool init_flash_fs(uint reset_mode) {
#if MICROPY_HW_SDCARD_MOUNT_AT_BOOT
STATIC bool init_sdcard_fs(void) {
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
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);
@@ -241,7 +241,16 @@ STATIC bool init_sdcard_fs(void) {
break;
}
vfs_fat->blockdev.flags = MP_BLOCKDEV_FLAG_FREE_OBJ;
- sdcard_init_vfs(vfs_fat, part_num);
+ 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);
+ }
// try to mount the partition
FRESULT res = f_mount(&vfs_fat->fatfs);