[S32K344] Hard Fault while Flash Erase Operation

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

[S32K344] Hard Fault while Flash Erase Operation

1,462 Views
enthuCutlet
Contributor II

As discussed in this post https://community.nxp.com/t5/S32K/S32K312-HardFault-issue-while-quot-sector-erase-quot/m-p/1465331#M... I have copied the functions in ITCM this way 

enthuCutlet_0-1719321577992.png

But after this I was still getting hard-faults on flash erase operation sometimes. What makes it hard to debug is that sometimes it erases successfully but sometimes it ends up in hardfault, specifically in the 

C40_Ip_MainInterfaceSectorEraseStatus() function. 

enthuCutlet_1-1719321839906.png

Another point to consider is that in my Mem_43_InFls_MemMap.h file MEM_43_INFLS_START_SEC_CODE macro was defined. in the header file we see that there is a compiler directive #pragma arm section code=".mcal_text". I'm copying the c40 drivers in ITCM but since I havent changed this macro could this be causing a problem? If yes then why does this not lead to hard fault every time and only happens intermittently on some erase operations.

enthuCutlet_3-1719322553015.png

 

Once in the hardfault handler, the LR has an address of 0xffffffe9 which is some invalid address. 

Later, I came across this post https://community.nxp.com/t5/S32K/ramcode-section-not-used-when-optimization-level-lt-O2/m-p/1834242 where the contributor has mentioned that #define MEM_43_INFLS_START_SEC_CODE needs to be replaced with #define MEM_43_INFLS_START_SEC_RAMCODE and similarly for STOP. And inside the Mem_43_InFls_MemMap.h file I have replaced the #pragma directive from ".ramcode" to ".itcm_text" since I am copying the C40 functions into the ITCM. 

enthuCutlet_2-1719322227719.png

When I do this I no longer get hardfaults and the flash erase operation works fine. 

 

0 Kudos
Reply
1 Reply

1,434 Views
danielmartynek
NXP TechSupport
NXP TechSupport

Hi @enthuCutlet,

It was discussed here:

https://community.nxp.com/t5/S32K/S32K344-C40-IP-Hardware-Fault-Problem/m-p/1697432

As you mentioned, by default, the code is placed to .ramcode but it can be modified.

 

You can check the location of the functions in the .map file.

 

BR, Daniel

0 Kudos
Reply