Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to configure VS Code to build and debug STM32 projects using cubeMX - Windows 10

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

like image 301
clixxclixx Avatar asked Jul 18 '18 00:07

clixxclixx


People also ask

How do I program a STM32 with Vscode?

Using the Open folder menu in Visual Studio Code, navigate to your project's root folder and open it. Now open the command palette ( Ctrl+Shift+P or F1 ) and run Build STM32 Project . A terminal should appear and you will see gcc (hopefully) compiling your project.

What is VisualGDB?

VisualGDB provides consistent Visual Studio debugging experience for local, SSH-based, JTAG-based debugging and many more. You hit F5, VisualGDB does the rest. Advanced debug features include: IntelliSense and preprocessor support in Watch windows. Built-in SSH terminal and file transfer for Linux debugging.

How do I launch code in VS?

To run or debug a simple app in VS Code, select Run and Debug on the Debug start view or press F5 and VS Code will try to run your currently active file.


1 Answers

  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.
like image 66
Bence Kaulics Avatar answered Sep 28 '22 01:09

Bence Kaulics