stlink-org / stlink

Open source STM32 MCU programming toolset
BSD 3-Clause "New" or "Revised" License
4.4k stars 1.24k forks source link

[STM32H743/753]: Cannot write to area at 0x0810_0000, but can at 0x0800_0000 #1146

Closed rcordeau closed 3 years ago

rcordeau commented 3 years ago

In order to allow developers to isolate and target your respective issue, please take some time to select the check boxes below and fill out each of the following items appropriate to your specific problem.

Commandline output: Good output @ 0x0800_0000 st-flash --reset write ~/fcc.bin 0x08000000 st-flash 1.7.0 2021-05-27T00:29:24 INFO common.c: H74x/H75x: 128 KiB SRAM, 2048 KiB flash in at least 128 KiB pages. file /Users/rcordeau/fcc.bin md5 checksum: c951e84957504eb54c2e2e73c5bb77c, stlink checksum: 0x0133d67c 2021-05-27T00:29:24 INFO common.c: Attempting to write 223904 (0x36aa0) bytes to stm32 address: 134217728 (0x8000000) 2021-05-27T00:29:25 INFO common.c: Flash page at addr: 0x08000000 erased 2021-05-27T00:29:25 INFO common.c: Flash page at addr: 0x08020000 erased 2021-05-27T00:29:25 INFO common.c: Finished erasing 2 pages of 131072 (0x20000) bytes 2021-05-27T00:29:25 INFO common.c: Starting Flash write for H7 223904/223904 bytes written 2021-05-27T00:29:30 INFO common.c: Starting verification of write complete 2021-05-27T00:29:32 INFO common.c: Flash written and verified! jolly good! 2021-05-27T00:29:32 WARN common.c: NRST is not connected

Bad output @ 0x0810_0000 st-flash --reset write ~/fcc.bin 0x08100000 st-flash 1.7.0 2021-05-27T00:30:58 INFO common.c: H74x/H75x: 128 KiB SRAM, 2048 KiB flash in at least 128 KiB pages. file /Users/rcordeau/fcc.bin md5 checksum: c951e84957504eb54c2e2e73c5bb77c, stlink checksum: 0x0133d67c 2021-05-27T00:30:58 INFO common.c: Attempting to write 223904 (0x36aa0) bytes to stm32 address: 135266304 (0x8100000) 2021-05-27T00:30:58 INFO common.c: Flash page at addr: 0x08100000 erased 2021-05-27T00:30:58 INFO common.c: Flash page at addr: 0x08120000 erased 2021-05-27T00:30:58 INFO common.c: Finished erasing 2 pages of 131072 (0x20000) bytes 2021-05-27T00:30:58 INFO common.c: Starting Flash write for H7 223904/223904 bytes written 2021-05-27T00:31:03 INFO common.c: Starting verification of write complete 2021-05-27T00:31:03 ERROR common.c: Verification of flash failed at offset: 0 stlink_fwrite_flash() == -1

OUTPUT/ERROR of the commandline tool(s)

The official STM32Programmer works fine. If I write the same file to 0x080e0000, it half-verifies. The portion starting at 0x08100000 reads back all F's.

When writing to 0x08000000, the debug output when writing shows (making it a short example): 214400/223904 bytes written2021-05-27T00:18:39 DEBUG common.c: stlink_write_mem32 64 bytes to 0x8034580 2021-05-27T00:18:39 DEBUG common.c: stlink_read_debug32 0x00010000 at 0x52002010

When writing to 0x08100000, the debug output when writing shows (making it a short example): 214400/223904 bytes written2021-05-27T00:17:06 DEBUG common.c: stlink_write_mem32 64 bytes to 0x8134580 2021-05-27T00:17:06 DEBUG common.c: stlink_read_debug32 0000000000 at 0x52002010

Ant-ON commented 3 years ago

@rcordeau When writing to the second bank, the FLASH_SR2 register (0x52002110) instead the FLASH_SR register (0x52002010) is use. Can you attach complete logs?

rcordeau commented 3 years ago

flashlog_08100000.txt Sure thing. This is the log that shows it erroring out when writing to 0x08100000

rcordeau commented 3 years ago

This is another error log when writing to 0x080e0000, which would cross into the 0x08100000 page. flashwrite_080e0000.txt

Ant-ON commented 3 years ago

@rcordeau Thanks for the logs! I seem to have found the problem. Could you check out https://github.com/Ant-ON/stlink/tree/h7_db_fix branch?

rcordeau commented 3 years ago

Hi @Ant-ON, yep, this fixed it! Thanks!