This project is a basic example on how to use CubeMX with Visual Studio Code.
For detailed guide on creating this project step-by-step, and to know what to change when adapting this project to your MCU, see my blog post
- STM32CubeMX
- ARM-GCC toolchain
- OpenOCD - this is actually optional, you can change the debugging interface to
stlink
in project config - compiledb package for Python, as it's used to generate
compile_commands.json
forclangd
. You can also modify this project to use Bear if you're working on Linux, butcompiledb
should work everywhere. - GNU Make, if you're working on Linux/MacOS you should have it. If you're working on Windows, i recommend getting it from MSYS/MinGW-W64 install, or WinLibs - i use WinLibs, i've copied
mingw32-make.exe
and renamed the copy tomake.exe
to use it withcompiledb
and it works fine. DO NOT use Make for Windows withcompiledb
, it won't work due to UTF encoding issues - at least in my case.
Set project type to Makefile
, nothing more.
Besides the standard C/C++ plugins, this project is based on clangd language server. For debugging, Cortex Debug plugin is used. I also recommend installing ARM assembly and LinkerScript syntax support.
compiledb
crashes due to UTF encoding issues - getmake
from different sourceImport error: no module named site
- this comes from GDB dependency. To solve it, install Python 2, and create environmental variable calledPYTHONHOME
. Set it to Python2 installation path (C:/Python27
by default). If you're usingcompiledb
, make sure you empty this variable intasks.json
(it's done in this project), otherwisecompiledb
will try to run using Python 2 and fail misearbly.