From e3ee5c09f2cea3e71c4711001ef6313f8bee1781 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrzej=20G=C5=82=C4=85bek?= Date: Wed, 13 Sep 2023 12:39:02 +0200 Subject: [PATCH] samples: code_relocation_nocopy: Make linker script more generic MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Instead of depending on the nRF5340 DK, use a path specific to just the nRF5340 SoC and get the size of the external flash in this case from devicetree so that the sample could be easily run on other boards based on the nRF5340 SoC (after just adding proper overlays). On the occasion, correct the attributes of the EXTFLASH memory region. Signed-off-by: Andrzej Głąbek --- .../linker_arm_nocopy.ld | 22 +++++++++---------- 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/samples/application_development/code_relocation_nocopy/linker_arm_nocopy.ld b/samples/application_development/code_relocation_nocopy/linker_arm_nocopy.ld index 934f928596c..916b1efe7fa 100644 --- a/samples/application_development/code_relocation_nocopy/linker_arm_nocopy.ld +++ b/samples/application_development/code_relocation_nocopy/linker_arm_nocopy.ld @@ -17,16 +17,14 @@ #include #include -#if CONFIG_BOARD_NRF5340DK_NRF5340_CPUAPP +#if defined(CONFIG_NORDIC_QSPI_NOR) && defined(CONFIG_SOC_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 -} +/* On nRF5340, external flash is mapped in XIP region at 0x1000_0000. */ + +#define EXTFLASH_NODE DT_INST(0, nordic_qspi_nor) +#define EXTFLASH_ADDR 0x10000000 +#define EXTFLASH_SIZE DT_PROP_OR(EXTFLASH_NODE, size_in_bytes, \ + DT_PROP(EXTFLASH_NODE, size) / 8) #else @@ -37,11 +35,11 @@ MEMORY #define EXTFLASH_ADDR 0x5000 #define EXTFLASH_SIZE (CONFIG_FLASH_SIZE * 1K - EXTFLASH_ADDR) +#endif + MEMORY { - EXTFLASH (wx) : ORIGIN = 0x5000, LENGTH = EXTFLASH_SIZE + EXTFLASH (rx) : ORIGIN = EXTFLASH_ADDR, LENGTH = EXTFLASH_SIZE } -#endif /* CONFIG_BOARD_NRF5340DK_NRF5340_CPUAPP */ - #include