summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDamien George <damien@micropython.org>2022-03-17 17:09:01 +1100
committerDamien George <damien@micropython.org>2022-03-22 12:41:15 +1100
commit63c7593df66533fc0c529d2ed2a5da38042c8970 (patch)
tree1a251c60ec854cc96ae3c9d7248baad35ec745ec
parent75d2bfcccf04e2740c51c345bc8a3145c2c2c7c7 (diff)
stm32/main: Support SD cards without a partition table.
Signed-off-by: Damien George <damien@micropython.org>
-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);