summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRandall Spangler <rspangler@chromium.org>2012-08-14 13:23:44 -0700
committerGerrit <chrome-bot@google.com>2012-08-14 17:30:22 -0700
commit7dbb17f07e639acb1836d1ddbd72aa9e59bea6b7 (patch)
tree785c437e4ea50c4459220aa5ae7740dae5019b1c
parent1178484e0e728ab123b8bf3433624c92936b7229 (diff)
downloadchrome-ec-7dbb17f07e639acb1836d1ddbd72aa9e59bea6b7.tar.gz
Include 0xea byte as the last byte in RO/RW images
This is better than having the 0xea byte only appended in ec.bin, since now the byte is present in ec.RW.flat and ec.RO.flat. Needed for EC software sync. BUG=chrome-os-partner:12412 BRANCH=link,snow CQ-DEPEND=30305 TEST=manual 1. xxd ec.RW.bin | tail; should end with 0xea 2. xxd -g4 build/link/ec.bin | grep -C3 454e44ea That word should be the last one before a bunch of 0xfffffff bytes. There should be 2 matches (since there's RO and RW firmware) Change-Id: I0de5cc78083f1a9b49202fbe2305a3101f401db3 Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/30303 Reviewed-by: Bill Richardson <wfrichar@chromium.org> Reviewed-by: Simon Glass <sjg@chromium.org>
-rw-r--r--common/system_common.c12
-rw-r--r--core/cortex-m/ec.lds.S11
2 files changed, 17 insertions, 6 deletions
diff --git a/common/system_common.c b/common/system_common.c
index 00b754c037..e2dcddc342 100644
--- a/common/system_common.c
+++ b/common/system_common.c
@@ -245,15 +245,15 @@ int system_get_image_used(enum system_image_copy_t copy)
if (size <= 0)
return 0;
- /* If the last byte isn't 0xff, the image is completely full */
- if (image[size - 1] != 0xff)
- return size;
-
- /* Scan backwards looking for 0xea byte */
+ /*
+ * Scan backwards looking for 0xea byte, which is by definition the
+ * last byte of the image. See ec.lds.S for how this is inserted at
+ * the end of the image.
+ */
for (size--; size > 0 && image[size] != 0xea; size--)
;
- return size;
+ return size ? size + 1 : 0; /* 0xea byte IS part of the image */
}
/* Returns true if the given range is overlapped with the active image.
diff --git a/core/cortex-m/ec.lds.S b/core/cortex-m/ec.lds.S
index 53c5960045..393c6c4bc6 100644
--- a/core/cortex-m/ec.lds.S
+++ b/core/cortex-m/ec.lds.S
@@ -136,7 +136,18 @@ SECTIONS
/* Shared memory buffer must be at the end of preallocated RAM, so it
* can expand to use all the remaining RAM. */
__shared_mem_buf = .;
+
+ /* Tag at end of firmware image so that we can find the image size.
+ * This may be overwritten by the shared memory buffer; that's ok
+ * because we only use it to find the image size in flash. */
+ . = ALIGN(4);
+ BYTE(0x45);
+ BYTE(0x4e);
+ BYTE(0x44);
+ BYTE(0xea);
+ /* NOTHING MAY GO AFTER THIS! */
} > IRAM
+
/* 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"