Exploring Choices for Microcontroller Operating Systems

When programming microcontrollers, we know there are two basic operations: bare-metal and operating systems. Bare-metal refers to a large loop that runs repeatedly.
Today, we will discuss several commonly used operating systems.
A Real-time Operating System (RTOS) is designed to manage system resources and provide a consistent foundation for application development by executing tasks in order.
Compared to general operating systems, the main feature of an RTOS is its “real-time” capability. If a task needs to be executed, the RTOS will execute it immediately without significant delay. This characteristic ensures timely execution of tasks.
Today, I will introduce 14 mainstream RTOSs, which are<span>μClinux</span>, <span>μC/OS-II</span>, <span>eCos</span>, <span>FreeRTOS</span>, <span>mbed OS</span>, <span>RTX</span>, <span>Vxworks</span>, <span>QNX</span>, <span>NuttX</span>; the domestic embedded operating systems include the Dujiangyan Operating System (<span>djyos</span>), <span>Alios Things</span>, <span>Huawei LiteOS</span>, <span>RT-Thread</span>, and <span>SylixOS</span>.
The characteristics of these 14 embedded operating systems are as follows.

01

μClinux

μClinux is an excellent version of embedded Linux, its full name is micro-control Linux, which refers to microcontroller Linux.

Compared to standard Linux, μClinux has a very small kernel, yet it inherits the main features of the Linux operating system, including good stability and portability, strong networking capabilities, excellent file system support, a rich set of APIs, and TCP/IP networking protocols.

Due to the absence of an MMU (Memory Management Unit), its multitasking implementation requires certain skills.

μClinux inherits the multitasking implementation of standard Linux, dividing processes into real-time and regular processes, using first-come-first-served and time-slicing scheduling, modified to suit the characteristics of mid-to-low-end embedded CPUs, and does not support kernel preemption, resulting in average real-time performance.

In summary, μClinux is designed for processors without an MMU, making it suitable for STM32F103 without MMU functionality. However, porting this system requires at least 512KB of RAM and 1MB of ROM/FLASH space, while STM32F103 has 256K of FLASH, necessitating external memory, which increases hardware design costs.

μClinux has a complex structure, is relatively difficult to port, and has a larger kernel, with some limitations in real-time performance. If the embedded product development focuses on file systems and network applications, μClinux is a good choice.
Exploring Choices for Microcontroller Operating Systems

Microcontrollers often use JTAG and SWD for downloading programs and online debugging, with common devices being J-LINK and ST-LINK, which are all copyrighted and relatively expensive.

Meanwhile, DAP-LINK is an open-source programming tool suitable for Cortex-M series microcontrollers, with no copyright constraints. I implemented this open-source project, which can be obtained for a total cost of 27 yuan + 4 yuan shipping.

02

μC/OS-II

μC/OS-II is developed based on μC/OS, written in C, and is a compact, preemptive multitasking real-time kernel. μC/OS-II can manage 64 tasks and provides task scheduling and management, memory management, inter-task synchronization and communication, time management, and interrupt service, featuring high execution efficiency, small space usage, excellent real-time performance, and strong scalability.

In terms of file system support, μC/OS-II is aimed at small to medium embedded systems, and even with all features included, the compiled kernel is less than 10KB, meaning the system itself does not provide file system support. However, μC/OS-II has good extensibility, and users can add file system content if needed.

In terms of hardware support, μC/OS-II can support most popular CPUs, with a minimum trimmed code size of 2KB, and a minimum data RAM space requirement of 4KB. Porting μC/OS-II is relatively simple, requiring only modifications to processor-related code.

In summary, μC/OS-II is a simple, fully functional, and highly real-time embedded operating system kernel, very suitable for CPUs without MMU functionality. It requires minimal kernel code space and data storage space, has good real-time performance, good scalability, and is open-source, with many resources and examples available online, making it very suitable for porting to the STM32F103 CPU.

Exploring Choices for Microcontroller Operating Systems

03

eCos
Exploring Choices for Microcontroller Operating Systems
<span>eCos (embedded Configurable Operating System)</span> is an embedded configurable operating system. It is a source code open, configurable, portable, real-time operating system aimed at deep embedded applications, characterized by flexible configuration and modular design, consisting of core components such as the kernel, C language library, and low-level runtime package.
Each component provides a large number of configuration options (the real-time kernel can also be an optional configuration). Using the configuration tool provided by eCos, it can be easily configured to meet different embedded application requirements through different configurations.
eCos has strong configurability, allowing users to add the necessary file systems. It also supports most popular embedded CPUs, and eCos can be ported across different architectures, including 16-bit, 32-bit, and 64-bit.
Due to its small kernel, the minimum trimmed code size of eCos can be 10KB, with a minimum data RAM requirement of 10KB. Additionally, eCos has good portability, making it easier to port than μC/OS-II and μClinux.
In summary, eCos’s main feature is its flexible configuration, supporting the portability of CPUs without MMUs, open-source with good portability, making it suitable for porting to STM32 platform CPUs. However, eCos is not as widely used as μC/OS-II, and there are fewer resources available compared to μC/OS-II. eCos is suitable for commercial or industrial embedded systems that are sensitive to cost, such as applications in consumer electronics.

