stlink
stlink copied to clipboard
STM32H7A: Flash write fails on second page
programmer: stlink/v2-clone
os: linux
version: v1.8.0-2-g65f062f
command: st-flash --debug write fw.bin 0x8000000 2> log.txt
Writing the first page, up to 8KiB, works fine, however as soon as the size of the bin file exceeds this I get:
ERROR common_flash.c: Verification of flash failed at offset: 6144
Size of fw.bin is 9704 bytes.
Full log: log.txt
There is a similar issue here: #1342 but it looks like despite the name that's actually talking about the second memory bank, not second page of the first bank.
There is also #1305, but for me erasing works fine, only writing to the second page fails. However it's still possible they are related.
According to one Neil Race there is a suspiciously similar issue with stm32flash: https://sourceforge.net/p/stm32flash/tickets/161/
I did some experiments:
$ stat -c '%s' small.bin big.bin
824
9704
$ st-flash write small.bin 0x08000000
st-flash 1.8.0-2-g65f062f
2024-02-15T17:35:51 INFO common.c: STM32H7Ax_H7Bx: 128 KiB SRAM, 1024 KiB flash in at least 8 KiB pages.
file small.bin md5 checksum: 29eda11138e397cb186819485e13dd2f, stlink checksum: 0x0002c60f
2024-02-15T17:35:51 INFO common_flash.c: Attempting to write 824 (0x338) bytes to stm32 address: 134217728 (0x8000000)
-> Flash page at 0x8000000 erased (size: 0x2000)
2024-02-15T17:35:51 INFO flash_loader.c: Starting Flash write for H7
824/824 bytes written
2024-02-15T17:35:51 INFO common_flash.c: Starting verification of write complete
2024-02-15T17:35:51 INFO common_flash.c: Flash written and verified! jolly good!
$ st-flash write big.bin 0x08000000
...
2024-02-15T17:35:56 ERROR common_flash.c: Verification of flash failed at offset: 6144
$ st-flash write small.bin 0x08002000
...
2024-02-15T17:36:02 ERROR common_flash.c: Verification of flash failed at offset: 0
$ st-flash write big.bin 0x08002000
...
2024-02-15T17:36:25 ERROR common_flash.c: Verification of flash failed at offset: 0
$ st-flash write small.bin 0x08004000
...
2024-02-15T17:50:24 ERROR common_flash.c: Verification of flash failed at offset: 0
$ st-flash write small.bin 0x08006000
...
2024-02-15T17:50:29 INFO common_flash.c: Flash written and verified! jolly good!
$ st-flash write small.bin 0x08100000
st-flash 1.8.0-2-g65f062f
2024-02-15T17:36:40 INFO common.c: STM32H7Ax_H7Bx: 128 KiB SRAM, 1024 KiB flash in at least 8 KiB pages.
Unknown memory region
You can see writing a binary image smaller than 8k(small.bin
) directly to the second page also fails, writing one bigger than page size fails too, everything with the same error.
However writing the small file to the page at 0x08006000
works funnily enough.
I also tried writing to the second bank of flash but it doesn't seem to know about it.