µTasker Forum

µTasker Forum => NXPTM M522XX, KINETIS and i.MX RT => Topic started by: jackking on March 13, 2024, 01:09:16 AM

Title: Caching of (XiP) Flash?
Post by: jackking on March 13, 2024, 01:09:16 AM
I am having a situation where immediately after clearing flash in the SerialLoader, reading back from flash returns the old value before the erase.  Is there a cache for the external Flash that needs to be flushed?

I tried fnCommandCache(INSTRUCTION_CACHE_INVALIDATE | DATA_CACHE_INVALIDATE);  But that seems to only be for the TCM memories.

thanks
Title: Re: Caching of (XiP) Flash?
Post by: mark on March 13, 2024, 02:12:07 AM
The FlexSpi has a cache.

Try
        FLEX_SPI_AHBCR = FLEX_SPI_AHBCR_READADDROPT;                     // disable FlexSPI caching

since that worked for me when I had a similar issue.
It completely disables it but, seeing as the serial loader is running in RAM, there will be no performance disadvantage just turning it off.

Regards

Mark
Title: Re: Caching of (XiP) Flash?
Post by: jackking on March 13, 2024, 05:47:45 PM
Awesome, that's seems to have worked for me as well.

Thanks!
Title: Re: Caching of (XiP) Flash?
Post by: mark on March 14, 2024, 12:03:47 AM
Note also that using the fnGetParsFile() method to read to a buffer also bypasses any caching. Only the XiP (memory mapped) accesses can be cached.