2021-05-20 18:30:08 +10:00
|
|
|
import gc
|
2022-08-19 22:58:37 +10:00
|
|
|
import os
|
2021-05-20 18:30:08 +10:00
|
|
|
import samd
|
|
|
|
|
|
|
|
bdev = samd.Flash()
|
|
|
|
|
|
|
|
# Try to mount the filesystem, and format the flash if it doesn't exist.
|
2022-08-19 22:58:37 +10:00
|
|
|
fs_type = os.VfsLfs2 if hasattr(os, "VfsLfs2") else os.VfsLfs1
|
2022-07-10 11:55:56 +02:00
|
|
|
|
2021-05-20 18:30:08 +10:00
|
|
|
try:
|
2023-05-24 16:19:33 +02:00
|
|
|
vfs = 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)
|
|
|
|
vfs = fs_type(bdev, progsize=256)
|
2022-08-19 22:58:37 +10:00
|
|
|
os.mount(vfs, "/")
|
2021-05-20 18:30:08 +10:00
|
|
|
|
2022-08-19 22:58:37 +10:00
|
|
|
del vfs, fs_type, bdev, os, samd
|
2021-05-20 18:30:08 +10:00
|
|
|
gc.collect()
|
2023-05-24 16:19:33 +02:00
|
|
|
del gc
|