Hi
I know this post is old, but it came up in my search of a similar topic so I thought I would post this as it might be useful for someone.
I put static FreeRTOS objects in DTCM routinely.
I use a #if switch to set them to DTCM or axi. so it I am using a processor without any or a lot of DTCM I can easily switch. When using the STM32H7 family employing the DTCM is a bit of a no brainer.
An example is:
#define USE_DTCM_RAM_FOR_WIFI_TASK 1
/* RTOS Objects */
#define STACK_SIZE_START_WIFI_TASK 512
#define STACK_SIZE_WIFI_TASK 512
#if(USE_DTCM_RAM_FOR_WIFI_TASK == 1)
StackType_t __attribute__((section (".DTCM_MISC"))) startWiFiTaskStack[STACK_SIZE_START_WIFI_TASK];
StaticTask_t __attribute__((section (".DTCM_MISC"))) startWiFiTskBuffer = {NULL};
StackType_t __attribute__((section (".DTCM_MISC"))) wiFiTaskStack[STACK_SIZE_WIFI_TASK];
StaticTask_t __attribute__((section (".DTCM_MISC"))) wiFiTskBuffer = {NULL};
TaskHandle_t __attribute__((section (".DTCM_MISC"))) startWiFiTskHandle = {NULL};
TaskHandle_t __attribute__((section (".DTCM_MISC"))) wiFiTskHandle = {NULL};
SemaphoreHandle_t __attribute__((section (".DTCM_MISC"))) wiFiReadySemHandle = {NULL};
StaticSemaphore_t __attribute__((section (".DTCM_MISC"))) wiFiReadySemBuff = {NULL};
volatile bool __attribute__((section (".DTCM_MISC"))) validWiFiRouterConn = false;
#else
StackType_t startWiFiTaskStack[STACK_SIZE_START_WIFI_TASK];
StaticTask_t startWiFiTskBuffer = {NULL};
StackType_t wiFiTaskStack[STACK_SIZE_WIFI_TASK];
StaticTask_t wiFiTskBuffer = {NULL};
TaskHandle_t startWiFiTskHandle = {NULL};
TaskHandle_t wiFiTskHandle = {NULL};
SemaphoreHandle_t wiFiReadySemHandle = {NULL};
StaticSemaphore_t wiFiReadySemBuff;
volatile bool validWiFiRouterConn = false;
#endif
As you can see I also pop other variables in: validWiFiRouterConn
The linker script:
/* Memories definition */
MEMORY
{
FIR_FILT_DW (xrw) : ORIGIN = 0x20000000, LENGTH = 4K
DTCM_MISC (xrw) : ORIGIN = 0x20001000, LENGTH = 120K
DTC_STACK (xrw) : ORIGIN = 0x20010000, LENGTH = 4K
...
.DTCM_MISC : {
. = ALIGN(4);
_sDTCM_MISC = .;
__sDTCM_MISC__ = _sDTCM_MISC;
*(.DTCM_MISC)
. = ALIGN(4);
_eDTCM_MISC = .;
__eDTCM_MISC__ = _eDTCM_MISC;
} >DTCM_MISC
You have to be careful with initialisation of the DTCM and make sure you set the variables to zero explicitly, or add a zero fill in your start up. I didn’t do this and I ended up with a Hard fault: Silly me. i.e.
/* Start and end of miscellaneous DTCM */
.word _sDTCM_MISC
.word _eDTCM_MISC
/* Do next segment */
ldr r2, = _sDTCM_MISC
b LoopFill_DTCM
/* Zero fill the DTCM segment. */
Fill_DTCM:
movs r3, #0
str r3, [r2], #4
LoopFill_DTCM:
ldr r3, = _eDTCM_MISC
cmp r2, r3
bcc Fill_DTCM
/* Do next segment */
ldr r2, = _sbss
b LoopFillZerobss
/* Zero fill the bss segment. */
FillZerobss:
movs r3, #0
str r3, [r2], #4
I hope someone finds this useful.
I’m not sure that it speeds things up all that much. I haven’t tested it, but it seems a waste not to use the DTCM as it doesn’t load up memory cache and frees up some of the AXI ram. The STM32H7B3I has 128 k of DTCM and it costs nothing to use it.
What’s not to like?
Regards
Rob