Skip to content

Compiling an STM32CubeMX with Zig's compiler instead of arm-none-eabi-gcc.

Notifications You must be signed in to change notification settings

haydenridd/stm32-zig-porting-guide

Repository files navigation

Porting STM32CubeMX Projects to Zig

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

Project Setup

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.

How to Use This Guide

This repo contains four different "project" directories:

They are meant to be read in order, as the complexity builds with each example.

Miscellaneous Notes + Thoughts

  • 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

About

Compiling an STM32CubeMX with Zig's compiler instead of arm-none-eabi-gcc.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages