当前位置:网站首页>RT thread quick start - experience RT thread
RT thread quick start - experience RT thread
2022-06-12 23:19:00 【Learn embedded together】
official account 【 Learn embedded software together 】,RTOS、Linux、C
At the beginning RT-Thread Before kernel learning , Let's experience it first RT-Thread.
To experience RT-Thread, First of all, you need to have an operating environment or an experimental environment .RT-Thread It can not only run on the actual hardware platform , It can also be run in a virtual environment .
If only to learn kernel knowledge , And cooperate with the practice experiment , Virtual environment is OK . If there is an actual hardware environment , Of course it would be better .
In the official learning materials , Two virtual environments are introduced :
- QEMU virtual machine
- Keil Simulator
Let's experience these two environments RT-Thread function .
Then I introduced RT-Thread Basic knowledge of kernel object model architecture .
QEMU virtual machine
RT-Thread Provides QEMU Simulated ARM vexpress A9 The board level support package of the development board (BSP).
stay Windows The platform is ready to run qemu-vexpress-a9 BSP engineering , But it needs to be built first Env development environment , You can refer to :
RT-Thread Study -Env Development environment construction
( remarks : The source code version of the example here is v4.0.2)
QEMU Simulated ARM vexpress A9 The board level support package of the development board (BSP) be located RT-Thread Source code BSP In the catalog qemu-vexpress-a9 Folder , Its content is shown in the figure below :

qemu-vexpress-a9 BSP The main documents and directories are described as follows :
| file / Catalog | describe |
|---|---|
| .vscode | vscode The configuration file |
| applications | User application code directory |
| drivers | RT-Thread The underlying drivers provided |
| qemu.bat | Windows Platform run script file |
| qemu.sh | Linux Platform run script file |
| qemu-dbg.bat | Windows Platform debugging script file |
| qemu-dbg.sh | Linux Platform debugging script file |
| README.md | BSP Documentation |
| rtconfig.h | BSP Configuration header file |
Compile operation
Get into bsp\qemu-vexpress-a9 Folder , open Env Tools , Input scons Instructions , Start compilation , After successful compilation, see the following figure :

After successful compilation , Input qemu.bat, Run the program

Env The command interface displays RT-Thread Information printed during the system process , Including initialization information and version number information .
RT-Thread Support Finsh function , Users debug and view system information , Users can use commands to operate . Input help Or press tab Key to view the commands supported by the system :

We try to enter instructions list_thread, Displays the threads currently running on the system , And thread status and stack size :

Finsh With automatic completion function , Enter some characters of the command , Press down Tab keyboard , Then the system will display the current input characters , Find the registered related commands from the system . This function is associated with Linux The command terminal under is very similar .

Keil Simulator
MDK-ARM Software simulation simulator in software , Fully software simulation is used to explain and execute ARM The machine instructions for , And realize some peripheral logic , So as to form a complete set of virtual hardware environment , So that users can execute the corresponding target program on the computer without the help of real hardware platform .
RT-Thread An example project is provided by the government , You can simulate STM32F103 In the software simulation environment . The project download link is as follows ( Because wechat cannot add external links , Need to copy to the browser to open ):
https://www.rt-thread.org/document/site/#/rt-thread-version/rt-thread-standard/tutorial/quick-start/stm32f103-simulator/stm32f103-simulator
When the download is complete , The unzipped directory structure is as follows :

The file types contained in each directory are described in the following table :
| Directory name | describe |
|---|---|
| applications | RT-Thread Application files . |
| rt-thread | RT-Thread The source file . |
| - components | RT-Thread Directory of various components of the . |
| - include | RT-Thread The header file of the kernel . |
| - libcpu | Transplant codes of various chips , This includes STM32 Migration files for . |
| - src | RT-Thread Kernel source file . |
| - tools | RT-Thread Command build tool script file . |
| drivers | RT-Thread The driver , The bottom drivers of different platforms are implemented in detail . |
| Libraries | ST Of STM32 Firmware library file . |
| kernel-sample-0.1.0 | RT-Thread Kernel routines . |
double-click project.uvprojx Open the project :

