Close

VSCode Configuring and Debugging

A project log for STM32 BluePill Frameworks Evaluation

The STM32F103 BluePill, what's under the hoods of mbed, platformIO, Arduino,...

wassimWassim 04/14/2017 at 08:062 Comments

Configuring Includes in VSCode

In VSCode you'll see the "mbed.h" underlined in green as not found

        {
            "name": "Win32",
            "includePath": [
                "C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/include/*",
                "C:/Users/User/.platformio/packages/framework-mbed"
            ],
            "browse": {
                "limitSymbolsToIncludedHeaders": true,
                "databaseFilename": ""
            }
        }
You should now be able to navigate, such as right click and the "Go to Definition" would open the file for you in VSCode

Before debugging

Debugging with VSCode (Start is right then got stuck)

well, haven't we seen this tool somewhere already ? Going back to the ".platformio\packages\tool-stlink" we find all of

st-flashthe flash utility used with the command line above
st-inforetrives information (flash, srma,... see help)
st-utilthis is the magic utility that changes your ST-Link HW+SW into a gdb server

I'm using this configuration

{
    "version": "0.2.0",
    "configurations": [
        {
            "type": "gdb",
            "request": "launch",
            "name": "Debug Microcontroller",
            "target": "extended-remote /dev/cu.usbmodem00000000",
            "executable": ".pioenvs/bluepill_f103c8/firmware.elf",
            "cwd": "${workspaceRoot}",
            "autorun": [
                "monitor tpwr enable",
                "monitor swdp_scan",
                "attach 1",
                "load .pioenvs/bluepill_f103c8/firmware.elf"
            ]
        },
    {
        "type": "gdb",
        "request": "attach",
        "name": "Attach to gdbserver",
        "executable": ".pioenvs/bluepill_f103c8/firmware.elf",
        "target": ":4242",
        "remote": true,
        "cwd": "${workspaceRoot}"
    }
    ]
}

With this, you can connect to the gdb server, load the program, but then I failed to step, I got an error, so here's where any help would be appreciated. I think the platformIO are working on an IDE with an integrated debug, well I bet it is the continuation of this process. But with the useful correct configuration that I'm probably missing.

Discussions

Hamid wrote 11/16/2018 at 19:02 point

im doing exact the same thing. my st-util is  listening on port 4242 but i get this error in vs code :(

""Debug adapter process has terminated unexpectedly (exit code: null)""

  Are you sure? yes | no

Alex wrote 06/20/2017 at 10:54 point

Try to use the following configuration (VSCode):

{
     "version": "0.2.0",
     "configurations": [
          {
              "type": "gdb",
              "request": "attach",
              "name": "Attach to gdbserver",
              "executable": "${workspaceRoot}/build/firmware.elf",
              "target": ":3333",
              "remote": true,
              "cwd": "${workspaceRoot}",
              "gdbpath": "path to arm-none-eabi-gdb.exe",
              "autorun": [
                  "monitor reset halt",
                  "load path to firmware.elf"
               ]
           }
     ],
     "compounds": []
}

"target": ":3333" - 3333 is the port which opens gdbserver (openocd).

"load path to firmware.elf" - load is the command gdb. 

  Are you sure? yes | no