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,469
Resource Number 38500 Last Updated 2025-02-24
¥ 0HKD 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/rt-thread-an-open-source-iot-operating-system-from-china/

Share free open-source source code

Q&A
  • 1. Automatic: After making an online payment, click the (Download) link to download the source code; 2. Manual: Contact the seller or the official to check if the template is consistent. Then, place an order and make payment online. The seller ships the goods, and both parties inspect and confirm that there are no issues. ICTcoder will then settle the payment for the seller. Note: Please ensure to place your order and make payment through ICTcoder. If you do not place your order and make payment through ICTcoder, and the seller sends fake source code or encounters any issues, ICTcoder will not assist in resolving them, nor can we guarantee your funds!
View details
  • 1. Default transaction cycle for source code: The seller manually ships the goods within 1-3 days. The amount paid by the user will be held in escrow by ICTcoder until 7 days after the transaction is completed and both parties confirm that there are no issues. ICTcoder will then settle with the seller. In case of any disputes, ICTcoder will have staff to assist in handling until the dispute is resolved or a refund is made! If the buyer places an order and makes payment not through ICTcoder, any issues and disputes have nothing to do with ICTcoder, and ICTcoder will not be responsible for any liabilities!
View details
  • 1. ICTcoder will permanently archive the transaction process between both parties and snapshots of the traded goods to ensure the authenticity, validity, and security of the transaction! 2. ICTcoder cannot guarantee services such as "permanent package updates" and "permanent technical support" after the merchant's commitment. Buyers are advised to identify these services on their own. If necessary, they can contact ICTcoder for assistance; 3. When both website demonstration and image demonstration exist in the source code, and the text descriptions of the website and images are inconsistent, the text description of the image shall prevail as the basis for dispute resolution (excluding special statements or agreements); 4. If there is no statement such as "no legal basis for refund" or similar content, any indication on the product that "once sold, no refunds will be supported" or other similar declarations shall be deemed invalid; 5. Before the buyer places an order and makes payment, the transaction details agreed upon by both parties via WhatsApp or email can also serve as the basis for dispute resolution (in case of any inconsistency between the agreement and the description of the conflict, the agreement shall prevail); 6. Since chat records and email records can serve as the basis for dispute resolution, both parties should only communicate with each other through the contact information left on the system when contacting each other, in order to prevent the other party from denying their own commitments. 7. Although the probability of disputes is low, it is essential to retain important information such as chat records, text messages, and email records, in case a dispute arises, so that ICTcoder can intervene quickly.
View details
  • 1. As a third-party intermediary platform, ICTcoder solely protects transaction security and the rights and interests of both buyers and sellers based on the transaction contract (product description, agreed content before the transaction); 2. For online trading projects not on the ICTcoder platform, any consequences are unrelated to this platform; regardless of the reason why the seller requests an offline transaction, please contact the administrator to report.
View details

Related Source code

ICTcoder Customer Service

24-hour online professional services