|
@@ -1,24 +1,24 @@
|
|
|
-# Start Guide: Simulate STM32F103 on keil simulator
|
|
|
+# 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.
|
|
|
+Because of its particularity, the embedded operating system is often closely related to the hardware platform, and specific embedded operating systems can only run on specific hardware. For those who might not have an RT-Thread compatible hardware module, or want to test out their ideas, a complete RT-Thread system can be developed in the simulation environment MDK-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.
|
|
|
+MDK-ARM (Microcontroller Development Kit - ARM) is a complete integrated development environment (IDE) from ARM. It includes an efficient C/C++ compiler for ARM chips (ARM7, ARM9, Cortex-M series, Cortex-R series, etc.), a project wizard and project management for various ARM devices and evaluation boards and a simulator for simulating hardware platforms in software. It supports debuggers connected to simulators debugging the target board, such as the commonly available ST-Link, J-Link, 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 a 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.
|
|
|
+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 exceptions, interrupts, clock timers, serial ports, etc., which is almost identical to the real hardware environment. RT-Thread can run on both the simulated environment and on real hardware.
|
|
|
|
|
|
-Next, we will select the MDK-ARM integrated development environment as the target hardware platform to observe how the RT-Thread operating system works.
|
|
|
+What will follow is a demonstration of RT-Thread running on a simulated STM32F103 microcontroller through MDK-ARM.
|
|
|
|
|
|
## 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).
|
|
|
+MDK development environment: MDK-ARM 5.24 (official or evaluation version, version 5.14 and above) needs to be installed. This version is a relatively new version, which can provide relatively complete debugging functions. An installation guide can be found here: [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:
|
|
|
+To see the code size of RT-Thread we first need to get an example of RT-Thread that is suited for this environment, which 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:
|
|
|
+This example is a zip file, unzip it. The directory structure after decompression is as shown below:
|
|
|
|
|
|

|
|
|
|
|
@@ -37,7 +37,7 @@ drivers | Driver of RT-Thread, implementations of bottom driver of different
|
|
|
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:
|
|
|
+In the directory, there is a file with the name "project.uvprojx", which is an MDK5 project file in the sample referenced in this manual. Double-click "project.uvprojx" icon to open the project file:
|
|
|
|
|
|

|
|
|
|
|
@@ -54,24 +54,24 @@ Under the "Project" column on the left side of the main window of the project, y
|
|
|
| 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,, compiling the project as shown:
|
|
|
+Now click the button from the toolbar on the top the window, , to compile the project as shown:
|
|
|
|
|
|

|
|
|
|
|
|
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 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:
|
|
|
+After compiling RT-Thread/STM32, we can simulate running RT-Thread through the MDK-ARM simulator. Click  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:
|
|
|
|
|
|

|
|
|
|
|
|
->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.
|
|
|
+>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.
|
|
|
|
|
|

|
|
|
|
|
|
|
|
|
## 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.
|
|
|
+The above startup code is 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)
|
|
@@ -85,7 +85,7 @@ int main(void)
|
|
|
|
|
|
## 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.
|
|
|
+For technical engineers working on electronics, marquee is probably the simplest example, the equivalent of Hello World in every programming language programmers learn. 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:
|
|
|
|
|
@@ -144,7 +144,7 @@ Cause: This type of problem is usually caused by installation of ADS, when ADS a
|
|
|
Solution:
|
|
|
|
|
|
- Delete ADS environment variables
|
|
|
-- Uninstall ADS and keil, restart the computer, reload keil
|
|
|
+- Uninstall ADS and Keil, restart the computer, reload Keil
|
|
|
|
|
|
|
|
|
|