From 15196acec9b793a4d4500f0ac659cf6e74e4ebe2 Mon Sep 17 00:00:00 2001 From: Mary Ruthven Date: Thu, 11 Apr 2019 15:50:43 -0700 Subject: cr50: sqa: don't modify flags if board id is erased Cr50 can only set a board id if the board id is blank. 0xffffffff:0xffffffff:0xffffffff is a blank board id. As SQA images are now if you run eraseflashinfo while the board id isn't set, eraseflashinfo will set the flags to 0 without changing the RLZ information. The BID will be 0xffffffff:0xffffffff:0. This board id isn't considered blank, so you won't be able to set the RLZ in the future. Also the second field is not the inverse of the first, so it will be considered invalid. This is a very bad state to get the board id into because you can't change it, but it's also invalid. This change checks that the board id is set before modifying the flags. Cr50 wont modify the flags of an erased board id. It will only change the flags if the board id is set. BUG=none BRANCH=none TEST=erase the board id. make sure flags aren't set to 0 after running eraseflashinfo. Set the board id. Make sure flags are set to 0 after running eraseflashinfo. Change-Id: Idc184e58c0dc398bc93c1119d822a13889c59963 Signed-off-by: Mary Ruthven Reviewed-on: https://chromium-review.googlesource.com/1565452 Reviewed-by: Namyoon Woo --- chip/g/flash.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'chip') diff --git a/chip/g/flash.c b/chip/g/flash.c index 2f567d89b4..8a9622e64c 100644 --- a/chip/g/flash.c +++ b/chip/g/flash.c @@ -551,7 +551,12 @@ static int command_erase_flash_info(int argc, char **argv) } } #endif - info1->board_space.bid.flags = flags; + if (board_id_is_blank(&info1->board_space.bid)) { + ccprintf("BID is erased. Not modifying flags\n"); + } else { + ccprintf("setting BID flags to %x\n", flags); + info1->board_space.bid.flags = flags; + } if (check_board_id_vs_header(&info1->board_space.bid, get_current_image_header())) { ccprintf("Flags %x would lock out current image\n", -- cgit v1.2.1