Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

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: https://github.com/FreeRTOS/FreeRTOS/tree/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

freertos_stm32h750/Src/main.c, vCommandConsoleTask()

Main FreeRTOS thread, which starts the other threads, and then runs the FreeRTOS CLI (Command Line Interface) on the serial console

WDT Thread

freertos_stm32h750/Src/wdt_test.c, wdt_task()

Strobes the WDT

LED Thread

freertos_stm32h750/Src/gpio_test.c, gpio_test_led()

Blinks the on-module and on-carrier LEDs

Push-Buttons Thread

freertos_stm32h750/Src/gpio_test.c, gpio_test_buttons()

Monitors the on-carrier user buttons; when a button has been pressed or released, reports the push-button state change

Timer Thread

freertos_stm32h750/Src/tim_test.c, tim_task()

Counting number of Timer interrupts

GUI Thread

freertos_stm32h750/Src/gui.c, gui_ts_main()

Implements a GUI interface on the LCD display, with touch screen, using the UI stack

WiFi Thread

freertos_stm32h750/Src/wifiesp_click_test.c, wifiesp_task()

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

Description

Location and Size

.text

FreeRTOS code

SDRAM, size is defined by a specific FreeRTOS application

.rodata

FreeRTOS read-only data

SDRAM, size is defined by a specific FreeRTOS application

.data

FreeRTOS initialized read-write data

SDRAM, size is defined by a specific FreeRTOS application

.bss

FreeRTOS non-initialized read-write data

SDRAM, size is defined by a specific FreeRTOS application

Stack

FreeRTOS stack

DTCMRAM, size is 0x400, grows upwards

Task Stack

FreeRTOS task stack

SDRAM, size is defined by a specific FreeRTOS application

Heap

FreeRTOS heap

SDRAM, size is defined at build time as configTOTAL_HEAP_SIZE

UBIFS ABI table

Table of UBI/UBIFS ABI entry points provided by U-Boot for RTOS

ICTM, 0x00000000, 1KB

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:

Code Block
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

.text

FreeRTOS code

RAM_D1, size is defined by a specific FreeRTOS application

.rodata

FreeRTOS read-only data

RAM_D1, size is defined by a specific FreeRTOS application

.data

FreeRTOS initialized read-write data

DTCMRAM, size is defined by a specific FreeRTOS application

.bss

FreeRTOS non-initialized read-write data

RAM_D1, size is defined by a specific FreeRTOS application

Stack

FreeRTOS stack

DTCMRAM, size is 0x400, grows upwards

Task Stack

FreeRTOS task stack

RAM_D1, size is defined by a specific FreeRTOS application

Heap

FreeRTOS heap

RAM_D1, size is defined at build time as configTOTAL_HEAP_SIZE

UBIFS ABI table

Table of UBI/UBIFS ABI entry points provided by U-Boot for RTOS

ICTM, 0x00000000, 1KB

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

sdram_test <ptrn> <ptrn> <size>

Write a certain ptrn to a size region in SDRAM, starting at 4MB offset, validate that the read-back data matches the pattern written. Command completes silently, unless an error is detected.

...