How can I put my callback function into ITCM memory ? S32K344

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How can I put my callback function into ITCM memory ? S32K344

2,194 Views
kyf
Contributor V

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.

kyf_0-1674486735906.png

But after checking the .map file after the build I've noticed that my function is put to flash memory instead of itcm.

kyf_1-1674486891794.png

 

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

 

0 Kudos
Reply
11 Replies

1,991 Views
kyf
Contributor V

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

0 Kudos
Reply

1,972 Views
lukaszadrapa
NXP TechSupport
NXP TechSupport

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

0 Kudos
Reply

1,965 Views
kyf
Contributor V

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

 

0 Kudos
Reply

2,052 Views
kyf
Contributor V

Hello @lukaszadrapa again !

I've tested what you've suggested into my code and the error that I'm getting is this:

kyf_0-1675270851091.png

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

0 Kudos
Reply

2,020 Views
lukaszadrapa
NXP TechSupport
NXP TechSupport

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

0 Kudos
Reply

2,160 Views
kyf
Contributor V

Hello @lukaszadrapa . Thank you for your quick response to my question.

I've tried your suggestion,

kyf_0-1674644772741.png

And I've declared my function with the attribute directive.

kyf_6-1674645752933.png

I've seen in the .map file that my functions are stored in the ITCM memory section.

kyf_2-1674645343818.png

But when I run my program I get an hard fault error. And the message that I get from the debugger is this:

kyf_4-1674645633301.png

My ISR callback is the first function running inside EMIOS0_4_IRQ() ISR.

kyf_3-1674645605122.png   kyf_5-1674645697490.png

 

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

 

0 Kudos
Reply

2,148 Views
lukaszadrapa
NXP TechSupport
NXP TechSupport

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

0 Kudos
Reply

2,128 Views
kyf
Contributor V

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.

kyf_0-1674812884443.png

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

0 Kudos
Reply

2,122 Views
lukaszadrapa
NXP TechSupport
NXP TechSupport

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.

lukaszadrapa_0-1674817906402.png

Second step - define the RAM and ROM addresses which will be used for copy-down:

lukaszadrapa_1-1674817983828.png

Next step - update the init_table. Add one more entry like this and increase the entries count:

lukaszadrapa_2-1674818061791.png

Then use the attribute for some function:

lukaszadrapa_3-1674818094736.png

And now it works:

lukaszadrapa_4-1674818126698.png

 

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

0 Kudos
Reply

2,119 Views
kyf
Contributor V

Thank you @lukaszadrapa I will test your suggestion and I will be back with feedback !

 

Kind regards,

kyf

0 Kudos
Reply

2,173 Views
lukaszadrapa
NXP TechSupport
NXP TechSupport

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.

https://community.nxp.com/t5/S32-Design-Studio-Knowledge-Base/HOWTO-Place-custom-data-into-flash-mem...

Regards,

Lukas

 

0 Kudos
Reply