Skip to main content
Javier1
Principal
July 21, 2025
Solved

VSCode launch.json for running/debuging with flash offset

  • July 21, 2025
  • 2 replies
  • 1355 views

 

I’m currently developing a template to help developers debug code located at address 0x8011000 using VSCode.
So far, I haven’t had any success getting the debugger to work properly.

The .elf file itself is fine, when I flash it using STM32CubeProgrammer and enable "Run after programming", the code executes as expected.

I’ve tried multiple solutions, including suggestions from ChatGPT, but nothing has worked yet.



Javier1_0-1753098029075.png

 

Best answer by Javier1

Got it to work, in case someone has a similar issue: 
In my case Reset_Handler is defined in startup_stm32g474xx.s

launch.json 

{
 "version": "0.2.0",
 "configurations": [
 {
 "name": "Debug UserApp at an offset (no full reset)",
 "type": "cortex-debug",
 "request": "launch",
 "servertype": "stlink", // you're using ST-LINK GDB server, not openocd
 "executable": "build/Debug/${workspaceFolderBasename}.elf",
 "device": "STM32G474RE",
 "gdbPath": "arm-none-eabi-gdb",
 "runToEntryPoint": "Reset_Handler",
 "postLaunchCommands": [
 "monitor halt",
 "break main"
 ],
 "overrideLaunchCommands": [
 "load"
 ],
 "showDevDebugOutput": "raw"
 }
 ]
}

tasks.json 

{
 "version": "2.0.0",
 "tasks": [
 {
 "label": "flash-userapp",
 "type": "shell",
 "command": "STM32_Programmer_CLI",
 "args": [
 "-c", "port=SWD",
 "-w", "build/Debug/${workspaceFolderBasename}.elf", // or .hex or .bin
 "-rst"
 ],
 "problemMatcher": []
 }
 ]
}

 

2 replies

Cartu38 OpenDev
Graduate II
July 22, 2025

Not sure to understand what you are tryi.g to do here. Please be explicit more. Maybe a chance to get help then.

Javier1
Javier1Author
Principal
July 22, 2025

I changpticed it for you @Cartu38 OpenDev , i was tired and not good articulating my problem

hit me up in https://www.linkedin.com/in/javiermuñoz/
Javier1
Javier1AuthorBest answer
Principal
July 22, 2025

Got it to work, in case someone has a similar issue: 
In my case Reset_Handler is defined in startup_stm32g474xx.s

launch.json 

{
 "version": "0.2.0",
 "configurations": [
 {
 "name": "Debug UserApp at an offset (no full reset)",
 "type": "cortex-debug",
 "request": "launch",
 "servertype": "stlink", // you're using ST-LINK GDB server, not openocd
 "executable": "build/Debug/${workspaceFolderBasename}.elf",
 "device": "STM32G474RE",
 "gdbPath": "arm-none-eabi-gdb",
 "runToEntryPoint": "Reset_Handler",
 "postLaunchCommands": [
 "monitor halt",
 "break main"
 ],
 "overrideLaunchCommands": [
 "load"
 ],
 "showDevDebugOutput": "raw"
 }
 ]
}

tasks.json 

{
 "version": "2.0.0",
 "tasks": [
 {
 "label": "flash-userapp",
 "type": "shell",
 "command": "STM32_Programmer_CLI",
 "args": [
 "-c", "port=SWD",
 "-w", "build/Debug/${workspaceFolderBasename}.elf", // or .hex or .bin
 "-rst"
 ],
 "problemMatcher": []
 }
 ]
}

 

hit me up in https://www.linkedin.com/in/javiermuñoz/
Cartu38 OpenDev
Graduate II
July 23, 2025
Javier1
Javier1Author
Principal
July 23, 2025

good catch

hit me up in https://www.linkedin.com/in/javiermuñoz/