FreeRTOS+MPU for CORTEXM4 - Linker script problem


For my project, I am testing freeRTOS with MPU on STM32G4XX processor.
I would like to give a one task statically allocated memory on defined addresses in RAM.
Example : Task1 Given RAM memory in range : 0x2000 0000 - 0x2000 0800 LEN=2K

I have generated code with STM32CubeMx with freeRTOS v10.2.1.
I have replaced generated files port.c and portmacro.h with files from STM32Cube_FW_G4_V1.2.0\Middlewares…\freeRTOS\GCC\ARM_CM4_MPU.

I have also added file mpu_wrappers. c.
Linker file is changed and pieces of code below are added.
In STM32 generated linker script added:
_Privileged_Functions_Region_Size = 2K;
_Privileged_Data_Region_Size = 1K;

FLASH_segment_start = ORIGIN( FLASH ) + 1024;
FLASH_segment_end = FLASH_segment_start + LENGTH( FLASH );
privileged_functions_start = ORIGIN( FLASH );
privileged_functions_end = privileged_functions_start + _Privileged_Functions_Region_Size;
SRAM_segment_start = ORIGIN( RAM );
SRAM_segment_end = SRAM_segment_start + LENGTH( RAM );
privileged_data_start = ORIGIN( RAM );
privileged_data_end = ORIGIN( RAM ) + _Privileged_Data_Region_Size;
/* User_heap_stack section, used to check that there is enough “RAM” Ram type memory left /
.privileged_functions :
With this added, privileged data is not defined.

I am trying to test xCreateRestrictedStatic function.
Can you please provide me some instructions how to write linker file so this function could work ?

Thanks in advance,

Here is the book chapter on the subjet:

Here are some examples in the FreeRTOS download:

(there are other demos too).

Hope that helps.

1 Like