summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYuval Peress <peress@chromium.org>2021-02-17 13:00:37 -0700
committerCommit Bot <commit-bot@chromium.org>2021-02-26 21:46:53 +0000
commitc4538718931382f514ea401a0d237649c79066d8 (patch)
treef1f8eb1bb0df1f9766ba89358cd7be2754d8be92
parentfceaf8c374321adcc7a145e90831dcb28f49d2be (diff)
downloadchrome-ec-c4538718931382f514ea401a0d237649c79066d8.tar.gz
zephyr: efs2: Compute the __image_size for efs2 in the linker
The __image_size should match used portion of the flash. Note that in Zephyr, different linker scripts have different variables. _flash_used is only available for the verified chips. Other chips may use a different name or may require manual calculation. Compute the size by using the Zephyr sections. This is the parallel to core/cortex-m/ec.lds.S's logic. BRANCH=none BUG=b:164421798 TEST=zmake testall Signed-off-by: Yuval Peress <peress@chromium.org> Change-Id: If91acd5dc2b925ad226f2d1c3feccc77617e04df Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2721495 Reviewed-by: Keith Short <keithshort@chromium.org> Reviewed-by: Simon Glass <sjg@chromium.org>
-rw-r--r--zephyr/linker/CMakeLists.txt3
-rw-r--r--zephyr/linker/image_size.ld15
-rw-r--r--zephyr/shim/src/system.c2
3 files changed, 18 insertions, 2 deletions
diff --git a/zephyr/linker/CMakeLists.txt b/zephyr/linker/CMakeLists.txt
index 3aa22c98e2..170055dba7 100644
--- a/zephyr/linker/CMakeLists.txt
+++ b/zephyr/linker/CMakeLists.txt
@@ -7,3 +7,6 @@ zephyr_linker_sources(ROM_START SORT_KEY 1 fixed-sections.ld)
# Support protection of part of the internal RAM
zephyr_linker_sources(RWDATA SORT_KEY 1 iram_text.ld)
+
+# Compute the image size
+zephyr_linker_sources(RAM_SECTIONS image_size.ld)
diff --git a/zephyr/linker/image_size.ld b/zephyr/linker/image_size.ld
new file mode 100644
index 0000000000..ab6935718a
--- /dev/null
+++ b/zephyr/linker/image_size.ld
@@ -0,0 +1,15 @@
+/* Copyright 2021 The Chromium OS Authors. All rights reserved.
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#if defined(CONFIG_CPU_CORTEX_M) || defined(CONFIG_CPU_CORTEX_R) || \
+ defined(CONFIG_CPU_CORTEX_A)
+__image_size = _flash_used;
+#else
+/*
+ * Intentionally set to 0. Some components, such as EFS2, need this value.
+ * Having it be 0 will make it easier to find and add new cores.
+ */
+__image_size = 0;
+#endif
diff --git a/zephyr/shim/src/system.c b/zephyr/shim/src/system.c
index e59cb59526..78195e8846 100644
--- a/zephyr/shim/src/system.c
+++ b/zephyr/shim/src/system.c
@@ -95,5 +95,3 @@ const char *system_get_chip_revision(void)
{
return "";
}
-
-const void *__image_size;