Embedded Development using Visual Studio Code

Several years ago, I never would have believed that embedded developers would use a tool like Visual Studio Code. Using a Microsoft product to develop embedded software seems ridiculous. Yet, I find myself using Visual Studio Code for development more than I use any other integrated development environment! In this post, I’ll share a little bit about Visual Studio Code and how you can use it to develop embedded software.

Introduction to Visual Studio Code

Visual Studio Code is a streamlined code editor with support for development operations like debugging, task running, and version control. It does not contain the more complex features or workflows developers find in an Eclipse-based IDE. However, the streamlined nature of Visual Studio Code makes it extremely flexible and easily used for many purposes.

Visual Studio Code is a text editor that is customized through extensions. For example, if you are working with C/C++, adding the C/C++ extension to Visual Studio Code can provide better IntelliSense. Adding the Doxygen extension makes it easy to generate code documentation.

Embedded Development using Visual Studio Code

In addition to text editing and the extension system, Visual Studio Code also includes quick access to a terminal. This allows developers to work within one environment and issue commands without having to bounce to other applications. I will often use the terminal to directly build my code, push changes to a Git repo, or load a Docker container and execute my CI/CD process.

Visual Studio Code Plug-ins for Embedded

Visual Studio Code provides a wide range of plug-ins that allows the environment to be used for embedded systems, mobile applications, and even Python development. Personally, it’s nice to have just a single environment to work from to do everything! However, if you don’t have the right plug-ins, it can definitely be difficult.

The plug-ins that you need are going to depend on what you want to accomplish. For example, if you are working with the ESP32, Visual Studio Code has several plug-ins that are extremely useful such as:

  • ESP-IDF
  • CMake
  • CMake Tools

These plug-ins simplify the setup for the ESP32 toolchain. In addition, developers have access to commands that can be quickly executed in the terminal without having to remember the commands. I often use the component create and the build/deploy/monitor shortcuts.

Several other plug-ins that I have found to be helpful include:

  • Doxygen
  • Docker
  • Jupyter

Debugging from Visual Studio Code

I know that one question developers have is how can I debug my code from Visual Studio Code. There are several ways to debug depending on the tools that you are using.

One option for debugging is to simply use the terminal to print messages into the terminal. I often do this when I’m working with ESP32 parts. (I know that I can set up my debug tools, but I often don’t require them).

Another option, and one that I use when I’m using my SEGGER J-Link Ultra+, is to use the Cortex-Debug plug-in. This plug-in adds debug support for ARM Cortex-M processors! (SEGGER has a nice Wiki here on how to set up and run the debugger).

Once the plug-in is installed, you can simply press F5 or select Start Debugging from the Debug menu! The debug session is then just like every other IDE.

Visual Studio Code Conclusions

Visual Studio Code is an interesting and flexible development tool for embedded software developers. It’s easy to use and has a wide range of extensions to get developers up and running. The tool is cross-platform, which makes it easy to develop a standard dev process whether a developer is using macOS, Linux, or Windows.

In future posts, we will explore a little bit more about this tool and how it is being used in modern development processes.

2 thoughts on “Embedded Development using Visual Studio Code”

  1. You can also use plaformio. Supports a lot of different MCUs out the box and allows you to code them from the same IDE… No need to have different variants of Eclipse installed

    1. True. There definitely are other options out there.

      The question though, in 5 years, will those other options still be here? What about 10, or 15? Or will they have been bought, gone out of business, or otherwise be unrecognizable?

      For flexibility and long-term support, I don’t think anyone can go wrong with Visual Studio Code. After all, I was using the original Visual Studio when I was a freshman in high school nearly 25 years ago and it’s still here! (And I’ve only in the last year started to use VSC after waiting to see the adoption rates).

      At the end of the day, it’s up to the teams need, perceived value, and maintenance needs.

Leave a Reply

Your email address will not be published. Required fields are marked *

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