move documentation repo to rt-thread repo

This commit is contained in:
Meco Man
2022-03-12 00:56:03 -05:00
parent a65e6d1613
commit 5af97a1f7f
255 changed files with 21076 additions and 95 deletions
Binary file not shown.

After

Width:  |  Height:  |  Size: 79 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 76 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 89 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 54 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 115 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 37 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 174 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 63 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 33 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

@@ -0,0 +1,36 @@
# Keil MDK Installation
Before running the RT-Thread operating system, we need to install MDK-ARM 5.24 (either official or evaluation version, version 5.14 and above), this version is also a relatively new version. This version can provide relatively complete debugging functions. Here, we are using evaluation version 5.24 of 16k compiled code limit. If you want to remove the 16k compiled code limit, please purchase the official MDK-ARM.
Firstly, download the MDK-ARM evaluation version from the official website of www.keil.com:
[http://www.keil.com/download/](http://www.keil.com/download/)
When downloading, you need to fill in some basic information, please fill in the corresponding complete information, and then start downloading. After it is downloaded, double-click the mouse to start the installation, you will see the software installation as shown:
![First Step](./figures/1.png)
This is the MDK-ARM installation instructions, click “Next>>” to enter the next step, as shown.
![Second Step](./figures/2.png)
Click "√" in the box next to "I agree to all the terms of the preceding License Agreement" and click "Next >>" to proceed to the next step of installation, as shown:
![Third Step](./figures/3.png)
Click "Browse..." to select the installation directory of MDK-ARM or directly input installation path in the "Destination Folder" box. Here, we default to "C:/Keil_v5", then click "Next>>" to proceed to the next step of installation, as shown:
![Fourth Step](./figures/4.png)
Input your name after "First Name", input your last name after "Last Name", input your company name after "Company Name", input your email address after "E-mail", and then click "Next>> " for the installation. Wait for a while for the installation to finish and you will see the following:
![Fifth Step](./figures/12.png)
The default selection does not need to be changed, just click “Next” to enter the next step as shown.
![MDK-ARM Installment Complete](./figures/13.png)
Here, you can click "Finish" to complete the installation of the entire MDK-ARM software.
With a useful took like MDK-ARM, you can start the RT-Thread operating system easily and explore real-time operating systems.
>Note: There is a charge for Official version of MDK-ARM. If you want to be able to compile larger binaries, please purchase the official version of MDK-ARM. RT-Thread operating system also supports GNU GCC compiler by Free Software Foundation which is an open source compiler. For more information on how to use GNU related tools, please refer to the related documentation on RT-Thread website.
+150
View File
@@ -0,0 +1,150 @@
# Start Guide: Simulate STM32F103 on keil simulator
Because of its particularity, the embedded operating system is often closely related to the hardware platform. Specific embedded operating system can only run on specific hardware. For those who are new to the RT-Thread operating system, it is not easy to get a hardware module that is compatible with the RT-Thread operating system. However, with the development of computer technology, we can use software to simulate a hardware module that has the ability to run RT-Thread operating system. This is the simulation environment called MDK-ARM produced by the company ARM.
MDK-ARM (MDK-ARM Mi6hyicrocontroller Development Kit) software is a complete integrated development environment (IDE) from ARM. It includes efficient C/C++ compiler for ARM chips (ARM7, ARM9, Cortex-M series, Cortex-R series, etc.) ; project wizard and project management for various ARM devices, evaluation boards; simulator for software simulating hardware platform; and debuggers connected to simulators debugging the target board, common on-line simulators on the market are stlink jlink, etc. The simulator software in MDK-ARM uses a complete software simulation to interpret and execute machine instructions from ARM and implement some peripheral logic to form a complete virtual hardware environment, enabling users to execute the corresponding target program on the computer without using real hardware platform.
Because of its full STM32F103 software simulation environment, the MDK-ARM integrated development environment gives us the opportunity to run object code directly on the computer without using a real hardware environment . This simulator platform can completely virtualize the various operating modes and peripherals of the ARM Cortex-M3, such as exceptional interrupts, clock timers, serial ports, etc., which is almost identical to the real hardware environment. Practice has also proved that the RT-Thread introductory sample used in this article, after compiling into binary code, can not only run on the simulator platform, but also can run normally on the real hardware platform without modification.
Next, we will select the MDK-ARM integrated development environment as the target hardware platform to observe how the RT-Thread operating system works.
## Preparation
MDK development environment: MDK-ARM 5.24 (official or evaluation version, version 5.14 and above) needs to be installed. This version is also a relatively new version, which can provide relatively complete debugging functions. How to install can be referred to the [Keil MDK Installation](./keil-installation/keil-installation.md).
## First acquaintance with RT-Thread
As an operating system, what is the code size of RT-Thread? Before we can figure this out, the first thing we need to do is to get an example of RT-Thread that corresponds to this manual. This example can be obtained from the following link:
[RT-Thread Simulator Sample](./rtthread_simulator_v0.1.0.zip)
This example is a zip file, unzip it. Here, we decompressed it to D:/. The directory structure after decompression is as shown below:
![rtthread_simulator_v0.1.0 Code Directory ](./figures/7.png)
Descriptions of the file types contained in each directory are shown in the following table:
Directory Name | Description
--- | ---
applications| RT-Thread application.
rt-thread | Source file for RT-Thread.
- components| Respective component directories of RT-Thread.
- include | Header file for RT-Thread kernel.
- libcpu | Porting code for various types of chips, including porting files of STM32.
- src | Source file for RT-Thread kernel.
- tools | Script file of RT-Thread commanding building tool.
drivers | Driver of RT-Thread, implementations of bottom driver of different platforms.
Libraries | ST's STM32 firmware library file.
kernel-sample-0.1.0 | Kernel sample for RT-Thread.
In the directory, there is project.uvprojx file, which is an MDK5 project file in the sample referenced in this manual. Double-click "project.uvprojx" icon to open the project file:
![Open the project](./figures/5.png)
Under the "Project" column on the left side of the main window of the project, you can see the file list of the project. These files are stored in the following groups, respectively:
| Directory Group | Description |
| :-------------- | ------------------------------------------------------------ |
| Applications | The corresponding directory is rtthread_simulator_v0.1.0/applications, used to store user application code. |
| Drivers | The corresponding directory is rtthread_simulator_v0.1.0/drivers, used to store the bottom driver code for RT-Thread. |
| STM32_HAL | The corresponding directory is rtthread_simulator_v0.1.0/Libraries/CMSIS/Device/ST/STM32F1xx, used to store the firmware library files of STM32. |
| kernel-sample | The corresponding directory is rtthread_simulator_v0.1.0/kernel-sample-0.1.0, used to store kernel samples of RT-Thread. |
| Kernel | The corresponding directory is rtthread_simulator_v0.1.0/src, used to store RT-Thread kernel core code. |
| CORTEX-M3 | The corresponding directory is rtthread_simulator_v0.1.0/rt-thread/libcpu, used to store ARM Cortex-M3 porting code. |
| DeviceDrivers | The corresponding directory is rtthread_simulator_v0.1.0/rt-thread/components/drivers, used to store driver framework source code of RT-Thread. |
| finsh | The corresponding directory is rtthread_simulator_v0.1.0/rt-thread/components/finsh, used to store command line of RT-Thread finsh command line component. |
Now let's click the button from the toolbar on the top the window,![img](./figures/compile.jpg), compiling the project as shown:
![compiling](./figures/9.png)
The result of the compilation is displayed in the "Build Output" bar at the bottom of the window. If nothing else, it will say "0 Error(s), * Warning(s)." on the last line, that is, there are no errors or warnings.
After compiling RT-Thread/STM32, we can simulate running RT-Thread through the MDK-ARM simulator. Click ![img](./figures/debug.jpg)at the top right of the window or directly hit Ctrl+F5 to enter the simulation interface and hit F5 to start, then click the button in the toolbar shown in the screen shot or select “View→Serial Windows→UART#1” in the menu bar to open the serial port 1 window. You can see that the output of the serial port only shows the LOGO of RT-Thread. This is because the user code is empty and the result of its simulation is as shown:
![simulate RT-Thread1](./figures/10.png)
>We can output all the commands supported by the current system by inputting the Tab key or `help + enter ` , as shown in the following figure.
![simulate RT-Thread2](./figures/6.png)
## User Entry Code
The above startup code is basically related to the RT-Thread system, so how do users add initialization code for their own applications? RT-Thread uses main function as the user code entry, all you need to do is just add your own code to the main function.
```c
int main(void)
{
/* user app entry */
return 0;
}
```
>Note: In order to complete the initialization for the system functions before entering the main program, you can use the `$sub$$` and `$super$$` function identifiers to call another sample before entering the main program, this was, users can ignore the initialization operations before the main() function. See [ARM® Compiler v5.06 for µVision® armlink User Guide](http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0377g/pge1362065967698.html) for details.
## Example of a Marquee
For technical engineers working on electronics, marquee is probably the simplest example, it is like the first program Hello World in every programming language that programmers learned. So we will start with a marquee in the following example, to make it periodically update (turn on or off) the LED.
Under UART#1, input msh command: led and then click Enter to run it, as shown:
![run led](./figures/11.png)
**Example of a Marquee**
```c
/*
* Manifest of programs: Marquee sample
*
* marquee is probably the simplest example, it is like the first program
* Hello World in every programming language that programmers learned. So we will start with a marquee in the following example, start a thread to make it periodically
* update (turn on or off) the LED.
*/
int led(void)
{
rt_uint8_t count;
rt_pin_mode(LED_PIN, PIN_MODE_OUTPUT);
for(count = 0 ; count < 10 ;count++)
{
rt_pin_write(LED_PIN, PIN_HIGH);
rt_kprintf("led on, count : %d\r\n", count);
rt_thread_mdelay(500);
rt_pin_write(LED_PIN, PIN_LOW);
rt_kprintf("led off\r\n");
rt_thread_mdelay(500);
}
return 0;
}
MSH_CMD_EXPORT(led, RT-Thread first led sample);
```
## Other Examples
Additional kernel examples can be found in the kernel-sample-0.1.0 directory.
![more kernel samples](./figures/14.png)
## Frequently Asked Question
* Compilation error occurred as following:
```
rt-thread\src\kservice.c(823): error: #929: incorrect use of vaarg fieldwidth = aarg(args, int);
rt-thread\src\kservice.c(842): error: #929: incorrect use of vaarg precision = aarg(args, int);
………
```
Cause: This type of problem is usually caused by installation of ADS, when ADS and keil coexist, the header file of va_start points to the ADS folder.
Solution:
- Delete ADS environment variables
- Uninstall ADS and keil, restart the computer, reload keil
Binary file not shown.

After

Width:  |  Height:  |  Size: 31 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 45 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 197 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 39 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 48 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 33 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 36 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 128 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 55 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 77 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 57 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 123 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 90 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 123 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 87 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 73 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 85 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 KiB

@@ -0,0 +1,146 @@
# Getting Started of QEMU (Windows)
The development of embedded software is inseparable from the development board. Without physical development boards, similar virtual machines like QEMU can be used to simulate the development board. QEMU is a virtual machine that supports cross-platform virtualization. It can virtualize many development boards. To facilitate the experience of RT-Thread without a development board, RT-Thread provides a board-level support package (BSP) for QEMU-simulated **ARM vexpress A9** development board.
## Preparations
- [Download RT-Thread Source Code](https://github.com/RT-Thread/rt-thread)
- Download Env Tool
- [Install Git on your PC](https://www.git-scm.com/download/)
## Instructions for the Env tool
When using Env tools, you need to enter the corresponding BSP directory in the Env terminal.
### Configuration
```
menuconfig
```
Type the `menuconfig` command in the Env terminal to enter the configuration interface, and then configure the BSP:
![menuconfig command](figures/win-menuconfig.png)
![enter the configuration interface](figures/env_menu.png)
You can use the keyboard `↑` key and `↓` key to look up and down menu items, use the `Enter` key to enter the selected directory, use the `Space` key to select or cancel bool variables, and use the `Esc` key to exit the current directory.
### Acquisition of software packages
```
pkgs --update
```
If a package is selected in menuconfig, download the package using the `pkgs --update` command (Git needs to be installed)
### Compile
```
scons
```
Compile using the `scons` command.
### Generate IDE's Project Files
```
scons --target=xxx
```
If you use the MDK or IAR IDE for development, you need to regenerate project files to make the configuration work after the configuration is completed. The command is `scons --target=xxx`, as shown below, which is the generation of IAR project, MDK4 project and MDK5 project.
```c
scons --target=iar
scons --target=mdk4
scons --target=mdk5
```
## Introduction of QEMU BSP Catalogue
The board-level support package (BSP) provided by RT-Thread simulates ARM vexpress A9 development board is located in the `qemu-vexpress-a9` folder under the BSP directory of RT-Thread source code. This BSP implements LCD, keyboard, mouse, SD card, Ethernet card, serial port and other related drivers. The contents of the folder are shown in the following figure.
![qemu-vexpress-a9 folder](figures/qemubsp.png)
The main files and directories of `qemu-vexpress-a9` BSP are described as follows:
| Fles/Directories | Description |
| ---------------- | ------------------------------------------- |
| .vscode | configuration file of vscode |
| applications | User application code directory |
| drivers | The underlying driver provided by RT-Thread |
| qemu.bat | Script files running on Windows platform |
| qemu.sh | Script files running on Linux platform |
| qemu-dbg.bat | Debugging script files on Windows platform |
| qemu-dbg.sh | Debugging script files on Linux platform |
| README.md | Description document of BSP |
| rtconfig.h | A header file of BSP |
## Compile and Run
### Step 1. Use the *scons* Command to Compile the Project
Open the Env folder and double-click the `env.exe` file to open the Env console:
![Env folder](figures/env.png)
Switch to the QEMU BSP directory and enter the `scons` command to compile the project. If the compilation is correct, the `rtthread.elf` file will be generated in the BSP directory, which is a target file required for QEMU to run.
![compile the project](figures/scons.png)
### Step 2. Use the *qemu.bat* Command to Run the Project
After compiling, type `qemu.bat` to start the virtual machine and BSP project. `qemu.bat` is a Windows batch file. This file is located in the BSP folder, mainly including the execution instructions of QEMU. The first run of the project will create a blank `sd.bin` file under the BSP folder, which is a virtual SD card with a size of 64M. The Env command interface displays the initialization information and version number information printed during the start-up of RT-Thread system, and the QEMU virtual machine is also running. As shown in the following picture:
![run the project](figures/qemu.bat.png)
![QEMU virtual machine](figures/qemu.png)
### Run the Finsh Console
RT-Thread supports Finsh, and users can use command operations in command line mode.
Type `help` or press `Tab` to view all supported commands. As shown in the figure below, commands are on the left and command descriptions are on the right.
![view all supported commands](figures/finsh-cmd.png)
For example, by entering the `list_thread` command, you can see the currently running threads, thread status and stack size; by entering the `list_timer`, you can see the status of the timers.
![threads and timers](figures/finsh-thread.png)
### Run the File System
Type `list_device` to view all devices registered in the system. You can see the virtual SD card "sd0" device as shown in the following picture. Next, we can format the SD card using the `mkfs sd0` command, which will format the SD card into a FatFS file system. FatFs is a Microsoft fat-compatible file system developed for small embedded devices. It is written in ANSI C, uses abstract hardware I/O layer and provides continuous maintenance, so it has good portability.
For more information on FatFS, click on the link: [http://elm-chan.org/fsw/ff/00index_e.html](http://elm-chan.org/fsw/ff/00index_e.html)
![format the SD card ](figures/mkfs-sd0.png)
The file system will not be loaded immediately after the first formatting of the SD card, and the file system will be loaded correctly only after the second boot. So exit the virtual machine, and then restart the virtual machine and project by entering `qemu.bat` on the Env command line interface. Entering `ls` command, you can see that the `Directory` directory has been added, the file system has been loaded, and then you can experience the file system with other commands provided by RT-Thread:
![commands of file system](figures/echo-cat.png)
- ls: Display file and directory information
- cd: Switch to the specified directory
- rm: Delete files or directories
- echo: Writes the specified content to the target file
- cat: Displays the details of a file
- mkdir: Create folders
Please enter `help` to see more commands.
## More Functions
Open the Env tool in the BSP directory and enter the `menuconfig` command:
![menuconfig](figures/menuconfig.png)
You can configure more functions in the configuration interface. After the configuration is completed, save the configuration first, and then exit the configuration interface:
![menuconfig interface](figures/menuconfig_menu.png)
1. If you choose a package, you need to use the command `pkgs --update` to download the package.
2. Compile with `scons`.
3. Then enter `qemu.bat` to run.
4. Use `help` to view all commands of the BSP. And then use the commands.

Some files were not shown because too many files have changed in this diff Show More