cancel
Showing results for 
Search instead for 
Did you mean: 

Flashing code with stlink does not run code

JKing.8
Associate III

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

8 REPLIES 8

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

JW

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

Pavel A.
Evangelist III

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 III

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.

Why dont you use cube programmer?

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.
Gltr
Associate

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

Better is open new and explain...