This example project , The example project implements a simulation LED Flashing function , And use RT-Thread The macro MSH_CMD_EXPORT Export an instruction led. Enter... At the control terminal led , You can run this function .
After compilation , We can go through MDK-ARM To simulate the running of RT-Thread, Here's the picture :

Enter the simulation page , Press again F5 Began to run ; Then click the button in the toolbar , Or select... In the menu bar “View→Serial Windows→UART#1”, Open the serial port 1 window , You can see that the output of the serial port only shows RT-Thread Of LOGO, This is because the user code is empty , The simulation results are shown in the figure :

At the prompt msh> Post input led, perform LED A function that simulates flicker :

FinSH Console
In the above two simulation runs RT-Thread In the experiments , Both mentioned FinSH. that FinSH What is it ?
Here it is , Just a brief introduction , To reach the level of understanding . With the deepening of learning , You can study it in detail later .
FinSH yes RT-Thread Command line component of , Be similar to Linux Under the shell, It provides a set of operation interfaces for users to call on the command line , It is mainly used for debugging or viewing system information , It can use serial port 、 so 、USB And so on PC communicate .
When serial port is used to connect equipment and control terminal ,FinSH The execution flow of the command is shown in the figure :

The user inputs a command at the control terminal , Control terminal through serial port 、 USB、 The command is transmitted to the device through the network FinSH, FinSH
Will read the device input commands , Parse and automatically scan the internal function table , Find the corresponding function name , Output the response after executing the function , Response through the original
The way back , Display the results on the control terminal .
FinSH Support auto completion 、 View historical commands and other functions , These functions can be easily used through the keys on the keyboard .
RT-Thread Source code
For the convenience of study RT-Thread, We download the standard source code . The official source code download channel is provided :
https://www.rt-thread.org/page/download.html

When the download is complete , The source code directory is as follows ( Be careful , The source code storage path location cannot contain Chinese ):

RT-Thread The source code directory structure is as follows :
| name | describe |
|---|---|
| BSP | Board Support Package( Board level support package ) Migration based on various development boards |
| components | RT-Thread Code of each component of , for example finsh,gui etc. . |
| documentation | The related documents , Such as coding specification, etc |
| examples | Related sample code |
| include | RT-Thread The header file of the kernel . |
| libcpu | Transplant codes of various chips . |
| src | RT-Thread Kernel source file . |
| tools | RT-Thread Command build tool script file . |
Kernel object model
RT-Thread The kernel is designed with object-oriented design idea , System level infrastructure is a kind of kernel object , For example, threads , Semaphore , The mutex , Timers, etc .
Kernel objects fall into two categories : Static kernel objects and dynamic kernel objects , Static kernel objects are usually placed in RW Paragraph and ZI In the paragraph , Initialize in the program after the system starts ; Dynamic kernel objects are created from the memory heap , Then do initialization manually .
Static objects take up RAM Space , Does not depend on the memory heap manager , Memory allocation time determination . Dynamic objects depend on memory heap
Manager , Runtime request RAM Space , When an object is deleted , The amount of RAM Space is released .
About the creation of dynamic objects and static objects , It will be introduced later .
Kernel object management
RT-Thread Kernel objects include : Threads , Semaphore , The mutex , event , mailbox , Message queues and timers , Memory pool , equipment
Drive, etc . The object container contains the information of each type of kernel object , Include object types , Size, etc .
The object container assigns a linked list to each type of kernel object , All kernel objects are linked to the linked list , Pictured RT-Thread The kernel object container and linked list of are shown in the following figure :

Each specific kernel object and object control block , In addition to the basic structure , It also has its own extended attributes .
for example , For thread control blocks , Extend based on base class objects , Added thread state 、 Priority and other properties . These properties are not used in the operation of base class objects , Only used in thread specific operations .
From an object-oriented perspective , Each concrete object is a derivation of an abstract object , Inherits the properties of the base object , And on this basis, it extends the attributes related to itself . As shown in the figure below , Derivation and inheritance of various kernel objects :

