"This document introduces the basic functions of RT thread nano 3.0.3, and describes how to download and use RT thread nano 3.0.3 and related BSP routines.
RT thread nano 3.0.3 has some new changes compared with the previous version 2.1.1:
New v2m-mps2 BSP support
Fix MDK 5.14 failure to copy license
Update the board. C template to simplify unnecessary configuration
MSH command export add RT by default_ The used attribute does not need to be added with the keep option
Update stm32_ MSH and lpc824_ The UART code of the MSH example no longer depends on the drivers IPC part
Remove the drivers IPC part of the source code
1 Purpose and structure of this paper
1.1 purpose and background of this paper
RT thread nano is a minimalist real-time operating system launched by RT thread. It is suitable for 32-bit arm entry-level MCU widely used in home appliances, consumer electronics, medical equipment, industrial control and other fields. This document is a quick start document for users to quickly start using RT thread nano 3.0.3.
1.2 structure of this paper
This paper first introduces the basic functions of RT thread nano 3.0.3, and then explains how to install and configure RT thread nano 3.0.3 and how to obtain RT thread nano 3.0.3 related routines.
2 Introduction to RT thread nano
RT thread nano is a refined hard real-time kernel with minimal memory resources. Its functions include relatively complete real-time operating system characteristics such as task processing, software timer, semaphore, mailbox and real-time scheduling. After mdk5, the chip and various related components will be managed in the form of a pack. RT thread nano is also released through MDK pack. RT thread nano pack includes three functions: device drivers, kernel and shell (MSH). Users can load it as needed from MDK's run-time environment.
Figure 2-1 main functions of RT thread nano
With the support of semaphore and mailbox features and two threads running (main thread + idle thread), ROM and ram still maintain a very small size. Based on an example of cortex M0 MCU, the compiled size (ROM: 3.25k, RAM: 1.04k), excluding the ROM and ram required by MCU, the ROM required by RT thread nano itself is 2.5k and ram is 1K.
Figure 2-2 memory usage of RT thread nano
Users can migrate nano based applications directly to the full version of RT thread. Next, we will describe how to create a small system project of RT thread RTOS based on RTE (run time environment) on mdk5, starting from bare metal.
3 Pack installation
Pack can be installed online through MDK or offline. Here are two installation methods.
Pack installer installation
Open the MDK software and click the pack installer icon in the toolbar:
Figure 3-1 packs installation
Click the pack on the right, expand general, find RT thread:: rtthread, and click Install of the corresponding action to install the pack online. After the installation is successful, the action bar displays "up to date".
Figure 3-2 packs management
Manual installation
We can also download the installation file from the official website, download the RT thread nano offline installation package, and double-click the downloaded file to install:
Figure 3-3 packs manual installation
4 preparation of foundation works
Before starting to create RT thread small system, we need to prepare a bare metal project that can run normally. As an example, this article uses an LED flashing program based on stm32l072 discovery and low level library. The main screenshots of the program are as follows:
Figure 4-1 stm32l072 discovery example
In our routine, after compiling the download program, we can see that the three LEDs flash alternately. Readers can use other chips according to their own needs to complete a simple bare metal project.
5 add RT thread nano to the project
Based on a bare metal program that can run, let's add RT thread to the project. As shown in the figure below, click manage run time environment.
Figure 5-1 MDK RTE
In the manage rum time environment, find RTOS in the "software component" column, select RT thread in the variable column, check kernel, and click "OK" to add RT thread kernel to the project.
Figure 5-2 adding nano kernel
Now you can see that RT thread RTOS has been added in the project. Expand RTOS to see the files added to the project:
Figure 5-3 project with RTOS added
Kernel files include:
clock.c components.c device.c idle.c ipc.c irq.c kservice.c mem.c object.c scheduler.c thread.c timer.c
Cortex-M chip kernel migration Code:
cpuport.c context_ rvds.s
Application code and configuration file:
board.c rtconfig.h
6 adapt rtthread
RT thread uses the exception handling function hardfault_ Handler() and pendsv_ Handler() and systick interrupt service function systick_ Handler (), so the user code needs to ensure that these functions are not used. If the compilation prompt function is repeatedly defined, please delete the self-defined function.
RT thread nano 3.0.3 completes the configuration of systick in board. C by default. You can modify the macro RT_ TICK_ PER_ The value of second configures the number of systicks per second.
Figure 6-1 systick configuration
RT thread nano 3.0.3 uses array as heap by default.
Figure 6-2 heap configuration
Replace the delay function in the routine:
1) . contains the relevant header file of RT thread
2) . replace the delay() function with RT_ thread_ delay(RT_ TICK_ PER_ SECOND)
Here is the code to complete the modification:
Figure 6-3 exception handling modification
After compiling the program and downloading it to the chip, you can see that the program based on RT thread is running.
7 RT thread nano configuration
RT thread is a highly configurable embedded real-time operating system. The configuration file is rtconfig. H. Nano is the kernel application of 2.5k ROM and 1K ram under rtconfig. H configuration. Users can configure corresponding functions according to their own needs by modifying the macro definition in rtconfig. H file.
RT thread nano does not enable macro RT by default_ USING_ Heap, so it only supports static creation of tasks and semaphores. To create objects dynamically, you need to turn on RT in the rtconfig. H file_ USING_ Heap macro definition.
The MDK configuration wizard can easily configure the project. In the value column, you can select the corresponding functions and modify the relevant values, which is equivalent to directly modifying the configuration file rtconfig. H.
Figure 7-1 nano configuration
8 BSP routine
At present, there are five RT thread nano reference routines, two stm32l0 based routines, two lpc824 based routines, and the v2m-mps2 based routines added in nano 3.0.3. All routines can be found on the MDK through the pack installer. Click the pack installer Icon:
Figure 8-1 pack installer
Enter stm32l0 in search, click stm32l0 Series in device, and then click example on the right. You can see two routines based on stm32l0 on the right.
Figure 8-2 routine
Introduction to v2m-mps2 MSH routine
V2m-mps2 is a development board provided by MDK. With fast models debugger (mdk-arm professional authorization is required and only 64 bit system is supported), you can debug code on Cortex-M platform without relying on any hardware.
To use v2m-mps2, you need to open the telnet client of windows:
Win7 open telnet client( https://jingyan.baidu.com/article/eb9f7b6d8701ae869364e826.html )
Win10 open telnet client( https://jingyan.baidu.com/article/ceb9fb10a9a1b48cad2ba0c4.html )
After opening Telnet, select arm from the device in MDK's pack installer, and click example on the right to see a v2m based_ MSH routine of Mps2.
Figure 8-3 v2m_ Mps2 MSH routine
Click Copy to export the example and compile the project simulation run. The following is a screenshot of the successful run.
Figure 8-4 v2m_ Screenshot of Mps2 MSH routine running successfully
RT thread also provides BSP (board level support package) based on the full version of RT thread v2m-mps2( https://github.com/RT-Thread/rt-thread/tree/master/bsp/v2m-mps2 ), users can get it through GitHub., Read the full text, original title: RT thread nano 3.0.3 Quick Start Guide
The source of the article: [micro signal: RTThread, WeChat official account: the LDA Internet of things] welcome to add attention! Please indicate the source of the article“
Our other product: