cancel
Showing results for 
Search instead for 
Did you mean: 

Partial or Full chip erase before programming?

Andrew Neil
Evangelist III

Keil (among others) allows the choice of whether to do a full or partial erase before programming:

AndrewNeil_0-1717712173910.png

Is it possible to do that in STM32CubeIDE ?

If so, how ?

 

1 ACCEPTED SOLUTION

Accepted Solutions

IDE work this way erase only code linker parts. I use this daily

View solution in original post

29 REPLIES 29
Kraal
Senior III

Hi @Andrew Neil 

I don't think there is a nice GUI window as in Keil, I'm using the external tool configuration and depending on the argument you specify it can do either mass erase or only needed sectors:

Kraal_0-1717742885920.png

For the sectors needed only, the argument is:
-c port=SWD mode=UR -d ${workspace_loc}\${project_name}\${config_name:${project_name}}\${project_name}.elf -v -rst

For mass erase instead:
-c port=SWD mode=UR -e all -d ${workspace_loc}\${project_name}\${config_name:${project_name}}\${project_name}.elf -v -rst

You can even skip the flash erase, or only some sectors. Everything is explained in the STM32_Programmer_CLI help.

Have a nice day,
Kraal

Thanks for that.

So is that all I need to do, or does it also need some reference to the "external tool" to be added/modified elsewhere?

From the external tool configuration, the last tab "Common" there is a checkbox under "Display in favorites menu" that you should check (red box below) :

Kraal_0-1717760371841.png

Your configurations will then show in the main menu in the IDE :

Kraal_1-1717760429806.png

Note that you don't need to develop the drop down menu if you always use the same configuration, you can directly click on "Play_toolbox" icon (if you hover over it, the text shall say "use latest tool" or something like so).

Warning: in my case, I have to select the project I want to flash in the project pane for the tool to work OK. Otherwise it fails to convert ${workspace_loc}\${project_name}\${config_name:${project_name}}\${project_name}.elf into something meaningful and will comply.

So this is giving a button to do just the programming - without debugging?

How do I integrate this with starting a Debug session?

How do I tell the Debug Configuration to use this to do its download? Or does it "just happen" automagically?

Or is there a way to tell the Debug Configuration to not do its download?

 

(I see I didn't mention that I wanted this included as part of starting a debug session - as Keil "just does it")


@Andrew Neil wrote:

Or is there a way to tell the Debug Configuration to not do its download?


Aha - that one is answered by @TDK here:

https://community.st.com/t5/stm32-mcus-boards-and-hardware/connecting-to-running-target/m-p/272667/highlight/true#M9438

 

But is there a way to modify the Debug Configuration's down load behaviour ?

If you run with GDB ans some GDBserver and the right memory map for the device, gdb does a sector erase  for the sectors involved. E.g. blackmagic has a monitor command "mon(itor) erase_mass" to do a full erase.

You should be able to modify the debug download behavior, but I'm not sure to what extent. @STTwo-32 can you help regarding this please ?

Otherwise, the old TrueStudio documentation suggested to create a "Launch group" which executes:
- first the external tool to download the executable in the microcontroller (this can include external memory like QSPI providing you have the right external loader)
- then the debug session, with its download checkbox unticked

Semer CHERNI
ST Employee

Hello @Andrew Neil 

First let me thank you for posting.

This option is not available at this stage using STM32CubeIDE. However, plan to integrate similar feature in the tool.

(113782: this is an internal ticket number).

KR,
Semer.

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.

You mean the "Launch Group" mentioned by @Kraal ?

Is it this:

AndrewNeil_0-1720099149094.png