circuitpython/ports/samd/modules/_boot.py
robert-hh 972212907d samd/mcu: Use lf2s for SAMD51 and lfs1 for SAMD21.
Using lfs1 gives a smaller code, but lfs2 has more features.
2022-10-06 23:14:21 +11:00

20 lines
354 B
Python

import gc
import uos
import samd
samd.Flash.flash_init()
bdev = samd.Flash()
# Try to mount the filesystem, and format the flash if it doesn't exist.
fs_type = uos.VfsLfs2 if hasattr(uos, "VfsLfs2") else uos.VfsLfs1
try:
vfs = fs_type(bdev)
except:
fs_type.mkfs(bdev)
vfs = fs_type(bdev)
uos.mount(vfs, "/")
gc.collect()
del uos, vfs, gc