EmbeddedRelated.com
Blogs
Memfault State of IoT Report

Visual Studio Code Extensions for Embedded Software Development

Jacob BeningoMarch 22, 20238 comments

Visual Studio Code has become one of the most popular IDEs in the world. To date, software developers have downloaded it more than 40 million times! I suspect you’ve at least heard of it, if not already attempting to use it. Visual Studio Code allows developers to easily customize their development environment which can help them accelerate development, minimize bugs, and make developing software overall much better.

One challenge with Visual Studio Code is that embedded software developers have struggled to adopt it due to the unique nature of writing software for hardware. When writing embedded software, you often need to connect to a target, examine registers, find the state of the RTOS, deploy code, and much more.

In this post, we are going to explore several Visual Studio Code extensions that will help make embedded software developers lives easier, and perhaps make you an advocate for using Visual Studio Code over your own vendors toolchain. I’m going to list them one after another and provide a little description of each. Where it makes sense, I’ll also show some examples and provide additional links so that you can check out the plug-in in more detail.

This article is available in PDF format for easy printing

(Note: There is quite a bit here, so don’t expect low-level details about how to set up each of these extensions. This post is pointing you to the extensions I’ve found useful. I may cover some of these in more detail in a future post).

Extensions for Interacting with Arm Cortex-M Microcontrollers

Arm Device Manager - This extension allows you to manage device connections for Arm Cortex-M based microcontrollers, development boards and debug probes. The extension can work in tandem with Arm CMSIS csolution and Arm Embedded Debugger to debug a project. It also includes an option to open a serial monitor through the debug probe.

Arm CMSIS csolution – This extension provides support for working with CMSIS solutions. It allows a developer to convert .uvprojx projects to csolutions. It provides an interface for selecting CMSIS software components and including them within the project.

Arm Embedded Debugger - This extension allows you to do flashing and debugging on Arm Cortex-M based microcontrollers, development boards and debug probes implementing the Microsoft Debug Adapter Protocol (DAP). Developers can create flash and debug configurations. For example, for an NXP microcontroller, the debug configuration might look something like the following:

``{
 // Use IntelliSense to learn about possible attributes.
 // Hover to view descriptions of existing attributes.
 // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
 "version": "0.2.0",
 "configurations": [
     {
         "name": "FRDM-K32L3A6 (CM4)",
         "type": "embedded-debug",
         "request": "launch",
         "serialNumber": "${command:device-manager.getSerialNumber}",
         "deviceName": "K32L3A60VPJ1A",
         "processorName": "cm4",
         "program": "${command:embedded-debug.getApplicationFile}",
         "cmsisPack": "https://mcuxpresso.nxp.com/cmsis_pack/repo/NXP.K32L3A60_DFP.13.1.0.pack"
     }
 ]
}``


Embedded Tools – This extension is most desired amongst embedded developers. It provides a register viewer for CMSIS-SVD files and an RTOS data viewer with support for Azure RTOS, FreeRTOS, and Zephyr! Being a Microsoft extension, it also comes with some great documentation which you can find here.

Cortex Debug – An alternative debugging extension that I’ve had a lot of success with is Cortex Debug.  It’s an open-source project that started out as a contributor hobby project. It has since been taken over and continues to have new features added to it. You can learn a bit more about this plug-in at https://github.com/Marus/cortex-debug/wiki  

Syntax Highlighting Extensions

Arm Assembly – Some of you may cringe at this extension, but it provides syntax highlighting for assembly language files. While many of you probably don’t write assembly code, there is sometimes a need to modify or customize a few lines of vendor provided start-up code. This extension can help make code far more legible.

Better C++ Syntax – This extension provides better colorization of the C++ code. In the early days, VS Code did not color the code very well to make things easy to read. There have been improvements over time, but as seen below, this extension can help to color things so that they catch a bit better to the eye.

C/C++ - Usually one of the first extensions installed. C/C++ adds language support including IntelliSense and debugging features. The extension is provided by Microsoft.

Code Spell Checker – Sometimes I’m a bit of a perfectionist and like things to be spelled correctly in code. This extension is a basic spell checker. Definitely optional, but can be useful if your coding style follows Clean Code methodologies and naming conventions. (Can be quite annoying if you aren’t careful, but thankfully it can be disabled if it becomes so).

Build Tool Support Extensions

Makefile Tools - This extension provides IntelliSense configurations to the VS Code C/C++ Extension for Makefile projects. It also provides convenient commands to build, debug, and run your targets. If you have been hiding behind vendor IDEs and tools, you might not have looked at a makefile in quite some time. I promise with Visual Studio Code you’ll be digging into your make system. Makefile Tools can help with that.

CMake Tools – To automate your builds, you’re either using Make or CMake. CMake tools is a Microsoft extension that provides native support for full-featured, convenient, and powerful workflow for CMake-based projects. (Note: for CMake scripting language support, there is a CMake extension from twxs).

GNU Linker Map files – Adds syntax highlighting for linker map files. (Hopefully you do check you map files!)

Formatting and Linting Support Extensions

cpplint – An extension that provides C and C++ code style checking within VS Code. The extension requires cpplint to be installed. (cpplint will check that Google’s C/C++ Coding Style formatting is being adhered to).

Clang-Format - is a tool to format C/C++/Java/JavaScript/Objective-C/Objective-C++/Protobuf code. It can be configured with a config file within the working folder or a parent folder. Configuration see: http://clang.llvm.org/docs/ClangFormatStyleOptions.html

