Get Started with RT-Thread Smart OpenSource Microkernel Operating System!

RT-Thread Smart is an open-source microkernel operating system that is aimed primarily at mid to high-end processors with MMU (Memory Management Unit), providing a more competitive operating system-based software platform for different industries. RT-Thread Smart is positioned as a professional high-performance micro-kernel operating system for real-time applications, to benefit the industries in Security, Industrial Control, Onboard Devices, Consumer Electronics, and so on.

RT-Thread Smart Architecture

RT-Thread Smart separates the whole system into kernel mode and user mode on the basis of the hardware platform by taking advantage of the MMU and System Call method and divides the address space for each mode (32-bit system provides 4G address space).

The RT-Thread Smart kernel includes the basic functionality and supports custom tailor as well. The RT-Thread Smart user-mode application environment uses musl libc to provide POSIX interface calls and C runtime supports, inherits RT-Thread original ecology that using scons or other build tools such as xmake, cmake, etc., and docking with RT-Thread 260+ out-of-box online software packages, as well as supporting POSIX for porting Linux applications.

This article will lead you to get started with RT-Thread Smart OpenSource Microkernel Operating System.

Software Introduction

RT-Thread Smart Software

First. Download, The package can be executed on QEMU-simulated VExpress-A9 or raspberry Pi 4B development boards to help RT-Thread developers further down on learning RT-Thread Smart.

Unzip it, and first, I’ll walk you through the document structure.

Prepare Toolchain

You’ll need to download the corresponding arm-linux-musleabi toolchain for different operating environment Linux and Windows, rt-smart package already contains a toolchain that under Linux environment.
● Linux:install_arm-linux-musleabi_for_x86_64-pc-linux-gnu.tar
● Windows:install_arm-linux-musleabi_for_i686-w64-mingw32

Download Toolchain:

Download the toolchain according to your development environment.
After downloading it, unzip and expand it into the rt-smart/tools/gnu_gcc directory, and the environmental variables set by smart-env.bat/sh in the rt-smart directory, where the toolchain path points to this directory.

Compile it on Linux and execute on the QEMU simulation environment.

Under Linux, you’ll need to install some basic environments before you can compile rt-smart. This document is taking the operations under Ubuntu16.04 environment, which is similar to other Linux versions.

Install Compile Environment

First, install some other tools and packages that you’ll need to use for compiling via some commands as shown below:

The above commands will request to install some system basic tools, python environments, scons, qemu tools, and so on.

Compile Application

After successfully compiled, the application under userapps/apps compiles into the elf executable files and places it in the userapps/root/bin directory, which can be converted into a romfs, C language array and provide to rt-smart, so that it can be executed directly without relying on other file systems. You can use the following command lines to generate romfs and C language arrays.

Compile RT-Smart Kernel

After successfully compiled, the rtthread.elf kernel file will be generated.

Simulate and Execute

Through QEMU to simulate vexpress-a9 and run it directly:

Press “Ctrl+A, X” to exit QEMU. We also run the compiled application /bin/hello.elf in above and it outputs hello world!.
On the first execution, Dir /mnt mount failed! is output, this is because the qemu script generates an empty sd.bin file as a sd card given to vexpress-a9 on the first execution, therefore, sd0 needs to be formatted.

Compile on Windows and Execute on Raspberry Pi 4B

The same work can be done on Windows and executed on the qemu or Raspberry Pi 4B board, let’s check out how to make it works on the Raspberry Pi 4B.

Prepare Compiling Environment

To compile RT-Thread Smart on Windows, you can use the RT-Thread Env tool:

First, check out if Env works. Because the package does not carry a toolchain in a Windows environment, it is important to download the Windows Toolchain and unzip it under rt-smart\tools\gnu_gcc as we mentioned above.
Then, open the end window of Env, switch to the root of this rt-smart code package and run smart-env.bat, it will set a certain amount of environment variables, and then the overall RT-Thread Smart development environment can be used.

Note that running the smart-env.bat setting environment here includes compiler settings, and it also sets the prefix of the toolchain, which can be entered under the Env terminal to check if the return results are effective:

Compile Application

When compiling the application, it is a similar method as compile on Linux:

Compile RT-Thread Smart Kernel

After successfully compiled, the kernel7.img file is generated in the current directory, it is the 32-bit version of Raspberry Pi. Currently, RT-Thread Smart only supports 32-bit systems, so it is executed in 32-bit mode on the Raspberry Pi 4B.

Connect Hardware

You’ll need to prepare the following hardware and connect the serial lines to the development board, as shown in the following connection diagram:

  1. Raspberry Pi 4B
  2. SD card (32GB or less)
  3. USB-TTL switching serial line
  4. Networking cables
  5. TYPE-C (for power supply)
  6. Card Reader (for writing compiled files to SD cards)

Prepare the software on the SD card

The load of the Raspberry Pi requires some boot files to be placed on the sd card. You can download the to help to load the Raspberry Pi.

The downloaded file is unzipped and placed with kernel7.img in an empty SD card root directory, as shown in the following image, where the bin folder holds the compiled executable elf files under the userapps\root\bin directory.

Open the serial debugging assistant and plug in the power, you can see that the program is successfully running, enter the bin directory can execute the sample program:

Contact RT-Thread if you have any ideas to share!

An Open-Source Community-Powered Real-Time Operating System (RTOS) Project! We develop, we DIY, we create, we share, we explore this new IoT World together!