diff options
author | Sam McNally <sammc@chromium.org> | 2020-02-27 21:29:25 +1100 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2020-03-03 07:47:32 +0000 |
commit | 6020472e12860d58ec3cf2d6336e4eecc2017b63 (patch) | |
tree | 351a3fc55a5e78c838147d7143c42998adcc2dd4 | |
parent | 9d3f321689ddcdc0989842055292aeb4e8d6f811 (diff) | |
download | chrome-ec-6020472e12860d58ec3cf2d6336e4eecc2017b63.tar.gz |
vboot: Add a reboot option to keep EFS in RO with the AP off.
With EFS, the EC will typically switch to RW shortly after boot.
cros_ec_softrec_power triggers recovery mode using the hostevent console
command after rebooting the EC with ap-off and then simulates a power
button press. This requires the EC to remain in RO after rebooting so
doesn't currently work with EFS.
Add a reboot option "ap-off-in-ro" to request the EC remain in RO with
the AP off after rebooting.
BUG=b:149657030
TEST=make buildall; firmware_RecoveryCacheBootKeys on puff
BRANCH=none
Change-Id: I65d291106accebf18bb46d951351def122627e61
Signed-off-by: Sam McNally <sammc@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2077699
Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
-rw-r--r-- | common/system.c | 14 | ||||
-rw-r--r-- | common/vboot/efs2.c | 6 | ||||
-rw-r--r-- | common/vboot/vboot.c | 7 | ||||
-rw-r--r-- | include/ec_commands.h | 3 | ||||
-rw-r--r-- | include/reset_flag_desc.inc | 1 | ||||
-rw-r--r-- | include/system.h | 4 |
6 files changed, 28 insertions, 7 deletions
diff --git a/common/system.c b/common/system.c index fa7eccabd5..72a3244fb0 100644 --- a/common/system.c +++ b/common/system.c @@ -213,6 +213,10 @@ void system_encode_save_flags(int reset_flags, uint32_t *save_flags) if (reset_flags & SYSTEM_RESET_LEAVE_AP_OFF) *save_flags |= EC_RESET_FLAG_AP_OFF; + /* Add in stay in RO flag into saved flags. */ + if (reset_flags & SYSTEM_RESET_STAY_IN_RO) + *save_flags |= EC_RESET_FLAG_STAY_IN_RO; + /* Save reset flag */ if (reset_flags & (SYSTEM_RESET_HARD | SYSTEM_RESET_WAIT_EXT)) *save_flags |= EC_RESET_FLAG_HARD; @@ -1213,6 +1217,9 @@ static int command_reboot(int argc, char **argv) flags &= ~SYSTEM_RESET_HARD; } else if (!strcasecmp(argv[i], "ap-off")) { flags |= SYSTEM_RESET_LEAVE_AP_OFF; + } else if (!strcasecmp(argv[i], "ap-off-in-ro")) { + flags |= (SYSTEM_RESET_LEAVE_AP_OFF | + SYSTEM_RESET_STAY_IN_RO); } else if (!strcasecmp(argv[i], "cancel")) { reboot_at_shutdown = EC_REBOOT_CANCEL; return EC_SUCCESS; @@ -1235,9 +1242,10 @@ static int command_reboot(int argc, char **argv) system_reset(flags); return EC_SUCCESS; } -DECLARE_CONSOLE_COMMAND(reboot, command_reboot, - "[hard|soft] [preserve] [ap-off] [wait-ext] [cancel]", - "Reboot the EC"); +DECLARE_CONSOLE_COMMAND( + reboot, command_reboot, + "[hard|soft] [preserve] [ap-off] [wait-ext] [cancel] [ap-off-in-ro]", + "Reboot the EC"); #ifdef CONFIG_CMD_SYSLOCK static int command_system_lock(int argc, char **argv) diff --git a/common/vboot/efs2.c b/common/vboot/efs2.c index 5c5771e58a..2e8947b84d 100644 --- a/common/vboot/efs2.c +++ b/common/vboot/efs2.c @@ -249,8 +249,10 @@ void vboot_main(void) return; } - if (is_manual_recovery()) { - CPRINTS("In recovery mode"); + if (is_manual_recovery() || + (system_get_reset_flags() & EC_RESET_FLAG_STAY_IN_RO)) { + if (is_manual_recovery()) + CPRINTS("In recovery mode"); if (!IS_ENABLED(CONFIG_BATTERY) && !IS_ENABLED(HAS_TASK_KEYSCAN)) { /* diff --git a/common/vboot/vboot.c b/common/vboot/vboot.c index 38924f4b3e..9819c9c316 100644 --- a/common/vboot/vboot.c +++ b/common/vboot/vboot.c @@ -204,8 +204,11 @@ void vboot_main(void) return; } - if (is_manual_recovery()) { - CPRINTS("Manual recovery"); + if (is_manual_recovery() || + (system_get_reset_flags() & EC_RESET_FLAG_STAY_IN_RO)) { + if (is_manual_recovery()) + CPRINTS("Manual recovery"); + if (battery_is_present() || has_matrix_keyboard()) { show_power_shortage(); return; diff --git a/include/ec_commands.h b/include/ec_commands.h index d68b7b6146..8f1e4ef523 100644 --- a/include/ec_commands.h +++ b/include/ec_commands.h @@ -5746,6 +5746,9 @@ struct ec_params_set_cbi { #define EC_RESET_FLAG_RBOX BIT(16) /* Fixed Reset Functionality */ #define EC_RESET_FLAG_SECURITY BIT(17) /* Security threat */ #define EC_RESET_FLAG_AP_WATCHDOG BIT(18) /* AP experienced a watchdog reset */ +#define EC_RESET_FLAG_STAY_IN_RO BIT(19) /* Do not select RW in EFS. This + * enables PD in RO for Chromebox. + */ struct ec_response_uptime_info { /* diff --git a/include/reset_flag_desc.inc b/include/reset_flag_desc.inc index 3d22b64633..58b142d3d3 100644 --- a/include/reset_flag_desc.inc +++ b/include/reset_flag_desc.inc @@ -26,3 +26,4 @@ "rbox", "security", "ap-watchdog", +"stay-in-ro", diff --git a/include/system.h b/include/system.h index af9fafb088..ced5446eee 100644 --- a/include/system.h +++ b/include/system.h @@ -263,6 +263,10 @@ const char *system_get_build_info(void); * Indicate that this reset was triggered by an AP watchdog */ #define SYSTEM_RESET_AP_WATCHDOG BIT(5) +/* + * Stay in RO next reboot, instead of potentially selecting RW during EFS. + */ +#define SYSTEM_RESET_STAY_IN_RO BIT(6) /** * Reset the system. |