S32K311 The FLASH failed to be erased AND a HardFault_Handler occurred

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

S32K311 The FLASH failed to be erased AND a HardFault_Handler occurred

Jump to solution
2,437 Views
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 Kudos
Reply
1 Solution
2,241 Views
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

 

 

 

View solution in original post

0 Kudos
Reply
12 Replies
612 Views
dujunqiu
Contributor I

hello,  must use 2 block?

0 Kudos
Reply
2,203 Views
EvaKi
Contributor I
0 Kudos
Reply
2,406 Views
davidtosenovjan
NXP TechSupport
NXP TechSupport

Do you have disabled cache?

0 Kudos
Reply
2,363 Views
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 Kudos
Reply
2,330 Views
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 Kudos
Reply
2,414 Views
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 Kudos
Reply
2,293 Views
davidtosenovjan
NXP TechSupport
NXP TechSupport

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

0 Kudos
Reply
2,290 Views
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 Kudos
Reply
2,242 Views
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 Kudos
Reply
611 Views
dujunqiu
Contributor I
hello,which doc is this? i want to learn more
0 Kudos
Reply
2,212 Views
EvaKi
Contributor I

Hi @davidtosenovjan 

Thanks for your support.

0 Kudos
Reply
2,433 Views
EvaKi
Contributor I

Erased area is PFLASH

0 Kudos
Reply