When debugging the S32K396 with S32DS 3.6.3 and RTD 6.0.0, I encountered a hardfault issue while testing the official Flash operation routine. Here is the situation:
If I set the program's pflash address to int_pflash : ORIGIN = 0x00400000, LENGTH = 0x00100000, then using C40_Ip_MainInterfaceSectorErase to erase the range 0x00500000 to 0x00502000 results in a hardfault. Erasing 0x005FE000 to 0x00600000 also causes a hardfault. However, erasing 0x00600000 to 0x00602000 works fine.
I tried placing the C40_Ip_MainInterfaceSectorErase function into the int_sram_fls_rsv : ORIGIN = 0x2045EF00, LENGTH = 0x00001000 section, but the hardfault still occurred. The issue was only resolved after I moved the main function into the int_sram_fls_rsv section as well.
Why is this happening? The erase sector size for S32K396 is 0x2000, but in practice, it seems erasing within a 0x00200000 length is not consistently allowed. I haven't found any documentation describing this behavior. Could there be a configuration issue on my end? I am using the C40_IP_Example_S32K396 example project.