What is scmRTOS? scmRTOS (single-chip microcontroller RTOS) is a preemptive real-time operating system designed specifically for microcontrollers with extremely limited resources. It is entirely written in C++, with an astonishingly small code size: it can run with a minimum of 512 B RAM and about 1 KB of program code. Supported MCUs include common platforms such as MSP430, AVR, ARM7, Cortex-M0/M3/M4, Blackfin, STM8, etc.
| Platform | Minimum RAM | Code Size |
| AVR | 512 B | ~1 KB |
| MSP430 | 512 B | ~1 KB |
| Cortex-M0 | 1 KB | ~1 KB |
| Cortex-M3 | 2 KB | ~1 KB |
| Cortex-M4 | 2 KB | ~1 KB |
What pain points does it address?
- • Resource Constraints: Many projects have MCUs with only a few hundred bytes of RAM, making traditional RTOS impossible to fit. scmRTOS lowers the threshold to just 512 B.
- • Switching Latency: Real-time systems require preemption, and scheduling latency cannot be too high. scmRTOS schedules in only 900 ns on Cortex-M4 (168 MHz) and just 38-42 µs on AVR (8 MHz), sufficient for high-frequency control demands.
- • Code Maintainability: Fully implemented in C++, it supports classes and templates, making it feel like a regular C++ program, which is natural for debugging and extending.
- • Customizability: The kernel provides extension points, allowing developers to hook into scheduling, logging, assertions, and other functionalities to meet specific project needs.
Installation & Usage: One-Step Setup
Tips: The following steps assume you are using the GCC toolchain (e.g., arm-none-eabi-gcc, avr-gcc). If you are using IDEs like Keil or IAR, simply add the source code to your project.
- 1. Download the Source Code
git clone https://github.com/scmrtos/scmrtos.git cd scmrtos - 2. Select the Platform In the
<span>src/</span>directory, there is a<span>port/</span>subdirectory containing the corresponding port layers categorized by MCU. For example, to run on STM8, copy<span>port/stm8/</span>to your project directory. - 3. Configure Macros Define
<span>SCMRTOS_ARCH_<PLATFORM></span>in the global header file (or compilation options) of your project, for example:#define SCMRTOS_ARCH_STM8 // Target platform #define SCMRTOS_PROCESS_COUNT 3 // Number of tasks #define SCMRTOS_ROUND_ROBIN // Enable time-slice round-robin (optional) - 4. Write Tasks
// task1.cpp #include "scmRTOS.h" void TTask1::exec() { for(;;) { // Place your business logic here LED_Toggle(); sleep(100); // 100ms delay } } - 5. Link and Flash Compile
<span>scmRTOS.cpp</span>, your task files, and the MCU startup files together to generate HEX/ELF, and use conventional programming tools to write to the chip.
Common Pitfalls:
- • Remember to enable the system clock in the startup file; otherwise, the timing in
<span>sleep()</span>will be off. - • For AVR,
<span>SCMRTOS_IDLE_HOOK</span>must implement an empty loop; otherwise, compilation will fail.
Pros and Cons Overview
| Pros | Cons |
| Extremely Low Memory Usage: Starting at 512 B RAM, suitable for extremely low-cost hardware | Relatively Simple Functionality: Does not provide advanced IPC (like message queues, semaphores) or other advanced features |
| Ultra-Low Scheduling Latency: Hardware-level preemption, millisecond-level task switching is easily achieved | C++ Dependency: There is a learning curve for embedded teams unfamiliar with C++ |
| Cross-Platform: Code can almost run across 8 major MCU series | Fragmented Documentation: Official documentation is primarily in English, with relatively few Chinese resources |
| Pluggable Extensions: Kernel hooks and debugging macros can be toggled freely | Smaller Ecosystem: Community plugins and third-party libraries are not as rich as those for FreeRTOS |
Conclusion: Why Choose It?
If your project is extremely resource-constrained and has strict real-time requirements, and you do not want to waste time on cumbersome configurations, scmRTOS is almost the only “hardcore” choice. It elevates the standard of “it just needs to run” to “run fast, run stable, run efficiently”. Even older MCUs like AVR and MSP430 can achieve preemptive scheduling with just a few hundred bytes of RAM, which is considered “unbelievable” in the industry.
Of course, if you need rich middleware, a mature ecosystem, or if your team is not familiar with C++, systems like FreeRTOS or Zephyr are still safer options. However, in scenarios with extreme resource constraints, the cost-performance ratio of scmRTOS is simply compelling enough to want to install it in every microcontroller.
In a nutshell: 512 B RAM can also run real-time operating systems, and this is the “hardcore” surprise that scmRTOS brings you!
Project Address: https://github.com/scmrtos/scmrtos