linker: Add flash end ROM offset
Reduces the size of an image in the linker script by using the ROM end offset Kconfig value Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
This commit is contained in:
parent
5031da95c6
commit
2522a78566
|
@ -18,12 +18,12 @@ math(EXPR FLASH_ADDR
|
|||
|
||||
if(CONFIG_FLASH_LOAD_SIZE GREATER 0)
|
||||
math(EXPR FLASH_SIZE
|
||||
"(${CONFIG_FLASH_LOAD_SIZE} + 0)"
|
||||
"(${CONFIG_FLASH_LOAD_SIZE} + 0) - (${CONFIG_ROM_END_OFFSET} + 0)"
|
||||
OUTPUT_FORMAT HEXADECIMAL
|
||||
)
|
||||
else()
|
||||
math(EXPR FLASH_SIZE
|
||||
"(${CONFIG_FLASH_SIZE} + 0) * 1024 - (${CONFIG_FLASH_LOAD_OFFSET} + 0)"
|
||||
"(${CONFIG_FLASH_SIZE} + 0) * 1024 - (${CONFIG_FLASH_LOAD_OFFSET} + 0) - (${CONFIG_ROM_END_OFFSET} + 0)"
|
||||
OUTPUT_FORMAT HEXADECIMAL
|
||||
)
|
||||
endif()
|
||||
|
|
|
@ -32,10 +32,16 @@
|
|||
#define ROM_ADDR (CONFIG_FLASH_BASE_ADDRESS + CONFIG_FLASH_LOAD_OFFSET)
|
||||
#endif
|
||||
|
||||
#if CONFIG_FLASH_LOAD_SIZE > 0
|
||||
#define ROM_SIZE CONFIG_FLASH_LOAD_SIZE
|
||||
#if defined(CONFIG_ROM_END_OFFSET)
|
||||
#define ROM_END_OFFSET CONFIG_ROM_END_OFFSET
|
||||
#else
|
||||
#define ROM_SIZE (CONFIG_FLASH_SIZE*1K - CONFIG_FLASH_LOAD_OFFSET)
|
||||
#define ROM_END_OFFSET 0
|
||||
#endif
|
||||
|
||||
#if CONFIG_FLASH_LOAD_SIZE > 0
|
||||
#define ROM_SIZE (CONFIG_FLASH_LOAD_SIZE - ROM_END_OFFSET)
|
||||
#else
|
||||
#define ROM_SIZE (CONFIG_FLASH_SIZE*1K - CONFIG_FLASH_LOAD_OFFSET - ROM_END_OFFSET)
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_XIP)
|
||||
|
|
|
@ -32,10 +32,16 @@
|
|||
#define ROM_ADDR (CONFIG_FLASH_BASE_ADDRESS + CONFIG_FLASH_LOAD_OFFSET)
|
||||
#endif
|
||||
|
||||
#if CONFIG_FLASH_LOAD_SIZE > 0
|
||||
#define ROM_SIZE CONFIG_FLASH_LOAD_SIZE
|
||||
#if defined(CONFIG_ROM_END_OFFSET)
|
||||
#define ROM_END_OFFSET CONFIG_ROM_END_OFFSET
|
||||
#else
|
||||
#define ROM_SIZE (CONFIG_FLASH_SIZE * 1024 - CONFIG_FLASH_LOAD_OFFSET)
|
||||
#define ROM_END_OFFSET 0
|
||||
#endif
|
||||
|
||||
#if CONFIG_FLASH_LOAD_SIZE > 0
|
||||
#define ROM_SIZE (CONFIG_FLASH_LOAD_SIZE - ROM_END_OFFSET)
|
||||
#else
|
||||
#define ROM_SIZE (CONFIG_FLASH_SIZE * 1024 - CONFIG_FLASH_LOAD_OFFSET - ROM_END_OFFSET)
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_XIP)
|
||||
|
|
|
@ -31,10 +31,16 @@
|
|||
#define ROM_ADDR (CONFIG_FLASH_BASE_ADDRESS + CONFIG_FLASH_LOAD_OFFSET)
|
||||
#endif
|
||||
|
||||
#if CONFIG_FLASH_LOAD_SIZE > 0
|
||||
#define ROM_SIZE CONFIG_FLASH_LOAD_SIZE
|
||||
#if defined(CONFIG_ROM_END_OFFSET)
|
||||
#define ROM_END_OFFSET CONFIG_ROM_END_OFFSET
|
||||
#else
|
||||
#define ROM_SIZE (CONFIG_FLASH_SIZE * 1K - CONFIG_FLASH_LOAD_OFFSET)
|
||||
#define ROM_END_OFFSET 0
|
||||
#endif
|
||||
|
||||
#if CONFIG_FLASH_LOAD_SIZE > 0
|
||||
#define ROM_SIZE (CONFIG_FLASH_LOAD_SIZE - ROM_END_OFFSET)
|
||||
#else
|
||||
#define ROM_SIZE (CONFIG_FLASH_SIZE * 1K - CONFIG_FLASH_LOAD_OFFSET - ROM_END_OFFSET)
|
||||
#endif
|
||||
|
||||
#define RAM_SIZE (CONFIG_SRAM_SIZE * 1K)
|
||||
|
|
|
@ -39,6 +39,11 @@
|
|||
* the exception vector is in RAM
|
||||
*/
|
||||
|
||||
#if defined(CONFIG_ROM_END_OFFSET)
|
||||
#define ROM_END_OFFSET CONFIG_ROM_END_OFFSET
|
||||
#else
|
||||
#define ROM_END_OFFSET 0
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_XIP
|
||||
#define ROMABLE_REGION FLASH
|
||||
|
@ -54,7 +59,7 @@ ASSERT(_RESET_VECTOR == _ROM_ADDR, "Reset vector not at beginning of ROM!")
|
|||
MEMORY
|
||||
{
|
||||
RESET (rx) : ORIGIN = _RESET_VECTOR, LENGTH = 0x20
|
||||
FLASH (rx) : ORIGIN = _RESET_VECTOR + 0x20 , LENGTH = (_ROM_SIZE - 0x20)
|
||||
FLASH (rx) : ORIGIN = _RESET_VECTOR + 0x20 , LENGTH = (_ROM_SIZE - 0x20 - ROM_END_OFFSET)
|
||||
RAM (wx) : ORIGIN = _EXC_VECTOR, LENGTH = _RAM_SIZE - (_EXC_VECTOR - _RAM_ADDR)
|
||||
/* Used by and documented in include/linker/intlist.ld */
|
||||
IDT_LIST (wx) : ORIGIN = 0xFFFFF7FF, LENGTH = 2K
|
||||
|
|
|
@ -30,6 +30,12 @@
|
|||
#define _EXCEPTION_SECTION_NAME exceptions
|
||||
#define _RESET_SECTION_NAME reset
|
||||
|
||||
#if defined(CONFIG_ROM_END_OFFSET)
|
||||
#define ROM_END_OFFSET CONFIG_ROM_END_OFFSET
|
||||
#else
|
||||
#define ROM_END_OFFSET 0
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_XIP
|
||||
#if DT_NODE_HAS_COMPAT_STATUS(DT_CHOSEN(zephyr_flash), soc_nv_flash, okay)
|
||||
#ifdef CONFIG_FLASH_LOAD_OFFSET
|
||||
|
@ -38,7 +44,7 @@
|
|||
#else /* !CONFIG_FLASH_LOAD_OFFSET */
|
||||
#define ROM_BASE DT_REG_ADDR(DT_CHOSEN(zephyr_flash))
|
||||
#endif /* CONFIG_FLASH_LOAD_OFFSET */
|
||||
#define ROM_SIZE DT_REG_SIZE(DT_CHOSEN(zephyr_flash))
|
||||
#define ROM_SIZE (DT_REG_SIZE(DT_CHOSEN(zephyr_flash)) - ROM_END_OFFSET)
|
||||
#elif DT_NODE_HAS_COMPAT(DT_CHOSEN(zephyr_flash), jedec_spi_nor)
|
||||
/* For jedec,spi-nor we expect the spi controller to memory map the flash
|
||||
* and for that mapping to be the second register property of the spi
|
||||
|
@ -46,11 +52,11 @@
|
|||
*/
|
||||
#define SPI_CTRL DT_PARENT(DT_CHOSEN(zephyr_flash))
|
||||
#define ROM_BASE DT_REG_ADDR_BY_IDX(SPI_CTRL, 1)
|
||||
#define ROM_SIZE DT_REG_SIZE_BY_IDX(SPI_CTRL, 1)
|
||||
#define ROM_SIZE (DT_REG_SIZE_BY_IDX(SPI_CTRL, 1) - ROM_END_OFFSET)
|
||||
#endif
|
||||
#else /* CONFIG_XIP */
|
||||
#define ROM_BASE CONFIG_SRAM_BASE_ADDRESS
|
||||
#define ROM_SIZE KB(CONFIG_SRAM_SIZE)
|
||||
#define ROM_SIZE (KB(CONFIG_SRAM_SIZE) - ROM_END_OFFSET)
|
||||
#endif /* CONFIG_XIP */
|
||||
|
||||
#define RAM_BASE CONFIG_SRAM_BASE_ADDRESS
|
||||
|
|
|
@ -50,12 +50,18 @@
|
|||
|
||||
/* "kernel RAM" for linker VMA allocations starts at the offset */
|
||||
|
||||
#if defined(CONFIG_ROM_END_OFFSET)
|
||||
#define ROM_END_OFFSET CONFIG_ROM_END_OFFSET
|
||||
#else
|
||||
#define ROM_END_OFFSET 0
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_XIP
|
||||
/* "ROM" is flash, we leave rodata and text there and just copy in data.
|
||||
* Board-level DTS must specify a flash region that doesn't overlap with
|
||||
* sram0, so that DT_PHYS_LOAD_ADDR is set.
|
||||
*/
|
||||
#define FLASH_ROM_SIZE DT_REG_SIZE(DT_CHOSEN(zephyr_flash))
|
||||
#define FLASH_ROM_SIZE (DT_REG_SIZE(DT_CHOSEN(zephyr_flash)) - ROM_END_OFFSET)
|
||||
#define PHYS_LOAD_ADDR DT_REG_ADDR(DT_CHOSEN(zephyr_flash))
|
||||
#else
|
||||
/* Physical RAM location where the kernel image is loaded */
|
||||
|
|
Loading…
Reference in a new issue