Skip to main content
Associate II
April 22, 2026
Solved

Segger J-Link Setup for Full Chip Erase in VSCode

  • April 22, 2026
  • 1 reply
  • 278 views

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!

Best answer by Florent V

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

1 reply

Pavel A.
Super User
April 22, 2026

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.

Andrew Neil
Super User
April 22, 2026

@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.
Florent V
Florent VAnswer
ST Employee
April 28, 2026

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.