MMCU
MMCU (Modular MCU) is a C++20 project scaffold and framework developed by 32bitmicro LLC that applies modern C++ module semantics to MCU firmware development. It explores the use of import / export module as a replacement for the traditional header-and-preprocessor model, targeting bare-metal embedded targets with CMake 4.0 as the build system.
The project is open source under AGPL-3.0 and hosted at https://github.com/32bitmicroLLC/MMCU.
Architecture
MMCU is organized around two pillars:
- C++20 Modules — replaces
.h/.cpppaired-file conventions withexport module/importunits compiled once into binary module interfaces. Eliminates macro leakage, reduces header parse overhead, and gives explicit control over the public API of each firmware component. - CMake 4.0 + module support — CMake 4.0 introduced first-class C++ module dependency scanning; MMCU requires it rather than working around older tooling. Build targets use
cxx_std_20andCXX_EXTENSIONS OFF.
Project layout:
MMCU/
CMakeLists.txt CMake project definition
src/main.cpp Firmware entry point — the main loop
build.sh Configure/build helper (--clean, --type, --jobs, --run)
clean.sh Remove build artefacts
docs/ MkDocs Markdown sources
mkdocs.yml Documentation site configuration
The firmware entry point deliberately starts with the simplest valid embedded program — an infinite loop — and builds complexity upward through modules:
int main(void)
{
for(;;);
}
This mirrors the philosophy documented in the project book: begin with the "hello main loop" before adding peripherals, drivers, or scheduling.
Embedded and Real-Time Use
- Target class — bare-metal MCUs where a full RTOS is unnecessary; the main loop is the scheduler
- Toolchain requirements — Clang 20+ or GCC 15+ for C++20 module support; Ninja recommended for build speed
- No dynamic allocation — the scaffold imposes no heap usage; module boundaries make it straightforward to audit which components allocate
- Module isolation — each hardware subsystem (GPIO, SPI, UART) becomes a named module;
import gpio;replaces a chain of nested includes and macro-guarded headers - Compile-time enforcement — modules make it impossible to use internal implementation details across unit boundaries, replacing fragile
PRIVATEinclude guards
Documentation
MMCU ships a MkDocs-based documentation site served locally with ./docs.sh serve and built statically with ./docs.sh build --clean. The book section (docs/book/) provides conceptual chapters:
| Chapter | Topic |
|---|---|
| Chapter 1 | Project layout and build workflow |
| Chapter 2 | The main loop as the first embedded program |
| Chapter 3 | C++20 modules: motivation, syntax, and references |
Versioning
MMCU is in early development. There are no versioned releases yet. The main branch is the active development branch.
| Item | Detail |
|---|---|
| License | AGPL-3.0-or-later |
| Repository | https://github.com/32bitmicroLLC/MMCU |
| Created | 2026-05-27 |
| Build system | CMake 4.0+ |
| Compiler | Clang 20+ or GCC 15+ |
Related Technologies
- LLVM / Clang — the primary compiler target; Clang 20 has the most complete C++20 module support
- Zephyr RTOS — the next step up in complexity when a bare-metal main loop is insufficient; MMCU occupies the tier below Zephyr
- CMake — build system used throughout; module support requires version 4.0 minimum
- C++ Modules (cppreference) — https://en.cppreference.com/w/cpp/language/modules.html
- Clang Standard C++ Modules — https://releases.llvm.org/20.1.0/tools/clang/docs/StandardCPlusPlusModules.html