From 9ece7c907dc8bfc7487fc33242e8b52f15879dc7 Mon Sep 17 00:00:00 2001 From: Scott Shawcroft Date: Thu, 12 Jan 2017 12:33:15 -0800 Subject: Add persistent VFS shares so that the devices can be used with USB that is present across soft-reset. --- atmel-samd/mpconfigport.h | 1 + py/mpconfig.h | 5 +++++ py/runtime.c | 3 ++- 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/atmel-samd/mpconfigport.h b/atmel-samd/mpconfigport.h index 139557343..667f9bf3f 100644 --- a/atmel-samd/mpconfigport.h +++ b/atmel-samd/mpconfigport.h @@ -70,6 +70,7 @@ #define MICROPY_FATFS_RPATH (2) #define MICROPY_FATFS_VOLUMES (4) #define MICROPY_FATFS_MULTI_PARTITION (1) +#define MICROPY_FATFS_NUM_PERSISTENT (1) #define MICROPY_FSUSERMOUNT (1) // Only enable this if you really need it. It allocates a byte cache of this // size. 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 -- cgit v1.2.3