RT-Thread – An open-source IoT operating system from China

RT-Thread – An open-source IoT operating system from China

2022-09-14 0 1,073
Resource Number 38500 Last Updated 2025-02-24
¥ 0USD Upgrade VIP
Download Now Matters needing attention
Can't download? Please contact customer service to submit a link error!
Value-added Service: Installation Guide Environment Configuration Secondary Development Template Modification Source Code Installation

As the name suggests, it is an embedded real-time multi-threaded operating system, one of the basic properties is to support multitasking, allowing multiple tasks to run at the same time does not mean that the processor is actually executing multiple tasks at the same time.

RT-Thread architecture

RT-Thread – An open-source IoT operating system from China插图

Architecture diagram

Architecture overview

  • Specifically, it includes the following sections:
  • Kernel layer: The RT-Thread kernel is the core part of RT-Thread, including the implementation of objects in the kernel system, such as multithreading and its scheduling, semaphore, mailbox, message queue, memory management, timer, etc.; libcpu/BSP (Chip Porting Related Files/Board Level Support Packages) is closely related to hardware and consists of peripheral drivers and CPU porting.
  • Component and service layer: Components are upper-layer software based on the RT-Thread kernel, such as virtual file systems, FinSH command line interfaces, network frameworks, device frameworks, etc. The modular design is adopted to achieve high cohesion within the components and low coupling between components.
  • RT-Thread Software Package: A common software component for different application areas that runs on the RT-Thread IoT operating system platform, consisting of description information, source code, or library files.
  • IoT-related software packages: Paho MQTT, WebClient, mongoose, WebTerminal, etc.
  • Scripting language-related packages: JerryScript and MicroPython are currently supported.
  • Multimedia-related software packages: Openmv, mupdf.
  • Utility packages: CmBacktrace, EasyFlash, EasyLogger, and SystemView.
  • System-related packages: RTGUI, Persimmon UI, lwext4, partition, SQLite, etc.
  • Peripheral libraries and driver packages: RealTek RTL8710BN SDK.

RT-Thread Overview

In fact, a processor core can only run one task at a time, and due to the short execution time of one task at a time, and the very fast switching between tasks through the task scheduler (the scheduler determines which task to execute at the moment based on priority), it gives the illusion that multiple tasks are running at the same time. In the RT-Thread system, tasks are implemented through threads, and the thread scheduler in RT-Thread is the task scheduler mentioned above.

Compared with the Linux operating system, RT-Thread is small in size, low in cost, low in power consumption, and fast in startup. While 32-bit MCUs are its primary operating platform, many application processors with MMUs, ARM9, ARM11, and even Cortex-A series CPUs are also suitable for specific applications using RT-Thread.

Features of RT-Thread:

  • Extremely low resource usage, ultra-low power consumption design, the smallest core (Nano version) only needs 1.2KB RAM, 3KB Flash.
  • A thriving package ecosystem with abundant components.
  • Simple and easy to use, elegant code style, easy to read and master.
  • Highly scalable, high-quality scalable software architecture, loosely coupled, modular, easy to tailor and expand.
  • Powerful to support high-performance applications.
  • Cross-platform, wide chip support.

Quick Start – Examples

This example is a zip file, unzip it, and here we decompress it to D:/. The directory structure after the decompression is completed is shown in the following figure:

RT-Thread – An open-source IoT operating system from China插图1

The following table describes the file types contained in each directory:

The name of the directory

description

applications

RT-Thread application.

rt-thread

The source file for RT-Thread.

– components

RT-Thread’s individual component catalogs.

– include

Header file for the RT-Thread kernel.

– libcpu

Porting code for various chips, including STM32 porting files here.

– src

The source file for the RT-Thread kernel.

– tools

RT-Thread command to build the script file of the tool.

drivers

The driver of RT-Thread, the underlying driver of different platforms is implemented.

Libraries

ST’s STM32 firmware library file.

kernel-sample-0.1.0

Kernel routines for RT-Thread.

In the directory, there is a project.uvprojx file, which is an MDK5 project file in the routine referenced in this article, double-click the “project.uvprojx” icon to open this project file:

RT-Thread – An open-source IoT operating system from China插图2

Now let’s click the button in the toolbar at the top of the window to compile the project, as shown in the image:

RT-Thread – An open-source IoT operating system from China插图3

System startup code

Generally speaking, most of the code starts with the startup part, and the same way is used here, looking for the source of the startup first. Taking MDK-ARM as an example, the user entry point for MDK-ARM is the main() function, which is located in the main.c file. After the system starts, start from the assembly code startup_stm32f103xe.s, then jump to the C code, initialize the RT-Thread system function, and finally enter the user program entry main().

