Browse Source

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>
pull/15785/head
iabdalkader 2 months ago
committed by Damien George
parent
commit
451ba1cf38
  1. 7
      ports/rp2/modules/_boot_fat.py

7
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

Loading…
Cancel
Save