Skip to main content
APaus.1
Associate II
April 19, 2024
Solved

Placing HAL functions into ITCM RAM

  • April 19, 2024
  • 4 replies
  • 2505 views

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

    This topic has been closed for replies.

    4 replies

    bbee
    Senior
    April 19, 2024

    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
    APaus.1Author
    Associate II
    April 19, 2024

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

    bbee
    bbeeBest answer
    Senior
    April 19, 2024
    APaus.1
    APaus.1Author
    Associate II
    April 29, 2024

    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