//components.c definition
/* re-define main function */
int $Sub$$main(void)
{
    rt_hw_interrupt_disable();
    rtthread_startup();
    return 0;
}

Here, the $Sub$$main function only calls the rtthread_startup() function. RT-Thread supports multiple platforms and multiple compilers, and the rtthread_startup() function is the unified entry point specified by RT-Thread, so the $Sub$$main function only needs to call the rtthread_startup() function. For example, RT-Thread, which is compiled using the GNU GCC compiler, jumps directly from the assembly startup code section to the rtthread_startup() function and starts the execution of the first C code. Find the rtthread_startup() function in the code of components.c, and we will see the startup process of RT-Thread:

int rtthread_startup(void)
{
    rt_hw_interrupt_disable();

    /* board level initalization
     * NOTE: please initialize heap inside board initialization.
     */
    rt_hw_board_init();

    /* show RT-Thread version */
    rt_show_version();

    /* timer system initialization */
    rt_system_timer_init();

    /* scheduler system initialization */
    rt_system_scheduler_init();

#ifdef RT_USING_SIGNALS
    /* signal system initialization */
    rt_system_signal_init();
#endif

    /* create init_thread */
    rt_application_init();

    /* timer thread initialization */
    rt_system_timer_thread_init();

    /* idle thread initialization */
    rt_thread_idle_init();

    /* start scheduler */
    rt_system_scheduler_start();

    /* never reach here */
    return 0;
}

This part of the startup code can be roughly divided into four parts:

  • Initialize system-related hardware;
  • Initialize system kernel objects such as timers, schedulers;
  • Initialize the system device, which is mainly for the RT-Thread device framework.
  • Initialize each application thread and start the scheduler.
资源下载此资源为免费资源立即下载
Telegram:@John_Software

Disclaimer: This article is published by a third party and represents the views of the author only and has nothing to do with this website. This site does not make any guarantee or commitment to the authenticity, completeness and timeliness of this article and all or part of its content, please readers for reference only, and please verify the relevant content. The publication or republication of articles by this website for the purpose of conveying more information does not mean that it endorses its views or confirms its description, nor does it mean that this website is responsible for its authenticity.

Ictcoder Free source code RT-Thread – An open-source IoT operating system from China https://ictcoder.com/kyym/rt-thread-an-open-source-iot-operating-system-from-china.html

Share free open-source source code

Q&A
  • 1, automatic: after taking the photo, click the (download) link to download; 2. Manual: After taking the photo, contact the seller to issue it or contact the official to find the developer to ship.
View details
  • 1, the default transaction cycle of the source code: manual delivery of goods for 1-3 days, and the user payment amount will enter the platform guarantee until the completion of the transaction or 3-7 days can be issued, in case of disputes indefinitely extend the collection amount until the dispute is resolved or refunded!
View details
  • 1. Heptalon will permanently archive the process of trading between the two parties and the snapshots of the traded goods to ensure that the transaction is true, effective and safe! 2, Seven PAWS can not guarantee such as "permanent package update", "permanent technical support" and other similar transactions after the merchant commitment, please identify the buyer; 3, in the source code at the same time there is a website demonstration and picture demonstration, and the site is inconsistent with the diagram, the default according to the diagram as the dispute evaluation basis (except for special statements or agreement); 4, in the absence of "no legitimate basis for refund", the commodity written "once sold, no support for refund" and other similar statements, shall be deemed invalid; 5, before the shooting, the transaction content agreed by the two parties on QQ can also be the basis for dispute judgment (agreement and description of the conflict, the agreement shall prevail); 6, because the chat record can be used as the basis for dispute judgment, so when the two sides contact, only communicate with the other party on the QQ and mobile phone number left on the systemhere, in case the other party does not recognize self-commitment. 7, although the probability of disputes is very small, but be sure to retain such important information as chat records, mobile phone messages, etc., in case of disputes, it is convenient for seven PAWS to intervene in rapid processing.
View details
  • 1. As a third-party intermediary platform, Qichou protects the security of the transaction and the rights and interests of both buyers and sellers according to the transaction contract (commodity description, content agreed before the transaction); 2, non-platform online trading projects, any consequences have nothing to do with mutual site; No matter the seller for any reason to require offline transactions, please contact the management report.
View details

Related Article

make a comment
No comments available at the moment
Official customer service team

To solve your worries - 24 hours online professional service