summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Hughes <tomhughes@chromium.org>2021-09-23 21:04:08 +0000
committerCommit Bot <commit-bot@chromium.org>2021-10-01 23:32:55 +0000
commit82393ec1c3c8a9d3e98cfccb52622d7af577427d (patch)
tree33211a7d68e31b42aa19f5650ceade13dacf7c9a
parent77d1122fd763f2d25662d45f276e9125adb658f7 (diff)
downloadchrome-ec-82393ec1c3c8a9d3e98cfccb52622d7af577427d.tar.gz
core: Add assert to check alignment
Assert that the RW image size padding adding results in correct alignment. This assertion will make it easier to verify future clang changes. BRANCH=none BUG=b:172020503, b:188117811 TEST=make buildall -j Signed-off-by: Tom Hughes <tomhughes@chromium.org> Change-Id: Ibdc6feaf31cf271f67594ae1e519272fd9a88cd4 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3179317 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-by: Denis Brockus <dbrockus@chromium.org>
-rw-r--r--core/cortex-m/ec.lds.S5
-rw-r--r--core/cortex-m0/ec.lds.S6
-rw-r--r--core/minute-ia/ec.lds.S6
-rw-r--r--core/nds32/ec.lds.S6
-rw-r--r--core/riscv-rv32i/ec.lds.S6
5 files changed, 29 insertions, 0 deletions
diff --git a/core/cortex-m/ec.lds.S b/core/cortex-m/ec.lds.S
index 7b08be81a6..fa35684e31 100644
--- a/core/cortex-m/ec.lds.S
+++ b/core/cortex-m/ec.lds.S
@@ -512,6 +512,11 @@ SECTIONS
__image_size = __flash_used + SIZEOF(.rw_image_size_alignment);
#endif
+#if defined(SECTION_IS_RW) && (CONFIG_FLASH_WRITE_SIZE > 0)
+ /* Alignment is needed by flash_command_write() for RW update. */
+ ASSERT(__image_size % CONFIG_FLASH_WRITE_SIZE == 0,
+ "Error: RW image is not aligned to CONFIG_FLASH_WRITE_SIZE")
+#endif
#endif /* CONFIG_CHIP_INIT_ROM_REGION */
#ifdef CONFIG_FLASH_CROS
diff --git a/core/cortex-m0/ec.lds.S b/core/cortex-m0/ec.lds.S
index bc461b90de..c5e66f9bcb 100644
--- a/core/cortex-m0/ec.lds.S
+++ b/core/cortex-m0/ec.lds.S
@@ -315,6 +315,12 @@ SECTIONS
__flash_used = LOADADDR(.data) + SIZEOF(.data) - ORIGIN(FLASH);
__image_size = __flash_used;
+#if defined(SECTION_IS_RW) && (CONFIG_FLASH_WRITE_SIZE > 0)
+ /* Alignment is needed by flash_command_write() for RW update. */
+ ASSERT(__image_size % CONFIG_FLASH_WRITE_SIZE == 0,
+ "Error: RW image is not aligned to CONFIG_FLASH_WRITE_SIZE")
+#endif
+
#ifdef CONFIG_FLASH_CROS
/*
* These linker labels are just for analysis and not used in the code.
diff --git a/core/minute-ia/ec.lds.S b/core/minute-ia/ec.lds.S
index dc61699fed..beda1dbfae 100644
--- a/core/minute-ia/ec.lds.S
+++ b/core/minute-ia/ec.lds.S
@@ -235,6 +235,12 @@ SECTIONS
/* TODO: Adjust __image_size to proper value for core minute-ia later */
__image_size = . - CONFIG_ISH_BOOT_START;
+#if defined(SECTION_IS_RW) && (CONFIG_FLASH_WRITE_SIZE > 0)
+ /* Alignment is needed by flash_command_write() for RW update. */
+ ASSERT(__image_size % CONFIG_FLASH_WRITE_SIZE == 0,
+ "Error: RW image is not aligned to CONFIG_FLASH_WRITE_SIZE")
+#endif
+
def_irq_low = ABSOLUTE(default_int_handler) & 0xFFFF;
def_irq_high = ABSOLUTE(default_int_handler) >> 16;
diff --git a/core/nds32/ec.lds.S b/core/nds32/ec.lds.S
index 2c21b94761..4993593f87 100644
--- a/core/nds32/ec.lds.S
+++ b/core/nds32/ec.lds.S
@@ -285,6 +285,12 @@ SECTIONS
__flash_used = LOADADDR(.data) + SIZEOF(.data) - FW_OFF(SECTION);
__image_size = __flash_used;
+#if defined(SECTION_IS_RW) && (CONFIG_FLASH_WRITE_SIZE > 0)
+ /* Alignment is needed by flash_command_write() for RW update. */
+ ASSERT(__image_size % CONFIG_FLASH_WRITE_SIZE == 0,
+ "Error: RW image is not aligned to CONFIG_FLASH_WRITE_SIZE")
+#endif
+
#ifdef CONFIG_FLASH_CROS
/*
* These linker labels are just for analysis and not used in the code.
diff --git a/core/riscv-rv32i/ec.lds.S b/core/riscv-rv32i/ec.lds.S
index e8963c1b14..2b88b14f24 100644
--- a/core/riscv-rv32i/ec.lds.S
+++ b/core/riscv-rv32i/ec.lds.S
@@ -360,6 +360,12 @@ SECTIONS
#endif
__image_size = __flash_used;
+#if defined(SECTION_IS_RW) && (CONFIG_FLASH_WRITE_SIZE > 0)
+ /* Alignment is needed by flash_command_write() for RW update. */
+ ASSERT(__image_size % CONFIG_FLASH_WRITE_SIZE == 0,
+ "Error: RW image is not aligned to CONFIG_FLASH_WRITE_SIZE")
+#endif
+
#ifdef CONFIG_FLASH_CROS
/*
* These linker labels are just for analysis and not used in the code.