Stlink: STM32F103CBT6: st-flash run_flash_loader(0x08000000) failed

Created on 9 Dec 2015  Â·  18Comments  Â·  Source: stlink-org/stlink

Hello. I try to load firmare in STM32F103CBT6 using compiled st-flash.exe utility under windows 8.1.

There is used command:
st-flash.exe write ${project_name}.bin 0x08000000

Here is result:

Flash page at addr: 0x08000000 erased
Flash page at addr: 0x08000400 erased
Flash page at addr: 0x08000800 erased
Flash page at addr: 0x08000c00 erased
Flash page at addr: 0x08001000 erased
Flash page at addr: 0x08001400 erased
Flash page at addr: 0x08001800 erased
Flash page at addr: 0x08001c00 erased
Flash page at addr: 0x08002000 erased
Flash page at addr: 0x08002400 erased
Flash page at addr: 0x08002800 erased
Flash page at addr: 0x08002c00 erased
Flash page at addr: 0x08003000 erased
Flash page at addr: 0x08003400 erased
Flash page at addr: 0x08003800 erased
Flash page at addr: 0x08003c00 erased
Flash page at addr: 0x08004000 erased
Flash page at addr: 0x08004400 erased
Flash page at addr: 0x08004800 erased
Flash page at addr: 0x08004c00 erased
Flash page at addr: 0x08005000 erased
Flash page at addr: 0x08005400 erased
Flash page at addr: 0x08005800 erased
Flash page at addr: 0x08005c00 erased
Flash page at addr: 0x08006000 erased
Flash page at addr: 0x08006400 erased
Flash page at addr: 0x08006800 erased
Flash page at addr: 0x08006c00 erased
Flash page at addr: 0x08007000 erased
Flash page at addr: 0x08007400 erased
Flash page at addr: 0x08007800 erased
Flash page at addr: 0x08007c00 erased
Flash page at addr: 0x08008000 erased
Flash page at addr: 0x08008400 erased
Flash page at addr: 0x08008800 erased
Flash page at addr: 0x08008c00 erased
Flash page at addr: 0x08009000 erased
Flash page at addr: 0x08009400 erased
Flash page at addr: 0x08009800 erased
Flash page at addr: 0x08009c00 erased
Flash page at addr: 0x0800a000 erased
Flash page at addr: 0x0800a400 erased
stlink_fwrite_flash() == -1
2015-12-09T22:01:57 INFO src/stlink-common.c: Loading device parameters....
2015-12-09T22:01:57 INFO src/stlink-common.c: Device connected is: F1 Medium-density device, id 0x20036410
2015-12-09T22:01:57 INFO src/stlink-common.c: SRAM size: 0x5000 bytes (20 KiB), Flash: 0xb4a000 bytes (11560 KiB) in pages of 1024 bytes
2015-12-09T22:01:57 INFO src/stlink-common.c: Attempting to write 42368 (0xa580) bytes to stm32 address: 134217728 (0x8000000)
2015-12-09T22:01:57 INFO src/stlink-common.c: Finished erasing 42 pages of 1024 (0x400) bytes
2015-12-09T22:01:57 INFO src/stlink-common.c: Starting Flash write for VL/F0/F3 core id
2015-12-09T22:01:57 INFO src/stlink-common.c: Successfully loaded flash loader in sram
2015-12-09T22:02:18 ERROR src/stlink-common.c: flash loader run error
2015-12-09T22:02:18 ERROR src/stlink-common.c: run_flash_loader(0x8000000) failed! == -1

What is the issue? Thank you)

buneeds-fix componenst-flash erroflash-loader needinvestigation olinux omacOS owindows targestm32f0 targestm32f1 targestm32l0 targestm32l4

All 18 comments

@Almaz1c could you test with v1.2.0 or master, and see if the problem still exists?

I can confirm this bug, but I get it only occasionally - sometimes it passes, sometimes it fails.

  • using the same command and params
  • Running on raspberry Pi 2, using Linux raspberrypi 4.1.7+, armv6l
  • chip STM32F091RCT6

I am using latest version, compiled yesterday. My output:

