[S32K144 EVB] Call a function on RAM from a function at Flash

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

[S32K144 EVB] Call a function on RAM from a function at Flash

Jump to solution
1,118 Views
AndersonStarling
Contributor I

Hi everyone, 

I set Fls_Erase function at RAM(address: 0x1fff8188), and I use Fls_Init_Node_Data at Flash(address: 0x674) call this function.

AndersonStarling_1-1643639065157.png

- However, once I call Fls_Erase from Fls_Init_Node_Data , the system crash and a WDOG fault exception executes.

AndersonStarling_7-1643639962621.png

 

- I try to move Fls_Init_Node_Data to RAM too, my system work normally. So, I think that Fls_Init_Node_Data call Fls_Erase at a far distance address. I also check assembly code: Fls_Erase is called by BL command(range +- 32MB).

AndersonStarling_5-1643639552419.png

 

AndersonStarling_3-1643639421446.png

- So, I would like to know how to call a RAM function from Flash. To do this, do we use a compiler option or another solution?

I hope I give your answer soon, thank you.

Tags (1)
0 Kudos
1 Solution
1,063 Views
danielmartynek
NXP TechSupport
NXP TechSupport

Hi @AndersonStarling,

I'm not sure how did you place the functions to .code section.

But it must be in .code_ram section.

Becasue the startup code (startup.c) copies the functions from ROM (flash) to SRAM after every reset, so that it can be called in the application from SRAM.

danielmartynek_0-1644318651739.png

 

Regards,

Daniel

 

View solution in original post

3 Replies
1,073 Views
AndersonStarling
Contributor I

Hi @danielmartynek

Yes, Fls_Erase() function is a blocking function that waits until the flash operation is complete in SRAM

I located Fls_Erase to ".code_ram" section instead of ".code" section, everything worked normally. Setting the function to ".code" section is the cause that led to my fault.

Map file in case function to ".code_ram" section:

AndersonStarling_0-1644249812725.png

Map file in case function to ".code" section(fault exception occurs)

AndersonStarling_1-1644249847749.png

My linker knowledge is small. So could you explain for me a little bit about ".code" and ".code_ram" sections in the linker script?

I attached my linker script to the topic that you could review.

Thank you,

0 Kudos
1,064 Views
danielmartynek
NXP TechSupport
NXP TechSupport

Hi @AndersonStarling,

I'm not sure how did you place the functions to .code section.

But it must be in .code_ram section.

Becasue the startup code (startup.c) copies the functions from ROM (flash) to SRAM after every reset, so that it can be called in the application from SRAM.

danielmartynek_0-1644318651739.png

 

Regards,

Daniel

 

1,096 Views
danielmartynek
NXP TechSupport
NXP TechSupport

Hello @AndersonStarling,

Can you please specify what driver do you use?

Is the Fls_Erase() function in SRAM a blocking function that waits until the flash operation is complete?

If so, it does not matter where the function that calls Fls_Erase() is located.

 

Regards,

Daniel

 

0 Kudos