From 451ba1cf386a2a0874ea20ea593dd6a009ede011 Mon Sep 17 00:00:00 2001 From: iabdalkader Date: Wed, 4 Sep 2024 12:14:01 +0200 Subject: [PATCH] rp2/modules: Fix FatFS boot script to detect invalid FAT filesystem. This change helps detect if the filesystem is invalid, by also including the first mount attempt within the try-except. Then the FAT is reformatted if needed. Fixes issue #15779. Signed-off-by: iabdalkader --- ports/rp2/modules/_boot_fat.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/ports/rp2/modules/_boot_fat.py b/ports/rp2/modules/_boot_fat.py index 5220584455..02d1f99f0d 100644 --- a/ports/rp2/modules/_boot_fat.py +++ b/ports/rp2/modules/_boot_fat.py @@ -5,10 +5,9 @@ import machine, rp2 # Try to mount the filesystem, and format the flash if it doesn't exist. bdev = rp2.Flash() try: - fs = vfs.VfsFat(bdev) + vfs.mount(vfs.VfsFat(bdev), "/") except: vfs.VfsFat.mkfs(bdev) - fs = vfs.VfsFat(bdev) -vfs.mount(fs, "/") + vfs.mount(vfs.VfsFat(bdev), "/") -del vfs, bdev, fs +del vfs, bdev