2021-05-20 18:30:08 +10:00
|
|
|
import gc
|
2023-11-22 16:24:10 +11:00
|
|
|
import vfs
|
2021-05-20 18:30:08 +10:00
|
|
|
import samd
|
2023-08-16 15:08:50 +10:00
|
|
|
import sys
|
2021-05-20 18:30:08 +10:00
|
|
|
|
|
|
|
|
bdev = samd.Flash()
|
|
|
|
|
|
|
|
|
|
# Try to mount the filesystem, and format the flash if it doesn't exist.
|
2023-11-22 16:24:10 +11:00
|
|
|
fs_type = vfs.VfsLfs2 if hasattr(vfs, "VfsLfs2") else vfs.VfsLfs1
|
2022-07-10 11:55:56 +02:00
|
|
|
|
2021-05-20 18:30:08 +10:00
|
|
|
try:
|
2023-11-22 16:24:10 +11:00
|
|
|
fs = fs_type(bdev, progsize=256)
|
2021-05-20 18:30:08 +10:00
|
|
|
except:
|
2023-05-24 16:19:33 +02:00
|
|
|
fs_type.mkfs(bdev, progsize=256)
|
2023-11-22 16:24:10 +11:00
|
|
|
fs = fs_type(bdev, progsize=256)
|
|
|
|
|
vfs.mount(fs, "/")
|
2023-08-16 15:08:50 +10:00
|
|
|
sys.path.append("/lib")
|
2021-05-20 18:30:08 +10:00
|
|
|
|
2023-11-22 16:24:10 +11:00
|
|
|
del fs, fs_type, bdev, vfs, samd, sys
|
2021-05-20 18:30:08 +10:00
|
|
|
gc.collect()
|
2023-05-24 16:19:33 +02:00
|
|
|
del gc
|