Some basic project templates which are intended for the arm-none-eabi-gcc toolchain. Does include support for unit tests if you wish to use them. Otherwise remove the relevant dirs if you decide against testing. Look at other branches for different setups e.g. FreeRTOS support, CMSIS support instead of Libopencm3 etc.
The project itself is blinking the user LED on the STM32G431KB Nucleo device.
The following tools are needed to build this project
- make or cmake
- arm-none-eabi-gcc
- gcc (for unit tests)
- st-flash in order to interact with the STM32
# Generation stage (unit tests and stm32 most be in different directories) cmake . -B build -DCMAKE_TOOLCHAIN_FILE=arm-none-eabi.cmake cmake . -B testbuild # Generation stage w/ my cmake debugging prints cmake . -B testbuild -DDEBUG_CMAKE=True # Build stage cmake --build build cmake --build testbuild # Flash to stm32 via st-flash (via generated makefile) make -C build flash-write/fast # Build and then flash erase stm32 cmake --build build --target all flash-erase # Running tests via ctest ctest --test-dir testbuild
# Generation stage $ cmake --preset stm32 $ cmake --preset host-tests # Build stage $ cmake --build --preset stm32 $ cmake --build --preset host-tests # Flash to stm32 via st-flash $ cmake --build --preset stm32 --target=flash-write # Build and then flash erase stm32 $ cmake --build --preset stm32 --target all flash-erase # Running tests via ctest $ ctest --preset host-tests
- ARM CMSIS V6
- STM32G4xx Nucleo BSP
- STM32G4 HAL
- CMSIS G4 CMSIS device library
- Greatest C test framework
CMSIS will also produce linker warnings due to newlib e.g. “_write is not implemented and will always fail”. There is quite a bit of a size overhead when pulling in all the CMSIS modules. An average project would be around ~100Mb.