2021-05-20 04:30:08 -04:00
|
|
|
import gc
|
|
|
|
import uos
|
|
|
|
import samd
|
|
|
|
|
|
|
|
bdev = samd.Flash()
|
|
|
|
|
|
|
|
# Try to mount the filesystem, and format the flash if it doesn't exist.
|
2022-07-10 05:55:56 -04:00
|
|
|
fs_type = uos.VfsLfs2 if hasattr(uos, "VfsLfs2") else uos.VfsLfs1
|
|
|
|
|
2021-05-20 04:30:08 -04:00
|
|
|
try:
|
2023-05-24 10:19:33 -04:00
|
|
|
vfs = fs_type(bdev, progsize=256)
|
2021-05-20 04:30:08 -04:00
|
|
|
except:
|
2023-05-24 10:19:33 -04:00
|
|
|
fs_type.mkfs(bdev, progsize=256)
|
|
|
|
vfs = fs_type(bdev, progsize=256)
|
2021-05-20 04:30:08 -04:00
|
|
|
uos.mount(vfs, "/")
|
|
|
|
|
2023-05-24 10:19:33 -04:00
|
|
|
del vfs, fs_type, bdev, uos, samd
|
2021-05-20 04:30:08 -04:00
|
|
|
gc.collect()
|
2023-05-24 10:19:33 -04:00
|
|
|
del gc
|