FlexSPI ROM API on RT1170 with FreeRTOS: Questions about Interrupt Disabling and Cache Coherency

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

FlexSPI ROM API on RT1170 with FreeRTOS: Questions about Interrupt Disabling and Cache Coherency

289 Views
langya
Contributor I

Dear NXP Team,

I would like to ask some questions about disabling interrupts and cache management when using the FlexSPI ROM API. I am using the RT1170 chip with FreeRTOS. Occasionally, the system hangs, and I suspect it may be caused by Flash operations using the ROM API.

1. In the SDK example `flexspi_romapi_cm7`, when reading/writing/erasing Flash with the ROM API, there is no interrupt disable/enable operation. I also found a document titled *"i.MX RT series FlexSPI Nor ROM APIs Usage & Flashloader.pdf"*, which mentions interrupts:

52liuyi52liuyi_1-1777029095740.png

Is it because the ROM API already handles interrupt masking internally, or is there another reason?

To implement write and erase operations at arbitrary Flash addresses, I have wrapped the ROM API into `flash_eraseData()` and `flash_writeData()` functions, and simply wrapped the read operation as `flash_readData()`:

52liuyi52liuyi_2-1777029153497.png

52liuyi52liuyi_3-1777029175571.png52liuyi52liuyi_4-1777029197881.png

Could you please review whether there are any potential errors in my three wrapper functions(I am a bit doubtful whether an erase operation is required before calling ROM_FLEXSPI_NorFlash_ProgramPage)? Also, when calling these functions (not the ROM API directly), is it necessary to disable/enable interrupts?

2. In the SDK example, after calling `ROM_FLEXSPI_NorFlash_ProgramPage` to write Flash, there is a `DCACHE_InvalidateByRange` operation to invalidate the D-Cache.
I understand that the ROM API operates on external NOR Flash through the FlexSPI controller's programming sequence, bypassing the Cache, so the CM7's data cache lines are not automatically updated.
Later, when we use `memcpy` to access Flash data, the access goes through D-Cache, and stale values may be fetched if the cache hits. Therefore, invalidating the D-Cache is necessary.
In my three wrapper functions that use these ROM APIs, could there also be cache coherency issues due to improper handling?

Any help would be very appreciated.

Best regards,

langya.

Tags (3)
0 Kudos
Reply
1 Reply

147 Views
db16122
Contributor III

AN12077: Using the i.MX RT FlexRAM – Application Note FYI, have you test your code on RT1170 EVK? More error log during system hang would be helpful

0 Kudos
Reply