Commit 8236d183 authored by Damien George's avatar Damien George
Browse files

stmhal/main: Allocate flash's VFS struct on the heap to trace root ptrs.

parent f07a56fa
......@@ -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);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment