summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2018-05-28 12:01:52 +1000
committerDamien George <damien.p.george@gmail.com>2018-05-28 21:46:20 +1000
commit6d83468a30f79be9baec297c38506da6517732b5 (patch)
tree93a364e991859e9633a5e2b531dfe5831d169683
parent5c0685912f8efc4e8345999aab647662a5875759 (diff)
stm32: Allow a board to disable MICROPY_VFS_FAT.
-rw-r--r--ports/stm32/modmachine.c2
-rw-r--r--ports/stm32/moduos.c4
-rw-r--r--ports/stm32/mpconfigport.h4
3 files changed, 9 insertions, 1 deletions
diff --git a/ports/stm32/modmachine.c b/ports/stm32/modmachine.c
index ff1eaec95..d8054c3f2 100644
--- a/ports/stm32/modmachine.c
+++ b/ports/stm32/modmachine.c
@@ -181,6 +181,7 @@ STATIC mp_obj_t machine_info(size_t n_args, const mp_obj_t *args) {
// free space on flash
{
+ #if MICROPY_VFS_FAT
for (mp_vfs_mount_t *vfs = MP_STATE_VM(vfs_mount_table); vfs != NULL; vfs = vfs->next) {
if (strncmp("/flash", vfs->str, vfs->len) == 0) {
// assumes that it's a FatFs filesystem
@@ -191,6 +192,7 @@ STATIC mp_obj_t machine_info(size_t n_args, const mp_obj_t *args) {
break;
}
}
+ #endif
}
#if MICROPY_PY_THREAD
diff --git a/ports/stm32/moduos.c b/ports/stm32/moduos.c
index 5728f9c61..0dde844f3 100644
--- a/ports/stm32/moduos.c
+++ b/ports/stm32/moduos.c
@@ -82,10 +82,12 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_0(os_uname_obj, os_uname);
/// \function sync()
/// Sync all filesystems.
STATIC mp_obj_t os_sync(void) {
+ #if MICROPY_VFS_FAT
for (mp_vfs_mount_t *vfs = MP_STATE_VM(vfs_mount_table); vfs != NULL; vfs = vfs->next) {
// this assumes that vfs->obj is fs_user_mount_t with block device functions
disk_ioctl(MP_OBJ_TO_PTR(vfs->obj), CTRL_SYNC, NULL);
}
+ #endif
return mp_const_none;
}
MP_DEFINE_CONST_FUN_OBJ_0(mod_os_sync_obj, os_sync);
@@ -148,7 +150,9 @@ STATIC const mp_rom_map_elem_t os_module_globals_table[] = {
{ MP_ROM_QSTR(MP_QSTR_dupterm), MP_ROM_PTR(&uos_dupterm_obj) },
{ 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) },
+ #if MICROPY_VFS_FAT
{ MP_ROM_QSTR(MP_QSTR_VfsFat), MP_ROM_PTR(&mp_fat_vfs_type) },
+ #endif
};
STATIC MP_DEFINE_CONST_DICT(os_module_globals, os_module_globals_table);
diff --git a/ports/stm32/mpconfigport.h b/ports/stm32/mpconfigport.h
index 84e489297..7bd944213 100644
--- a/ports/stm32/mpconfigport.h
+++ b/ports/stm32/mpconfigport.h
@@ -76,7 +76,9 @@
#define MICROPY_ENABLE_SCHEDULER (1)
#define MICROPY_SCHEDULER_DEPTH (8)
#define MICROPY_VFS (1)
+#ifndef MICROPY_VFS_FAT
#define MICROPY_VFS_FAT (1)
+#endif
// control over Python builtins
#define MICROPY_PY_FUNCTION_ATTRS (1)
@@ -103,7 +105,7 @@
#define MICROPY_PY_MATH_SPECIAL_FUNCTIONS (1)
#define MICROPY_PY_CMATH (1)
#define MICROPY_PY_IO (1)
-#define MICROPY_PY_IO_FILEIO (1)
+#define MICROPY_PY_IO_FILEIO (MICROPY_VFS_FAT) // because mp_type_fileio/textio point to fatfs impl
#define MICROPY_PY_SYS_MAXSIZE (1)
#define MICROPY_PY_SYS_EXIT (1)
#define MICROPY_PY_SYS_STDFILES (1)