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

pull/2942/head
Damien George 2017-03-10 19:02:20 +11:00
rodzic f07a56fa3b
commit 8236d18338
1 zmienionych plików z 6 dodań i 2 usunięć

Wyświetl plik

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