Some more info from a gdb session:
Looking at the fault information, I see that it's due to a bus fault caused by a PRECISEERR at address 0x8020200 (somewhere in flash).
That region is all zeros, and is readable from gdb:
Code: Select all
(gdb) x/20w 0x8020200
0x8020200: 0x00000000 0x00000000 0x00000000 0x00000000
0x8020210: 0x00000000 0x00000000 0x00000000 0x00000000
0x8020220: 0x00000000 0x00000000 0x00000000 0x00000000
0x8020230: 0x00000000 0x00000000 0x00000000 0x00000000
0x8020240: 0x00000000 0x00000000 0x00000000 0x00000000
Code: Select all
(gdb) bt
#0 HardFault_Handler () at stm32_it.c:223
#1 <signal handler called>
#2 memcpy (dst=dst@entry=0x2400b840, src=<optimized out>, n=n@entry=512)
at ../../shared/libc/string0.c:40
#3 0x08086968 in flash_bdev_readblock (dest=dest@entry=0x2400b840 "", block=block@entry=1)
at flashbdev.c:277
#4 0x08086c5a in storage_read_block (dest=dest@entry=0x2400b840 "", block=block@entry=257)
at storage.c:167
#5 0x08086c78 in storage_read_blocks (dest=0x2400b840 "", block_num=257, num_blocks=1)
at storage.c:202
#6 0x08086cce in pyb_flash_readblocks (n_args=3, args=0x2400b7d0) at storage.c:337
#7 0x0805330c in fun_builtin_var_call (self_in=0x80c232c <pyb_flash_readblocks_obj>, n_args=3,
n_kw=0, args=0x2400b7d0) at ../../py/objfun.c:131
#8 0x0804e8d0 in mp_call_function_n_kw (fun_in=0x80c232c <pyb_flash_readblocks_obj>, n_args=3,
n_kw=n_kw@entry=0, args=0x2400b7d0) at ../../py/runtime.c:655
#9 0x0804e9bc in mp_call_method_n_kw (n_args=n_args@entry=2, n_kw=n_kw@entry=0,
args=<optimized out>) at ../../py/runtime.c:671
#10 0x08064e9e in mp_vfs_blockdev_read (self=<optimized out>, block_num=block_num@entry=257,
num_blocks=num_blocks@entry=1, buf=buf@entry=0x2400b840 "") at ../../extmod/vfs_blockdev.c:57
#11 0x080027dc in disk_read (pdrv=<optimized out>, buff=buff@entry=0x2400b840 "",
sector=sector@entry=257, count=count@entry=1) at ../../extmod/vfs_fat_diskio.c:66
#12 0x08000504 in move_window (sector=257, fs=0x2400b804) at ../../lib/oofatfs/ff.c:1047
#13 move_window (fs=0x2400b804, sector=257) at ../../lib/oofatfs/ff.c:1034
#14 0x080009e2 in get_fat (clst=clst@entry=2, obj=<optimized out>, obj=<optimized out>)
at ../../lib/oofatfs/ff.c:1138
#15 0x08001d52 in f_getfree (fs=fs@entry=0x2400b804, nclst=nclst@entry=0x2407fd7c)
at ../../lib/oofatfs/ff.c:4514
#16 0x080650a6 in fat_vfs_statvfs (vfs_in=0x2400b7c0, path_in=<optimized out>)
at ../../extmod/vfs_fat.c:343
#17 0x08053270 in fun_builtin_2_call (self_in=0x80b3ff0 <fat_vfs_statvfs_obj>,
n_args=<optimized out>, n_kw=<optimized out>, args=0x2407fdbc) at ../../py/objfun.c:86
#18 0x0804e8d0 in mp_call_function_n_kw (fun_in=0x80b3ff0 <fat_vfs_statvfs_obj>, n_args=2,
n_kw=n_kw@entry=0, args=0x2407fdbc) at ../../py/runtime.c:655
#19 0x0804e9bc in mp_call_method_n_kw (n_args=n_args@entry=1, n_kw=n_kw@entry=0,
args=args@entry=0x2407fdb8) at ../../py/runtime.c:671
#20 0x08064780 in mp_vfs_proxy_call (vfs=vfs@entry=0x2400ba40, meth_name=meth_name@entry=1556,
n_args=n_args@entry=1, args=args@entry=0x2407fddc) at ../../extmod/vfs.c:122
#21 0x08064cc8 in mp_vfs_statvfs (path_in=<optimized out>) at ../../extmod/vfs.c:524
#22 0x0805322a in fun_builtin_1_call (self_in=0x80b3ed8 <mp_vfs_statvfs_obj>,
n_args=<optimized out>, n_kw=<optimized out>, args=0x2407fec0) at ../../py/objfun.c:71
#23 0x0804e8d0 in mp_call_function_n_kw (fun_in=0x80b3ed8 <mp_vfs_statvfs_obj>, n_args=1, n_kw=0,
args=0x2407fec0) at ../../py/runtime.c:655
#24 0x0804e9bc in mp_call_method_n_kw (n_args=<optimized out>, n_kw=<optimized out>,
args=args@entry=0x2407feb8) at ../../py/runtime.c:671
#25 0x0805d08e in mp_execute_bytecode (code_state=code_state@entry=0x2407fea0,
inject_exc=inject_exc@entry=0x0) at ../../py/vm.c:1090
#26 0x080533f8 in fun_bc_call (self_in=0x2400ba70, n_args=134539473, n_kw=0, args=0x0)
at ../../py/objfun.c:289
#27 0x0804e8d0 in mp_call_function_n_kw (fun_in=fun_in@entry=0x2400ba70, n_args=n_args@entry=0,
--Type <RET> for more, q to quit, c to continue without paging--c
=n_kw@entry=0, args=args@entry=0x0) at ../../py/runtime.c:655
#28 0x0804e8f8 in mp_call_function_0 (fun=fun@entry=0x2400ba70) at ../../py/runtime.c:629
#29 0x0806a106 in parse_compile_execute (source=source@entry=0x2407ffa0, input_kind=<optimized out>, exec_flags=exec_flags@entry=22) at ../../shared/runtime/pyexec.c:116
#30 0x0806a444 in pyexec_friendly_repl () at ../../shared/runtime/pyexec.c:661
#31 0x0807bdf2 in stm32_main (reset_mode=<optimized out>) at main.c:624
#32 0x0808899e in Reset_Handler ()
So I'm baffled as to why a flash read there should cause a bus fault.
Any ideas?