pi@raspberrypi ~/Desktop/Tester $ sudo st-flash write fw_v13.bin 0x08000000
2016-05-26T10:23:34 INFO src/common.c: Loading device parameters....
2016-05-26T10:23:34 INFO src/common.c: Device connected is: F09X device, id 0x10006442
2016-05-26T10:23:34 INFO src/common.c: SRAM size: 0x8000 bytes (32 KiB), Flash: 0x40000 bytes (256 KiB) in pages of 2048 bytes
2016-05-26T10:23:34 INFO src/common.c: Attempting to write 196964 (0x30164) bytes to stm32 address: 134217728 (0x8000000)
Flash page at addr: 0x08030000 erased
2016-05-26T10:23:37 INFO src/common.c: Finished erasing 97 pages of 2048 (0x800) bytes
2016-05-26T10:23:37 INFO src/common.c: Starting Flash write for VL/F0/F3 core id
2016-05-26T10:23:37 INFO src/flash_loader.c: Successfully loaded flash loader in sram
2016-05-26T10:23:47 ERROR src/flash_loader.c: flash loader run error
2016-05-26T10:23:47 ERROR src/common.c: stlink_flash_loader_run(0x8000000) failed! == -1
stlink_fwrite_flash() == -1

@vladiks which version/git tag do you use of the st-flash tool?

Current version is unable to compile with visual studio, probably it should work under MinGW but I have not tested this.

@xor-gate I'm sorry, but I don't know how to find out the git tag. I've downloaded master as zip and copied it to raspberry. I am retty sure it's 1.2.0, there are also news for 1.2.0 in changelog.

I've avoided the issue by erasing memory by separate command before flashing it again - the problem now disappeared.

@vladiks when you downloaded zipfile for master you running latest version (beyond 1.2.0). I have seen an exact issue where people erase the flash (mass erase/full?) and then it worked. This is a problem which I saw some other people have but have not confirmed and seen this myself. In the upcoming time I will prepare a continues hardware/stlink testing setup at Dual Inventive and hopefully I will catch this nasty bug.

This needs some documentation somewhere if people tried to (mass)erased and then flashed and the problem resolved. I will keep this issue open until I have documented/noted it somewhere.

Good luck and many thanks for your work on this utility.

I have put it in the README.md. So people will see it :+1:. Thanks all for the feedback, feel free to open a issue when something is not working as expected!

Hello I have the same problem with STML0xx. This error occurs only with st-link utility in linux and mac os X. Utility from STM works fine.

Yep, finally I can test it. For me it's

2020-03-29T13:55:22 INFO flash_loader.c: Successfully loaded flash loader in sram
2020-03-29T13:55:22 ERROR flash_loader.c: write error, count == 1023
2020-03-29T13:55:22 ERROR common.c: stlink_flash_loader_run(0x8000800) failed! == -1

always on macOS, so it's pretty stable. Tired of mass erasing before, want to help %)

@yeswolf: Which version of stlink do you use?

@Nightwalker-87 I use v1.6.0-dirty built from sources (downloaded from releases) with STM32F103RCT6 High-density.

I wonder if this could be related to a missing flash loader for F1 devices ...
We currently only have one for F0, F4, F7, L0, L1 and L4.

@yeswolf: Any changes with v1.6.1?

@Nightwalker-87 Will test after 23th of August.

Will test after 23th of August.

OK, enjoy your vacation.
Please do the testing, it will help to reduce the amount of open issues of this cool project.

Besides @yeswolf also high-lighting @Almaz1c and @vladiks .
See #1000 for other requests how to support this project.

So, I've tried 1.6.1 using 2 approaches: a) installed from HomeBrew b) built from source. The result is strange: a) there is no issue with erasing the firmware as it was before b) but I can't launch debugging my firmware, I always have SIGTRAP in startup_stm32f103xe.s:

LoopFillZerobss:
  ldr r3, = _ebss
  cmp r2, r3
  bcc FillZerobss

/* Call the clock system intitialization function.*/
    bl  SystemInit
/* Call static constructors */
    bl __libc_init_array
