From 031dccad78b9d4df6b970bc36ef2f9d469239708 Mon Sep 17 00:00:00 2001 From: Daisuke Nojiri Date: Tue, 30 May 2017 13:41:13 -0700 Subject: vboot_ec:Read try slot from BBRAM This patch makes EC read the slot to verify and jump to from the battery backed up RAM (BBRAM). BUG=b:38462249 BRANCH=none TEST=Boot Fizz Change-Id: I0c78861ea3ccdc45d0aa08e690e3a68f53658409 Signed-off-by: Daisuke Nojiri Reviewed-on: https://chromium-review.googlesource.com/518255 --- chip/npcx/system.c | 4 ++++ chip/npcx/system_chip.h | 1 + common/vboot.c | 6 +++++- include/system.h | 1 + 4 files changed, 11 insertions(+), 1 deletion(-) diff --git a/chip/npcx/system.c b/chip/npcx/system.c index 15d575658d..a3dad67bc5 100644 --- a/chip/npcx/system.c +++ b/chip/npcx/system.c @@ -184,6 +184,10 @@ static int bbram_idx_lookup(enum system_bbram_idx idx) return BBRM_DATA_INDEX_PD0; if (idx == SYSTEM_BBRAM_IDX_PD1) return BBRM_DATA_INDEX_PD1; +#endif +#ifdef CONFIG_VBOOT_EC + if (idx == SYSTEM_BBRAM_IDX_TRY_SLOT) + return BBRM_DATA_INDEX_TRY_SLOT; #endif return -1; } diff --git a/chip/npcx/system_chip.h b/chip/npcx/system_chip.h index 21560895c5..37e49a406c 100644 --- a/chip/npcx/system_chip.h +++ b/chip/npcx/system_chip.h @@ -19,6 +19,7 @@ enum bbram_data_index { BBRM_DATA_INDEX_WAKE = 8, /* Wake reasons for hibernate */ BBRM_DATA_INDEX_PD0 = 12, /* USB-PD saved port0 state */ BBRM_DATA_INDEX_PD1 = 13, /* USB-PD saved port1 state */ + BBRM_DATA_INDEX_TRY_SLOT = 14, /* Vboot EC try slot */ BBRM_DATA_INDEX_VBNVCNTXT = 16, /* VbNvContext for ARM arch */ BBRM_DATA_INDEX_RAMLOG = 32, /* RAM log for Booter */ BBRM_DATA_INDEX_PANIC_FLAGS = 35, /* Flag to indicate validity of diff --git a/common/vboot.c b/common/vboot.c index b298a1d427..6f16d05380 100644 --- a/common/vboot.c +++ b/common/vboot.c @@ -48,9 +48,13 @@ static int verify_slot(int slot) static int verify_rw(void) { - uint8_t slot = VBOOT_EC_SLOT_A; + uint8_t slot; /* 1. Read BBRAM to decide which slot to verify */ + if (system_get_bbram(SYSTEM_BBRAM_IDX_TRY_SLOT, &slot)) { + CPRINTS("Failed to read try slot"); + slot = VBOOT_EC_SLOT_A; + } /* 2. Verify the slot */ return verify_slot(slot); } diff --git a/include/system.h b/include/system.h index 10c10ccf52..8bc63332c2 100644 --- a/include/system.h +++ b/include/system.h @@ -307,6 +307,7 @@ enum system_bbram_idx { /* PD state for CONFIG_USB_PD_DUAL_ROLE uses one byte per port */ SYSTEM_BBRAM_IDX_PD0, SYSTEM_BBRAM_IDX_PD1, + SYSTEM_BBRAM_IDX_TRY_SLOT, }; /** -- cgit v1.2.1