Microcontrollers Running Operating Systems: What Are Your Options?
When programming microcontrollers, we know there are two basic operations: bare metal and operating systems. Bare metal means a large loop running repeatedly.Today, we will discuss several commonly used operating systems.A Real-time Operating System (RTOS) runs tasks in order, manages system resources, and provides a consistent foundation for developing applications.Compared to general operating systems, the biggest feature of RTOS is its “real-time” capability. If a task needs to be executed, RTOS will execute it immediately without significant delay. This feature ensures the timely execution of various tasks.Today, I will introduce 14 mainstream RTOS: namely<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>; while the domestic embedded operating systems include 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 embedded version of Linux, whose full name is micro-control Linux, literally meaning micro-control Linux.
Compared to standard Linux, μClinux has a very small kernel, but it still inherits the main features of the Linux operating system, including good stability and portability, powerful networking capabilities, excellent file system support, a rich set of APIs, and TCP/IP networking protocols.
Due to the lack of MMU (Memory Management Unit), its multitasking implementation requires certain techniques.
μClinux inherits the multitasking implementation method of standard Linux, divided into real-time processes and ordinary processes, adopting first-come, first-served and time-slice round-robin scheduling, modified specifically for the characteristics of mid-to-low-end embedded CPUs, and does not support kernel preemption, resulting in average real-time performance.
In summary, μClinux’s biggest feature is its design for MMU-less processors, which is suitable for the STM32F103 that lacks MMU functionality; however, porting this system requires at least 512KB of RAM space and 1MB of ROM/FLASH space, while the STM32F103 has 256K of FLASH and needs external memory, increasing hardware design costs.
μClinux has a complex structure, is relatively difficult to port, has a larger kernel, and its real-time performance is not as good. If the embedded product being developed emphasizes file systems and network applications, μClinux is a good choice.
Microcontroller programming and online debugging often involve JTAG and SWD, with common devices being J-LINK and ST-LINK, both of which are copyrighted and expensive.
Meanwhile, DAP-LINK is an open-source programming tool suitable for Cortex-M series microcontrollers, free of copyright constraints.
02
μC/OS-II
μC/OS-II is developed based on μC/OS and is a compact, preemptive multitasking real-time kernel written in C. μC/OS-II can manage 64 tasks and provides task scheduling and management, memory management, inter-task synchronization and communication, time management, and interrupt servicing, featuring high execution efficiency, small footprint, 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 full functionality, the compiled kernel is less than 10KB, so 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.
Regarding hardware support, μC/OS-II can support most popular CPUs. Since the kernel itself is very small, the trimmed code can be as small as 2KB, requiring a minimum data RAM space of 4KB. The porting of μC/OS-II is relatively simple, needing only modifications related to processor-specific code.
In summary, μC/OS-II is a simple structure, fully functional, and highly real-time embedded operating system kernel that is very suitable for CPUs without MMU functionality. It requires very little kernel code space and data storage space, possesses good real-time performance and scalability, is open-source, and has abundant resources and examples available online, making it very suitable for porting to the STM32F103 CPU.
03
eCos
<span>eCos(embedded Configurable operating system)</span>, is an open-source configurable, portable, real-time operating system aimed at deeply embedded applications. Its biggest feature is flexible configuration, adopting a modular design, with the core part composed of small components including the kernel, C language library, and underlying runtime package.Each component can provide a large number of configuration options (the real-time kernel can also be an optional configuration). Using the configuration tool provided by eCos, users can easily configure it, and different configurations allow eCos to meet various embedded application requirements.eCos has powerful configurability, allowing users to add the necessary file system. eCos also supports most popular embedded CPUs and can be ported between different architectures such as 16-bit, 32-bit, and 64-bit.Because eCos has a very small kernel, the trimmed code can be as small as 10KB, requiring a minimum data RAM space of 10KB. Additionally, in terms of system porting, eCos’s portability is very good, easier than μC/OS-II and μClinux.In conclusion, eCos’s biggest feature is its flexible configuration and support for porting to MMU-less CPUs, open-source with good portability, making it suitable for porting to STM32 platform CPUs. However, eCos’s application is not very widespread and does not have as much documentation as μC/OS-II. eCos is suitable for commercial or industrial embedded systems that are cost-sensitive, such as some applications in the consumer electronics field.
04
FreeRTOSSince 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, featuring open source, portability, configurability, and flexible scheduling strategies, making it easy to port to various microcontrollers, with its latest version being 6.0.As a lightweight operating system, FreeRTOS provides functionalities including task management, time management, semaphores, message queues, memory management, and logging, which can basically meet 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 allowing the highest priority ready task to run first.FreeRTOS kernel also supports round-robin scheduling, allowing different tasks to share CPU time when there are no higher priority tasks ready.Compared to the common μC/OS-II operating system, FreeRTOS has both advantages and disadvantages.Its shortcomings are evident in the system service functions, as FreeRTOS only provides implementations for message queues and semaphores, unable to send messages to message queues in a last-in-first-out order; on the other hand, FreeRTOS is just an operating system kernel and requires external third-party 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 OSAn open-source embedded operating system, ARM provides mbed OS free of charge to all manufacturers, offering a relatively systematic and comprehensive development environment for smart hardware.Main features: Provides a general operating system foundation for developing IoT devices to solve the fragmentation problem in embedded design. Supports all major connectivity and device management open standards for future-oriented designs. Allows secure and upgradeable edge devices to support new processing capabilities and functionalities. Addresses complex energy consumption issues through automatic power management.Main characteristics: Fast development speed, powerful functionality, high security, designed for mass production, supports offline development and web-based editing.
06
RTXThis is an embedded real-time operating system from ARM, written in standard C structure and compiled using the RealView compiler. It is not just a real-time kernel but also has rich middleware components, is free, and has open code.Main functions: Start and stop tasks (processes), and support inter-process communication, such as task synchronization, shared resource (peripherals or memory) management, and message passing between tasks. Developers can use basic functions to start real-time runners, begin and end tasks, and pass control between tasks (round-robin scheduling). Developers can assign priorities to tasks.Main features: Supports time-slice, preemptive, and cooperative scheduling. No limit on the number of tasks, with each task having 254 priority levels. No limit on the number of semaphores, mutex semaphores, message mailboxes, and soft timers. Supports multi-threading and thread-safe operations. The MDK configuration wizard based on dialogs makes MDK configuration easy.
07
VxWorks
Developed by WindRiver in the U.S. in 1983, VxWorks is an embedded real-time operating system (RTOS) that offers hard real-time, determinism, and stability, as well as scalability and security required by aerospace, defense, industrial, medical, automotive, consumer electronics, networking, and other industries.
Main functions: Supports predictable task synchronization mechanisms, inter-task communication, memory optimization management, and the behavior of the operating system (interrupt latency, task switching, driver latency, etc.) is knowable and predictable. Real-time clock services + interrupt management services.Main features: Has a high-performance operating system kernel Wind (good real-time performance, configurable), friendly development and debugging environment, good compatibility, and supports various development and runtime environments.
08
QNXBorn in 1980, QNX is a commercial embedded real-time operating system that complies with POSIX standards.Main functions: Supports scheduling and executing multiple tasks simultaneously on the same computer; allows multiple users to share a computer, with these users able to submit tasks to the system via multiple terminals and interact with QNX.
Main features: The core only provides four services: process scheduling, inter-process communication, low-level network communication, and interrupt handling, with its processes running in independent address spaces. All other OS services are implemented as cooperating user processes, making the QNX core very small (QNX4.x is about 12Kb) and extremely fast.
09
NuttXNuttX 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 built as an open, flat embedded RTOS, or separately built as a microkernel with system call interfaces. Easily extendable to new processor architectures, SoC architectures, or board-level architectures. Real-time, deterministic, supports priority inheritance. BSD socket interface. Extended priority management. Optional tasks (processes) with address environments.Main features: Flexible configuration, adopting a modular design, with the core part composed of small components including the kernel, C language library, and underlying runtime package. Each component can provide a large number of configuration options (the real-time kernel can also be an optional configuration), using the configuration tool provided by eCos to easily configure, allowing eCos to meet various embedded application requirements.
10
Dujiangyan Operating System (djyos)(Note: The Dujiangyan Operating System official website indicates that STM32’s F4 and F7 have not been debugged.)The Dujiangyan Operating System, abbreviated as djyos, is named after a great hydraulic project: Dujiangyan.Unlike traditional operating systems, djyos schedules based on events rather than threads. This scheduling algorithm frees programmers from the mindset of simulating computer execution processes to write programs, allowing them to write applications in a way that aligns with human cognitive processes, similar to introducing VC into embedded programming.The scheduling algorithm of djyos allows programmers to break free from the constraints of threads and processes. djyos does not have APIs related to threads, allowing programmers with no thread knowledge to smoothly write applications under djyos.
The djyos operating system is event-driven, allowing programmers to program according to human cognitive habits rather than computer habits.
11
Alios ThingsAccording to the well-known media embedded operating system RTOS introduction, AliOS Things is a scalable IoT operating system under the AliOS family.AliOS Things aims to build a unified IoT infrastructure in the cloud, featuring extreme performance, simple development, integrated cloud capabilities, and rich components, ensuring secure connections of terminal devices to Alibaba Cloud Link, widely applicable in smart homes, smart cities, and new transportation fields.Comment: Backed by Alibaba resources, AliOS is a strong player in the IoT market, collaborating with chip and module manufacturers, but this also poses its biggest disadvantage!
12
Huawei LiteOSHuawei LiteOS is a lightweight IoT operating system built by Huawei for the IoT field, emphasizing lightweight, low power consumption, fast startup, interconnectivity, and security, providing developers with a complete software platform to effectively lower development thresholds and shorten development cycles.
Comment: Huawei’s system, but its open-source degree is relatively low, mainly used for Huawei’s own products, under a big tree.
13
RT-ThreadRT-Thread is a technology platform that integrates a real-time operating system (RTOS) kernel, middleware components, and a developer community, developed by Mr. Xiong Puxiang and the open-source community. RT-Thread is a complete and rich component, highly scalable, easy to develop, ultra-low power consumption, 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 become the largest embedded open-source community in China and is widely used in various industries, including energy, automotive, medical, and consumer electronics, with cumulative installations exceeding 20 million, becoming the most mature, stable, and widely installed open-source RTOS in China.Comment: The most likely to become Top 1 domestically, with advantages in rich components and a neutral stance! Seized the opportunity, received support from many chip manufacturers, and is well-liked by developers. However, its tutorials and documentation are weaker compared to FreeRTOS.
14
SylixOSSylixOS is an open-source, cross-platform large-scale real-time operating system (RTOS), born in 2006. After more than a decade of continuous development, SylixOS has become one of the most comprehensive domestic operating systems.It already has numerous product and project application cases across various fields, including aerospace, military defense, rail transit, smart grid, industrial automation, etc. SylixOS fully complies with POSIX standards, and the rich free software in the open-source community makes it very convenient for porting.Comment: This company is also quite interesting, having started in 2006, primarily in military applications, but only recently gaining prominence. Its strength should not be underestimated!
Source: Electronic Engineering World
Submission/ Reprint/ Academic Exchange
Scan to add the editor’s WeChat
(Note: This article is a reprint. If there are errors in content or source attribution, or if your legal rights are infringed, please contact us in a timely manner, and we will promptly make corrections or deletions.)