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 <i.abdalkader@gmail.com>
This commit is contained in:
iabdalkader
2024-09-04 12:14:01 +02:00
committed by Damien George
parent ded8bbdd5e
commit 451ba1cf38

View File

@@ -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