Skip to content

A basic boilerplate to start working with STM32, arm-none-eabi and CMake with custom toolchain setup for bare-metal development.

Notifications You must be signed in to change notification settings

ErniW/STM32-CMake-boilerplate

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

STM32 CMake boilerplate

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.

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)

Setup:

  1. Set the CMSIS_DIR directory in CMakeLists.txt to CMSIS/include (or copy that folder to CMSIS folder).
  2. Make sure to include in system PATH all required libraries (especially on Windows).
  3. To change the microcontroller create similar folder to STM32F446RE. Then switch names and parameters in CMakeLists.txt both in MCU folder and main CMake file.
  4. Change project name in makefile.

How to use:

  1. Run make init-linux or make init-windows to prepare build system.
  2. Run make compile to compile.
  3. Run make upload to upload the code (make compile upload does 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.

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.

About

A basic boilerplate to start working with STM32, arm-none-eabi and CMake with custom toolchain setup for bare-metal development.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages