summaryrefslogtreecommitdiff
path: root/chip/g/board_id.c
diff options
context:
space:
mode:
authorVadim Bendebury <vbendeb@chromium.org>2017-06-13 15:47:23 -0700
committerchrome-bot <chrome-bot@chromium.org>2017-06-15 20:13:51 -0700
commitdcca1de5288660409a78e5682dc2d445450fe1a5 (patch)
tree8688bccc2f5af293f0977c83607aeb0d418ad296 /chip/g/board_id.c
parent94a9cfc02fa2aae6bfde6afc3454bf9089019bdf (diff)
downloadchrome-ec-dcca1de5288660409a78e5682dc2d445450fe1a5.tar.gz
g: add a function to report current board ID mismatch status
Until the Board ID check is moved to RO, it is possible to start an RW with a mismatching Board ID. Let's add a function to check for mismatch and report the status. Also eliminating the unnecessary check for empty header Board ID field - it is going to match any board ID anyways and fixing a CPRINTF statement in read_board_id(). BRANCH=cr50 BUG=b:35586335 TEST=verified that empty board ID header does not trigger a mismatch on a board with a non-empty INFO1. With the rest of the patches applied verified that board ID mismatch is reported properly. Change-Id: Ie03f8137e494117b7a238e3af72527e0a46369e1 Signed-off-by: Vadim Bendebury <vbendeb@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/535975 Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
Diffstat (limited to 'chip/g/board_id.c')
-rw-r--r--chip/g/board_id.c23
1 files changed, 16 insertions, 7 deletions
diff --git a/chip/g/board_id.c b/chip/g/board_id.c
index fb3fb8755e..85b84c63ed 100644
--- a/chip/g/board_id.c
+++ b/chip/g/board_id.c
@@ -39,12 +39,6 @@ uint32_t check_board_id_vs_header(const struct board_id *id,
header_board_id_mask = SIGNED_HEADER_PADDING ^ h->board_id_type_mask;
header_board_id_flags = SIGNED_HEADER_PADDING ^ h->board_id_flags;
- /* Blank header means this is a common image, can run on any device. */
- if ((header_board_id_type |
- header_board_id_mask |
- header_board_id_flags) == 0)
- return 0;
-
/*
* Masked bits in header Board ID type must match type and inverse from
* flash.
@@ -92,7 +86,7 @@ int read_board_id(struct board_id *id)
id_p);
if (rv != EC_SUCCESS) {
CPRINTF("%s: failed to read word %d, error %d\n",
- i, rv);
+ __func__, i, rv);
return rv;
}
id_p++;
@@ -100,6 +94,21 @@ int read_board_id(struct board_id *id)
return EC_SUCCESS;
}
+uint32_t board_id_mismatch(void)
+{
+ struct board_id id;
+ const struct SignedHeader *sh;
+
+ /* Get header of the currently running image. */
+ sh = get_current_image_header();
+
+ /* Get Board ID from INFO1. */
+ if (read_board_id(&id) != EC_SUCCESS)
+ return 1;
+
+ return check_board_id_vs_header(&id, sh);
+}
+
/**
* Write board ID into the flash INFO1 space.
*