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
4,724 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
4,528 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
13 Replies
959 Views
久叶草
Contributor I

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.

Tags (3)
0 Kudos
Reply
2,899 Views
dujunqiu
Contributor I

hello,  must use 2 block?

0 Kudos
Reply
4,490 Views
EvaKi
Contributor I
0 Kudos
Reply
4,693 Views
davidtosenovjan
NXP TechSupport
NXP TechSupport

Do you have disabled cache?

0 Kudos
Reply
4,650 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
4,617 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
4,701 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
4,580 Views
davidtosenovjan
NXP TechSupport
NXP TechSupport

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

0 Kudos
Reply
4,577 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
4,529 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
2,899 Views
dujunqiu
Contributor I
hello,which doc is this? i want to learn more
0 Kudos
Reply
4,499 Views
EvaKi
Contributor I

Hi @davidtosenovjan 

Thanks for your support.

0 Kudos
Reply
4,720 Views
EvaKi
Contributor I

Erased area is PFLASH

0 Kudos
Reply
%3CLINGO-SUB%20id%3D%22lingo-sub-1943892%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3ES32K311%20The%20FLASH%20failed%20to%20be%20erased%20AND%20a%20HardFault_Handler%20occurred%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1943892%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EHi%20NXP.%3C%2FP%3E%3CP%3EI%20use%20S32K311%2C%20RTD%203%20to%20erase%20flash%20by%20using%20C40.%3C%2FP%3E%3CP%3EWhen%20I%20do%20some%20erase%20operation%2C%20the%20flash%20failed%20to%20be%20erased%20and%20triggered%20a%20hardfault%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22EvaKi_0-1724979161082.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22EvaKi_0-1724979161082.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3Cspan%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22EvaKi_0-1724979161082.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3Cimg%20src%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F296158i26D465395B501FCE%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22EvaKi_0-1724979161082.png%22%20alt%3D%22EvaKi_0-1724979161082.png%22%20%2F%3E%3C%2Fspan%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3EI%20added%20some%20debug%20messages%20in%20the%26nbsp%3BC40_Ip_MainInterfaceSectorErase%20like%20the%20below%3A%3C%2FP%3E%3CP%3EWe%20can%20see%20that%20when%3A%26nbsp%3B%3C%2FP%3E%3CP%3E%2F*%20start%20internal%20erase%2Fprogram%20sequence%20*%2F%3CBR%20%2F%3E%3CFONT%20color%3D%22%23FF9900%22%3E%3CSTRONG%3EC40_Ip_pFlashBaseAddress-%26gt%3BMCR%20%7C%3D%20FLASH_MCR_EHV_MASK%3B%3C%2FSTRONG%3E%3C%2FFONT%3E%26nbsp%3B%3CSTRONG%3Eis%20executed%2C%26nbsp%3B%3C%2FSTRONG%3E%3C%2FP%3E%3CP%3EHardfault%20is%20triggered%20directly.%3C%2FP%3E%3CP%3ESometimes%2C%20I%20step%20through%20debugging%2C%20step%20by%20step%20execution%2C%20but%20will%20erase%20successfully%2C%20will%20not%20trigger%20the%20hardfault%20error%2C%3C%2FP%3E%3CP%3EIs%20there%20a%20correct%20way%20to%20erase%20FLASH%3F%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22EvaKi_1-1724979192706.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22EvaKi_1-1724979192706.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3Cspan%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22EvaKi_1-1724979192706.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3Cimg%20src%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F296159i51F9A3A8B50411BD%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22EvaKi_1-1724979192706.png%22%20alt%3D%22EvaKi_1-1724979192706.png%22%20%2F%3E%3C%2Fspan%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22EvaKi_2-1724979244040.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22EvaKi_2-1724979244040.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3Cspan%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22EvaKi_2-1724979244040.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3Cimg%20src%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F296160iA57D14644F0520EB%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22EvaKi_2-1724979244040.png%22%20alt%3D%22EvaKi_2-1724979244040.png%22%20%2F%3E%3C%2Fspan%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22EvaKi_3-1724979313091.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22EvaKi_3-1724979313091.png%22%20style%3D%22width%3A%20203px%3B%22%3E%3Cspan%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22EvaKi_3-1724979313091.png%22%20style%3D%22width%3A%20203px%3B%22%3E%3Cimg%20src%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F296161i0C1DC88AC83206A4%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22EvaKi_3-1724979313091.png%22%20alt%3D%22EvaKi_3-1724979313091.png%22%20%2F%3E%3C%2Fspan%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%3CBR%20%2F%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2102381%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%E5%9B%9E%E5%A4%8D%EF%BC%9A%20S32K311%20The%20FLASH%20failed%20to%20be%20erased%20AND%20a%20HardFault_Handler%20occurred%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2102381%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3Ehello%EF%BC%8Cwhich%20doc%20is%20this%3F%20i%20want%20to%20learn%20more%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2102376%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3ERe%3A%20S32K311%20The%20FLASH%20failed%20to%20be%20erased%20AND%20a%20HardFault_Handler%20occurred%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2102376%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3Ehello%2C%26nbsp%3B%20must%20use%202%20block%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1951545%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%E5%9B%9E%E5%A4%8D%EF%BC%9A%20S32K311%20The%20FLASH%20failed%20to%20be%20erased%20AND%20a%20HardFault_Handler%20occurred%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1951545%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2FS32K%2FRWW-read-while-write%2Fm-p%2F1063397%22%20target%3D%22_blank%22%3ERWW%EF%BC%88read%20while%20write%EF%BC%89%20-%20NXP%20Community%3C%2FA%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1951542%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%E5%9B%9E%E5%A4%8D%EF%BC%9A%20S32K311%20The%20FLASH%20failed%20to%20be%20erased%20AND%20a%20HardFault_Handler%20occurred%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1951542%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EHi%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F52613%22%20target%3D%22_blank%22%3E%40davidtosenovjan%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThanks%20for%20your%20support.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1951050%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%E5%9B%9E%E5%A4%8D%EF%BC%9A%20S32K311%20The%20FLASH%20failed%20to%20be%20erased%20AND%20a%20HardFault_Handler%20occurred%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1951050%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EIt%20is%20apparetnly%20RWW%20issue.%20You%20must%20execute%20the%20code%20from%20different%20block%20or%20from%20internal%20SRAM%20as%20it%20is%20the%20same%20partition%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22davidtosenovjan_1-1725965798253.png%22%20style%3D%22width%3A%20639px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22davidtosenovjan_1-1725965798253.png%22%20style%3D%22width%3A%20639px%3B%22%3E%3Cspan%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22davidtosenovjan_1-1725965798253.png%22%20style%3D%22width%3A%20639px%3B%22%3E%3Cimg%20src%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F298265i64976C611E98750B%2Fimage-dimensions%2F639x61%3Fv%3Dv2%22%20width%3D%22639%22%20height%3D%2261%22%20role%3D%22button%22%20title%3D%22davidtosenovjan_1-1725965798253.png%22%20alt%3D%22davidtosenovjan_1-1725965798253.png%22%20%2F%3E%3C%2Fspan%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CBR%20%2F%3E%0A%3CBR%20%2F%3E%0A%3CBR%20%2F%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1948859%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%E5%9B%9E%E5%A4%8D%EF%BC%9A%20S32K311%20The%20FLASH%20failed%20to%20be%20erased%20AND%20a%20HardFault_Handler%20occurred%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1948859%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EHi%20%3CA%20href%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F52613%22%20target%3D%22_blank%22%3E%40davidtosenovjan%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThe%20application%20scenario%20is%20that%20the%20boot%20program%20erases%20the%20app%20part%2C%20so%20the%20boot%20code%20and%20the%20app%20code%20will%20be%20in%20Block0%2C%20but%20in%20the%20same%20Block%2C%20erasing%20the%20App%20in%20the%20Boot%20will%20trigger%20hardfault%3C%2FP%3E%3CP%3ESee%20this%20pic%3A%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22EvaKi_0-1725608585305.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22EvaKi_0-1725608585305.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3Cspan%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22EvaKi_0-1725608585305.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3Cimg%20src%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F297548iA64CC15E306F0602%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22EvaKi_0-1725608585305.png%22%20alt%3D%22EvaKi_0-1725608585305.png%22%20%2F%3E%3C%2Fspan%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%3CBR%20%2F%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1948839%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%E5%9B%9E%E5%A4%8D%EF%BC%9A%20S32K311%20The%20FLASH%20failed%20to%20be%20erased%20AND%20a%20HardFault_Handler%20occurred%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1948839%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EDon't%20you%20execute%20this%20code%20from%20the%20same%20block%20you%20are%20trying%20to%20erase%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1945923%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3ERe%3A%20S32K311%20The%20FLASH%20failed%20to%20be%20erased%20AND%20a%20HardFault_Handler%20occurred%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1945923%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EI%20have%20done%20double%20verification%2C%20the%20area%20to%20be%20erased%20is%20indeed%20unlocked%2C%20so%20there%20should%20be%20no%20area%20to%20be%20erased%20is%20protected%20or%20the%20unlock%20fails%2C%20resulting%20in%20Hardfault%20error%20when%20erasing%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1944889%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3ERe%3A%20S32K311%20The%20FLASH%20failed%20to%20be%20erased%20AND%20a%20HardFault_Handler%20occurred%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1944889%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EHi%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F52613%22%20target%3D%22_blank%22%3E%40davidtosenovjan%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThere%20are%20different%20caches%20that%20I%20had%20disabled.%3C%2FP%3E%3CP%3EThis%20will%20still%20trigger%20Hardfault%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22EvaKi_3-1725239399560.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22EvaKi_3-1725239399560.png%22%20style%3D%22width%3A%20244px%3B%22%3E%3Cspan%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22EvaKi_3-1725239399560.png%22%20style%3D%22width%3A%20244px%3B%22%3E%3Cimg%20src%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F296410i0ACCDD98D2AB19D3%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22EvaKi_3-1725239399560.png%22%20alt%3D%22EvaKi_3-1725239399560.png%22%20%2F%3E%3C%2Fspan%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CP%3E%3CSTRONG%3E1.%26nbsp%3B%23define%20C40_IP_SYNCRONIZE_CACHE%20(STD_OFF)%3C%2FSTRONG%3E%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22EvaKi_0-1725239151652.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22EvaKi_0-1725239151652.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3Cspan%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22EvaKi_0-1725239151652.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3Cimg%20src%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F296407iBB386DFD3E7D12B3%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22EvaKi_0-1725239151652.png%22%20alt%3D%22EvaKi_0-1725239151652.png%22%20%2F%3E%3C%2Fspan%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSTRONG%3E2.%26nbsp%3B%3CSPAN%3E%23define%3C%2FSPAN%3E%20%3CSPAN%3ECACHE_IP_IS_AVAILABLE%3C%2FSPAN%3E%3CSPAN%3E%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3BSTD_OFF%3C%2FSPAN%3E%3C%2FSTRONG%3E%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22EvaKi_1-1725239235153.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22EvaKi_1-1725239235153.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3Cspan%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22EvaKi_1-1725239235153.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3Cimg%20src%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F296408iBADC4844F32CB7A2%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22EvaKi_1-1725239235153.png%22%20alt%3D%22EvaKi_1-1725239235153.png%22%20%2F%3E%3C%2Fspan%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22EvaKi_2-1725239343798.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22EvaKi_2-1725239343798.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3Cspan%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22EvaKi_2-1725239343798.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3Cimg%20src%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F296409i428EECBF9F22E793%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22EvaKi_2-1725239343798.png%22%20alt%3D%22EvaKi_2-1725239343798.png%22%20%2F%3E%3C%2Fspan%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%3CBR%20%2F%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1944474%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3ERe%3A%20S32K311%20The%20FLASH%20failed%20to%20be%20erased%20AND%20a%20HardFault_Handler%20occurred%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1944474%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EDo%20you%20have%20disabled%20cache%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1944125%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%E5%9B%9E%E5%A4%8D%EF%BC%9A%20S32K311%20The%20FLASH%20failed%20to%20be%20erased%20AND%20a%20HardFault_Handler%20occurred%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1944125%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EIf%20I%20set%20the%20PFLASH's%20.ld%20address%20to%20be%20in%20Block%200(512KB)%2C%20such%20as%20use%20200KB.%3C%2FP%3E%3CP%3EThen%20erase%20the%20remaining%20addresses%2C%20triggering%20an%20HardFault.%3C%2FP%3E%3CP%3Eat%20the%20same%20time%2C%20If%20I%20erase%20the%20Block%201%2C%20everything%20is%20ok.%3C%2FP%3E%3CP%3EHow%20to%20solve%20this%20condition%3F%3C%2FP%3E%3CP%3EThe%20application%20scenario%20is%20that%20the%20Bootloader%20needs%20to%20erase%20the%20Flash%20address%20of%20the%20App%3C%2FP%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22EvaKi_0-1724995839787.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22EvaKi_0-1724995839787.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3Cspan%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22EvaKi_0-1724995839787.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3Cimg%20src%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F296216iC6258153E116585C%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22EvaKi_0-1724995839787.png%22%20alt%3D%22EvaKi_0-1724995839787.png%22%20%2F%3E%3C%2Fspan%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1943893%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%E5%9B%9E%E5%A4%8D%EF%BC%9A%20S32K311%20The%20FLASH%20failed%20to%20be%20erased%20AND%20a%20HardFault_Handler%20occurred%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1943893%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EErased%20area%20is%20PFLASH%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2291194%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3E%E5%9B%9E%E5%A4%8D%EF%BC%9A%20S32K311%20The%20FLASH%20failed%20to%20be%20erased%20AND%20a%20HardFault_Handler%20occurred%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2291194%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%20class%3D%22%22%3E%3CSPAN%3EWhen%20debugging%20the%20S32K396%20with%20S32DS%203.6.3%20and%20RTD%206.0.0%2C%20I%20encountered%20a%26nbsp%3B%3C%2FSPAN%3Ehardfault%3CSPAN%3E%26nbsp%3Bissue%20while%20testing%20the%20official%20Flash%20operation%20routine.%20Here%20is%20the%20situation%3A%3C%2FSPAN%3E%3C%2FP%3E%3CP%20class%3D%22%22%3E%3CSPAN%3EIf%20I%20set%20the%20program's%20pflash%20address%20to%26nbsp%3B%3C%2FSPAN%3Eint_pflash%20%3A%20ORIGIN%20%3D%200x00400000%2C%20LENGTH%20%3D%200x00100000%3CSPAN%3E%2C%20then%20using%26nbsp%3B%3C%2FSPAN%3EC40_Ip_MainInterfaceSectorErase%3CSPAN%3E%26nbsp%3Bto%20erase%20the%20range%26nbsp%3B%3C%2FSPAN%3E0x00500000%3CSPAN%3E%26nbsp%3Bto%26nbsp%3B%3C%2FSPAN%3E0x00502000%3CSPAN%3E%26nbsp%3Bresults%20in%20a%20hardfault.%20Erasing%26nbsp%3B%3C%2FSPAN%3E0x005FE000%3CSPAN%3E%26nbsp%3Bto%26nbsp%3B%3C%2FSPAN%3E0x00600000%3CSPAN%3E%26nbsp%3Balso%20causes%20a%20hardfault.%20However%2C%20erasing%26nbsp%3B%3C%2FSPAN%3E0x00600000%3CSPAN%3E%26nbsp%3Bto%26nbsp%3B%3C%2FSPAN%3E0x00602000%3CSPAN%3E%26nbsp%3Bworks%20fine.%3C%2FSPAN%3E%3C%2FP%3E%3CP%20class%3D%22%22%3E%3CSPAN%3EI%20tried%20placing%20the%26nbsp%3B%3C%2FSPAN%3EC40_Ip_MainInterfaceSectorErase%3CSPAN%3E%26nbsp%3Bfunction%20into%20the%26nbsp%3B%3C%2FSPAN%3Eint_sram_fls_rsv%20%3A%20ORIGIN%20%3D%200x2045EF00%2C%20LENGTH%20%3D%200x00001000%3CSPAN%3E%26nbsp%3Bsection%2C%20but%20the%20hardfault%20still%20occurred.%20The%20issue%20was%20only%20resolved%20after%20I%20moved%20the%26nbsp%3B%3C%2FSPAN%3Emain%3CSPAN%3E%26nbsp%3Bfunction%20into%20the%26nbsp%3B%3C%2FSPAN%3Eint_sram_fls_rsv%3CSPAN%3E%26nbsp%3Bsection%20as%20well.%3C%2FSPAN%3E%3C%2FP%3E%3CP%20class%3D%22%22%3E%3CSPAN%3EWhy%20is%20this%20happening%3F%20The%20erase%20sector%20size%20for%20S32K396%20is%26nbsp%3B%3C%2FSPAN%3E0x2000%3CSPAN%3E%2C%20but%20in%20practice%2C%20it%20seems%20erasing%20within%20a%26nbsp%3B%3C%2FSPAN%3E0x00200000%3CSPAN%3E%26nbsp%3Blength%20is%20not%20consistently%20allowed.%20I%20haven't%20found%20any%20documentation%20describing%20this%20behavior.%20Could%20there%20be%20a%20configuration%20issue%20on%20my%20end%3F%20I%20am%20using%20the%26nbsp%3B%3C%2FSPAN%3EC40_IP_Example_S32K396%3CSPAN%3E%26nbsp%3Bexample%20project.%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E