summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVadim Bendebury <vbendeb@chromium.org>2017-07-06 18:32:41 -0700
committerHung-Te Lin <hungte@chromium.org>2017-08-03 04:37:29 +0000
commit06a4499472b1919eea0fdd12ef75b946e246b924 (patch)
treee0340e844b3f4ff17f84409485d766dd8d6c4a7e
parent1a09831d0fdc6515e5d516074ee563a3e6e8ca12 (diff)
downloadchrome-ec-06a4499472b1919eea0fdd12ef75b946e246b924.tar.gz
usb_updater: display board ID information from RW headers
This patch adds code to interpret the contents of the Cr50 image's RW headers board ID fields. Board ID fields are added to the RW and RW_B version strings, as a three field colon separated value. The actual board ID is likely to be a 4 symbol ASCII string, if it is, the 4 ASCII characters are displayed. If it is not - the 8 character hex value is printed. The rest of the fields are displayed as 8 characters hex values. BRANCH=none BUG=b:62294740 TEST=tried the new option on various Cr50 images: $ ./extra/usb_updater/usb_updater -b build/cr50/ec.bin read 524288(0x80000) bytes from build/cr50/ec.bin RO_A:4919.0.0 RW_A:0.0.21[00000000:00000000:00000000] ... $ ./extra/usb_updater/usb_updater -b cr50.bin.dev read 524288(0x80000) bytes from cr50.bin.dev RO_A:0.0.10 RW_A:0.0.21[XXXR:00000004:00000001]... Change-Id: I5a92a600d24e4a7d6d615f256b5979414e883d77 Signed-off-by: Vadim Bendebury <vbendeb@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/562919 Reviewed-by: Randall Spangler <rspangler@chromium.org> (cherry picked from commit f50e0086e61aed2b722bd37c188e7e2204735f32) Reviewed-on: https://chromium-review.googlesource.com/599169 Reviewed-by: Hung-Te Lin <hungte@chromium.org> Commit-Queue: Hung-Te Lin <hungte@chromium.org> Tested-by: Hung-Te Lin <hungte@chromium.org> Trybot-Ready: Hung-Te Lin <hungte@chromium.org>
-rw-r--r--extra/usb_updater/usb_updater.c35
1 files changed, 35 insertions, 0 deletions
diff --git a/extra/usb_updater/usb_updater.c b/extra/usb_updater/usb_updater.c
index fa4f5e383f..48d45d08fb 100644
--- a/extra/usb_updater/usb_updater.c
+++ b/extra/usb_updater/usb_updater.c
@@ -5,6 +5,7 @@
*/
#include <asm/byteorder.h>
+#include <ctype.h>
#include <endian.h>
#include <fcntl.h>
#include <getopt.h>
@@ -1232,11 +1233,45 @@ static int show_headers_versions(const void *image)
for (i = 0; i < ARRAY_SIZE(sections); i++) {
const struct SignedHeader *h;
+ size_t j;
+ uint32_t bid;
+ uint32_t bid_mask;
+ uint32_t bid_flags;
h = (const struct SignedHeader *)((uintptr_t)image +
sections[i].offset);
printf("%s%s:%d.%d.%d", i ? " " : "", sections[i].name,
h->epoch_, h->major_, h->minor_);
+
+ if (sections[i].name[1] != 'W')
+ continue;
+
+ /*
+ * For read/write sections print the board ID fields'
+ * contents, which are stored XORed with a padding value.
+ */
+ bid = h->board_id_type ^ SIGNED_HEADER_PADDING;
+ bid_mask = h->board_id_type_mask ^ SIGNED_HEADER_PADDING;
+ bid_flags = h->board_id_flags ^ SIGNED_HEADER_PADDING;
+
+ /* Beginning of a board ID section of the string. */
+ printf("[");
+
+ /*
+ * If board ID is an ASCII string (as it ought to be), print
+ * it as 4 symbols, otherwise print it as an 8 digit hex.
+ */
+ for (j = 0; j < sizeof(bid); j++)
+ if (!isalnum(((const char *)&bid)[j]))
+ break;
+
+ if (j == sizeof(bid))
+ printf("%.4s", (const char *)&bid);
+ else
+ printf("%08x", bid);
+
+ /* Print the rest of the board ID fields. */
+ printf(":%08x:%08x]", bid_mask, bid_flags);
}
printf("\n");