Visual Studio Code STM32 IDE

This is a story about how I transformed Visual Studio Code to an IDE for embedded projects, that can work with STM32 CubeMX generated Makefile, OpenOCD and all the goodies that VS Code offers.

Why?

  1. I like Visual Studio Code. I think it is an amazing editor. I also like STM32CubeMX for generating basic initialization code.
  2. I wanted to pimp-up old project and I hit Keil code size restriction.
  3. I certanly don’t wish to spend the rest of my life configuring Eclipse settings to blink an LED.

How?

I also like Python. So, I created a set of scripts that can parse CubeMX generated Makefile and VS Code ‘c_cpp_properties.json’ file and do some magic, which is better described on GitHub.

The result is a VS Code which can build, compile, download, reset, … CPU and has no limitations. After the initial, relatively quick setup, a simple “Run task > Update workspace” is needed to update VS Code files and coding can continue. 

And the best thing?

You can still use STM32CubeMX without any restrictions (regenerate, rebuild files, …). You can add custom files and folders, C/ASM defines. You can enjoy VS Code Intellisense and all other available extensions while coding.
Compile, build project and check all compiler flags in special file. Debug embedded code. See CPU and core registers. Map your own shortcuts to tasks. Develop C and Python project in the same IDE.

And the best of all: customize it, because it is free and open source. Implement custom tasks, launch configurations, settings, …

Explore the docs, guide and example on our GitHub and share if you like.

 

 

10 Comments

  1. How is this comparable to Atollic TrueStudio

  2. Atollic TrueStudio (and others) is a more complete, advanced IDE package. Which means, for any serious project where debug/multicore/OS/trace/… is needed, some sort of advanced IDE is the only way to go, and Atollic TrueStudio is fine I think.

    For a simpler projects you sometimes just want two things: a good text editor and a basic debug capabilities. This is what this project is about. It cannot compare with other advanced IDEs in terms of features, but it can compare (and probably win) in terms of simplicity and straight-forwardness.

    In fact, I tried Atollic TrueStudio, and it is a good capable IDE – if you wish to bother configuring Eclipse and all 10^8 settings to blink a LED. 😀

  3. Thanks for your reply.
    As I am a noob, and an Arduino user, I find these complicated IDE (like Atollic) quite troublesome and not straight forward. Just adding and deleting files could cause a compile errors if you are not careful, not to mention importing other eclipse project.
    Thanks anyway for the thought.

  4. This had just became an amazing tool. Thank you very much for your effort.

  5. Thank you very much for the nice work. Things progressed nicely. I get the following message when running update.py “Enter path or command for ‘stm32SvdPath:”Any help in resolving it is appreciated.

    • Hello Gargamel,
      please create an issue here: https://github.com/damogranlabs/VS-Code-STM32-IDE/issues
      Describe (with as much details as you can) how I can reproduce this issue, how exactly your environment is set (where project is located, where is/should be your .svd file, …). Copy update.py task output and give as much clues as you can – what you have already tried, …

      But, first of all, make sure you use the latest version of ideScripts.

      Thank you, good luck!

  6. Hi,
    In Update time i got error
    ERROR (8 seconds).
    Unexpected error occured during ‘Update’ procedure. Exception:
    Traceback (most recent call last):
    File “d:/STM32/VSCode_STM32_IDE/STM32CubeMx_WS/STM32_Test/ideScripts/update.py”, line 56, in
    makefileData = makefile.getMakefileData(makeExePath, gccExePath)
    File “d:\STM32\VSCode_STM32_IDE\STM32CubeMx_WS\STM32_Test\ideScripts\updateMakefile.py”, line 93, in getMakefileData
    projectName = self.getMakefileVariable(makeExePath, gccExePath, self.mkfStr.projectName)[0]
    File “d:\STM32\VSCode_STM32_IDE\STM32CubeMx_WS\STM32_Test\ideScripts\updateMakefile.py”, line 366, in getMakefileVariable
    proc = Popen(arguments, stdout=PIPE)
    File “C:\Users\kumar\AppData\Local\Programs\Python\Python38-32\lib\subprocess.py”, line 854, in init
    self._execute_child(args, executable, preexec_fn, close_fds,
    File “C:\Users\kumar\AppData\Local\Programs\Python\Python38-32\lib\subprocess.py”, line 1307, in _execute_child
    hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
    PermissionError: [WinError 5] Access is denied

  7. Thank you for all the hard work you did to make this tool and then for sharing it for others such as myself. It is too bad that there isn’t a VSCode extension that would make CubeMX work directly from within VSCode.
    By the way, many people are now using Stm32CubeIDE which includes the cross-compiler tools and debugger interface tools in the setup (!!). It is a “slam dunk” to install, run, compile, debug. The makefile directory structure that results using it is slightly different than the Stm32CubeMX one but almost the same.
    Could your tool be adapted to work with this instead (CubeIDE)? It seems valuable to be able to use the Eclipse based tool to verify things if or when there is a problem using VSCode. And again, it simplifies setting up a working set of tools. It might even make it so that your Python scripts can find everything without having to ask the user since those tools are all in a defined place.
    I will note that I am having some trouble applying your tool to my Mac OS computer with CubeMX on it. Hopefully I figure it out but for now I am stuck relying on using CubeIDE for my work while on the Mac.

    • Hello and thank you.
      This of course is possible, but doesn’t make sense – although VS Code is an amazing editor, it still doesn’t have proper debug capabilities and other things you usually need when developing embedded application. VS Code STM32 IDE project was meant for simple projects and can’t compare with proper IDEs.
      However, what you are asking is possible, maybe even easier to do than with CubeMX usage, but it is basically a rewrite – project is tightly coupled to CubeMX and read/generate makefile. Maybe STM32CubeIDE has better capabilities external control (like triggering build process or regenerate workspace, …), but this is a whole other story.
      I don’t have time, but feel free to take my project as a template and expand it. I can only offer you a help for a current project. And think twice – for more comple embedded projects just go with their or others IDE.

      Good luck, Domen

Leave a Reply