Skip to main content
JKing.8
Associate II
March 8, 2023
Question

Flashing code with stlink does not run code

  • March 8, 2023
  • 5 replies
  • 3993 views

I used the STM32CubeIDE to make a simple LED flashing program for an STM32H753. When I run the code with the CubeIDE, it uploads and flashes the LED as intended.

I would like to be able to run this code without the CubeIDE. I am on Mac and have stlink tools installed. I tried running:

st-flash write STM32H753XIHX_FLASH.ld 0x8000000

which outputted:

st-flash 1.7.0
2023-03-08T10:36:48 INFO usb.c: Unable to match requested speed 1800 kHz, using 1000 kHz
2023-03-08T10:36:48 INFO common.c: H74x/H75x: 128 KiB SRAM, 2048 KiB flash in at least 128 KiB pages.
file STM32H753XIHX_FLASH.ld md5 checksum: 517ef4c77a491566f06f321eb8bba767, stlink checksum: 0x00050078
2023-03-08T10:36:48 INFO common.c: Attempting to write 4713 (0x1269) bytes to stm32 address: 134217728 (0x8000000)
2023-03-08T10:36:48 WARN common.c: unaligned len 0x1269 -- padding with zero
2023-03-08T10:36:49 INFO common.c: Flash page at addr: 0x08000000 erased
2023-03-08T10:36:49 INFO common.c: Finished erasing 1 pages of 131072 (0x20000) bytes
2023-03-08T10:36:49 INFO common.c: Starting Flash write for H7
4714/4714 bytes written
2023-03-08T10:36:49 INFO common.c: Starting verification of write complete
2023-03-08T10:36:49 INFO common.c: Flash written and verified! jolly good!

I then tried again with:

st-flash write STM32H753XIHX_RAM.ld 0x8000000 

which outputted:

st-flash 1.7.0
2023-03-08T10:37:33 INFO usb.c: Unable to match requested speed 1800 kHz, using 1000 kHz
2023-03-08T10:37:33 INFO common.c: H74x/H75x: 128 KiB SRAM, 2048 KiB flash in at least 128 KiB pages.
file STM32H753XIHX_RAM.ld md5 checksum: 226d4e61708c5f589a484848218556c, stlink checksum: 0x00050b31
2023-03-08T10:37:33 INFO common.c: Attempting to write 4728 (0x1278) bytes to stm32 address: 134217728 (0x8000000)
2023-03-08T10:37:34 INFO common.c: Flash page at addr: 0x08000000 erased
2023-03-08T10:37:34 INFO common.c: Finished erasing 1 pages of 131072 (0x20000) bytes
2023-03-08T10:37:34 INFO common.c: Starting Flash write for H7
4728/4728 bytes written
2023-03-08T10:37:34 INFO common.c: Starting verification of write complete
2023-03-08T10:37:34 INFO common.c: Flash written and verified! jolly good!

Both seemed to have valid outputs, but neither make the LED flash. What could I be doing wrong?

Thanks

This topic has been closed for replies.

5 replies

waclawek.jan
Super User
March 8, 2023

Are you sure the .ld file is the output of what you've compiled? .ld is usually used for the linker script.

JW

JKing.8
JKing.8Author
Associate II
March 8, 2023

Would Debug/<projectName>.elf be the correct file to flash?

Pavel A.
March 8, 2023

This software is not from ST. It is an opensource project. For help you can ask the authors and maintainers.

From this documentation, it accepts only bin files, not elf.

WojtekP1
Associate II
March 8, 2023

No idea what stm32cube does - never used it, but openocd does not run a program after flashing. You need to execute reset command manually or add to programming sequence.

I highly recommend openocd for ST-LINK. Recently they added STM32G/C support.

Works just perfectly under FreeBSD. and for sure almost any other commonly used unix systems.

March 9, 2023

Why dont you use cube programmer?

WojtekP1
Associate II
March 9, 2023

Because there are still people in the world that:

  • don't want to use point and click way of "work"
  • don't want vendor lock in
  • don't want binary only packages
  • want unix style tools that can be easily integrated with everything
  • want small and simple tools doing one thing well, according to unix philosophy
  • want tools that they can fully understand.
  • want tools that never limit you.
Visitor II
June 28, 2024

I have the issue here, did you find a solution to your problem?

MM..1
Chief III
June 28, 2024

Better is open new and explain...