Advice on using PRIVILEGED_FUNCTION & PRIVILEGED_DATA To allocate FreeRTOS to Specified RAM


Just looking for a little advice on memory allocation.

I am using an STM32H7 processor with ITCM and DTCM ram. I am looking for speed and so I wish to put critical code in ITCM and critical data in DTCM.

I am setting up the MPU outside of the operating system and don’t wish to use FreeRTOS MPU features.

I had a look at the mpu_wrappers.h file and noticed the following code:

	#define portUSING_MPU_WRAPPERS 0

I figured that if I do the following in this file then functions would be placed in ITCM and data would be placed in DTCM.

#define USE_DTCM __attribute__((section (".DTCM_MISC")))
//#define USE_DTCM

#define USE_ITCM __attribute__((section(".ITCM_SECTION")))
//#define USE_ITCM

	#define PRIVILEGED_DATA              USE_DTCM
	#define portUSING_MPU_WRAPPERS 0

Where .ITCM_MISC and .DTCM_MISC are the definitions for the two memory regions as defined in the GCC linker script.

Is this method going to achieve my objective?

Is there a better way of doing it? In other words what would a real programmer do not a hacker like me?

Best regards

You can control placement using your linker script. That would be better as you would not need to modify source.

This link might be helpful -How to put functions from one object file to one special section and memory region for GCC linker? - Stack Overflow


Do you mean use the PRIVLEDGED_DATA as the section name in the linker script?


I mean use the file name to control the placement. For example, something like the following to place all the symbols from tasks.c to ITCM:

.itcm_text : {
}  > ITCM