Hello NXP team,
I want to place my ISR callback function to ITCM memory of S32K344 MCU. I've used the __attribute__ directive in order to put myISRfunction to ITCM memory.
But after checking the .map file after the build I've noticed that my function is put to flash memory instead of itcm.
1. Is there any example of how to use the itcm memory ?
2. Can you provide me with any documentation regarding this matter except the reference manual ? Is there any ppt file regarding itcm memory ?
Kind regards,
kyf
Hello @lukaszadrapa .
Does anything comes to your mind that can affect the build at that stage ? If I remove those sections from the linker file and from the startup_cm7 file my project compiles as it should.
Kind regards,
kyf
Hi @kyf
the only idea I have is that some "start" or "end" address has wrong value. But I can't see that in your linker/startup. Just shoot from the hip - I guess you tried to clean the project, right?
Regards
Lukas
Hello @lukaszadrapa .
the only idea I have is that some "start" or "end" address has wrong value. But I can't see that in your linker/startup.
I know, I've thoroughly searched for any mistype or something that could possibly gone wrong but everything seems to be fine.
I guess you tried to clean the project, right?
Yeah, I've done it and I've tried changing optimization level also, but it did not workout.
I'm starting to believe that something else not related with the linker is causing the problem. Something that runs before the linker but I'm not familiar with all the commands and the utilities that run in order to build the project.
Kind regards,
kyf
Hello @lukaszadrapa again !
I've tested what you've suggested into my code and the error that I'm getting is this:
Have you ever anticipated this ?
I'm uploading the linker file and my startup. I've confirmed that there are no diffs with the one that you've used with winmerge software.
Kind regards,
kyf
Hi @kyf ,
I can't see a reason for this. Do you have whole project which could be shared with me to replicate it?
Regards,
Lukas
Hello @lukaszadrapa . Thank you for your quick response to my question.
I've tried your suggestion,
And I've declared my function with the attribute directive.
I've seen in the .map file that my functions are stored in the ITCM memory section.
But when I run my program I get an hard fault error. And the message that I get from the debugger is this:
My ISR callback is the first function running inside EMIOS0_4_IRQ() ISR.
I've checked the memory that my function supposed to be stored and there is nothing there. The whole ITCM memory section is set to 0 (as it is after the startup code initialization).
Do I have to do anything else in order for my code to run inside the ITCM?
Kind regards,
kyf
Aah, OK, sorry, that's solution for flash, not for RAM / ITCM. When using this way, the code is compiled for these addresses, but it's not copied to the RAM. It's either necessary to copy the code manually or to force startup code via linker file to do that automatically - which is better option, of course. I don't know this from top of my head, let me check this later today or tomorrow.
Regards,
Lukas
Good morning @lukaszadrapa .
I need also to move my vector table to ITCM memory in order to avoid cache maintainance as mentioned in the chapter 5.4 at S32K344 RM.
Has this to be done also at the startup code ? If yes how can I do this? Can you please provide me any assistance with this (documentation or any resource regarding this) ?
Kind regards,
kyf
Hi @kyf
attached is working example.
For more details about linker syntax, see please this document:
c:\NXP\S32DS.3.4\S32DS\build_tools\gcc_v10.2\gcc-10.2-arm32-eabi\arm-none-eabi\share\docs\pdf\ld.pdf
What is necessary to do:
Define section like this in the linker file. You can use .shareable_data as a template for itcm. "AT" directive is important.
Second step - define the RAM and ROM addresses which will be used for copy-down:
Next step - update the init_table. Add one more entry like this and increase the entries count:
Then use the attribute for some function:
And now it works:
It will the same for interrupt vector table. By default, it's in normal RAM. Just remove it from the RAM and add it to the ITCM.
Hope this helps.
Regards,
Lukas
Thank you @lukaszadrapa I will test your suggestion and I will be back with feedback !
Kind regards,
kyf
Hi @kyf
the problem is that int_itcm is defined in MEMORY section in the linker file but there's no further definition in SECTIONS. You need to add something like this to SECTIONS:
.int_itcm_code :
{
KEEP(*(int_itcm_code))
} > int_itcm
And then:
__attribute__ ((section(".int_itcm_code")))
void test(void)
{
}
Now the function will be forced to itcm.
Regards,
Lukas