Hi NXP.
I use S32K311, RTD 3 to erase flash by using C40.
When I do some erase operation, the flash failed to be erased and triggered a hardfault
I added some debug messages in the C40_Ip_MainInterfaceSectorErase like the below:
We can see that when:
/* start internal erase/program sequence */
C40_Ip_pFlashBaseAddress->MCR |= FLASH_MCR_EHV_MASK; is executed,
Hardfault is triggered directly.
Sometimes, I step through debugging, step by step execution, but will erase successfully, will not trigger the hardfault error,
Is there a correct way to erase FLASH?
已解决! 转到解答。
It is apparetnly RWW issue. You must execute the code from different block or from internal SRAM as it is the same partition
If I set the PFLASH's .ld address to be in Block 0(512KB), such as use 200KB.
Then erase the remaining addresses, triggering an HardFault.
at the same time, If I erase the Block 1, everything is ok.
How to solve this condition?
The application scenario is that the Bootloader needs to erase the Flash address of the App
The application scenario is that the boot program erases the app part, so the boot code and the app code will be in Block0, but in the same Block, erasing the App in the Boot will trigger hardfault
See this pic: