Read data directly from external nor flash

Hello,

I'm using the following setup:

  1. nRF Connect SDK v2.9.0
  2. B0, upgradable secure MCUBoot, and application
  3. Statically defined partitions in the partition manager

I have an external NOR flash of 4MB.

I'm storing a large amount of data (~4KB) in my external NOR flash, which will always be at the same offset in the flash.

Currently, I'm using flash_read to retrieve the data, but it consumes a significant amount of RAM. I saw that XIP (Execute In Place) can be used for read-only purposes, but I can't find any samples or guidance on how to implement it.

Please note that I'm not referring to using XIP to run code from the external flash; all I need is a way to hold a pointer to data that is stored in it.

Could you provide any examples or hints on how to use XIP for accessing read-only data in external NOR flash without wasting RAM?

Thank you for your assistance.

Best regards,
Udi

Parents Reply Children
  • Hi Amanda.

    The post is irrelevant as it speaks of cache for XIP.
    We are not talking about that, the request is simple:
    An example of zephyr app (for nrf52840-dk) that uses XIP preferable the last 1 mb of the flash for reading (not executing anything of the external flash, just reading data). for now assume we don't care how the data got there, we don't need to flash it with nrfjprog and .hex file.

    There are such examples for nrf53840 but not for nrf52840. For the very least a ref to the product spec and registers or driver you have (if you have) cause we were unable to find that data.

  • Hi, 

    The nRF52840 has hardware support for XiP, but due to Errata 215 and 216, the support is severely limited for the nRF52840 w.r.t XiP. In nRF Connect SDK there is no support for XiP for the nRF52840. 

    -Amanda H.

  • Thanks for the reply Ammanda.

    So the only option is to set the "XIP" window ourselves using the registers directly ? 
    our needs are very basic and i think are ok with the limiatation : read only code, we use the QSPI wire api to write the data and use XIP only to read the data "as if" it was from RAM.
    I believe it's in the bounds of the ERRATAs.

    which files (nrf\nrfx files) should we include' i don't belive any of them in the nrf-connect don't have ref to the registers, it's a bit strange that we'll have to write the the structs and pointers ourselves (though we can according to the product spec).

    Or if it's not in the SDK, where was this code in nrf-sdk , maybe we can copy form there.

  • While it is possible to set up the XIP window using registers directly with the QSPI HAL, you must be extremely cautious about the limitations imposed by Errata [216] QSPI: Race condition occurs in XIP

  • checking the product spec on your site of nrf52840 + the nrf52840.h from the old sdk (mbk) + the NRF_QSPI_Type type taken from the nrf52840.h file in the nrf dir in nrf connect it seems there is no XIPEN register, only XIPOFFSET, am i to understand that it is always active ? if not i need an example on how to activate it in nrf52840 as even the product spec doesn't explains it. again i do not fear for race condition cause i read specific areas into ram and use them later on from there and next time is 24 hours later...

Related