A basic boilerplate code.
- It sets the CMake environment.
- It includes necessary files for STM32F446RE board (linker, svd, startup, system, header).
- Builds the binary file to upload with STLink.
- Tested with VS code on windows and linux.
Please be aware that the boilerplate is made for STM32F446RE but you can simply change the files.
Requirements:
- Arm-none-eabi toolchain
- Make
- CMake
- ST-Link
- MinGW (windows)
- C/C++ extensions (VS code)
- Cortex-Debug (VS code)
Setup:
- Make sure to include in system PATH all required libraries (especially on Windows).
- To change the microcontroller create similar folder to STM32F446RE. Then switch names and parameters in
CMakeLists.txtboth in MCU folder and main CMake file. - Change project name in
makefile.
How to use:
- Run
make init-linuxormake init-windowsto prepare build system. - Run
make compileto compile. - Run
make uploadto upload the code (make compile uploaddoes both).
After uploading the build-in LED should blink.
VS code can't find headers:
The code compiles correctly but the VS code still doesn't recognize the headers - you need to add includes to the c_cpp_properties.json generated by VS code. If you know any better way of doing it please make a pull request.
VS code highlights things like uint32_t
In c_cpp_properties.json add "__CC_ARM"
I've spend a few days to figure this out from scratch. Please be aware there are many possible issues if it doesn't work on your computer, not necessairly with this code itself. Tested in VS Code.