summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorMaureen Helm <maureen.helm@nxp.com>2019-12-19 16:00:00 -0600
committerDamien George <damien.p.george@gmail.com>2020-02-07 11:24:06 +1100
commit2d7ec8e704968fdac574de1bd0f2d48bc43bd485 (patch)
treebd1724407cd9fc7ec9ee6495d07810c2809f90dd
parenta0440b01ea3eea03fd31a719ca479893ab19d25b (diff)
downloadmicropython-2d7ec8e704968fdac574de1bd0f2d48bc43bd485.tar.gz
micropython-2d7ec8e704968fdac574de1bd0f2d48bc43bd485.zip
zephyr: Enable fatfs.
Enables the fatfs filesystem in the zephyr port. Example usage with an SD card on the mimxrt1050_evk board: import zephyr, os bdev = zephyr.DiskAccess('SDHC') os.VfsFat.mkfs(bdev) os.mount(bdev, '/sd') with open('/sd/hello.txt','w') as f: f.write('Hello world') print(open('/sd/hello.txt').read())
-rw-r--r--ports/zephyr/Makefile5
-rw-r--r--ports/zephyr/moduos.c7
-rw-r--r--ports/zephyr/mpconfigport.h7
3 files changed, 18 insertions, 1 deletions
diff --git a/ports/zephyr/Makefile b/ports/zephyr/Makefile
index 612548dbd0..4357786110 100644
--- a/ports/zephyr/Makefile
+++ b/ports/zephyr/Makefile
@@ -17,6 +17,8 @@ OUTDIR_PREFIX = $(BOARD)
MICROPY_HEAP_SIZE = 16384
FROZEN_DIR = scripts
+MICROPY_VFS_FAT ?= 1
+
# Default target
all:
@@ -48,6 +50,7 @@ SRC_C = main.c \
machine_pin.c \
uart_core.c \
zephyr_storage.c \
+ lib/timeutils/timeutils.c \
lib/utils/stdout_helpers.c \
lib/utils/printf.c \
lib/utils/pyexec.c \
@@ -61,7 +64,7 @@ SRC_QSTR += $(SRC_C)
OBJ = $(PY_O) $(addprefix $(BUILD)/, $(SRC_C:.c=.o))
CFLAGS = $(Z_CFLAGS) \
- -std=gnu99 -fomit-frame-pointer -DNDEBUG -DMICROPY_HEAP_SIZE=$(MICROPY_HEAP_SIZE) $(CFLAGS_EXTRA) $(INC)
+ -std=gnu99 -fomit-frame-pointer -DNDEBUG -DMICROPY_HEAP_SIZE=$(MICROPY_HEAP_SIZE) $(CFLAGS_MOD) $(CFLAGS_EXTRA) $(INC)
include $(TOP)/py/mkrules.mk
diff --git a/ports/zephyr/moduos.c b/ports/zephyr/moduos.c
index 8bda39b562..d33c317ce6 100644
--- a/ports/zephyr/moduos.c
+++ b/ports/zephyr/moduos.c
@@ -28,6 +28,10 @@
#include "extmod/vfs.h"
+#if MICROPY_VFS_FAT
+#include "extmod/vfs_fat.h"
+#endif
+
#if MICROPY_PY_UOS
STATIC const mp_rom_map_elem_t uos_module_globals_table[] = {
@@ -47,6 +51,9 @@ STATIC const mp_rom_map_elem_t uos_module_globals_table[] = {
{ MP_ROM_QSTR(MP_QSTR_mount), MP_ROM_PTR(&mp_vfs_mount_obj) },
{ MP_ROM_QSTR(MP_QSTR_umount), MP_ROM_PTR(&mp_vfs_umount_obj) },
#endif
+ #if MICROPY_VFS_FAT
+ { MP_ROM_QSTR(MP_QSTR_VfsFat), MP_ROM_PTR(&mp_fat_vfs_type) },
+ #endif
};
STATIC MP_DEFINE_CONST_DICT(uos_module_globals, uos_module_globals_table);
diff --git a/ports/zephyr/mpconfigport.h b/ports/zephyr/mpconfigport.h
index 73362f7e9d..7044c175d0 100644
--- a/ports/zephyr/mpconfigport.h
+++ b/ports/zephyr/mpconfigport.h
@@ -84,6 +84,13 @@
#define MICROPY_VFS (1)
#define MICROPY_READER_VFS (MICROPY_VFS)
+// fatfs configuration used in ffconf.h
+#define MICROPY_FATFS_ENABLE_LFN (1)
+#define MICROPY_FATFS_LFN_CODE_PAGE 437 /* 1=SFN/ANSI 437=LFN/U.S.(OEM) */
+#define MICROPY_FATFS_USE_LABEL (1)
+#define MICROPY_FATFS_RPATH (2)
+#define MICROPY_FATFS_NORTC (1)
+
// Saving extra crumbs to make sure binary fits in 128K
#define MICROPY_COMP_CONST_FOLDING (0)
#define MICROPY_COMP_CONST (0)