Author Topic: Caching of (XiP) Flash?  (Read 15013 times)

Offline jackking

  • Newbie
  • *
  • Posts: 34
    • View Profile
Caching of (XiP) Flash?
« 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

Offline mark

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3243
    • View Profile
    • uTasker
Re: Caching of (XiP) Flash?
« Reply #1 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

Offline jackking

  • Newbie
  • *
  • Posts: 34
    • View Profile
Re: Caching of (XiP) Flash?
« Reply #2 on: March 13, 2024, 05:47:45 PM »
Awesome, that's seems to have worked for me as well.

Thanks!

Offline mark

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3243
    • View Profile
    • uTasker
Re: Caching of (XiP) Flash?
« Reply #3 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.