File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -65,7 +65,6 @@ void SystemClock_Config(void);
6565
6666pyb_thread_t pyb_thread_main ;
6767fs_user_mount_t fs_user_mount_flash ;
68- mp_vfs_mount_t mp_vfs_mount_flash ;
6968
7069void flash_error (int n ) {
7170 for (int i = 0 ; i < n ; i ++ ) {
@@ -219,12 +218,17 @@ MP_NOINLINE STATIC bool init_flash_fs(uint reset_mode) {
219218 } else if (res == FR_OK ) {
220219 // mount sucessful
221220 } else {
221+ fail :
222222 printf ("PYB: can't mount flash\n" );
223223 return false;
224224 }
225225
226226 // mount the flash device (there should be no other devices mounted at this point)
227- mp_vfs_mount_t * vfs = & mp_vfs_mount_flash ;
227+ // we allocate this structure on the heap because vfs->next is a root pointer
228+ mp_vfs_mount_t * vfs = m_new_obj_maybe (mp_vfs_mount_t );
229+ if (vfs == NULL ) {
230+ goto fail ;
231+ }
228232 vfs -> str = "/flash" ;
229233 vfs -> len = 6 ;
230234 vfs -> obj = MP_OBJ_FROM_PTR (vfs_fat );
You can’t perform that action at this time.
0 commit comments