diff options
author | Damien George <damien.p.george@gmail.com> | 2017-03-10 19:02:20 +1100 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2017-03-10 19:02:20 +1100 |
commit | 8236d18338f6d8db25dcc5e81b176b006d56f39d (patch) | |
tree | 3c8cfb2cacf2fe50763f67b839ab11cc77c9a863 | |
parent | f07a56fa3b10b767960029c82bb2ab7af29e7a04 (diff) | |
download | micropython-8236d18338f6d8db25dcc5e81b176b006d56f39d.tar.gz micropython-8236d18338f6d8db25dcc5e81b176b006d56f39d.zip |
stmhal/main: Allocate flash's VFS struct on the heap to trace root ptrs.
-rw-r--r-- | stmhal/main.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/stmhal/main.c b/stmhal/main.c index e07f6cf8c5..3c9906ad26 100644 --- a/stmhal/main.c +++ b/stmhal/main.c @@ -65,7 +65,6 @@ void SystemClock_Config(void); pyb_thread_t pyb_thread_main; fs_user_mount_t fs_user_mount_flash; -mp_vfs_mount_t mp_vfs_mount_flash; void flash_error(int n) { for (int i = 0; i < n; i++) { @@ -219,12 +218,17 @@ MP_NOINLINE STATIC bool init_flash_fs(uint reset_mode) { } else if (res == FR_OK) { // mount sucessful } else { + fail: printf("PYB: can't mount flash\n"); return false; } // mount the flash device (there should be no other devices mounted at this point) - mp_vfs_mount_t *vfs = &mp_vfs_mount_flash; + // we allocate this structure on the heap because vfs->next is a root pointer + mp_vfs_mount_t *vfs = m_new_obj_maybe(mp_vfs_mount_t); + if (vfs == NULL) { + goto fail; + } vfs->str = "/flash"; vfs->len = 6; vfs->obj = MP_OBJ_FROM_PTR(vfs_fat); |