Skip to main content
Associate II
April 11, 2025
Solved

No argument to stop flash erase before programming using the stlink gdb server

  • April 11, 2025
  • 1 reply
  • 515 views

So I know if I use the STM32CubeProgrammer there's an option to skip flash erase before programming which is great. However, I'm trying to debug some code and I need to prevent flash erase, because I have some code in a sector which I need to keep, but also program some new code in that same sector.

By using the 'ST-LINK_gdbserver --help' command, there's no option/argument which I can use to prevent the flash erase before programming. I tried using the '--skipErase' option mentioned here:
https://community.st.com/t5/stm32cubeprogrammer-mcus/skipping-flash-erase-with-stm32-programmer-cli-and-stlink-v3/td-p/608809 

 

But it didn't work for me:
'/opt/ST/STM32CubeCLT_1.18.0/STLink-gdb-server/bin/ST-LINK_gdbserver -p 50000 -cp /opt/ST/STM32CubeCLT_1.18.0/STM32CubeProgrammer/bin --swd --halt --skipErase -m 0
PARSE ERROR: Argument: --skipErase
Couldn't find match for argument'

 

It seems like the --skipErase command is specific for the programmer, but there's no way to invoke it from the gdb server.

 

Would appreciate some guidance on this, thanks.

Best answer by Aziz BRIGUI

Hello @rockybalboa__ ,

I can confirm that with ST-LINK_gdbserver, there's no option to skip the erase. However, I don't think it should be added since you have the possibility to only attach (-g) to a running target instead of downloading the binary via GDB.

=> You can use STM32CubeProgrammer to download your file while skipping the erase:

STM32_Programmer_CLI -c port=SWD -d File.elf --skipErase

 and then attach to the target with ST-LINK_gdbserver:

ST-LINK_gdbserver -p 50000 -cp /opt/ST/STM32CubeCLT_1.18.0/STM32CubeProgrammer/bin --swd -g

Let me know if this resolved your issue.

Aziz

1 reply

Aziz BRIGUI
Aziz BRIGUIBest answer
Technical Moderator
April 17, 2025

Hello @rockybalboa__ ,

I can confirm that with ST-LINK_gdbserver, there's no option to skip the erase. However, I don't think it should be added since you have the possibility to only attach (-g) to a running target instead of downloading the binary via GDB.

=> You can use STM32CubeProgrammer to download your file while skipping the erase:

STM32_Programmer_CLI -c port=SWD -d File.elf --skipErase

 and then attach to the target with ST-LINK_gdbserver:

ST-LINK_gdbserver -p 50000 -cp /opt/ST/STM32CubeCLT_1.18.0/STM32CubeProgrammer/bin --swd -g

Let me know if this resolved your issue.

Aziz

In order to give better visibility on the answered topics, please click on 'Accept as Solution' on the reply which solved your issue or answered your question.