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.
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
Select the SW4STM32 IDE/toolchain from the when exporting your project.
NUCLEO-F042K6 development board
MIT license unless designated otherwise. Generated files maintain their original licenses. Contributions welcome.