micropython/ports/rp2/modules/_boot.py
Damien George 7d28789544 ports: Use vfs module instead of os.
Signed-off-by: Damien George <damien@micropython.org>
2024-02-07 13:25:09 +11:00

16 lines
375 B
Python

import vfs
import machine, rp2
# Try to mount the filesystem, and format the flash if it doesn't exist.
# Note: the flash requires the programming size to be aligned to 256 bytes.
bdev = rp2.Flash()
try:
fs = vfs.VfsLfs2(bdev, progsize=256)
except:
vfs.VfsLfs2.mkfs(bdev, progsize=256)
fs = vfs.VfsLfs2(bdev, progsize=256)
vfs.mount(fs, "/")
del vfs, bdev, fs