8000 Add persistent VFS shares so that the devices can be used with USB · cpforbes/circuitpython@9ece7c9 · GitHub
[go: up one dir, main page]

Skip to content
8000

Commit 9ece7c9

Browse files
committed
Add persistent VFS shares so that the devices can be used with USB
that is present across soft-reset.
1 parent 0d40848 commit 9ece7c9

File tree

3 files changed

+8
-1
lines changed

3 files changed

+8
-1
lines changed

atmel-samd/mpconfigport.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@
7070
#define MICROPY_FATFS_RPATH (2)
7171
#define MICROPY_FATFS_VOLUMES (4)
7272
#define MICROPY_FATFS_MULTI_PARTITION (1)
73+
#define MICROPY_FATFS_NUM_PERSISTENT (1)
7374
#define MICROPY_FSUSERMOUNT (1)
7475
// Only enable this if you really need it. It allocates a byte cache of this
7576
// size.

py/mpconfig.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -403,6 +403,11 @@
403403
#define MICROPY_READER_FATFS (0)
404404
#endif
405405

406+
// Number of VFS mounts to persist across soft-reset.
407+
#ifndef MICROPY_FATFS_NUM_PERSISTENT
408+
#define MICROPY_FATFS_NUM_PERSISTENT (0)
409+
#endif
410+
406411
// Hook for the VM at the start of the opcode loop (can contain variable
407412
// definitions usable by the other hook functions)
408413
#ifndef MICROPY_VM_HOOK_INIT

py/runtime.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,8 @@ void mp_init(void) {
103103

104104
#if MICROPY_FSUSERMOUNT
105105
// zero out the pointers to the user-mounted devices
106-
memset(MP_STATE_VM(fs_user_mount), 0, sizeof(MP_STATE_VM(fs_user_mount)));
106+
memset(MP_STATE_VM(fs_user_mount) + MICROPY_FATFS_NUM_PERSISTENT, 0,
107+
sizeof(MP_STATE_VM(fs_user_mount)) - MICROPY_FATFS_NUM_PERSISTENT);
107108
#endif
108109

109110
#if MICROPY_PY_THREAD_GIL

0 commit comments

Comments
 (0)
0