cancel
Showing results for 
Search instead for 
Did you mean: 

Placing HAL functions into ITCM RAM

APaus.1
Associate II

Hello,

Is there a simple way how to tell CubeMX to place HAL drivers (all or selected modules) into ITCM RAM instead of FLASH? Or it is possible only by manual writing directive to each function?

If manual way is the only one, is it at least possible to tell CubeMX to keep directives when re-generating project code?

 

Thank you in advance.

 

Anton

1 ACCEPTED SOLUTION
4 REPLIES 4
bbee
Associate III

I think you have to modify your linker file. If you use IAR you can try to use the linker 'place in' directive like described here:

https://www.iar.com/knowledge/support/technical-notes/linker/how-do-i-place-a-group-of-functions-or-variables-in-a-specific-section/



define symbol __ICFEDIT_region_ITCMR_start__ = 0x00000000;
define symbol __ICFEDIT_region_ITCMR_end__ = 0x0000FFFF;
define region ITCMR_region = mem:[from __ICFEDIT_region_ITCMR_start__ to __ICFEDIT_region_ITCMR_end__ ];

place in ITCMR_region { readonly object STM32H7xx_HAL_*.o };


According to the IAR linker manual the object keyword allows to use wildcards like STM32H7xx_HAL_*.o

APaus.1
Associate II

Unfortunately I'm using STM32CubeIDE. Is something similar possible also for GCC?

APaus.1
Associate II

Thanks a lot. This will make it much simpler. 

I have one additional question. So far I used directive: __attribute__((section(".itcm_text")))  in front of definition of each function I wanted to put into ITCMRAM. In linker script I have following:

/* Copy specific fast-executing code to ITCM RAM */
itcm_data = LOADADDR(.itcm_text);

.itcm_text :
{
. = ALIGN(4);
itcm_text_start = .;
*(.itcm_text)
*(.itcm_text*)
. = ALIGN(4);
itcm_text_end = .;
} >ITCM_RAM AT> FLASH

 

To add whole files I extended the script:

 

/* Copy specific fast-executing code to ITCM RAM */
itcm_data = LOADADDR(.itcm_text);

.itcm_text :
{
. = ALIGN(4);
itcm_text_start = .;
*(.itcm_text)
*(.itcm_text*)

./Target/build/file1.o (.text .text*)
./Target/build/file2.o (.text .text*)
./Target/build/file3.o (.text .text*)
./Target/build/file4.o (.text .text*)


. = ALIGN(4);
itcm_text_end = .;
} >ITCM_RAM AT> FLASH

 

Should I remove  __attribute__((section(".itcm_text"))) in files placed in linker script? I can I keep it? 

Thank you in advance