diff options
| author | Glenn Ruben Bakke <glennbakke@gmail.com> | 2020-07-24 00:38:33 +0200 |
|---|---|---|
| committer | Damien George <damien@micropython.org> | 2021-08-08 23:17:55 +1000 |
| commit | 7b6ad0ce2e6c3c623966c5568989ed5042fb9b1d (patch) | |
| tree | f0de18134fa3d2a5679c24beee3c5b4991475c9f | |
| parent | ffc636de2f2e91e1fecfca1b4b2691a59d83a8eb (diff) | |
nrf/modules/scripts: Add file system formatting script.
Add a helper script _mkfs.py which automatically formats the file system if
nrf.Flash() is located and a VFS file system has been included in the
compilation.
The precedence is: first LFS1, LFS2 then FAT.
| -rw-r--r-- | ports/nrf/modules/scripts/_mkfs.py | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/ports/nrf/modules/scripts/_mkfs.py b/ports/nrf/modules/scripts/_mkfs.py new file mode 100644 index 000000000..00522ffbb --- /dev/null +++ b/ports/nrf/modules/scripts/_mkfs.py @@ -0,0 +1,23 @@ +import uos, nrf + +try: + from uos import VfsLfs1 + + uos.VfsLfs1.mkfs(nrf.Flash()) +except ImportError: + try: + from uos import VfsLfs2 + + uos.VfsLfs2.mkfs(nrf.Flash()) + except ImportError: + try: + from uos import VfsFat + + uos.VfsFat.mkfs(nrf.Flash()) + 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) |
