Visual Studio Code for C/C++ with ARM Cortex-M: Part 5 – ToolKit

The previous parts were about installation, project setup, building and debugging. This one is about defining the ‘tool kit’ so I can make use more of the CMake infrastructure in Visual Studio Code:

Tool Chain loaded in Visual Studio Code

Outline

There are still a few things to be configured for our project. We can build and debug, but building is done through ‘Tasks‘ but not through CMake directly. This is because I have not configured a ‘kit’ yet. I can see this from a status message on the bottom:

No Kit Selected in Visual Studio Code

If I try to make a ‘CMake: clean’ (use command palette or CTRL+SHIFT+P) with CMake: Clean

There is a list of ‘kits’ (somehow detected automatically?), but the GNU ARM Embedded toolchain I have installed and using is not listed:

Select a Kit

Scan for Kits or using ‘unspecified‘ just resulted in wrong kits/compiler used, breaking the build for the ARM Cortex-M I’m using :-(.

Obviously the CMake with Visual Studio integration is missing something. Thanks to Martin investigating and commenting in the previous part 3 solved the problem: I need to add an extra cmake-kits.json file.

Adding a Kit with cmake-kits.json

Create a new file inside the .vscode folder and name it cmake-kits.json, with the following content (or copy it from GitHub):

[
    {
        "name": "GCC Arm Embedded",
        "toolchainFile": "${workspaceRoot}/arm-none-eabi-gcc.cmake"
    }
]
Kit successfully loaded

You can give it any name but it has to point to the correct toolchain file for Cmake. With this I have a ‘kit’ recognized and can assign it to a project using the icon in the bottom toolbar:

Selecting Kit in Visual Studio Code

CMake Actions

With the proper toolchain or kit configured, I can use commands like CMake: Build or CMake: Clean:

CMake Build or Clean

Summary

To use the CMake commands, Visual Studio Code needs to know about the toolchain using the cmake-kits.json file present in the .vscode folder. Be sure to have that one added to the project to unlock more of the Visual Studio Code features.

Happy Coding 🙂

Links

18 thoughts on “Visual Studio Code for C/C++ with ARM Cortex-M: Part 5 – ToolKit

    • thanks! There should be more coming. I don’t have a plan, but what I want to check out are some more advanced features and looking into the extension made by Liviu.

      Like

    • Thanks! I’m still learning things in CMake. I see the potential and the power of it, the same time it is rather hard to understand and learn. IMHO make files are much easier to handle, but I hope that over time things will get easier using CMake.

      Like

  1. Pingback: Visual Studio Code for C/C++ with ARM Cortex-M: Part 6 | MCU on Eclipse

  2. Pingback: Visual Studio Code for C/C++ with ARM Cortex-M: Part 1 | MCU on Eclipse

  3. Pingback: Visual Studio Code for C/C++ with ARM Cortex-M: Part 2 | MCU on Eclipse

  4. Pingback: Visual Studio Code for C/C++ with ARM Cortex-M: Part 3 | MCU on Eclipse

  5. Pingback: Visual Studio Code for C/C++ with ARM Cortex-M: Part 4 | MCU on Eclipse

  6. Pingback: Visual Studio Code for C/C++ with ARM Cortex-M: Part 7 – FreeRTOS | MCU on Eclipse

  7. Pingback: Visual Studio Code for C/C++ with ARM Cortex-M: Part 8 – xPack C/C++ Managed Build Tools | MCU on Eclipse

  8. Pingback: Visual Studio Code for C/C++ with ARM Cortex-M: Part 9 – RTT | MCU on Eclipse

  9. Pingback: Visual Studio Code for C/C++ with ARM Cortex-M: Part 10 – Assembly Stepping | MCU on Eclipse

  10. First of all thanks a lot for your wonderful series. Is there any way to use system environment variables to replace static toolchain folders that is defined in the arm-none-eabi-gcc.cmake files. Something like env:ARM_TOOLCHAIN_DIR instead of C::Program Files… definition?

    I had a bit of research through the web but couldn’t find specific answer.

    Thanks a lot for the help.

    Liked by 1 person

  11. Great series. Really helped to connect the different links in the toolchain :-).
    Especially using gdb and gdb server.
    Most IDE’s encourage limited debug to, set a breakpoint, step in, step out so its been great to explore command line gdb while having viewing source code terminal.

    Regarding .svd files, this part seemed inevitable to lack full support.
    I am having difficulty locating a .svd file for Renesas R7FS7G27H3A01CFC.
    One forum indicated IAR has one but IAR is not big on offering free download

    Checked Keil but no support their either.

    Does anyone know where to locate a .svd file for Renesas R7FS7G27H3A01CFC?

    Like

What do you think?

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.