04

FreeRTOS
Exploring Choices for Microcontroller Operating Systems
Since RTOS requires certain system resources (especially RAM), only a few real-time operating systems like μC/OS-II, embOS, Salvo, and FreeRTOS can run on small RAM microcontrollers.
Compared to commercial operating systems like μC/OS-II and embOS, FreeRTOS is a completely free operating system with open-source code, portable, customizable, and flexible scheduling policies, making it easy to port to various microcontrollers. Its latest version is 6.0.
As a lightweight operating system, FreeRTOS provides features including task management, time management, semaphores, message queues, memory management, and logging, sufficiently meeting the needs of smaller systems.
FreeRTOS kernel supports priority scheduling algorithms, allowing each task to be assigned a priority based on its importance, with the CPU always running the highest-priority ready task first.
FreeRTOS kernel also supports round-robin scheduling, allowing different tasks with the same priority to share CPU time when no higher-priority tasks are ready.
Compared to the common μC/OS-II operating system, FreeRTOS has both advantages and disadvantages.
Its shortcomings are reflected in the system’s service functions, such as FreeRTOS only providing implementations for message queues and semaphores, lacking the ability to send messages in a last-in-first-out order to message queues; on the other hand, FreeRTOS is just an operating system kernel, requiring third-party extensions for GUI (Graphical User Interface), TCP/IP stack, FS (File System), etc., to implement a more complex system, unlike μC/OS-II which can seamlessly integrate with μC/GUI, μC/FS, μC/TCP-IP, etc.

05

mbed OS
Open-source embedded operating system, ARM provides mbed OS free of charge to all manufacturers, offering a relatively systematic and comprehensive smart hardware development environment.
Main features: Provides a general operating system foundation for developing IoT devices to address the fragmentation issue in embedded design. Supports all important connectivity and device management open standards for future-oriented designs. Enables secure, upgradeable edge devices to support additional processing capabilities and functions. Addresses complex energy consumption issues through automatic power management.
Main characteristics: Fast development speed, powerful functionality, high security, designed for mass production, can be developed offline or edited on the web.
Exploring Choices for Microcontroller Operating Systems

06

RTX
This is an embedded real-time operating system from ARM, written in standard C structure, compiled using the RealView compiler. It is not just a real-time kernel; it also has a rich set of middleware components, is free, and its code is open.
Main functions: Start and stop tasks (processes), and support inter-process communication, such as task synchronization, management of shared resources (peripherals or memory), and message passing between tasks. Developers can use basic functions to start the real-time runner, begin and end tasks, and pass control between tasks (round-robin scheduling). Developers can assign priorities to tasks.
Main features: Supports time-slicing, preemptive and cooperative scheduling. Unlimited tasks with each task having up to 254 priorities. Unlimited semaphores, mutex semaphores, message mailboxes, and soft timers. Supports multithreading and thread-safe operations. The MDK configuration wizard based on dialog boxes makes it easy to complete MDK configuration.

07

VxWorks
Exploring Choices for Microcontroller Operating Systems
Developed by WindRiver in the USA in 1983, VxWorks is an embedded real-time operating system (RTOS) that features hard real-time, determinism, and stability, as well as scalability and security required by various industries such as aerospace and defense, industrial, medical, automotive, consumer electronics, and networking.
Main functions: Supports predictable task synchronization mechanisms, inter-task communication, memory optimization management, and known and predictable behavior of the operating system (interrupt latency, task switching, driver latency, etc.). Real-time clock services + interrupt management services.
Main features: A high-performance operating system kernel with a friendly development debugging environment, good compatibility, and support for various development and runtime environments.

08

QNX
Born in 1980, QNX is a commercial real-time operating system that conforms to POSIX standards.
Main functions: Supports scheduling and executing multiple tasks simultaneously on the same computer; allows multiple users to share a computer, submitting tasks to the system through multiple terminals and interacting with QNX.

Main features: The kernel provides only four services: process scheduling, inter-process communication, low-level network communication, and interrupt handling, with processes running in independent address spaces. All other OS services are implemented as cooperative user processes, making the QNX kernel very compact (QNX4.x is about 12Kb) and extremely fast.

Exploring Choices for Microcontroller Operating Systems

09

