ports: Use vfs module instead of os.

Signed-off-by: Damien George <damien@micropython.org>
This commit is contained in:
Damien George
2023-11-22 16:24:10 +11:00
parent b87bbaeb43
commit 7d28789544
13 changed files with 58 additions and 58 deletions

View File

@@ -1,21 +1,21 @@
import gc
import os
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 = os.VfsLfs2 if hasattr(os, "VfsLfs2") else os.VfsLfs1
fs_type = vfs.VfsLfs2 if hasattr(vfs, "VfsLfs2") else vfs.VfsLfs1
try:
vfs = fs_type(bdev, progsize=256)
fs = fs_type(bdev, progsize=256)
except:
fs_type.mkfs(bdev, progsize=256)
vfs = fs_type(bdev, progsize=256)
os.mount(vfs, "/")
fs = fs_type(bdev, progsize=256)
vfs.mount(fs, "/")
sys.path.append("/lib")
del vfs, fs_type, bdev, os, samd, sys
del fs, fs_type, bdev, vfs, samd, sys
gc.collect()
del gc