summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMary Ruthven <mruthven@chromium.org>2019-10-30 18:43:44 -0700
committerCommit Bot <commit-bot@chromium.org>2019-11-07 22:52:12 +0000
commit7d561ace8577c20c2c2ffd5eb01cf0a36abff619 (patch)
treeb5d821b2075b9a353917a058146dc3c3a23099a4
parentc3126e7f49743606d1686163b446af3a4db15965 (diff)
downloadchrome-ec-7d561ace8577c20c2c2ffd5eb01cf0a36abff619.tar.gz
g: board_id: allow setting bid type if only flags are set
It's ok to set the board id type if it's blank. It doesn't matter if the flags are set. Use the given flags if the flags are empty or use the existing flags if they're already set. BUG=b:143649068 BRANCH=cr50 TEST=manual eraseflashinfo gsctool -i ZZAF:0x7f7f - SUCCEEDS. Board ID: 5a5a4146:a5a5beb9, flags 00007f7f gsctool -i ZZAF:0x7f7f - FAILS Board ID: 5a5a4146:a5a5beb9, flags 00007f7f eraseflashinfo gsctool -i 0xffffffff:0x3f80 - SUCCEEDS. Board ID: ffffffff:ffffffff, flags 00003f80 gsctool -i ZZAF:0x7f7f - SUCCEEDS. Board ID: 5a5a4146:a5a5beb9, flags 00003f80 eraseflashinfo bid 0xffffffff 0x3f80 Board ID: ffffffff:00000000, flags 00003f80 gsctool -i ZZST:0x3f80 - FAILS. Board ID: ffffffff:00000000, flags 00003f80 update to image with BID TEST:ffff:10 eraseflashinfo gsctool -i 0xffffffff:0x3f80 - FAILS Board ID: ffffffff:ffffffff, flags ffffffff gsctool -i ZZAF:0x7f7f - FAILS Board ID: ffffffff:ffffffff, flags ffffffff gsctool -i ZZST:0x7f7f - SUCCEEDS. Board ID: 5a5a5354:a5a5acab, flags 00007f7f update to image with BID TEST:0:100 eraseflashinfo gsctool -i whitelabel - SUCCEEDS. Board ID: ffffffff:ffffffff, flags 00003f80 gsctool -i ZZST:0 - SUCCEEDS. Board ID: 5a5a5354:a5a5acab, flags 00003f80 Change-Id: I07de4721cb9cc9ad6e74a51e1794a49cb70f70fb Signed-off-by: Mary Ruthven <mruthven@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1892122 Reviewed-by: Namyoon Woo <namyoon@chromium.org>
-rw-r--r--chip/g/board_id.c30
1 files changed, 17 insertions, 13 deletions
diff --git a/chip/g/board_id.c b/chip/g/board_id.c
index 1c9fe81afb..6a7309e739 100644
--- a/chip/g/board_id.c
+++ b/chip/g/board_id.c
@@ -133,21 +133,11 @@ uint32_t board_id_mismatch(const struct SignedHeader *sh)
* @return EC_SUCCESS or an error code in cases of various failures to read or
* if the space has been already initialized.
*/
-static int write_board_id(const struct board_id *id)
+static int write_board_id(struct board_id *id)
{
struct board_id id_test;
uint32_t rv;
- /*
- * Make sure the current header will still validate against the
- * proposed values. If it doesn't, then programming these values
- * would cause the next boot to fail.
- */
- if (check_board_id_vs_header(id, get_current_image_header()) != 0) {
- CPRINTS("%s: Board ID wouldn't allow current header", __func__);
- return EC_ERROR_INVAL;
- }
-
/* Fail if Board ID is already programmed */
rv = read_board_id(&id_test);
if (rv != EC_SUCCESS) {
@@ -156,8 +146,22 @@ static int write_board_id(const struct board_id *id)
}
if (!board_id_is_blank(&id_test)) {
- CPRINTS("%s: Board ID already programmed", __func__);
- return EC_ERROR_ACCESS_DENIED;
+ if (!board_id_type_is_blank(&id_test)) {
+ CPRINTS("%s: Board ID already programmed", __func__);
+ return EC_ERROR_ACCESS_DENIED;
+ }
+ CPRINTS("%s: using old flags.", __func__);
+ id->flags = id_test.flags;
+ }
+
+ /*
+ * Make sure the current header will still validate against the
+ * proposed values. If it doesn't, then programming these values
+ * would cause the next boot to fail.
+ */
+ if (check_board_id_vs_header(id, get_current_image_header()) != 0) {
+ CPRINTS("%s: Board ID wouldn't allow current header", __func__);
+ return EC_ERROR_INVAL;
}
flash_info_write_enable();