Understanding FreeRTOS RAM Architecture and Demo Application
The STM32H7 BSP comes with a demo FreeRTOS application, specially developed for the STM32H7 SOM and Starter Kit. This application note explains the architecture and use of the demo application.
1. FreeRTOS BSP
1.1. FreeRTOS Version
Emcraft provides a FreeRTOS BSP specifically ported, optimized and otherwise enhanced for the STM32H750 system-on-module. The FreeRTOS BSP is based on FreeRTOS V10.3.1. This version of FreeRTOS is available for download from the following location: GitHub - FreeRTOS/FreeRTOS at V10.3.1 . FreeRTOS source files are located in the following sub-tree: Middlewares/Third_Party/FreeRTOS
.
1.2. STM32Cube HAL
The integral part of the FreeRTOS BSP is the ST's STM32CubeH7 software, which is integrated (linked together) with the FreeRTOS BSP build. STM32CubeH7 provides a HAL (Hardware Abstraction Layer) as well as device drivers and software APIs for various I/O interfaces of the STM32H7.
In the FreeRTOS source tree, the STM32CubeH7 HAL component resides in the following sub-tree: Drivers/STM32H7xx_HAL_Driver
.
2. FreeRTOS Demo Application
2.1. FreeRTOS Demo App Source Files
The FreeRTOS BSP comes with a FreeRTOS demo application illustrating and validating the software features supported by the BSP. The FreeRTOS demo application is integrated (linked together) with the FreeRTOS BSP build.
In the FreeRTOS source tree, the FreeRTOS demo application resides in the following sub-tree: Projects/STM32H7_SOM/Applications/FreeRTOS/freertos_stm32h750
.
2.2. FreeRTOS Demo App Tasks
The FreeRTOS demo application implements several threads (FreeRTOS tasks) running in parallel. These threads are as follows:
Thread | Location in Source Tree | Comments |
Main Thread |
| Main FreeRTOS thread, which starts the other threads, and then runs the FreeRTOS CLI (Command Line Interface) on the serial console |
WDT Thread |
| Strobes the WDT |
LED Thread |
| Blinks the on-module and on-carrier LEDs |
Push-Buttons Thread |
| Monitors the on-carrier user buttons; when a button has been pressed or released, reports the push-button state change |
Timer Thread |
| Counting number of Timer interrupts |
GUI Thread |
| Implements a GUI interface on the LCD display, with touch screen, using the UI stack |
WiFi Thread |
| Implements a sample TCP server utilizing the WiFi ESP Click board, using the WiFi ESP Click driver |
3. FreeRTOS Boot Up
The U-Boot loader makes use of the bootcmd
environment variable to automatically execute commands during startup. The default value of bootcmd
is implemented in such a way that the FreeRTOS application image is loaded from QSPIFlash and started by calling the FreeRTOS app entry point.
4. FreeRTOS Memory Architecture
4.1. Running FreeRTOS BSP from External SDRAM
The default configuration of the FreeRTOS BSP is to run from external SDRAM of the STM32H7 module. To achieve that, the FreeRTOS BSP must be be linked using the freertos_stm32h750_sdram.ld
script.
In this configuration, the FreeRTOS BSP makes use of external SDRAM, as follows:
Section | Cache Attribute | Location and Size |
Display frame buffer | Non-cached | 0xD0000000, 4MB |
Reserved SDRAM storage | Cached | 0xD0400000, 2MB |
FreeRTOS run-time memory | Cached | 0xD0600000, 24MB or 56MB, for 32MB and 64MB SDRAM configurations, respectively |
U-Boot (callable by FreeRTOS for UBI/UBIFS services) | Cached | Last 2MB of SDRAM |
Allocation of the logical FreeRTOS software sections in SDRAM is as follows:
Section | Description | Location and Size |
| FreeRTOS code |
|
| FreeRTOS read-only data |
|
| FreeRTOS initialized read-write data |
|
| FreeRTOS non-initialized read-write data |
|
Stack | FreeRTOS stack |
|
Task Stack | FreeRTOS task stack |
|
Heap | FreeRTOS heap |
|
UBIFS ABI table | Table of UBI/UBIFS ABI entry points provided by U-Boot for RTOS |
|
4.2. Running FreeRTOS BSP from Internal SRAM
Another supported option is to run the FreeRTOS BSP out of internal SRAM. In this option, the FreeRTOS BSP and demo application make use of the internal SRAM of the STM32H7 to perform critical OS code and store OS data. The internal SRAM has L1-cache level performance, it is the fastest memory that is available on the STM32H750 System-on-Module. To achieve this option, the FreeRTOS BSP must be be linked using the freertos_stm32h750_sram.ld
script.
The FreeRTOS BSP makes use of the following SRAM regions:
DTCMRAM (xrw) : ORIGIN = 0x20000000, LENGTH = 128K
RAM_D1 (xrw) : ORIGIN = 0x24000000, LENGTH = 512K
Allocation of the logical FreeRTOS software sections in SRAM is as follows:
Section | Description | Location and Size |
| FreeRTOS code |
|
| FreeRTOS read-only data |
|
| FreeRTOS initialized read-write data |
|
| FreeRTOS non-initialized read-write data |
|
Stack | FreeRTOS stack |
|
Task Stack | FreeRTOS task stack |
|
Heap | FreeRTOS heap |
|
UBIFS ABI table | Table of UBI/UBIFS ABI entry points provided by U-Boot for RTOS |
|
Additionally, the FreeRTOS BSP makes use of external SDRAM, as follows:
Section | Cache Attribute | Location and Size |
Display frame buffer | Non-cached | 0xD0000000, 4MB |
General SDRAM storage (used for graphical assets, large application code, etc) | Cached | 0xD0400000, 26MB or 58MB, for 32MB and 64MB SDRAM configurations of the System-on-Module, respectively |
U-Boot (callable by FreeRTOS for UBI/UBIFS services) | Cached | Last 2MB of SDRAM |
4.3. SDRAM CLI Commands
The FreeRTOS demo application implements the following SDRAM related CLI command:
Command | Description | Comments |
| Write a certain |
|