一种新的开源嵌入式操作系统
嵌入式 RT-Thread RT-Thread Smart

> 
> RT-Thread Smart 致力于物联网和边缘计算领域的开源。
> 
> 
> 


![](/data/attachment/album/202205/06/131909kdb7f966j22qf7o9.jpg "An intersection of pipes.")


目前对 [嵌入式操作系统](https://opensource.com/article/20/6/open-source-rtos) 有巨大的需求，你建立的操作系统最好是开源的。[RT-Thread](https://www.rt-thread.io/) 项目的研发团队花了两年时间，研发出了该项目的最新成果：RT-Thread Smart。这是一款微内核的操作系统，主要针对中高端的处理器，如具有内存管理单元（MMU）的 RISC-V 或 Arm Cortex-A，为嵌入式领域的所有行业提供了一个具有竞争力的、基于 POSIX 的软件平台。


### 谁需要 RT-Thread Smart?


RT-Thread Smart 是一款专业的、高性能的微内核操作系统，用于实时应用。它为所有市场的嵌入式设备提供了开源基础，如安全（IP 摄像头）、工业控制、车载设备、消费电子及其他嵌入式科技应用，可谓一切场景。它的意义在于：不像传统的物联网操作系统，一个微内核的操作系统可以填补传统实时操作系统 RTOS 和相对大型的操作系统如 Linux 之间的空白，实现实时性能、成本、安全、启动速度等等各方面之间的最佳平衡。


### RT-Thread Smart 的架构


RT-Thread Smart 通过 MMU 和系统调用将系统分割为内核模式和用户模式，并为每种模式区分了地址空间（一个 32 位系统可以提供 4G 地址空间）。


![RT-Thread Smart 架构](/data/attachment/album/202205/06/131929b6v8hbzh87v86siv.png "RT-Thread Smart architecture")


（RT-Thread, [CC BY-SA 4.0](https://creativecommons.org/licenses/by-sa/4.0/legalcode)）


RT-Thread Smart 内核包括平台的基础功能，并支持定制化。RT-Thread Smart 的用户应用环境使用 [musl libc](https://musl.libc.org/) 来提供 [POSIX](https://opensource.com/article/19/7/what-posix-richard-stallman-explains) 接口调用和 C 语言的运行时支持。它也继承了原始的 RT-Thread 生态系统，使用 [SCons](https://scons.org/) 或者其他编译工具如 [Autotools](https://opensource.com/article/19/7/introduction-gnu-autotools)、Makefile、[CMake](https://opensource.com/article/21/5/cmake) 等等来支持开发，以及 RT-Thread 开箱即用的在线软件包（撰写本文时超过 342 个）。你甚至可以将 Linux 应用程序（如 wget/cURL、BusyBox、OpenSSL 和 Simple DirectMedia Layer）移植到你的平台。


压缩的 RT-Thread Smart 内核仅 217 KB，搭配一个 127 KB 的根文件系统。大约 2 MB的存储占用。包括了对文件系统、网络协议栈、多媒体的完整支持。RT-Thread 只需要 3 到 5 秒完成启动，而在不运行其他功能组件时，RT-Thread Smart 需要的启动及准备时间不到 500ms。


通过其集成的 Persimmon 用户界面（UI）组件，RT-Thread Smart 从上电到运行 UI 需要大约 1 秒。换句话说，这是一个非常轻巧快速的系统。当然，“实时”不是指启动，而是指系统随着时间推进而表现出的一致性。对于 RT-Thread ，实时性能需要优先考虑，中断时延小于 1μs，满足大部分实时性要求严格的场景需求。


### RT-Thread Smart 和 RT-Thread


你可能想知道 RT-Thread Smart 和 RT-Thread 之间的不同。简单来说， RT-Thread Smart 是一个基于 RT-Thread RTOS 的操作系统，但它整合了用户态的处理过程。RT-Smart 的内核部分本质上是 RT-Thread RTOS，它在虚拟地址上运行，增加了进程管理，使用进程间通信机制（IPC）、虚拟内存/地址空间管理、ELF 加载器等等，以上特性全部在 RT-Thread RTOS 内实现，当这些组件被禁用时，RT-Smart 会回归 RT-Thread RTOS。


以下是对比：




|  | RT-Thread | RT-Thread Smart |
| --- | --- | --- |
| 支持芯片 | Cortex-M/R、RISC-V RV32IMAC（以及类似）、Cortex-A MPU | Cortex-A 等具有 MMU 的 MPU |
| 编译 | 内核和应用都编译到一个镜像 | 内核和应用可以被分开编译和运行 |
| 存储 | 使用线性地址空间（即使有 MMU），使用物理地址的虚拟寻址 | 运行在内核占用超过 1GB 的 32 位操作系统，拥有完整 4G 地址空间的用户态进程彼此隔离，外设驱动程序必须通过虚拟地址访问外设 |
| 运行错误 | 当一个应用程序失败时，整个系统就会崩溃 | 当应用程序失败时，它不会影响内核和其他进程的执行 |
| 运行模式 | 多线程模型 | 多进程模型（进程内支持多线程，内核线程由内核支持） |
| 用户模型 | 单用户模型 | 单用户模型 |
| API | RT-Thread API、POSIX PSE52 | RT-Thread API（内核态和用户态），以及完整的 POSIX API |
| 实时性 | 抢占式硬实时系统 | 抢占式硬实时系统 |
| 资源使用 | 非常小 | 相对小 |
| 调试 | 通常需要模拟器调试 | 支持 GDB 调试，不需要模拟器 |


RT-Thread RTOS 非常紧凑，它的所有应用和子系统都编译到镜像中，多线程应用运行并分享相同的地址空间。


RT-Thread Smart 是独立的。系统和应用是分别编译和运行的。应用拥有完整且互相隔离的地址空间。它也继承了 RT-Thread 优秀的实时性，同时也具有 POSIX 环境的特性。


类似地，它们都与 RT-Thread API 兼容。RT-Thread RTOS 的应用可以被平滑移植到 RT-Thread Smart。


### 嵌入式开源


RT-Thread Smart 是一个开源项目，项目地址：[GitHub](https://github.com/RT-Thread/rt-thread/tree/rt-smart)。你可以下载代码和文档，尝试一下，并提交评论和反馈，将该项目传播给更多开源倡导者。嵌入式系统属于它们的用户，有太多的嵌入式开发人员没有找到太多可用的嵌入式系统。


如果你是开发人员，请帮助改进 RT-Thread Smart。随着 RT-Thread 项目的不断推进，我们希望创建物联网和边缘计算的令人激动的开源世界。




---


via: <https://opensource.com/article/21/7/rt-thread-smart>


作者：[Zhu Tianlong](https://opensource.com/users/zhu-tianlong) 选题：[lujun9972](https://github.com/lujun9972) 译者：[tendertime](https://github.com/tendertime) 校对：[wxy](https://github.com/wxy)


本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译，[Linux中国](https://linux.cn/) 荣誉推出


OK
There's a growing demand for [embedded operating systems](https://opensource.com/article/20/6/open-source-rtos), and it's best when the one you build upon is open source. The [RT-Thread](https://www.rt-thread.io/) project's R&D team has spent two years of research and intensive development to arrive at the project's latest offering: RT-Thread Smart. It is a microkernel operating system aimed primarily at midrange to high-end processors such as RISC-V or Arm Cortex-A that with a memory management unit (MMU) and provides a competitive and [POSIX](https://opensource.com/article/19/7/what-posix-richard-stallman-explains)-based software platform for all industries in the embedded space.

## Who needs RT-Thread Smart?


RT-Thread Smart is a professional, high-performance, microkernel operating system for real-time applications. It offers an open source foundation for embedded devices in any market, including security (e.g., internet protocol cameras), industrial control, onboard devices, consumer electronics, and anything else using embedded technology (which is increasingly coming to mean "everything"). It's significant because, unlike traditional IoT operating systems, a microkernel operating system can fill the gap between a traditional real-time operating system (RTOS) and a comparatively large operating system like Linux to achieve the best balance between real-time performance, cost, security, startup speed, and more.

## RT-Thread Smart's architecture

RT-Thread Smart splits a system into kernel space and user space by taking advantage of the MMU and system call methods. It then divides the address space for each mode (a 32-bit system provides 4G address space).

![RT-Thread Smart architecture RT-Thread Smart architecture](https://opensource.com/sites/default/files/uploads/rt-thread-smart.png)

(RT-Thread, CC BY-SA 4.0)

The RT-Thread Smart kernel includes the platform's basic functionality and supports customizations. RT-Thread Smart's userspace application environment uses [musl libc](https://musl.libc.org/) to provide [POSIX](https://opensource.com/article/19/7/what-posix-richard-stallman-explains) interface calls and C runtime supports. It also inherits the original RT-Thread ecosystem, using [SCons](https://scons.org/) or other build tools such as [Autotools](https://opensource.com/article/19/7/introduction-gnu-autotools), Makefiles, [CMake](https://opensource.com/article/21/5/cmake), and so on to support development, as well as RT-Thread's out-of-the-box online software packages (over 342 at the time of this writing). You can even port Linux applications, such as wget/cURL, BusyBox, OpenSSL, and Simple DirectMedia Layer, to your platform.

The compressed RT-Thread Smart kernel is just 217KB, with a root filesystem of 127KB. Typical memory usage is about 2MB.

Including full support for filesystems, network protocol stacks, and multimedia, it takes only three to five seconds for RT-Thread to finish its startup process. Without running or loading complex user applications, RT-Thread Smart requires less than 500ms to start and be ready.

With its integrated Persimmon user interface (UI) component, the time it takes from power-on to a running UI is about one second. In other words, this is a seriously tiny and fast system. Of course, "real time" isn't about startup but how the system performs consistently over time. For RT-Thread, real-time performance is a priority, and the interrupt latency is less than 1 μs, which meets most application cases with the strictest real-time requirements.

## RT-Thread Smart vs. RT-Thread

You might be wondering about the differences between RT-Thread Smart and RT-Thread. Simply put, RT-Thread Smart is an RT-Thread RTOS-based operating system, but it integrates the user-space process. The kernel part of RT-Smart is essentially RT-Thread RTOS; it runs on virtual addresses, adds process management, and uses interprocess communication mechanisms, virtual memory/address space management, ELF loaders, and so on, and it makes all of these features components within RT-Thread RTOS. When the components are disabled, RT-Smart falls back onto RT-Thread RTOS.

Here's a comparison:

RT-Thread | RT-Thread Smart | |
---|---|---|

Supported chips | Cortex-M/R, RISC-V RV32IMAC (and similar), Cortex-A MPU | MPU with MMU, such as ARM Cortex-A and RISC-V |

Compiling | The kernel and application are compiled into an image program. | The kernel and application can be separately compiled and executed. |

Memory | Runs on a linear address space (even with MMU) and uses virtual addressing with the physical address | Runs on a 32-bit system with the kernel running on more than 1GB, the user-space process that has full 4G address spaces are isolated from each other. Peripheral drivers must access peripherals with virtual addresses. |

Running errors | When an application fails, the overall system collapses. | When an application fails, it does not affect kernel and other process execution. |

Running model | Multi-thread model | Multiprocess model (multithread is supported within the process, and kernel threads are supported by the kernel) |

User model | Single-user model | Single-user model |

API | RT-Thread API, POSIX PSE52 | RT-Thread API (on kernel and userspace), plus a full POSIX API |

Real time | Preemptive hard real-time system | Preemptive hard real-time system |

Resource utilization | Very small | Relatively small |

Debugging | Generally debugged through the emulator | Supports GDB debugging and no emulator required |


RT-Thread RTOS is very compact. All applications and subsystems are compiled into the image, and multi-thread applications run and share the same address space.

RT-Thread Smart is independent. Systems and applications are separately compiled and executed. Applications have a full address space and are kept isolated from each other. It also inherits all the great real-time features of RT-Thread and features a POSIX environment.

Similarly, they're both compatible with the RT-Thread API, so applications on RT-Thread RTOS can be smoothly ported to RT-Thread Smart.

## Embed open source

RT-Thread Smart is an open source project, with its code available on [GitHub](https://github.com/RT-Thread/rt-thread/tree/rt-smart). You can download the code and its documentation, give it a try, submit comments and feedback, and help spread it to more open source advocates. Embedded systems should belong to their users, and there are too many embedded developers out there who don't realize what's available.

If you're a developer, help hack on RT-Thread Smart! As the RT-Thread project continues to advance, we aim to make the exciting worlds of IoT and edge computing open source.

## Comments are closed.