[NUCLEO_H743ZI2] MSC not working; reboots when used

Discussion and questions about boards that can run MicroPython but don't have a dedicated forum.
Target audience: Everyone interested in running MicroPython on other hardware.
Post Reply
nedkonz
Posts: 24
Joined: Thu Aug 05, 2021 9:58 pm

[NUCLEO_H743ZI2] MSC not working; reboots when used

Post by nedkonz » Fri Aug 06, 2021 12:03 am

I built the NUCLEO_H743ZI binary from the latest HEAD and loaded it using deploy-stlink (and later using DFU).
In both cases, I can interact with the VCP serial port just fine but the MSC disk doesn't work.

When I connect the board via USB, I get a notification (this is on a Mac but I get the same thing in a Linux VM):

Code: Select all

The disk you inserted was not readable by this computer.
When I use pyboard.py to copy a file to the board I get this (it ends with the board rebooting):

Code: Select all

(py39) [ned@ned micropython (master)]$ tools/pyboard.py -d /dev/cu.usbmodem356E336331392 -f cp boot.py :/flash/boot.py
cp boot.py :/flash/boot.py
Traceback (most recent call last):
  File "/usr/local/anaconda3/envs/py39/lib/python3.9/site-packages/serial/serialposix.py", line 575, in read
    buf = os.read(self.fd, size - len(read))
OSError: [Errno 6] Device not configured
and the board reboots. Diskutil reports:

Code: Select all

/dev/disk10 (external, physical):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:     FDisk_partition_scheme                        *262.1 KB   disk10
   1:                 DOS_FAT_12                         131.1 KB   disk10s1
Interacting with the board, I see this:

Code: Select all

>>> import uos
>>> import pyb
>>> pyb.usb_mode()
'VCP+MSC'
>>> uos.statvfs('/')
(0, 0, 0, 0, 0, 0, 0, 0, 0, 128)
>>> uos.statvfs('/flash')
MicroPython v1.16-160-ga3675294a on 2021-08-05; NUCLEO_H743ZI with STM32H743
Type "help()" for more information.
The board rebooted after that last statvfs() call.

The same thing (reboot) happens upon a uos.mkdir() call.

Any suggestions as to how to diagnose this?

nedkonz
Posts: 24
Joined: Thu Aug 05, 2021 9:58 pm

Re: [NUCLEO_H743ZI2] MSC not working; reboots when used

Post by nedkonz » Fri Aug 06, 2021 5:25 pm

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?

nedkonz
Posts: 24
Joined: Thu Aug 05, 2021 9:58 pm

Re: [NUCLEO_H743ZI2] MSC not working; reboots when used

Post by nedkonz » Fri Aug 06, 2021 5:52 pm

After reading a bit about the ECC scheme (and its bugs), I erased the flash a few times and used GDB to re-program the flash.

Now I can see boot.py, main.py, pybcdc.inf, README.txt, and .fseventsd in the /flash directory.

Post Reply