solved: kinetis sector erase succeeds with some data not deleted

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

solved: kinetis sector erase succeeds with some data not deleted

1,034 Views
a_schulz
Contributor I

MKE18f512 ; Call on FLASH_Erase from "fsl_flash.c" doesn't erase first 96 bits of sector. After power cycle, sector can be erased but next sector erase leaves first 96 bits not erased too.

FLASH_Erase always returns with "kStatus_FLASH_Success".

Algorithm checks a sector for all 0xff. If not, sector gets erased and checked again -> check fails.

This shouldn't be possible according to manual.

Disabling Interrupts (__disable_irq()) nor running completely in RAM changes anything.

Flash config is default startup (Flash_Config = {0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFF7DFE})

Attached file is the main in a generated default project in MCUxpresso V10.0.0 (no clock change).

How can i solve this problem?

Jings reply solved issue.

Labels (1)
0 Kudos
Reply
3 Replies

874 Views
jingpan
NXP TechSupport
NXP TechSupport

Hi Schulz,

I think you get fake data when you try to verify erase operation by read data back from flash. KE18 has cache. When  you read 0x9000 first time, you get real data. And these data is also kept into cache. Then you erase the flash. When you read 0x9000 second time, the system give you cached data.
So if you want to verify data by reading back, you should disable cache first by LMEM->PCCCR.ENCACHE.

Regards,

Jing

874 Views
a_schulz
Contributor I

In fact it was a cache coherence problem. I missed it on first run because the compiler optimized my software solution away.

Library only refreshes prefetch unit and misses to address cache data. Maybe it should do both.

Does the backport (JTAG/SW) access through cache too?

Regards,

Schulz

0 Kudos
Reply

874 Views
jingpan
NXP TechSupport
NXP TechSupport

Yes, obviously. SWD/JTAG is a part of ARM core. It's eyesight is same as the core.

Regards,

Jing 

0 Kudos
Reply