Skip to main content
Graduate II
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

 

    This topic has been closed for replies.
    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

    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.

    Javier1Author
    Graduate II
    July 22, 2025

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

    Javier1AuthorAnswer
    Graduate II
    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": []
     }
     ]
    }

     

    Graduate II
    July 23, 2025
    Javier1Author
    Graduate II
    July 23, 2025

    good catch