MMCU Update: C++20 Modules for Bare-Metal Firmware

A 32bitmicro open-source project update.


MMCU (Modular MCU) has been updated as part of 32bitmicro's open-source embedded systems work.

The project explores a modern C++20 approach to bare-metal MCU firmware: use import and export module to replace traditional header-heavy component boundaries, then build the scaffold with CMake 4.0's first-class C++ module support.

MMCU is intentionally starting from the simplest embedded program shape: a firmware entry point and an infinite main loop. From there, the project can grow toward isolated modules for hardware subsystems such as GPIO, SPI, and UART.

int main(void)
{
    for(;;);
}

That small starting point is deliberate. Bare-metal firmware is easier to reason about when the boot path, scheduling model, and component boundaries are visible from the beginning.

Why Modules Matter for MCU Firmware

Traditional embedded C and C++ projects often accumulate fragile include chains, macro leakage, and accidental dependencies between hardware components. MMCU experiments with C++20 modules as a cleaner boundary:

  • export module defines the public surface of a firmware component.
  • import makes dependencies explicit at the use site.
  • Module boundaries reduce preprocessor coupling across GPIO, SPI, UART, and future peripheral layers.
  • CMake 4.0's module support gives the build system a first-class way to scan and order module dependencies.

The goal is not to make MCU firmware abstract for its own sake. The goal is to make low-level code easier to audit, easier to build reproducibly, and less dependent on header conventions that were designed around older compiler models.

Current Project Shape

The current MMCU reference includes:

  • C++20 module-oriented project scaffolding
  • CMake 4.0 build requirements
  • a minimal firmware main
  • local build and clean helper scripts
  • MkDocs documentation with early book chapters covering project layout, the main loop, and C++20 modules

MMCU targets bare-metal MCU projects where a full RTOS is unnecessary and the main loop remains the scheduler. Toolchain requirements are intentionally modern: Clang 20+ or GCC 15+ for C++20 module support.

Project Links

MMCU is open source under AGPL-3.0-or-later:

github.com/32bitmicroLLC/MMCU

The 32bitmicro project reference page is here:

MMCU — Modular MCU Framework

If you are exploring modern C++ for deeply embedded systems, MMCU is where 32bitmicro is collecting that work in the open.

Copyright © 32bitmicro, LLC 2024-2026