2026-04-22 7:44 AM
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!
Solved! Go to Solution.
2026-04-28 7:41 AM
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
2026-04-22 9:13 AM
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.
2026-04-22 9:33 AM
@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.
2026-04-24 9:39 AM
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.
2026-04-24 10:03 AM
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.
2026-04-28 7:41 AM
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