In the object management module , Defines a common data structure , Used to store the common attributes of various objects , Various concrete objects only need to be in
On this basis, we add some special properties of our own , Can clearly express their own characteristics .
The advantages of this design method are :
(1) It improves the reusability and expansibility of the system , Adding new object categories is easy , You only need to inherit the properties of the common object and add less Quantity expansion is enough .
(2) Provide a unified object operation mode , It simplifies the operation of various concrete objects , Improve the reliability of the system .
OK, Come here first today , The next to continue . come on. ~
official account 【 Learn embedded software together 】, Wonderful content will be delivered first
边栏推荐
- 2202 - production de CV
- MOOG servo valve d634-341c/r40ko2m0nss2
- Detr (detection with transformers) learning notes
- Flutter库推荐Sizer 可帮助您轻松创建响应式 UI
- The most widely used dynamic routing protocol: OSPF
- 深度学习-神经网络:卷积的实现方法【直接法(精度没损失)、GEMM(矩阵乘法,精度没损失)、FFT(傅里叶变换,精度有损失)、Winograd(精度有损失)】
- Alien Skin Exposure X7调色滤镜插件,RAW后期处理工具
- Leetcode 890 finding and replacing patterns [map] the leetcode path of heroding
- 【LeetCode】300. Longest ascending subsequence
- Introduction to Quaternion
猜你喜欢

The programmer has worked for 7 years. At the age of 31, he has no choice but to deliver takeout. I really don't want you to go through his journey again
![[opencv learning] small ticket recognition based on perspective transformation and OCR recognition](/img/47/08b9dd9dbea9e9cb6deda975f4d652.jpg)
[opencv learning] small ticket recognition based on perspective transformation and OCR recognition

MySQL case when then function use

Shardingsphere-proxy-5.0.0 deployment table implementation (I)

The carrying capacity of L2 level ADAS increased by more than 60% year-on-year in January, and domestic suppliers "emerged"

ShardingSphere-proxy-5.0.0部署之分表实现(一)
![[web technology] 1348- talk about several ways to implement watermarking](/img/5f/c4f6ba6799202c79d1e9cb7a083952.png)
[web technology] 1348- talk about several ways to implement watermarking

Industry reshuffle, a large number of programmers are going to lose their jobs? How can we break the current workplace dilemma
![[opencv learning] use the Tesseract OCR movement to recognize numbers](/img/ed/92e5261c9abda4e79d58e9404d3aee.jpg)
[opencv learning] use the Tesseract OCR movement to recognize numbers

Summary of MySQL foundation view
随机推荐
Web3 principle and decentralization
〖Kubernetes指南⑤〗Label快速入门
The development trend of digital collections!
项目里面的traceID的设计
Lua conditional statement
MySQL row to column, column to row, multiple columns to one row, one row to multiple columns
Analysis report on the "fourteenth five year plan" and the latest development trend of China's medical information industry from 2022 to 2028
The annual salary of 500000 is one line, and the annual salary of 1million is another line
Gradient accumulation in pytorch [during the experiment, due to the limitation of GPU video memory, the batch\u size can no longer be increased. To solve this problem, the gradient accumulation method
csredis-in-asp. Net core theory practice - use examples
Inventory of CV neural network models from 2021 to 2022
Anti aliasing / anti aliasing Technology
Modify the text color of the menu on the right of toobar
[North Asia data recovery] data recovery cases in which the partitions disappear and the partitions are inaccessible after the server reinstalls the system
[opencv learning] perspective transformation matrix
LeetCode —— 26. Remove duplicates from an ordered array
[890. find and replace mode]
2022 heavyweight: growth law - skillfully use digital marketing to break through enterprise difficulties
Alcohol detector based on 51 single chip microcomputer
The Milvus graphical management tool Attu is coming!
