Note
This project is currently under actively developing and improving, some APIs and interfaces may change as the design continues to mature.
-
MOS is a Real-Time Operating System (RTOS) project built in C++/Rust, which consists of a preemptive kernel and a command-line shell with other applications (e.g., GuiLite and FatFS).
-
Renode is a virtual development tool created by Antmicro for multi-node embedded networks (both wired and wireless) and is intended to enable a scalable workflow for creating effective, tested and secure IoT systems.
mos-core- The Kernel and the Shell, check here.mos-stm32- Running on STM32 series, check here.mos-renode- Test on Renode emulation, check here.mos-rust- A "Vibe Coding" Chimera, check here.
-
- Install the CMake and the
Arm GNU Toolchain - Run
./build.shto call CMake Tools and build the project
- Install the CMake and the
-
- Run
git submodule init && git submodule updateto pull the submodulecore - Install EIDE extension and the
Arm GNU Toolchain, then open*.code-workspaceusingVS Code
- Run
-
- Install the Renode platform, and add
renodeto the/usr/binpath or environment variables - Run
Start Debuggingor pressF5to start, open aTCPconnection onlocalhost:3333, and observe the serial output
- Install the Renode platform, and add
.
βββ π emulation // Renode emulation script
βββ π vendor // Vendor HALs
βββ π core
β βββ π external // External Library
β βββ π arch // Architecture-Specific Code
β β βββ cpu.hpp // Initialization/Context Switch assembly code
β β
β βββ π kernel // Kernel Layer
β β βββ macro.hpp // Kernel Constants Macro
β β βββ type.hpp // Basic Types
β β βββ concepts.hpp // Type Constraints
β β βββ data_type.hpp // Basic Data Structures
β β βββ alloc.hpp // Memory Management
β β βββ global.hpp // Kernel Global Variables
β β βββ printf.h/.c // Thread-Safe printf
β β βββ task.hpp // Task Management
β β βββ sync.hpp // Synchronization Primitives
β β βββ async.hpp // Asynchronous Stackless Coroutines
β β βββ scheduler.hpp // Scheduler
β β βββ ipc.hpp // Inter-Process Communication
β β βββ utils.hpp // Other Utilities
β β
β βββ config.h // System Configuration
β βββ kernel.hpp // Kernel Modules
β βββ shell.hpp // Shell Command Line
β
βββ π app // User Code
βββ main.cpp // Entry Function
βββ test.hpp // Test Code
Mutex Test(Priority Ceiling Protocol)

