micropython/ports/samd/modules/_boot.py
robert-hh 69cb5e8f2a samd: Adapt existing samd.Flash and integrate with (Q)SPI flash in boot.
Checks are added to ensure, that only one of the flash drivers is selected.

Signed-off-by: robert-hh <robert@hammelrath.com>
2023-06-06 00:49:36 +10:00

20 lines
396 B
Python

import gc
import uos
import samd
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, progsize=256)
except:
fs_type.mkfs(bdev, progsize=256)
vfs = fs_type(bdev, progsize=256)
uos.mount(vfs, "/")
del vfs, fs_type, bdev, uos, samd
gc.collect()
del gc