2022-08-19 13:58:37 +01:00
|
|
|
import os, nrf
|
2020-07-23 23:38:33 +01:00
|
|
|
|
|
|
|
try:
|
2022-08-19 13:58:37 +01:00
|
|
|
from os import VfsLfs1
|
2020-07-23 23:38:33 +01:00
|
|
|
|
2022-08-19 13:58:37 +01:00
|
|
|
os.VfsLfs1.mkfs(nrf.Flash())
|
2020-07-23 23:38:33 +01:00
|
|
|
except ImportError:
|
|
|
|
try:
|
2022-08-19 13:58:37 +01:00
|
|
|
from os import VfsLfs2
|
2020-07-23 23:38:33 +01:00
|
|
|
|
2022-08-19 13:58:37 +01:00
|
|
|
os.VfsLfs2.mkfs(nrf.Flash())
|
2020-07-23 23:38:33 +01:00
|
|
|
except ImportError:
|
|
|
|
try:
|
2022-08-19 13:58:37 +01:00
|
|
|
from os import VfsFat
|
2020-07-23 23:38:33 +01:00
|
|
|
|
2022-08-19 13:58:37 +01:00
|
|
|
os.VfsFat.mkfs(nrf.Flash())
|
2020-07-23 23:38:33 +01:00
|
|
|
except ImportError:
|
|
|
|
pass
|
|
|
|
except OSError as e:
|
|
|
|
if e.args[0] == 5: # I/O Error
|
|
|
|
flashbdev_size = (nrf.Flash.ioctl(4, 0) * nrf.Flash.ioctl(5, 0)) // 1024
|
|
|
|
print()
|
|
|
|
print("Is `FS_SIZE=%iK` enough for FAT filesystem?" % flashbdev_size)
|