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