diff options
author | iabdalkader <i.abdalkader@gmail.com> | 2024-09-04 12:14:01 +0200 |
---|---|---|
committer | Damien George <damien@micropython.org> | 2024-09-19 13:04:48 +1000 |
commit | 451ba1cf386a2a0874ea20ea593dd6a009ede011 (patch) | |
tree | 73f5aea21db7ff9e7199d859a8867cc389dfa54d | |
parent | ded8bbdd5efc50d2b86e3020462ced8bbcf4d25c (diff) | |
download | micropython-451ba1cf386a2a0874ea20ea593dd6a009ede011.tar.gz micropython-451ba1cf386a2a0874ea20ea593dd6a009ede011.zip |
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>
-rw-r--r-- | ports/rp2/modules/_boot_fat.py | 7 |
1 files 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 |