summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorMaureen Helm <maureen.helm@nxp.com>2019-12-30 17:46:17 -0600
committerDamien George <damien.p.george@gmail.com>2020-02-07 11:24:06 +1100
commit7a5752a7489f6be1c7307455b33119888392a09d (patch)
tree7938aafce6d38865ae5aa28fe33be5581d04ce6a
parent86a66960f9a3538de9d48abb719975741569495f (diff)
downloadmicropython-7a5752a7489f6be1c7307455b33119888392a09d.tar.gz
micropython-7a5752a7489f6be1c7307455b33119888392a09d.zip
zephyr: Enable littlefs.
Enables the littlefs (v1 and v2) filesystems in the zephyr port. Example usage with the internal flash on the reel_board or the rv32m1_vega_ri5cy board: import os from zephyr import FlashArea bdev = FlashArea(FlashArea.STORAGE, 4096) os.VfsLfs2.mkfs(bdev) os.mount(bdev, '/flash') with open('/flash/hello.txt','w') as f: f.write('Hello world') print(open('/flash/hello.txt').read()) Things get a little trickier with the frdm_k64f due to the micropython application spilling into the default flash storage partition defined for this board. The zephyr build system doesn't enforce the flash partitioning when mcuboot is not enabled (which it is not for micropython). For now we can demonstrate that the littlefs filesystem works on frdm_k64f by constructing the FlashArea block device on the mcuboot scratch partition instead of the storage partition. Do this by replacing the FlashArea.STORAGE constant above with the value 4.
-rw-r--r--ports/zephyr/Makefile2
-rw-r--r--ports/zephyr/moduos.c10
2 files changed, 12 insertions, 0 deletions
diff --git a/ports/zephyr/Makefile b/ports/zephyr/Makefile
index 4357786110..0d62e5a7ac 100644
--- a/ports/zephyr/Makefile
+++ b/ports/zephyr/Makefile
@@ -18,6 +18,8 @@ MICROPY_HEAP_SIZE = 16384
FROZEN_DIR = scripts
MICROPY_VFS_FAT ?= 1
+MICROPY_VFS_LFS1 ?= 0
+MICROPY_VFS_LFS2 ?= 1
# Default target
all:
diff --git a/ports/zephyr/moduos.c b/ports/zephyr/moduos.c
index d33c317ce6..46745e656a 100644
--- a/ports/zephyr/moduos.c
+++ b/ports/zephyr/moduos.c
@@ -32,6 +32,10 @@
#include "extmod/vfs_fat.h"
#endif
+#if MICROPY_VFS_LFS1 || MICROPY_VFS_LFS2
+#include "extmod/vfs_lfs.h"
+#endif
+
#if MICROPY_PY_UOS
STATIC const mp_rom_map_elem_t uos_module_globals_table[] = {
@@ -54,6 +58,12 @@ STATIC const mp_rom_map_elem_t uos_module_globals_table[] = {
#if MICROPY_VFS_FAT
{ MP_ROM_QSTR(MP_QSTR_VfsFat), MP_ROM_PTR(&mp_fat_vfs_type) },
#endif
+ #if MICROPY_VFS_LFS1
+ { MP_ROM_QSTR(MP_QSTR_VfsLfs1), MP_ROM_PTR(&mp_type_vfs_lfs1) },
+ #endif
+ #if MICROPY_VFS_LFS2
+ { MP_ROM_QSTR(MP_QSTR_VfsLfs2), MP_ROM_PTR(&mp_type_vfs_lfs2) },
+ #endif
};
STATIC MP_DEFINE_CONST_DICT(uos_module_globals, uos_module_globals_table);