/* Call the application's entry point.*/
  bl main
  bx lr // SIGTRAP here
.size Reset_Handler, .-Reset_Handler

If I use st-link 1.6.0 dirty (compiled from HEAD being 84f63d25bd77d61f8feccf08dd24d0d11895ef32), there is no automatic mass-erasing (as I wrote in my previous comments), but debugging starts successfully without any problem. Same code, same project, same toolchain, same device - everything is the same except the path to st-util.

I'll be happy to provide any logs to troubleshoot this issue.

Hi,

I got the same issue on L496Disco board on Mac OS Catalina.
I used mass erase prior flashing.
Interesting is AC6 System workbench works, but I want to migrate to VSCode.

st-link v.1.6.1. from Homebrew.

Debugging from VSCode using openOCD starts the project, but breaks into startup asm startup_stm32l496xx.s.
It doesn't run the code, looks like the code is not flashed.

➜  anemoss.vscode git:(master) ✗ st-flash erase; st-flash write build/anemoss.2.bin 0x8000000 
st-flash 1.6.1
2021-01-23T20:42:02 INFO common.c: L496x/L4A6x: 256 KiB SRAM, 1024 KiB flash in at least 2 KiB pages.
Mass erasing
st-flash 1.6.1
2021-01-23T20:42:02 INFO common.c: L496x/L4A6x: 256 KiB SRAM, 1024 KiB flash in at least 2 KiB pages.
file build/anemoss.2.bin md5 checksum: 3bf4f2cd944342fcf5012ecda24c954, stlink checksum: 0x00648757
2021-01-23T20:42:02 INFO common.c: Attempting to write 79656 (0x13728) bytes to stm32 address: 134217728 (0x8000000)
EraseFlash - Page:0x0 Size:0x800 2021-01-23T20:42:02 INFO common.c: Flash page at addr: 0x08000000 erased
EraseFlash - Page:0x1 Size:0x800 2021-01-23T20:42:02 INFO common.c: Flash page at addr: 0x08000800 erased
EraseFlash - Page:0x2 Size:0x800 2021-01-23T20:42:02 INFO common.c: Flash page at addr: 0x08001000 erased
EraseFlash - Page:0x3 Size:0x800 2021-01-23T20:42:02 INFO common.c: Flash page at addr: 0x08001800 erased
EraseFlash - Page:0x4 Size:0x800 2021-01-23T20:42:02 INFO common.c: Flash page at addr: 0x08002000 erased
EraseFlash - Page:0x5 Size:0x800 2021-01-23T20:42:02 INFO common.c: Flash page at addr: 0x08002800 erased
EraseFlash - Page:0x6 Size:0x800 2021-01-23T20:42:02 INFO common.c: Flash page at addr: 0x08003000 erased
EraseFlash - Page:0x7 Size:0x800 2021-01-23T20:42:02 INFO common.c: Flash page at addr: 0x08003800 erased
EraseFlash - Page:0x8 Size:0x800 2021-01-23T20:42:02 INFO common.c: Flash page at addr: 0x08004000 erased
EraseFlash - Page:0x9 Size:0x800 2021-01-23T20:42:02 INFO common.c: Flash page at addr: 0x08004800 erased
EraseFlash - Page:0xa Size:0x800 2021-01-23T20:42:02 INFO common.c: Flash page at addr: 0x08005000 erased
EraseFlash - Page:0xb Size:0x800 2021-01-23T20:42:02 INFO common.c: Flash page at addr: 0x08005800 erased
EraseFlash - Page:0xc Size:0x800 2021-01-23T20:42:02 INFO common.c: Flash page at addr: 0x08006000 erased
EraseFlash - Page:0xd Size:0x800 2021-01-23T20:42:02 INFO common.c: Flash page at addr: 0x08006800 erased
EraseFlash - Page:0xe Size:0x800 2021-01-23T20:42:03 INFO common.c: Flash page at addr: 0x08007000 erased
EraseFlash - Page:0xf Size:0x800 2021-01-23T20:42:03 INFO common.c: Flash page at addr: 0x08007800 erased
EraseFlash - Page:0x10 Size:0x800 2021-01-23T20:42:03 INFO common.c: Flash page at addr: 0x08008000 erased
EraseFlash - Page:0x11 Size:0x800 2021-01-23T20:42:03 INFO common.c: Flash page at addr: 0x08008800 erased
EraseFlash - Page:0x12 Size:0x800 2021-01-23T20:42:03 INFO common.c: Flash page at addr: 0x08009000 erased
EraseFlash - Page:0x13 Size:0x800 2021-01-23T20:42:03 INFO common.c: Flash page at addr: 0x08009800 erased
EraseFlash - Page:0x14 Size:0x800 2021-01-23T20:42:03 INFO common.c: Flash page at addr: 0x0800a000 erased
EraseFlash - Page:0x15 Size:0x800 2021-01-23T20:42:03 INFO common.c: Flash page at addr: 0x0800a800 erased
EraseFlash - Page:0x16 Size:0x800 2021-01-23T20:42:03 INFO common.c: Flash page at addr: 0x0800b000 erased
EraseFlash - Page:0x17 Size:0x800 2021-01-23T20:42:03 INFO common.c: Flash page at addr: 0x0800b800 erased
EraseFlash - Page:0x18 Size:0x800 2021-01-23T20:42:03 INFO common.c: Flash page at addr: 0x0800c000 erased
EraseFlash - Page:0x19 Size:0x800 2021-01-23T20:42:03 INFO common.c: Flash page at addr: 0x0800c800 erased
EraseFlash - Page:0x1a Size:0x800 2021-01-23T20:42:03 INFO common.c: Flash page at addr: 0x0800d000 erased
EraseFlash - Page:0x1b Size:0x800 2021-01-23T20:42:03 INFO common.c: Flash page at addr: 0x0800d800 erased
EraseFlash - Page:0x1c Size:0x800 2021-01-23T20:42:03 INFO common.c: Flash page at addr: 0x0800e000 erased
EraseFlash - Page:0x1d Size:0x800 2021-01-23T20:42:03 INFO common.c: Flash page at addr: 0x0800e800 erased
EraseFlash - Page:0x1e Size:0x800 2021-01-23T20:42:03 INFO common.c: Flash page at addr: 0x0800f000 erased
EraseFlash - Page:0x1f Size:0x800 2021-01-23T20:42:03 INFO common.c: Flash page at addr: 0x0800f800 erased
EraseFlash - Page:0x20 Size:0x800 2021-01-23T20:42:03 INFO common.c: Flash page at addr: 0x08010000 erased
EraseFlash - Page:0x21 Size:0x800 2021-01-23T20:42:03 INFO common.c: Flash page at addr: 0x08010800 erased
EraseFlash - Page:0x22 Size:0x800 2021-01-23T20:42:03 INFO common.c: Flash page at addr: 0x08011000 erased
EraseFlash - Page:0x23 Size:0x800 2021-01-23T20:42:03 INFO common.c: Flash page at addr: 0x08011800 erased
EraseFlash - Page:0x24 Size:0x800 2021-01-23T20:42:03 INFO common.c: Flash page at addr: 0x08012000 erased
EraseFlash - Page:0x25 Size:0x800 2021-01-23T20:42:03 INFO common.c: Flash page at addr: 0x08012800 erased
EraseFlash - Page:0x26 Size:0x800 2021-01-23T20:42:03 INFO common.c: Flash page at addr: 0x08013000 erased
2021-01-23T20:42:03 INFO common.c: Finished erasing 39 pages of 2048 (0x800) bytes
2021-01-23T20:42:03 INFO common.c: Starting Flash write for F2/F4/L4
2021-01-23T20:42:03 INFO flash_loader.c: Successfully loaded flash loader in sram
size: 32768
2021-01-23T20:42:04 ERROR flash_loader.c: flash loader run error
2021-01-23T20:42:04 ERROR common.c: stlink_flash_loader_run(0x8000000) failed! == -1
stlink_fwrite_flash() == -1
Was this page helpful?
0 / 5 - 0 ratings