Damien George 7d28789544 ports: Use vfs module instead of os.
Signed-off-by: Damien George <damien@micropython.org>
2024-02-07 13:25:09 +11:00

22 lines
432 B
Python

import gc
import vfs
import samd
import sys
bdev = samd.Flash()
# Try to mount the filesystem, and format the flash if it doesn't exist.
fs_type = vfs.VfsLfs2 if hasattr(vfs, "VfsLfs2") else vfs.VfsLfs1
try:
fs = fs_type(bdev, progsize=256)
except:
fs_type.mkfs(bdev, progsize=256)
fs = fs_type(bdev, progsize=256)
vfs.mount(fs, "/")
sys.path.append("/lib")
del fs, fs_type, bdev, vfs, samd, sys
gc.collect()
del gc