Skip to main content
Javier1
Principal
Jul 21, 2025 11:41 AM UTC
Solved

VSCode launch.json for running/debuging with flash offset

 

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

 

This topic has been closed for replies.
Javier1
Javier1Best answer
Principal
Jul 22, 2025 8:15 AM UTC

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/

5 replies

Cartu38 OpenDev
Graduate II
Jul 22, 2025 5:43 AM UTC

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
Jul 22, 2025 8:16 AM UTC

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
Jul 22, 2025 8:15 AM UTC

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
Jul 23, 2025 7:17 AM UTC
Javier1
Javier1Author
Principal
Jul 23, 2025 12:13 PM UTC

good catch

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