This repo serves as a guide for porting existing STM32CubeMX projects to the Zig C/C++ compiler, unlocking the ability to mix C/C++ and Zig code in your project. It is intended to track major release versions of Zig, as Zig is still in development and subject to change. This repo is currently tracking Zig:
0.13.0
STM32CubeMX, using the "Makefile" toolchain selection, was used to generate a very simple blinky program for the STM32F750N8 MCU. This MCU uses a Cortex M7, and supports hardware floating point operations. The program itself isn't the important part of this guide, rather following along with what needs to be modified/changed to get generated STM32CubeMX code to compile with Zig's C/C++ compiler.
This repo contains four different "project" directories:
- 1: The baseline project generated by STM32CubeMX without modification
- 2: Using zig as a drop in compiler replacement in a Makefile
- 3: Replacing the Makefile with a build.zig file to make use of Zig's build system
- 4: Using more advanced features of Zig's build system + integrating Zig code
They are meant to be read in order, as the complexity builds with each example.
- Zig emits to stderror when
blinky_exe.setVerboseLink(true);
is used, see here - When
blinky_exe.setVerboseLink(true);
is used, linker command appears to use "armelf_linux_eabi" as its triple which I've confirmed is "correct" but that triple is a bit of a misnomer given we are NOT compiling/linking for a linux system