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.
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
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
Yes, obviously. SWD/JTAG is a part of ARM core. It's eyesight is same as the core.
Regards,
Jing