9
votes

I am new to the realm of STM32 programming and have been trying to find a suitable IDE for quite a while now. I know of all the other IDE's like Keil and IAR but the cost of buying them just to learn is far to steep for me at this point in time.

I have started using VS Code for a growing amount of my development work and I though it would be a good IDE to use for STM32 development. I have found many examples online over the past few days on how to configure the IDE to build STM32 projects but they all seem to be missing important information that I need to properly get the project to compile. It is rather frustrating,

I was wondering if there is anyone that can point me to a complete setup guide on how to set up VS code to work with cubeMX and the arm tool-chain, or if you are feeling really kind, send me a sample project that I can use as a base learn from.

Just some background information, I know how to use cubeMX to generate the base project as well as the associated makefile, I also have the latest GNU-Tools-Arm-Embedded installed.

Thank you in advance for your help

3
While I don't have details regarding VS Code in conjunction with STM32, have you thought of Atollic TrueSTUDIO? It's based on Eclipse, actively supported by ST and CubeMX should generate ready projects for it. And most importantly - it's free.Jacek Ślimok
I have not heard of this, I will definitely check this option out as well then, thank you very much.clixxclixx
What have you tried? What was not working? I don't use VS Code, but setting compiler to gcc-arm-none-eabi, pointing include and source dirs with CMSIS, HAL, and LL, and defining linker script should be enough. Here is a CMake based version I use in Emacs.pan-mroku
I know this is an old topic, and I like VSC a lot but for this purpose, a free package that works just out of the box is SW4STM32: openstm32.org/HomePage. In the cubeMX set the toolchain for it and it just compiles easy. Also has a strong debugging tool, trust me you gonna need them.anishtain4

3 Answers

8
votes
  1. Install GNU Arm Embedded toolchain and add its bin folder to your PATH environment variable.
  2. You will also need a make to execute your makefiles so download Make for Windows. Easiest way is to download the binaries and extract it somewhere on your system. Add it (C:\make-3.81-bin\bin) to your PATH as well.
  3. Create an STM32CubeMX project and select Makefile as Toolchain/IDE. enter image description here
  4. At this point you will be able to build the generated project by simply using make in the project's root folder.
  5. If you open the project in VS Code you can build using its terminal or you can create a VS Code task to execute the make command. You can bind your task to a hotkey as well to spare some time.
  6. To debug, the easiest way is to install Cortex-Debug VS Code extension. Follow the instructions to configure your debug sessions.
5
votes

A while ago I had the same question, but did not find anything that I really liked. So I created STM32 for VSCode, it is an extension for VSCode which works with STM32CubeMX generated files and sets up building and debugging for you.

1
votes

There is a library of python scripts that does just this, it has been released recently with excellent documentation and after testing I can say it works as advertised.

VSCode STM32 IDE

The process is quite straight forward:

  1. Export the files using STM32CubeMX
  2. Cpen the VSCode folder and save it as workspace
  3. Copy the scripts "ideScripts" directory to your project folder
  4. Run update.py

Here is a video on how it works:

VSCode STM32 IDE - Getting Started