2021-05-07 09:21:09 -04:00
|
|
|
# _boot.py
|
|
|
|
# Try to mount the filesystem, and format the flash if it doesn't exist.
|
|
|
|
# Note: the flash requires the programming size to be aligned to 256 bytes.
|
|
|
|
|
|
|
|
import os
|
2021-08-01 05:20:39 -04:00
|
|
|
import sys
|
2021-05-07 09:21:09 -04:00
|
|
|
import mimxrt
|
2021-08-01 05:20:39 -04:00
|
|
|
from machine import Pin
|
2021-05-07 09:21:09 -04:00
|
|
|
|
|
|
|
bdev = mimxrt.Flash()
|
|
|
|
try:
|
|
|
|
vfs = os.VfsLfs2(bdev, progsize=256)
|
|
|
|
except:
|
|
|
|
os.VfsLfs2.mkfs(bdev, progsize=256)
|
|
|
|
vfs = os.VfsLfs2(bdev, progsize=256)
|
2021-08-01 05:20:39 -04:00
|
|
|
os.mount(vfs, "/flash")
|
|
|
|
os.chdir("/flash")
|
|
|
|
sys.path.append("/flash")
|
|
|
|
|
|
|
|
# do not mount the SD card if SKIPSD exists.
|
|
|
|
try:
|
|
|
|
os.stat("SKIPSD")
|
|
|
|
except:
|
|
|
|
try:
|
|
|
|
from machine import SDCard
|
|
|
|
|
|
|
|
sdcard = SDCard(1)
|
|
|
|
|
|
|
|
fat = os.VfsFat(sdcard)
|
|
|
|
os.mount(fat, "/sdcard")
|
|
|
|
os.chdir("/sdcard")
|
|
|
|
sys.path.append("/sdcard")
|
|
|
|
except:
|
|
|
|
pass # Fail silently
|