How to erase/write into 4 MB FlexSPI NOR flash while executing from it (i.MX RT1064)

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

How to erase/write into 4 MB FlexSPI NOR flash while executing from it (i.MX RT1064)

Jump to solution
211 Views
shreya1
Contributor I

Hello,

I am working on the i.MX RT1064- EVK, which has 4 MB of internal FlexSPI NOR flash.
My application is currently running from this flash, but I also need to erase and program parts of the same flash at runtime.

What I’ve done so far:

  • I ran the SDK examples flexspi_nor_polling_transfer and ota_mcuboot_server_enet on the EVK — both examples work standalone on the board.

  • When I integrate the FlexSPI erase/program/read functions from flexspi_nor_polling_transfer into my application, calls to the FlexSPI NOR functions always end in a HardFault (infinite loop).

  • The ota_mcuboot_server_enet example uses an mflash wrapper; integrating those wrappers into my project also fails.

I suspect this is an XIP / execution-from-flash conflict (code being executed from flash while the flash is being erased/programmed), or a cache/MPU/driver-init issue.

What project configuration or setting could I be missing that causes the FlexSPI flash operations to HardFault in my project, even though they work in the SDK examples?

What is the best approach to safely erase and write into the 4 MB FlexSPI NOR flash while the application is also executing from it

0 Kudos
Reply
1 Solution
171 Views
mayliu1
NXP Employee
NXP Employee

Hi @shreya1 ,

Thank you so much for your interest in our products and for using our community.

There are some description about your issue in AN12564-Implement RWW on i.MX RT Series.

Most of Flash do not support Read While Write(RWW). You need allocate the flash write function to other memory(except currently writing flash, generally allocate to
internal SRAM), and disable interrupt to avoid any unexpected flash access until writing operation complete.

mayliu1_0-1757053094669.png

 The SDK example "evkmimxrt1064_flexspi_nor_polling_transfer" moves the Flash-related operation code to run in Sram.  

mayliu1_1-1757053180343.png

Wish it helps you.
If you still have question about it, please kindly let me know.

Best Regards
MayLiu

View solution in original post

0 Kudos
Reply
2 Replies
172 Views
mayliu1
NXP Employee
NXP Employee

Hi @shreya1 ,

Thank you so much for your interest in our products and for using our community.

There are some description about your issue in AN12564-Implement RWW on i.MX RT Series.

Most of Flash do not support Read While Write(RWW). You need allocate the flash write function to other memory(except currently writing flash, generally allocate to
internal SRAM), and disable interrupt to avoid any unexpected flash access until writing operation complete.

mayliu1_0-1757053094669.png

 The SDK example "evkmimxrt1064_flexspi_nor_polling_transfer" moves the Flash-related operation code to run in Sram.  

mayliu1_1-1757053180343.png

Wish it helps you.
If you still have question about it, please kindly let me know.

Best Regards
MayLiu

0 Kudos
Reply
158 Views
shreya1
Contributor I

Hi @mayliu1
Thank you for your prompt response.

The issue was resolved by copying the entire linkscripts folder from the example project into mine, but deleting the bss.ldt file. The problem was that this file was introducing an extra BSS section definition that conflicted with the default linker script generated by the IDE. Removing it allowed the build system to use the correct memory layout, and everything compiled and linked successfully and the mflash and FlexSPI-related functions were correctly placed into SRAM_ITC to enable execution from SRAM while performing flash operations such as erase and write.

0 Kudos
Reply