S32K311 The FLASH failed to be erased AND a HardFault_Handler occurred

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

S32K311 The FLASH failed to be erased AND a HardFault_Handler occurred

跳至解决方案
2,485 次查看
EvaKi
Contributor I

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

EvaKi_0-1724979161082.png

 

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?

EvaKi_1-1724979192706.png

EvaKi_2-1724979244040.png

EvaKi_3-1724979313091.png

 

0 项奖励
回复
1 解答
2,289 次查看
davidtosenovjan
NXP TechSupport
NXP TechSupport

It is apparetnly RWW issue. You must execute the code from different block or from internal SRAM as it is the same partition

davidtosenovjan_1-1725965798253.png

 

 

 

在原帖中查看解决方案

0 项奖励
回复
12 回复数
660 次查看
dujunqiu
Contributor I

hello,  must use 2 block?

0 项奖励
回复
2,251 次查看
EvaKi
Contributor I
0 项奖励
回复
2,454 次查看
davidtosenovjan
NXP TechSupport
NXP TechSupport

Do you have disabled cache?

0 项奖励
回复
2,411 次查看
EvaKi
Contributor I

Hi @davidtosenovjan 

There are different caches that I had disabled.

This will still trigger Hardfault

EvaKi_3-1725239399560.png

 

 

1. #define C40_IP_SYNCRONIZE_CACHE (STD_OFF)

EvaKi_0-1725239151652.png

2. #define CACHE_IP_IS_AVAILABLE                        STD_OFF

EvaKi_1-1725239235153.pngEvaKi_2-1725239343798.png

 

0 项奖励
回复
2,378 次查看
EvaKi
Contributor I

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

0 项奖励
回复
2,462 次查看
EvaKi
Contributor I

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

 

 

EvaKi_0-1724995839787.png

 

 

0 项奖励
回复
2,341 次查看
davidtosenovjan
NXP TechSupport
NXP TechSupport

Don't you execute this code from the same block you are trying to erase?

0 项奖励
回复
2,338 次查看
EvaKi
Contributor I

Hi @davidtosenovjan 

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:

EvaKi_0-1725608585305.png

 

0 项奖励
回复
2,290 次查看
davidtosenovjan
NXP TechSupport
NXP TechSupport

It is apparetnly RWW issue. You must execute the code from different block or from internal SRAM as it is the same partition

davidtosenovjan_1-1725965798253.png

 

 

 

0 项奖励
回复
659 次查看
dujunqiu
Contributor I
hello,which doc is this? i want to learn more
0 项奖励
回复
2,260 次查看
EvaKi
Contributor I

Hi @davidtosenovjan 

Thanks for your support.

0 项奖励
回复
2,481 次查看
EvaKi
Contributor I

Erased area is PFLASH

0 项奖励
回复