Firstly, get the list of supported microcontroller. If you don't find your microcontroller, don't worry ! This template is customizable and you can easily add your microcontroller.
This framework is cross-platform, it is supported by Linux and Windows (other OS have not been tested but should work). Download all tools listed in the following table.
| Name | Version | URL | 
|---|---|---|
| CMake | 3.31.2 | https://cmake.org/download/ | 
| Ninja | 1.12.1 | https://github.com/ninja-build/ninja/releases | 
| Arm-none-eabi-toolchain | 13.3.Rel1 | https://developer.arm.com/downloads/-/arm-gnu-toolchain-downloads | 
| Openocd | 0.12.0 | https://openocd.org/pages/getting-openocd.html | 
Once downloaded, install the tools and add the path to the toll binaries to the PATH environment variable. After that, check that the tools are available by opening a console (Git Bash or Powershell on Windows, Bash on Linux).
$ cmake --version
cmake version 3.31.2
#####################
$ ninja --version
1.12.1
#####################
$ arm-none-eabi-gcc --version
arm-none-eabi-gcc.exe (Arm GNU Toolchain 13.3.Rel1(Build arm-13.24))
#####################
$ openocd --version
xPack Open On-Chip Debugger 0.12.0+dev-01685-gb9224c0c0-dirtyNucleo board from ST, need install drivers on the host : https://www.st.com/en/development-tools/stsw-link009.html
CMake allows to be cross-platform and manage the build system on 2 steps :
- Configure : Detect the architecture and toolchains, find dependencies and write build tool files.
- Build : Compile and link binaries, run tests.
At the top of project, enter the following command depending on your context for configuring. Three context are available :
- Debug : Build cross-compiling firmware on debug mode.
- Release : Build cross-compiling firmware on release mode.
- Test : Build native test suite binaries.
$ cmake -G Ninja -B build/debug -DCMAKE_BUILD_TYPE=Debug -DSELECTED_BOARD=<Your_Board> --toolchain "cmake/toolchain-arm-none-eabi.cmake"Notes:
- --toolchain <TOOLCHAIN_FILE>is equivalent to- -DCMAKE_TOOLCHAIN_FILE=<TOOLCHAIN_FILE>
- Add --freshto configure a fresh build tree, removing any existing cache file
$ cmake -G Ninja -B build/release -DCMAKE_BUILD_TYPE=Release -DSELECTED_BOARD=<Your_Board> --toolchain "cmake/toolchain-arm-none-eabi.cmake"$ cmake -G Ninja -B build/test -DCMAKE_BUILD_TYPE=Test --toolchain "cmake/toolchain-native.cmake"At root of project and after configuring, build binaries with the following command :
cmake --build <build_folder>The <build_folder> is depending of your context :
- For Debug mode = <build_folder>=build/debug
- For Release mode = <build_folder>=build/release
- For Test mode = <build_folder>=build/test
It is possible to build directly on the <build_folder>, follows the commands at the root of the project :
$ cd <build_folder>
$ cmake --build .After building the cross-compiling firmware in Debug or Release mode, flash it on the board with the following command :
$ cmake --build <build_folder> --target flashNeed to plug the nucleo-board !
After building the firmware in Debug mode, debug it on the board with the following command :
$ cmake --build build/debug --target debugAfter configuring and at build time, available commands can be display with this command :
$ cmake --build <build_folder> --target helpNo-exhaustive list :
$ cmake --build <build_folder> --target clean # Clean the build foldercmake -B build/Test -GNinja -DCMAKE_BUILD_TYPE=Test
cmake --build build/Test
ctest -V --test-dir build/Test # Run all tests with verbose output
cmake --build build/Test --target coverage # Generate code coverage reportopenocd -f config/openocd.cfg -c "setup <OPENOCD_TARGET_BOARD>" -c "program_debug"arm-none-eabi-gdb --tui bin/<firmware_name>.elf
(gdb) target extended-remote localhost:3333
(gdb) load
(gdb) monitor reset halt