cancel
Showing results for 
Search instead for 
Did you mean: 

Segger J-Link Setup for Full Chip Erase in VSCode

ETX
Associate II

I'm using VSCode and J-Link for programming/flashing my STM23 MCUs.
Unfortunately using the default setup from SEGGER (https://kb.segger.com/J-Link_Visual_Studio_Code#Support),
J-Link only erases areas/pages needed.
I found no information about modifying the process of flashing.
Is there a way to modify the setup within VSCode in a way, to do a full chip erase when flasing by default?

Many thanks!

1 ACCEPTED SOLUTION

Accepted Solutions

Hi @ETX,

You should be able to perform the full erase by adding this attribute to your debug configuration

"initCommands": ["monitor flash erase"],

 "initCommands" is the list of GDB commands sent after attaching to the target and before loading the image.

Kind Regards,

/Flo

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.

View solution in original post

5 REPLIES 5
Pavel A.
Super User

Do you want to fully erase the STM32 every time you download a program, or only one time or rarely? If the latter, you can erase with the JFlash GUI or CLI, or other tool. Erasing only the needed pages actually is a good feature.


@Pavel A. wrote:

Erasing only the needed pages actually is a good feature.


Indeed it is!

 

@ETX You can also use STM32CubeProgrammer to do a full-chip erase.

A complex system that works is invariably found to have evolved from a simple system that worked.
A complex system designed from scratch never works and cannot be patched up to make it work.

Yes, of course it's a good feature for standard applications.
But for developement purpose, where you are using eeprom emulation on separate flash pages, there would often be the need for a full chip erase.
And this shouldn't be done with a different software tool, it should work with VSCode developement enviroment.

So my question was about a way how to setup VSCode to do this automatically or maybe with a configuration modification of the J-Link debugger with J-Link Commander.
Till now, I couldn't find any information how to change the flashing behavior of the Segger driver.

I don't have a setup handy but generally you can add a custom command to VS Code environment, in the same json file where other debug & run commands are defined.

J-Flash has command line mode. The "-erasechip" option does full erase.

 

Hi @ETX,

You should be able to perform the full erase by adding this attribute to your debug configuration

"initCommands": ["monitor flash erase"],

 "initCommands" is the list of GDB commands sent after attaching to the target and before loading the image.

Kind Regards,

/Flo

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.