❝
Before the porting process, it is important to note that this article, along with the subsequent ones, is based on the CM-3 processor (specifically the STM32F103VET6 used in previous STM32 notes) and utilizes the core files from FreeRTOS version 9.0.0. We only need to add the required FreeRTOS core files to the existing STM32 base project (STM32 tutorial link ☜[1]).
❞
1. Development Environment: Keil uVision5 V5.21 2. ST Peripheral Standard Firmware Library: V3.5 3. FreeRTOS Version Library: V9.0.0 4. Target Chip: STM32F103VET6 (Cotrex-M3) 5. Download Debugging Tool: J-Link
Extracting FreeRTOS Core Files
In the previous article Analysis of Official FreeRTOS Source Code[2], we identified the necessary files located in FreeRTOSv9.0.0/FreeRTOS. Therefore, we will extract the needed items.
First, create a folder named FreeRTOS in the main project directory.
Next, place the files shown in the following image from the downloaded FreeRTOSv9.0.0\FreeRTOS\Source
folder into the project folder. To manage these scattered source files, we will create a folder named src
. The specific structure of the files after porting will be shown later:
As for the contents in the portable
folder, we only need to copy the necessary interfaces; copying all files would be too large and not meet the lightweight requirement. Therefore, enter the FreeRTOSv9.0.0\FreeRTOS\Source\portable
folder, where you will find many folders named after compilers. Since our development environment is Keil
, we will use the contents from the Keil
folder. Let’s take a look inside. You will find only a See also the RVDS directory.txt
text file, which instructs us to check the RVDS
directory. Let’s go check it out:
Now we can see the interfaces that support our operation, so let’s copy the RVDS
directory over.
Additionally, we also need to copy the FreeRTOS/Source/portable/MemMang
directory because we need a file for heap management, and the official source has provided several heap allocation schemes, which are the heap_x.c
files inside.
Finally, after the porting process, we obtain the following structure:
Lastly, we need to copy the FreeRTOSv9.0.0\FreeRTOS\Demo\CORTEX_STM32F103_Keil
path’s FreeRTOSConfig.h
file (as this demo folder is the most suitable for our current porting project) to the user-modifiable App
folder.
Importing the Project and Modifying Properties
Keep the previous project unchanged and add the files shown in the image below:
img
Then change the configuration properties to ARMCM3. The configuration properties do not need to be changed; select the corresponding M3 chip, for example, if using stm32f103zet6, select that one:
img
Now, the basic project porting is complete. You may wonder why the heap_4
heap allocation scheme was chosen; this will be analyzed in the next article.
Reference
STM32 tutorial link ☜: https://arachnid.cc/categories/STM32
[2]Analysis of Official FreeRTOS Source Code: https://arachnid.cc/freertos-file-analyse/