2025-05-28 9:23 AM - last edited on 2025-05-28 10:07 AM by Andrew Neil
2025-05-28 10:52 AM
Describe the memory regions in your linker script or scatter file.
Use compiler directives say attributes or pragmas to direct specific code, or buffers to use the memory.
Code in specific source files, via object file, can be directed via linker scripts
A for filling/preloading DTCM, for GNU/GCC you'd need to add initialization code in startup.s and staging via the linker script, in a similar manner to how statics are handled for RAM from FLASH
2025-05-28 9:29 AM
Solved: Using ITCM and DTCM memories - STMicroelectronics Community
2025-05-28 10:02 AM
Thank you,
I know that is very important to understand the MPU architecture, but what I need to know is:
in what way can I insert in my project some lines of code that make that type of memory (DTCM, ITCM,...) usage available to my project.
2025-05-28 10:38 AM
You would do this in the Linker script (the .ld file, for CubeIDE) rather than in the code.
The thread @TDK linked says, "See also X-CUBE-PERF-H7 (related to the said application note) how linker files are implemented" ...
2025-05-28 10:52 AM
Describe the memory regions in your linker script or scatter file.
Use compiler directives say attributes or pragmas to direct specific code, or buffers to use the memory.
Code in specific source files, via object file, can be directed via linker scripts
A for filling/preloading DTCM, for GNU/GCC you'd need to add initialization code in startup.s and staging via the linker script, in a similar manner to how statics are handled for RAM from FLASH
2025-05-28 11:29 AM
I will be looking into Andrew's suggestion as well. But, in the mean time if you just want to see how you can improve the speed of a routine you can use the attribute prior to the routine:
/*
* @brief ADE9430 Initialization.
* @PAram hspi : pointer to a SPI_HandleTypeDef structure that contains
* the configuration information for SPI module.
* @return 0 (HAL_OK) in case of success, error code otherwise.
*/
__attribute__((section(".ITCM_Section")))
int ade9430_init(SPI_HandleTypeDef *hspi_pq, SPI_HandleTypeDef *hspi_s2, SPI_HandleTypeDef *hspi_s1)
{
and, of course your linker script would have to refer to the ITCM memory as .ITCM_Section
.ARM.attributes 0 : { *(.ARM.attributes) }
/* Unitialized ITCM section into "ITCM" ITCM type memory [MMT section] */
.ITCM_Section :
{
. = ALIGN(4);
KEEP (*(.ITCM_Section))
. = ALIGN(4);
} >ITCM
.dtcm_data :
{
. = ALIGN(4);
*(.dtcm_data) /* Include data */
. = ALIGN(4);
} AT> DTCM
when I did this and looking at the routine on a logic analyzer, before and after using ITCM I
saw a vast improvement.
Still struggling with DTCM but still plan to use it. I'm not able to get more than 64K specified and I
used the following to put data in the DTCM area:
volatile uint8_t __attribute__((section (".dtcm_data"))) __attribute__((aligned(32))) gShadowPQ_WFB[SIZE_ADE9430_uC_WFB] = {1, 2, 3, 4, 5, 6, 7, 8};
2025-05-29 12:26 AM
GREAT !
I've used the "attribute section" and it works good:
float32_t accL[6000] __attribute__((section("DTCMRAM")));
float32_t accR[6000] __attribute__((section("DTCMRAM")));
float32_t float_buffer_L[6000] __attribute__((section("DTCMRAM")));
float32_t float_buffer_R[6000] __attribute__((section("DTCMRAM")));
the four buffers seem to be placed in the DTCMRAM area:
arm-none-eabi-size MedAudioDev.elf
text data bss dec hex filename
211572 96220 181092 488884 775b4 MedAudioDev.elf
Finished building: default.size.stdout
even if it doesn't appear in the Build Analyzer...
Thank you