summaryrefslogtreecommitdiff
path: root/py
diff options
context:
space:
mode:
authorScott Shawcroft <scott.shawcroft@gmail.com>2017-01-12 12:33:15 -0800
committerScott Shawcroft <scott.shawcroft@gmail.com>2017-01-12 12:46:44 -0800
commit9ece7c907dc8bfc7487fc33242e8b52f15879dc7 (patch)
treee8f7d4dc3b87757a3f020e585681f4ac9f5deae3 /py
parent0d408488c5d328ac45bcb276d444089f0c297cf4 (diff)
Add persistent VFS shares so that the devices can be used with USB
that is present across soft-reset.
Diffstat (limited to 'py')
-rw-r--r--py/mpconfig.h5
-rw-r--r--py/runtime.c3
2 files changed, 7 insertions, 1 deletions
diff --git a/py/mpconfig.h b/py/mpconfig.h
index 6d1893717..df75e0752 100644
--- a/py/mpconfig.h
+++ b/py/mpconfig.h
@@ -403,6 +403,11 @@
#define MICROPY_READER_FATFS (0)
#endif
+// Number of VFS mounts to persist across soft-reset.
+#ifndef MICROPY_FATFS_NUM_PERSISTENT
+#define MICROPY_FATFS_NUM_PERSISTENT (0)
+#endif
+
// Hook for the VM at the start of the opcode loop (can contain variable
// definitions usable by the other hook functions)
#ifndef MICROPY_VM_HOOK_INIT
diff --git a/py/runtime.c b/py/runtime.c
index cd02debf8..c407a58a4 100644
--- a/py/runtime.c
+++ b/py/runtime.c
@@ -103,7 +103,8 @@ void mp_init(void) {
#if MICROPY_FSUSERMOUNT
// zero out the pointers to the user-mounted devices
- memset(MP_STATE_VM(fs_user_mount), 0, sizeof(MP_STATE_VM(fs_user_mount)));
+ memset(MP_STATE_VM(fs_user_mount) + MICROPY_FATFS_NUM_PERSISTENT, 0,
+ sizeof(MP_STATE_VM(fs_user_mount)) - MICROPY_FATFS_NUM_PERSISTENT);
#endif
#if MICROPY_PY_THREAD_GIL