summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile.rules4
-rw-r--r--core/cortex-m/ec.lds.S30
-rw-r--r--core/cortex-m0/ec.lds.S23
-rw-r--r--core/nds32/ec.lds.S8
-rw-r--r--core/riscv-rv32i/ec.lds.S10
5 files changed, 43 insertions, 32 deletions
diff --git a/Makefile.rules b/Makefile.rules
index 15f87d1c63..209307047b 100644
--- a/Makefile.rules
+++ b/Makefile.rules
@@ -408,10 +408,10 @@ ifeq ($(V),0)
cmd_size=
else
cmd_size=$(Q)awk '\
- /__image_size =/ {image_size = strtonum($$1)} \
+ /__flash_used =/ {flash_used = strtonum($$1)} \
/^FLASH/ {flash_size = strtonum($$3)} \
/__ram_free =/ {ram_free = strtonum($$1)} \
- END {room_free = flash_size - image_size; \
+ END {room_free = flash_size - flash_used; \
print ram_free > "$(out)/$(1)/space_free_ram.txt"; \
printf " *** "; \
if (flash_size > 0) { \
diff --git a/core/cortex-m/ec.lds.S b/core/cortex-m/ec.lds.S
index 27d71946e5..c24ee8321b 100644
--- a/core/cortex-m/ec.lds.S
+++ b/core/cortex-m/ec.lds.S
@@ -41,7 +41,7 @@ MEMORY
*/
FLASH_HDR (rx) : ORIGIN = FW_OFF(RO_HDR), LENGTH = FW_SIZE(RO_HDR)
FLASH (rx) : ORIGIN = FW_OFF(SECTION) + FW_SIZE(RO_HDR), \
- LENGTH = FW_SIZE(SECTION)
+ LENGTH = FW_SIZE(SECTION) - FW_SIZE(RO_HDR)
#else
FLASH (rx) : ORIGIN = FW_OFF(SECTION), LENGTH = FW_SIZE(SECTION)
#endif
@@ -413,14 +413,12 @@ SECTIONS
(__shared_mem_buf + CONFIG_SHAREDMEM_MINIMUM_SIZE);
/*
- * The linker won't notice if the .data section is too big to fit,
- * apparently because we're sending it into IRAM, not FLASH.
- * The following symbol isn't used by the code, but running
- * "objdump -t *.elf | grep hey" will let us check how much
- * flash space we're actually using. The explicit ASSERT afterwards
- * will cause the linker to abort if we use too much.
+ * __flash_used is used in flash free calculations by the makefile.
+ * __image_size is stored in the struct image_data header and used
+ * in hash calcuations.
*/
- __hey_flash_used = LOADADDR(.data) + SIZEOF(.data) - FW_OFF(SECTION);
+ __flash_used = LOADADDR(.data) + SIZEOF(.data) - ORIGIN(FLASH);
+ __image_size = __flash_used;
#ifdef CONFIG_FLASH
/*
@@ -433,23 +431,21 @@ SECTIONS
__config_ec_writable_storage_size = CONFIG_EC_WRITABLE_STORAGE_SIZE;
#endif
-#ifdef CONFIG_FLASH_PHYSICAL
- ASSERT((FW_SIZE(SECTION)
+ /*
+ * The linker won't notice if the .data section is too big to fit,
+ * apparently because we're sending it into IRAM, not FLASH.
+ * Verify that all sections linked into the FLASH region will fit.
+ */
+ ASSERT((LENGTH(FLASH)
#if defined(CONFIG_RWSIG) && defined(SECTION_IS_RO)
- CONFIG_RO_PUBKEY_SIZE
#endif
#if defined(CONFIG_RWSIG) && defined(SECTION_IS_RW)
- CONFIG_RW_SIG_SIZE
#endif
- ) >= (LOADADDR(.data) + SIZEOF(.data) - FW_OFF(SECTION)),
+ ) >= __flash_used,
"No room left in the flash")
-#endif /* CONFIG_FLASH_PHYSICAL */
-#if defined(SECTION_IS_RO) && defined(NPCX_RO_HEADER)
- __image_size = __hey_flash_used - FW_SIZE(RO_HDR);
-#else
- __image_size = __hey_flash_used;
-#endif
#ifdef CONFIG_CHIP_MEMORY_REGIONS
#define REGION(name, attr, start, size) \
diff --git a/core/cortex-m0/ec.lds.S b/core/cortex-m0/ec.lds.S
index bfcbaecc18..77f3f9c8a7 100644
--- a/core/cortex-m0/ec.lds.S
+++ b/core/cortex-m0/ec.lds.S
@@ -291,14 +291,12 @@ SECTIONS
(__shared_mem_buf + CONFIG_SHAREDMEM_MINIMUM_SIZE);
/*
- * The linker won't notice if the .data section is too big to fit,
- * apparently because we're sending it into IRAM, not FLASH.
- * The following symbol isn't used by the code, but running
- * "objdump -t *.elf | grep hey" will let us check how much
- * flash space we're actually using. The explicit ASSERT afterwards
- * will cause the linker to abort if we use too much.
+ * __flash_used is used in flash free calculations by the makefile.
+ * __image_size is stored in the struct image_data header and used
+ * in hash calcuations.
*/
- __hey_flash_used = LOADADDR(.data) + SIZEOF(.data) - FW_OFF(SECTION);
+ __flash_used = LOADADDR(.data) + SIZEOF(.data) - ORIGIN(FLASH);
+ __image_size = __flash_used;
#ifdef CONFIG_FLASH
/*
@@ -311,17 +309,22 @@ SECTIONS
__config_ec_writable_storage_size = CONFIG_EC_WRITABLE_STORAGE_SIZE;
#endif
- ASSERT((FW_SIZE(SECTION)
+ /*
+ * The linker won't notice if the .data section is too big to fit,
+ * apparently because we're sending it into IRAM, not FLASH.
+ * Verify that all sections linked into the FLASH region will fit.
+ */
+ ASSERT((LENGTH(FLASH)
#if defined(CONFIG_RWSIG) && defined(SECTION_IS_RO)
- CONFIG_RO_PUBKEY_SIZE
#endif
#if defined(CONFIG_RWSIG) && defined(SECTION_IS_RW)
- CONFIG_RW_SIG_SIZE
#endif
- ) >= (LOADADDR(.data) + SIZEOF(.data) - FW_OFF(SECTION)),
+ ) >= __flash_used,
"No room left in the flash")
- __image_size = __hey_flash_used;
+ __image_size = __flash_used;
#ifdef CONFIG_CHIP_MEMORY_REGIONS
#define REGION(name, attr, start, size) \
diff --git a/core/nds32/ec.lds.S b/core/nds32/ec.lds.S
index 2dad18c28a..24ee1ef0ae 100644
--- a/core/nds32/ec.lds.S
+++ b/core/nds32/ec.lds.S
@@ -259,7 +259,13 @@ SECTIONS
__ram_free = (CONFIG_RAM_BASE + CONFIG_RAM_SIZE) -
(__shared_mem_buf + CONFIG_SHAREDMEM_MINIMUM_SIZE);
- __image_size = LOADADDR(.data) + SIZEOF(.data) - FW_OFF(SECTION);
+ /*
+ * __flash_used is used in flash free calculations by the makefile.
+ * __image_size is stored in the struct image_data header and used
+ * in hash calcuations.
+ */
+ __flash_used = LOADADDR(.data) + SIZEOF(.data) - FW_OFF(SECTION);
+ __image_size = __flash_used;
#ifdef CONFIG_FLASH
/*
diff --git a/core/riscv-rv32i/ec.lds.S b/core/riscv-rv32i/ec.lds.S
index 6efbe49f1f..31a7972fa2 100644
--- a/core/riscv-rv32i/ec.lds.S
+++ b/core/riscv-rv32i/ec.lds.S
@@ -303,12 +303,18 @@ SECTIONS
__ram_free = (CONFIG_RAM_BASE + CONFIG_RAM_SIZE) -
(__shared_mem_buf + CONFIG_SHAREDMEM_MINIMUM_SIZE);
+ /*
+ * __flash_used is used in flash free calculations by the makefile.
+ * __image_size is stored in the struct image_data header and used
+ * in hash calcuations.
+ */
#if defined(CHIP_FAMILY_IT8XXX2)
- __image_size = LOADADDR(.data) + SIZEOF(.data) + \
+ __flash_used = LOADADDR(.data) + SIZEOF(.data) + \
CHIP_ILM_BASE - FW_OFF(SECTION);
#else
- __image_size = LOADADDR(.data) + SIZEOF(.data) - FW_OFF(SECTION);
+ __flash_used = LOADADDR(.data) + SIZEOF(.data) - FW_OFF(SECTION);
#endif
+ __image_size = __flash_used;
#ifdef CONFIG_FLASH
/*