Add persistent VFS shares so that the devices can be used with USB

that is present across soft-reset.
This commit is contained in:
Scott Shawcroft 2017-01-12 12:33:15 -08:00
parent 0d408488c5
commit 9ece7c907d
3 changed files with 8 additions and 1 deletions

View File

@ -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.

View File

@ -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

View File

@ -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