LCD Driver & GUI Demo
Concurrent Task Period & Time Sequence
// MOS Kernel & Shell
#include "mos/kernel.hpp"
#include "mos/shell.hpp"
// HAL and Device
#include "drivers/stm32f4xx/hal.hpp"
#include "drivers/device/led.hpp"namespace MOS::User::Global
{
using namespace HAL::STM32F4xx;
using namespace Driver::Device;
using namespace DataType::SyncUartDev_t;
// Shell I/O UART and Buffer
auto stdio = SyncUartDev_t<32> {USARTx};
// LED red, green, blue
Device::LED_t leds[] = {...};
}namespace MOS::User::BSP
{
using namespace Driver;
using namespace Global;
void LED_Config()
{
for (auto& led: leds) {
led.init();
}
}
void USART_Config()
{
stdio.init(9600-8-1-N)
.rx_config(PXa) // RX -> PXa
.tx_config(PYb) // TX -> PYb
.it_enable(RXNE) // Enable RXNE interrupt
.enable(); // Enable UART
}
...
}namespace MOS::User::App
{
// Blinky by Task::delay() -> Thread Model
void red_blink(Device::LED_t leds[])
{
while (true) {
leds[0].toggle(); // red
Task::delay(500_ms);
}
}
// Blinky by Async::delay() -> Coroutine Model
Async::Future_t<void> blue_blink(Device::LED_t leds[])
{
while (true) {
leds[1].toggle(); // blue
co_await Async::delay(500_ms);
}
}
...
}int main()
{
using namespace MOS;
using namespace Kernel;
using namespace User::Global;
BSP::config(); // Init periphs and clocks
Task::create( // Create a calendar with RTC
App::time_init, nullptr, 0, "time/init"
);
Task::create( // Create a shell on stdio
Shell::launch, &stdio.buf, 1, "shell"
);
/* User Tasks */
Task::create(App::red_blink, &leds, 2, "blinky");
...
/* Test examples */
Test::MutexTest();
Test::MsgQueueTest();
Test::AsyncTest();
...
// Launch Scheduler, never return
Scheduler::launch();
} A_A _ [name] @ x.x.x(Version)
o'' )_____// Build @ TIME, DATE
`_/ MOS ) Chip @ MCU, ARCH
(_(_/--(_/ 2023-2026 Copyright by Eplankton
<Tid> <Name> <Priority> <Status> <Mem%>
---------------------------------------
#0 idle 15 READY 10%
#1 shell 1 BLOCKED 21%
#2 blinky 2 RUNNING 9%
---------------------------------------
π¦ v0.5
β DoneοΌ
- [Experimental] Port to
ESP32-C6(RISC-V)- [Experimental] Rewrite it in Rust
π¦ v0.4
β DoneοΌ
- Add Hardware
FPUsupport- CMake Tools are now available for compiling the project
- Add external library ETL, a C++ template library for embedded applications
- Add
Renodeemulation platform, add stable support forCortex-Mseries- [Experimental] Add scheduler lock
Scheduler::suspend()- [Experimental] Add Asynchronous stackless coroutines
Async::{Executor, Future_t, co_await/yield/return}π Planned:
- Shift from
FatFStoLittleFS
π¦ v0.3
β Done:
- Mapping
TidstoBitMap_t- Message queue
IPC::MsgQueue_tTask::createallows generic function signatures asvoid fn(auto argv)with type checker- Add
ESP32-C3as aWiFicomponent- Add
Driver::Device::SD_t,SDcard driver, portingFatFsfile system- Add
Shell::usr_cmdsfor user-registered commands- [Experimental] Atomic types
<stdatomic.h>- [Experimental]
Utils::IrqGuard_t, nested interrupt critical sections- [Experimental] Simple formal verification of
Scheduler + Mutexπ Planned:
- Inter-Process Communication: pipes/channels
FPUhardware float support- Performance benchmarking
- Error handling with
Result<T, E>,Option<T>DMA_tDMA Driver- Software/hardware timers
Timer- [Experimental] Adding
POSIXsupport- [Experimental] More real-time scheduling algorithms
π¦ v0.2
β Done:
- Synchronization primitives
Sync::{Sema_t, Lock_t, Mutex_t<T>, CondVar_t, Barrier_t}Scheduler::Policy::PreemptPriwithRoundRobinscheduling for same priority levelsTask::terminateimplicitly called upon task exit to reclaim resources- Simple command-line interaction
Shell::{Command, CmdCall, launch}HAL::STM32F4xx::SPI_tandDriver::Device::ST7735S_t, porting theGuiLitegraphics library- Blocking delay with
Kernel::Global::os_ticksandTask::delay- Refactored project organization into
{kernel, arch, drivers}- Support for
GCCcompilation, compatible withSTM32Cube HAL- Real-time calendar
HAL::STM32F4xx::RTC_t,CmdCall::date_cmd,App::CalendaridleusesKernel::Global::zombie_listto reclaim inactive pages- Three basic page allocation policies
Page_t::Policy::{POOL, DYNAMIC, STATIC}
π¦ v0.1
β Done:
- Basic data structures, scheduler, and task control, memory management
π Planned:
- Timers, round-robin scheduling
- Inter-Process Communication (IPC), pipes, message queues
- Process synchronization (Sync), semaphores, mutexes
- Design a simple Shell
- Variable page sizes, memory allocator
- SPI driver, porting GuiLite/LVGL graphics libraries
- Porting to other boards/arch, e.g., ESP32-C3 (RISC-V)
- How to build a Real-Time Operating System(RTOS)
- PeriodicScheduler_Semaphore
- STM32F4-LCD_ST7735s
- A printf/sprintf Implementation for Embedded Systems
- GuiLite
- STMViewer
- FatFs
- The Zephyr Project
- Eclipse ThreadX
- Embassy
- Renode
- Embedded Template Library (ETL)
I hope the Pacific is as blue as it has been in my dreams.
I hope.
-- Stephen King's "Rita Hayworth and the Shawshank Redemption", 1982









