This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Concurrently using XIP and QSPI to read back data from external flash

Dear Nordic,

I have a 4MB external flash on my board, I've successfully run the code on it by using XIP. However, I got stuck when I was trying to read back data from external flash. The following picture has the call stack trace. It's a failure of NRFX_ASSERT.

Some more details:

Using nrfx driver both in bootloader and application is not a good idea, because the driver status is stored in the different RAM area. I add a fake initialization function for QSPI to keep the peripheral status consistent. Do you have any better ideas?

Best Regards,

Eugene

  • Hi Eugene, 

    We are releasing the PAN and the workaround for the issue. I attached here the draft version:

    Condition

    Code executing from internal flash or RAM reads data located in XIP region.
    The read performs two consecutive LDR instructions from XIP addresses, where the result of the first LDR instruction is used as the address of the second LDR. This occurs when dereferencing a pointer located in the XIP addresses

    Result

    • Data read from XIP area is incorrect.

    Workaround

    To avoid the race condition, where code executing in internal memory accesses data stored in the XIP region, perform one of the following:
    * Copy the read-only data into internal RAM before accessing it by the use of the memcpy() function.
    * Place the read-only data in internal flash memory at compile time in the linker script

    I'm not sure the issue you are experiencing now is exactly the issue described in the PAN. Could you check if it is ? And could you try the workaround to use memcpy()? 

    (Please don't redistribute the PAN before it's published)

  • Hi Hung,

    I'm not sure whether this workaround can solve my problem. Let's put it in another way, since Nordic has an example maybe called `qspi_bootloader`, imaging this, if you divide the external flash into two parts, the first part is for data storage, the second part is XIP region. To avoid the limitation that we can't execute code in XIP and access QSPI flash using the code in XIP, you put the QSPI driver in the internal flash. In your application running in the external flash, it calls the QSPI driver in the internal flash to read/write data to the data region in the external flash. Does it work?

    I'd really appreciate it if you can provide this kind of example for me.

  • I guess we also encountered you mentioned that Data read from the XIP area is incorrect, the workaround we're using is to change the optimization to O0 for that particular function.

  • Hey Eugene,

    Hung is away on vacation and I've got your case for now.

    You'll have to compile the QSPI driver and place it in internal flash, then link to the driver in internal flash when you compile the application in XiP. 

    BR,
    Håkon H.

  • Hi Håkon, thanks for your reply.

    You'll have to compile the QSPI driver and place it in internal flash, then link to the driver in internal flash when you compile the application in XiP. 

    In this case, we have to disable all interrupts when reading/wiring data to an external flash because we can not execute any code at that time, right? Do you have any idea how to solve this side effect?

Related