Skip to content

CMake script to build microcontroller firmware generated by STM32CubeMX.

Notifications You must be signed in to change notification settings

windsorschmidt/stm32cubemx-cmake

Repository files navigation

About

This is a collection CMake build scripts used to build code generated by the STM32CubeMX tool from STMicroelectronics. An example project exists to demonstrate using a project file with code generated for the STM32F042K6 part as found on the NUCLEO-F042K6 development board.

STM32CubeMX currently exports build files for a few embedded-centric IDEs, which is not so helpful for people using gcc from the command-line or in my case, inside Emacs. I have added my own attempt at a CMake build script to handle generating a firmware binary, and flashing it to a development board using OpenOCD.

CMakeLists.txt here is the only noteworthy file; the generated firmware source code is simply convenient for testing the build process. Using this script with other targets should be a matter of using STM32CubeMX to generate code for your target, changing some file paths, and adjusting your compiler/linker flags.

Running the Example Project

Prerequisites:

  • Linux (OSX untested but should be usable)
  • GNU ARM toolchain (i.e. arm-none-eabi-gcc, etc. are available)
  • NUCLEO-F042K6 development board connected to USB
  • OpenOCD (and R/W permissions to the USB device)

Compiling and flashing to target:

$ mkdir example/build; cd example/build
$ cmake ..
$ make flash

Exporting Your Projects from STM32CubeMX

Select the SW4STM32 IDE/toolchain from the when exporting your project.

References

STM32CubeMX

NUCLEO-F042K6 development board

OpenOCD

License

MIT license unless designated otherwise. Generated files maintain their original licenses. Contributions welcome.

About

CMake script to build microcontroller firmware generated by STM32CubeMX.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages