2025-03-21 5:55 AM - last edited on 2025-03-21 10:10 AM by Andrew Neil
We are looking to up the performance on our system by moving some code into ITCM RAM. I have updated my link file and am able to get a single custom function executing out of ITCM RAM. The function prints its address, so I know its running out of ITCM RAM. My method has been to place the functions for ITCMRAM into their own flash space, that gets copied to ITCM RAM at start of main.
However, if I put any more functions also into ITCM RAM, I get a bad instruction hard fault. Are there any WORKING examples of using ITCM RAM and/or any documentation to support moving functions into ITCM ram?
2025-03-21 6:15 AM
ITCM accesses should be 32-bit aligned. If not, it could cause hard faults.
2025-03-21 6:40 AM
I am placing functions using
#define IN_RAM __attribute__((section(".itcm_text")))
And the linker file has alignment settings.
__itcm_flash_base__ = LOADADDR(.itcm_text);
.itcm_text : ALIGN_WITH_INPUT
{
. = ALIGN(4);
PROVIDE(__itcm_text_base_ram__ = .);
/* *(.ramfunc.$ITCM_RAM) */
KEEP(*(.itcm_text*))
KEEP(*(.bss.__itcm_text_*))
KEEP(*lld.o (.text*))
. = ALIGN(4);
PROVIDE(__itcm_text_end_ram__ = .);
} >ITCM_RAM AT> APP_CODE
I think the alignment should be fine?
2025-03-21 9:56 AM - edited 2025-03-21 9:56 AM
> The function prints its address, so I know its running out of ITCM RAM.
It's running out of ITCM RAM so your linker is probably correct and copying the function over probably works. Are you sure it's not an issue specific to the functions you're using? Can you step through and see precisely where it hard faults?
I don't see any examples which load functions into itcmram, but examples suggest the functionality is there with "#pragma location = ".itcmram".
I don't see a reason to suspect alignment issues. That sounds like ChatGPT advice.