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

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

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

跳至解决方案
1,934 次查看
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.

标记 (1)
0 项奖励
回复
1 解答
1,879 次查看
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

 

在原帖中查看解决方案

3 回复数
1,889 次查看
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 项奖励
回复
1,880 次查看
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,912 次查看
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 项奖励
回复