Hi Sudhakar p,
I do not see where CACHE_DISABLE is implemented. Can you point me to that?
I general the Flash Controller has 4-way, 4-set cache enabled. Please review the FMC chapter of the Reference Manual.
If you think the cache is getting corrupted than after your code re-programs the flash invalidate the cache. Reference:
28.6 Initialization and application information
The FMC does not require user initialization. Flash acceleration features are enabled by default.
The FMC has no visibility into flash memory erase and program cycles because the Flash
Memory module manages them directly. As a result, if an application is executing flash
memory commands, the FMC's cache might need to be disabled and/or flushed to prevent
the possibility of returning stale data. Use the PFB0CR[CINV_WAY] field to invalidate
the cache in this manner.
The g_FlashLaunchCommand = (pFLASHCOMMANDSEQUENCE)RelocateFunction() is copying code from Flash to SRAM. The code to execute flash commands needs to run outside of flash space (it must run from SRAM for Kinetis K devices). The LAUNCH_CMD_SIZE is just a size that is bigger than the flash code size that gets copied to SRAM (i.e. it is the size of SRAM reserved and then used to run Flash commands). Increasing it is not needed unless you have modified the code to be bigger.
Attached is my main.c from the project C:\Freescale\KSDK_1.2.0\examples\frdmk64f\driver_examples\flash\kds .
This code setup to erase 0x80000-0x100000, and then program the beginning 0x80 bytes of each sector that can be viewed in the memory window when debugger is halted.
Regards,
David