nrf7002dk - External Flash as XIP

Hi all, I'm working a small PoC on my nrf7002dk. I'd like to use the integrated external flash (a mx25r6435f, connected through standard SPI) to allocate custom sections of code.

To do so, I found the Code relocation nocopy sample which does what I want. It's based on the 5340dk (which has the same flash memory, but connected in QSPI mode). That samples works great (on a 5340dk, of course), but I'm struggling to adapt it to the 7002dk. So far I made the following:

  • Created a nrf7002dk_nrf5340_cpuapp.conf file with the following settings:

CONFIG_NRFX_SPIM4=y
CONFIG_SPI=y
CONFIG_NRF_ENABLE_CACHE=n

  • Created a nrf7002dk_nrf5340_cpuapp.overlay file:

/ {
	chosen {
		nordic,pm-ext-flash = &mx25r64;
	};
};

&mx25r64 {
    status = "okay";
};

But now I'm lost regarding the external memory initialization. For the 5340dk there is an ext_mem_init.c file which initializes the QSPI memory during the system initialization. I guess I should do something analogue but for the spi4 node, but I'm not sure about how (apologies in advance, I know that this is quite vague from my side, I'm reading about manual configuration of SPIM while writing this post). For the moment the function only returns a 0.

The other thing is related to the linker script. For the 5340dk we have the following:

#if CONFIG_BOARD_NRF5340DK_NRF5340_CPUAPP

/*
 * nRF5340dk is shipping a QSPI external flash mapped at 0x1000_0000 that can
 * be used for XIP
 */
MEMORY
{
     EXTFLASH (wx) : ORIGIN = 0x10000000, LENGTH = 0x800000
}

#else ...

So I decided to perform the same, but using CONFIG_BOARD_NRF7002DK_NRF5340_CPUAPP as condition.

As a result, the code compiles fine, but it fails on the linking stage:

arm-zephyr-eabi/bin/ld.bfd: section _EXTFLASH_TEXT_SECTION_NAME LMA [0000000000005000,000000000000502f] overlaps section text LMA [00000000000001e0,000000000000882f]
collect2: error: ld returned 1 exit status
ninja: build stopped: subcommand failed.

With all this information, which direction should I take in order to adapt the sample? Is there any documentation that may fulfill my needs?

Thanks in advance, and apologies if the question seems to be lazy, it's my first time interfacing an external flash on Zephyr.

Kind Regards,

Leandro

Parents Reply Children
Related