summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNamyoon Woo <namyoon@chromium.org>2020-03-10 09:58:42 -0700
committerCommit Bot <commit-bot@chromium.org>2020-03-11 20:55:39 +0000
commit717f46db47b86e1c1d2d4698bad8dbe54a326d04 (patch)
tree43ce65901c1657777276dd42248c1a5b8a9ec38f
parentc34880f460e6aee75550ef105f1c8aabc3089a68 (diff)
downloadchrome-ec-717f46db47b86e1c1d2d4698bad8dbe54a326d04.tar.gz
allowing repeating an EC-EFS command, SET_BOOT_MODE
This patch allows the repeating SET_BOOT_MODE command except one case that attempts to change the boot mode from NO_BOOT to NORMAL. Cr50 resets EC on those violating commands. This patch adds error handling for an unknown boot mode parameter. BUG=none BRANCH=cr50 TEST=ran unittest, 'make run-ec_comm'. Signed-off-by: Namyoon Woo <namyoon@chromium.org> Change-Id: Ib6c97596ed9c7b7563fbe5e6497cbd668f57a474 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2096840 Reviewed-by: Mary Ruthven <mruthven@chromium.org>
-rw-r--r--common/ec_efs.c29
1 files changed, 27 insertions, 2 deletions
diff --git a/common/ec_efs.c b/common/ec_efs.c
index 8f5bece989..f801696338 100644
--- a/common/ec_efs.c
+++ b/common/ec_efs.c
@@ -43,7 +43,9 @@ static struct ec_efs_context_ {
*/
static void set_boot_mode_(uint8_t mode_val)
{
- CPRINTS("boot_mode: 0x%02x -> 0x%02x", ec_efs_ctx.boot_mode, mode_val);
+ if (ec_efs_ctx.boot_mode != mode_val)
+ cprints(CC_SYSTEM, "boot_mode: 0x%02x -> 0x%02x",
+ ec_efs_ctx.boot_mode, mode_val);
ec_efs_ctx.boot_mode = mode_val;
@@ -181,9 +183,28 @@ uint16_t ec_efs_set_boot_mode(const char * const data, const uint8_t size)
boot_mode = data[0];
- if (ec_efs_ctx.boot_mode != EC_EFS_BOOT_MODE_NORMAL) {
+ switch (boot_mode) {
+ case EC_EFS_BOOT_MODE_NORMAL:
+ /*
+ * Per EC-EFS2 design, CR50 accepts the repeating commands
+ * as long as the result is the same. It is to be tolerant
+ * against CR50 response loss, so that EC can resend the
+ * same command.
+ */
+ if (ec_efs_ctx.boot_mode == EC_EFS_BOOT_MODE_NORMAL)
+ break;
+ /*
+ * Once the boot mode is NO_BOOT, then it must not be
+ * set to NORMAL mode without resetting EC.
+ */
board_reboot_ec_deferred(0);
return 0;
+
+ case EC_EFS_BOOT_MODE_NO_BOOT:
+ break;
+
+ default:
+ return CR50_COMM_ERROR_BAD_PAYLOAD;
}
set_boot_mode_(boot_mode);
@@ -220,6 +241,10 @@ uint16_t ec_efs_verify_hash(const char *hash_data, const uint8_t size)
return CR50_COMM_ERROR_BAD_PAYLOAD;
}
+ /*
+ * Once the boot mode is not NORMAL, (i.e. it is NO_BOOT), then CR50
+ * should not approve the hash verification, but reset EC.
+ */
if (ec_efs_ctx.boot_mode != EC_EFS_BOOT_MODE_NORMAL) {
board_reboot_ec_deferred(0);
return 0;