/boilerplate-stm32-libopencm3

Boilerplate for STM32 and libopencm3 - a simple starting point for any embedded project

Primary LanguageCMake

STM32 & libopencm3 boilerplate

disclaimer

It is not a professional code example. It's only for personal needs to be able to very quickly setup something that is not meant to be perfect but only to work :).

It works with STM32L476 but it can be adjusted to any STM by changing some linker options and opencm3 settings.

prerequisites

setup

  • Download the repo to the src directory.
  • Create local.cmake file in .local directory in source directory. Fill it with content specified in local-cmake-example.
  • Create build directory on the same level as src directory.
  • Go to build directory.
  • Run cmake ([path-to-cmake]/cmake.exe -DCMAKE_BUILD_TYPE=Debug -DCMAKE_C_COMPILER=[path-to-arm-none-eabi]/arm-none-eabi-gcc.exe -DCMAKE_CXX_COMPILER=[path-to-arm-none-eabi]/arm-none-eabi-g++.exe -G Ninja -DLOCAL_CFG=[path-to-project-sources]/.local/local.cmake [path-to-project-sources]).
  • Run ninja all.
  • Run ninja stm32.flash.
  • Enjoy.

While running cmake the important part is: -G Ninja -DLOCAL_CFG=../src/.local/local.cmake - use Ninja as generator and local.cmake as file defining your specific paths.