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?
Solved! Go to Solution.
It is apparetnly RWW issue. You must execute the code from different block or from internal SRAM as it is the same partition
hello, must use 2 block?
Do you have disabled cache?
There are different caches that I had disabled.
This will still trigger Hardfault
1. #define C40_IP_SYNCRONIZE_CACHE (STD_OFF)
2. #define CACHE_IP_IS_AVAILABLE STD_OFF
I have done double verification, the area to be erased is indeed unlocked, so there should be no area to be erased is protected or the unlock fails, resulting in Hardfault error when erasing
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
Don't you execute this code from the same block you are trying to erase?
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:
It is apparetnly RWW issue. You must execute the code from different block or from internal SRAM as it is the same partition
Thanks for your support.
Erased area is PFLASH