diff options
-rw-r--r-- | chip/npcx/system.c | 4 | ||||
-rw-r--r-- | chip/npcx/system_chip.h | 1 | ||||
-rw-r--r-- | common/vboot.c | 6 | ||||
-rw-r--r-- | include/system.h | 1 |
4 files changed, 11 insertions, 1 deletions
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 @@ -185,6 +185,10 @@ static int bbram_idx_lookup(enum system_bbram_idx idx) 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, }; /** |