How ventzl/cmrx works
Project type & purpose
• CMRX is a microkernel-based real-time operating system for Cortex-M microcontrollers (and POSIX/testing environments).
• Its primary goals are minimal privileged-mode code, full memory isolation (via the MPU), POSIX-like APIs, and a CMake-driven build.
File structure
• Top-level:
• cmake/ & CMakeLists.txt – build system and multi-arch support
• /cmrx – public kernel APIs (application, IPC, RPC, syscalls, util)
• src/os – kernel implementation (core, context switching, scheduler, syscalls, MPU setup) and architecture ports (ARM/CMSIS, Linux/posix, testing)
• src/lib – user-level library stubs for threads, mutexes, timers, RPC, etc.
• src/extra – optional userspace services (IPI, queue server, systick provider)
• testsuite/ & testing/ – integration and unit tests
• Layered ARCH directories under both cmake/arch and src/os/arch: these provide hardware-abstraction for Cortex-M, POSIX, testing.
Extract README insights
• Microkernel: small privileged core (~13 kB Flash, ~2 kB RAM), compile-time config
• Process isolation: one library = one userspace process, enforced by MPU
• IPC & RPC services facilitate safe communication
• CMake automates memory region setup, linking, and integration with vendor SDKs (CMSIS headers)
a. Main components (layers)
– Hardware Layer: CPU core, MPU, NVIC, SysTick timer, device buses/peripherals
– Microkernel Core: context switcher, scheduler, syscall handler, MPU manager, interrupt handling
– Architecture Abstraction (Porting Layer): CMSIS/arch code for ARM, POSIX shim for Linux/testing
– Kernel Services:
• IPC (mutex, signal, notify, shared memory, threads, timers)
• RPC framework (interface, implementation, internal marshaling)
• System calls / runtime / tracing
– User-level Libraries (Userspace Processes):
• One library = one process; thread APIs, device drivers, queue_server, ipi, systick modules
– Build & Tooling: CMake build scripts, Doxygen docs, test suite, CI pipelines
b. Relationships & data-flow
– Kernel Core ↔ MPU hardware (to enforce memory isolation)
– Build system orchestrates compilation of include/cmrx, src/os, src/lib, src/extra into separate binaries or static libraries
c. Architectural patterns & principles
– Microkernel: minimal privileged footprint, everything else runs in userspace
– Layered architecture: hardware → porting layer → core → services → user libraries
– Compile-time configuration (static composition of processes, memory regions)
d. Key technologies & frameworks
– CMake (multi-arch, cross-compile, testing integration)
– CMSIS (Cortex-M hardware abstraction)
– Doxygen (documentation)
– C11/CMake-based unit tests and testsuite for CI