NuttX
NuttX is a real-time embedded operating system (Embedded RTOS), with its first version released by Gregory Nutt in 2007 under a permissive BSD license.
Main functions: Can be constructed as an open, flat embedded RTOS, or built as a microkernel with system call interfaces. Easily extensible to new processor architectures, SoC architectures, or board-level architectures. Real-time, deterministic, and supports priority inheritance. BSD socket interface. Extended priority management. Optional tasks (processes) with address environments.
Main features: Flexible configuration, adopting a modular design, with core components including the kernel, C language library, and low-level runtime package. Each component offers a large number of configuration options (the real-time kernel can also be an optional configuration), and the configuration tool provided by eCos can easily configure it to meet different embedded application requirements.

10

Dujiangyan Operating System (djyos)
(Note: The official website of the Dujiangyan Operating System indicates that STM32 F4 and F7 have not been debugged.)
The Dujiangyan Operating System, abbreviated as djyos, is named after a great water conservancy project: Dujiangyan.
Unlike traditional operating systems, djyos uses events as the core of scheduling rather than threads. This scheduling algorithm allows programmers to break free from the mindset of simulating computer execution processes and instead write applications in a way that aligns with human cognition, akin to introducing VC into embedded programming.
The scheduling algorithm of djyos allows programmers to escape the constraints of threads and processes. djyos has no APIs related to threads, allowing programmers with no knowledge of threads to smoothly write applications under djyos.

The djyos operating system schedules based on events, enabling programmers to program according to human cognitive habits instead of computer habits.

Exploring Choices for Microcontroller Operating Systems

11

Alios Things
According to well-known media on embedded operating systems RTOS, AliOS Things is a scalable IoT operating system under the AliOS family.
AliOS Things aims to build an integrated IoT infrastructure on the cloud, featuring extreme performance, simple development, cloud integration, rich components, and security protection, supporting terminal devices to connect to Alibaba Cloud Link, widely applicable in smart homes, smart cities, and new mobility fields.
Comment: Backed by Alibaba resources, AliOS Things is a strong player in the IoT market through partnerships with chip and module manufacturers, but this is also its biggest disadvantage!
Exploring Choices for Microcontroller Operating Systems

12

Huawei LiteOS
According to the introduction of embedded operating systems RTOS, Huawei LiteOS is a lightweight IoT operating system built by Huawei for the IoT field, featuring lightweight, low power consumption, fast startup, interconnectivity, and security, providing developers with a “one-stop” complete software platform to effectively lower development thresholds and shorten development cycles.

Comment: Huawei’s system, but its open-source level is relatively low, mainly used for Huawei’s own products, under the cover of a large tree.

Exploring Choices for Microcontroller Operating Systems

13

RT-Thread
According to the introduction of embedded operating systems RTOS, RT-Thread is a technology platform that integrates a real-time operating system (RTOS) kernel, middleware components, and a developer community, developed by Mr. Xiong Pu Xiang and the open-source community. RT-Thread is a complete and rich component, highly scalable, easy to develop, ultra-low power, and highly secure IoT operating system.
RT-Thread has all the key components required for an IoT OS platform, such as GUI, network protocol stack, secure transmission, low-power components, etc. After 11 years of cumulative development, RT-Thread has the largest embedded open-source community in China and is widely used in various industries such as energy, automotive, medical, and consumer electronics, with a cumulative installation of over 20 million units, becoming the most mature and stable open-source RTOS developed independently by Chinese people.
Comment: The most likely to become Top 1 in China, with advantages in rich components and a neutral stance! It has seized the opportunity and received support from many chip manufacturers, and is well-liked by developers. Its downside is that its tutorial documentation is weaker compared to FreeRTOS and others.

14

SylixOS
According to the introduction of embedded operating systems RTOS, SylixOS is an open-source, cross-platform large real-time operating system (RTOS), born in 2006, and has become one of the most comprehensive domestic operating systems after more than a decade of continuous development.
Currently, there are numerous product and project application cases, covering industries like aerospace, military defense, rail transportation, smart grid, industrial automation, and more. SylixOS fully complies with POSIX standards, making it easy to port a wealth of free software from the open-source community.
Comment: This one is also quite interesting; it started in 2006, focusing on military applications, and has only recently come to prominence. Its strength should not be underestimated!
Of course, RTOS is not limited to the above; everyone is welcome to leave comments and add more!
-END-
Previous recommendations: Click on the image to jump to read

Exploring Choices for Microcontroller Operating Systems

Arduino Major Update! IDE 2.0 is Here

Exploring Choices for Microcontroller Operating Systems

Why are Embedded Salaries Lower than Pure Software Salaries?

Exploring Choices for Microcontroller Operating Systems

The 555 is Called One of the Greatest Chips of All Time

Exploring Choices for Microcontroller Operating Systems

If I Became a Microcontroller…

Leave a Comment