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>
This commit is contained in:
robert-hh
2023-05-24 16:19:33 +02:00
committed by Damien George
parent 2b5a5a0f35
commit 69cb5e8f2a
5 changed files with 39 additions and 29 deletions

View File

@@ -2,18 +2,18 @@ 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)
vfs = fs_type(bdev, progsize=256)
except:
fs_type.mkfs(bdev)
vfs = fs_type(bdev)
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 uos, vfs, gc
del gc