How to prevent flash accesses during RWSC flash wait state update (S32K344)?

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

How to prevent flash accesses during RWSC flash wait state update (S32K344)?

Jump to solution
1,456 Views
andye
Contributor I

The documentation for flash wait states on the S32K344 (configured by CTL.RWSC) says:

Updates to this configuration field that control reads must take place only when the flash memory is idle. Changing configuration settings while flash memory access is in progress can lead to non-deterministic behavior.

I assume this means code to change RWSC ought to execute from RAM or TCM, instead of from flash.

However, due to pipelining and prefetching in the Cortex-M7 core, it seems to me that flash accesses could still occur in the background even if the instructions to change RWSC execute from RAM or TCM. This makes me worried about triggering this non-determinism even with the wait state change code executing from outside flash.

Could you please clarify what the safe RWSC update procedure is on the S32K344, which avoids any non-determinism? Is just executing the RWSC change code from RAM or TCM sufficient?

0 Kudos
Reply
1 Solution
1,429 Views
davidtosenovjan
NXP TechSupport
NXP TechSupport

You would apparently need to flush the pipeline (instructions ISB/DSB) before start of execution from RAM accessing flash control register. davidtosenovjan_0-1700825776678.png

 

View solution in original post

0 Kudos
Reply
2 Replies
1,430 Views
davidtosenovjan
NXP TechSupport
NXP TechSupport

You would apparently need to flush the pipeline (instructions ISB/DSB) before start of execution from RAM accessing flash control register. davidtosenovjan_0-1700825776678.png

 

0 Kudos
Reply
1,381 Views
andye
Contributor I

Hello, thank you for the reply! I was curious if NXP recommends anything else be done, such as disable the I-cache, or configure the MPU to mark flash as XN/non-readable to inhibit speculative accesses during the wait state change. But I actually now see in section 5.2 a similar recommendation for avoiding flash accesses during flash operations, which seems like it also applies here. I think this is sufficient for me, thank you for the help.

0 Kudos
Reply