Port RT-Thread to STM32

This article refers to [ Wild Fire EmbedFire] "RT-Thread Kernel Implementation and Application Development Practice - Based on STM32" and is only used as personal study notes. For more detailed content and steps, please view the original text (can be downloaded from the Wildfire Information Download Center)

Table of contents

1. Obtain the STM32 bare metal project template

2. Download RT-Thread Nano source code

3. Install RT-Thread Package

4. Add RT-Thread source code to the project

5. Specify RT-Thread header file path

6. Modify rtconfig.h

7. Modify board.c

        1. Add the "board.h" header file

        2. Shield the configuration function of the system clock

        3. Shield the call of the original system clock configuration function, and add the system clock configuration corresponding to this chip later.

8. Compile


1. Obtain the STM32 bare metal project template

Copy an STM32 bare-metal project template from Wildfire's information. My chip model is STM32F103VET6 (Guide). Use the project of the firmware library to light up the LED light experiment as the project template:

2. Download RT-Thread Nano source code

Link: Arm Keil | RealThread RT-Thread

 Just download the latest version

3. Install RT-Thread Package

After the .pack file is downloaded, install it directly. Remember the installation path. You will need to copy the RT-Thread source code to that path later.

4. Add RT-Thread source code to the project

From the path just now, copy the RT-Thread folder to the root directory of the bare metal project, as shown below:
Copy board.c and rtconfig.h to the user/ directory

 

Add board.c and rtconfig.h files to the project

 

Create new rtt/source and rtt/ports groups

Add the src file under RT-Thread to rtt/source

Since my development board model is M3 series, add context_rvds.S and cpuport.c in the RT-Thread->libcpu->ARM->cortex-m3 folder to rtt/ports

The final result is as shown in the figure. If the file has a small key, cancel read-only and reopen the project.

 

 5. Specify RT-Thread header file path

 6. Modify rtconfig.h

7. Modify board.c

1. Add the "board.h" header file

 

2. Shield the configuration function of the system clock

3. Shield the call of the original system clock configuration function, and add the system clock configuration corresponding to this chip later.
The SysTick initialization function is replaced by the SysTick_Config() function in the firmware library file core_cm3/4/7 .

8. Compile

After compilation, 3 errors will appear, which are caused by repeated definitions.

 

 The solution is Usr/stm32f10x_it.cto annotate all three functions inside, compile and run, and it will be successful.

Guess you like

Origin blog.csdn.net/weixin_51244415/article/details/131592179