Clang-Tidy - This extension integrates clang-tidy into VS Code.

Clang-Tidy documentation can be found here.

Trailing Spaces - White space and hidden characters can sometimes cause compilation issues that are hard to find and fix. The trailing spaces extension highlights trailing spacing and highlights them for you. You can then remove them and ensure that your code isn't hiding any spaces that will get you in trouble later!

Vendor Specific Extensions

CppUTest Test Adapter – I normally just run my tests from within a Docker environment. However, if you want to run CppUTest from within Visual Studio Code, there’s an extension for that! The extension provides a sidebar that allows you to manage your tests and see their current status.

Platform IO - If you're looking for a vendor agnostic, collaborative environment to develop embedded, IoT, Arduino, mbed, and other applications, this might be worth a look. The extension integrates a wide variety of features that I've listed in this post independently such as linting, C/C++ intellisense, library management, etc. The project creator can be a great tool to get up and running quickly with the microcontroller platform or development board of your choice. 

GitHub Copilot – There’s nothing like AI trying to help you write code! I’ve found this plugin from GitHub to be intriguing at times. You can write some comments and the AI will recommend that code. Start writing a class, function, etc, and it will recommend autocomplete. Sometimes it’s scary on how helpful it is. Othertimes, it’s scary how off it is. Still a worthy extension to explore.

STM32 VS Code Extension – Brings the STM32 development environment into VS Code. The plug-in is quite full featured. It does require STM32 tools to be installed, but that is okay. The extension dramatically simplifies working with STM32 parts from within VS Code.

Keil Studio Pack Extension - The Keil Studio Pack Extension is a collection of extensions that will be helpful to any embedded software developer working with Arm Cortex-M microcontrollers. Some of the extensions are Arm specific, while others provide a supporting role. In fact, we’ve discussed a few of these extensions already! Here is a quick summary of the extensions included in this pack:

  • Arm CMSIS csolution
  • Arm Device Manager
  • Arm Embedded Debugger
  • Arm Remote Build
  • Better C++ Syntax
  • C/C++ Themes
  • Embedded Tools
  • YAML

Conclusions

You can dramatically customize how your development environment looks and feels from within Visual Studio Code. It’s certainly an IDE for the 21st century. There have been a ton of little unofficially released extensions to help support embedded software development over the years. The extensions we’ve explored are mostly officially released extensions from major players in the embedded software space, or software industry in general.

If you are looking to get started with Visual Studio Code and embedded software, these plug-ins will help you to get going on your way. I would recommend installing one extension at a time and reading the documentation to fully understand what that extension does. Before you know it, you’ll have a sweet development environment up and running and be debugging embedded targets from within Visual Studio Code.

What extensions have you found helpful in your software development efforts? 



Memfault State of IoT Report
[ - ]
Comment by dcomerApril 12, 2023

I understand Stroom's comment on Platform IO, yet at the same time, it is clear why Platform IO is not mentioned; it's a separate approach to the same problem. Therefore, it seems as if there is an opportunity to post a blog entry on Platform IO. That said, Jacobs' blog posts are really appreciated for their informative content and quality. There are plenty of YouTube channels that produce Visual Studio Code information, but not as concise, IMHO, as Jacobs's posts. Jacob is a credit to the embedded development industry.

[ - ]
Comment by StrooomMarch 25, 2023

How can you not mention PlatformIO in this BlogPost ? 

Which one is more popular ?

STM32 extensions : 4K downloads vs PlatformIO 3.2M downloads.

This extension is vendor independent, and can be used to develop firmware over a wide range of MCUs, as well as supporting many frameworks. It has many of the features mentioned above, all included in a single extension.


[ - ]
Comment by beningjwMarch 25, 2023

Thanks for the comment. 

It's right there after cpputest and before Github CoPilot. 

[ - ]
Comment by StrooomMarch 26, 2023

Yes, I can see it now. I must have missed it when switching between the blog post and trying out some of the extensions. I apologize.

[ - ]
Comment by dcomerApril 12, 2023

Perhaps the difference in downloads is due to the recent introduction of STM32 released for use on VS Code? PlatformIO has take plenty of time to come into its own. I suspect that STMicro will gain traction in time.

[ - ]
Comment by beningjwApril 12, 2023

I agree. At the point this was written, ST had just released the plug-in. 

PlatformIO also abstracts quite a bit, so I would expect more makers to use it over professional developers. 

You won't see a lot of STM developers switch to VS Code overnight. 

[ - ]
Comment by ingar_hanssenMarch 28, 2023

I miss Nordic Semiconductors nRF Connect for VS Code in this article, it has 50k downloads now.
It contains support for setting up new projects based on examples, editing, RTOS aware debugging, SW configuration (kconfig), a pre-release version of a GUI for configuring hardware (devicetree), device programming and more.

[ - ]
Comment by beningjwMarch 28, 2023

Excellent! Thanks for letting us know about it!

To post reply to a comment, click on the 'reply' button attached to each comment. To post a new comment (not a reply to a comment) check out the 'Write a Comment' tab at the top of the comments.

Please login (on the right) if you already have an account on this platform.

Otherwise, please use this form to register (free) an join one of the largest online community for Electrical/Embedded/DSP/FPGA/ML engineers: