mirror of
https://github.com/micropython/micropython.git
synced 2025-09-07 18:30:27 +02:00
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>
14 lines
253 B
Python
14 lines
253 B
Python
import vfs
|
|
import machine, rp2
|
|
|
|
|
|
# Try to mount the filesystem, and format the flash if it doesn't exist.
|
|
bdev = rp2.Flash()
|
|
try:
|
|
vfs.mount(vfs.VfsFat(bdev), "/")
|
|
except:
|
|
vfs.VfsFat.mkfs(bdev)
|
|
vfs.mount(vfs.VfsFat(bdev), "/")
|
|
|
|
del vfs, bdev
|