--- a/include/zephyr/arch/arm/cortex_m/scripts/linker.ld
+++ b/include/zephyr/arch/arm/cortex_m/scripts/linker.ld
@@ -87,6 +87,9 @@ MEMORY
#endif
FLASH (rx) : ORIGIN = ROM_ADDR, LENGTH = ROM_SIZE
RAM (wx) : ORIGIN = RAM_ADDR, LENGTH = RAM_SIZE
+#if defined(CONFIG_SDRAM_LMA_ADJUST)
+ NXP_FLASH_LMA (rx) : ORIGIN = 0x60000000, LENGTH = 4M
+#endif
#if defined(CONFIG_LINKER_DEVNULL_MEMORY)
DEVNULL_ROM (rx) : ORIGIN = DEVNULL_ADDR, LENGTH = DEVNULL_SIZE
#endif
@@ -95,6 +98,18 @@ MEMORY
IDT_LIST (wx) : ORIGIN = 0xFFFF7FFF, LENGTH = 32K
}
+#define GROUP_LINK_IN_AT(where) > where
+#if defined(CONFIG_SDRAM_LMA_ADJUST)
+#undef GROUP_ROM_LINK_IN
+#undef GROUP_DATA_LINK_IN
+
+#define GROUP_ROM_LINK_IN(vregion, lregion) > lregion AT> NXP_FLASH_LMA
+#define GROUP_DATA_LINK_IN(vregion, lregion) > vregion AT> NXP_FLASH_LMA
+
+#undef GROUP_LINK_IN
+#define GROUP_LINK_IN(where) > where AT> NXP_FLASH_LMA
+#endif
+
ENTRY(CONFIG_KERNEL_ENTRY)
SECTIONS
@@ -124,7 +139,7 @@ SECTIONS
__rom_region_start = ROM_ADDR;
- SECTION_PROLOGUE(rom_start,,)
+ SECTION_PROLOGUE(rom_start,,)
{
/* Located in generated directory. This file is populated by calling
@@ -132,7 +147,6 @@ SECTIONS
* table and debug information.
*/
#include <snippets-rom-start.ld>
-
} GROUP_LINK_IN(ROMSTART_REGION)
#ifdef CONFIG_CODE_DATA_RELOCATION
@@ -141,7 +155,7 @@ SECTIONS
#endif /* CONFIG_CODE_DATA_RELOCATION */
- SECTION_PROLOGUE(_TEXT_SECTION_NAME,,)
+ SECTION_PROLOGUE(_TEXT_SECTION_NAME,,)
{
__text_region_start = .;
@@ -158,7 +172,6 @@ SECTIONS
*/
*(.glue_7t) *(.glue_7) *(.vfp11_veneer) *(.v4_bx)
. = ALIGN(4);
-
} GROUP_LINK_IN(ROMABLE_REGION)
__text_region_end = .;
@@ -187,7 +200,6 @@ SECTIONS
#endif
__exidx_end = .;
} GROUP_LINK_IN(ROMABLE_REGION)
-
__rodata_region_start = .;
#include <zephyr/linker/common-rom.ld>
@@ -198,6 +210,9 @@ SECTIONS
#include <zephyr/linker/thread-local-storage.ld>
SECTION_PROLOGUE(_RODATA_SECTION_NAME,,)
+#if defined(CONFIG_SDRAM_LMA_ADJUST)
+ ALIGN_WITH_INPUT
+#endif
{
*(.rodata)
*(".rodata.*")
@@ -222,10 +237,9 @@ SECTIONS
*/
. = ALIGN(4);
} GROUP_LINK_IN(ROMABLE_REGION)
-
#include <zephyr/linker/cplusplus-rom.ld>
-#if defined(CONFIG_BUILD_ALIGN_LMA) || !defined(CONFIG_XIP)
+#if 1//defined(CONFIG_BUILD_ALIGN_LMA) || !defined(CONFIG_XIP)
/*
* Include a padding section here to make sure that the LMA address
* of the sections in the RAMABLE_REGION are aligned with those
@@ -301,7 +315,6 @@ SECTIONS
#include <linker_sram_data_relocate.ld>
#endif
__data_end = .;
-
} GROUP_DATA_LINK_IN(RAMABLE_REGION, ROMABLE_REGION)
__data_size = __data_end - __data_start;
__data_load_start = LOADADDR(_DATA_SECTION_NAME);
@@ -334,7 +347,7 @@ GROUP_START(ITCM)
#include <snippets-itcm-section.ld>
__itcm_end = .;
- } GROUP_LINK_IN(ITCM AT> ROMABLE_REGION)
+ } GROUP_LINK_IN_AT(ITCM AT> ROMABLE_REGION)
__itcm_size = __itcm_end - __itcm_start;
__itcm_load_start = LOADADDR(_ITCM_SECTION_NAME);
@@ -373,7 +386,7 @@ GROUP_START(DTCM)
#include <snippets-dtcm-section.ld>
__dtcm_data_end = .;
- } GROUP_LINK_IN(DTCM AT> ROMABLE_REGION)
+ } GROUP_LINK_IN_AT(DTCM AT> ROMABLE_REGION)