summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--common/ec_comm.c29
-rw-r--r--common/ec_efs.c10
-rw-r--r--include/ec_comm.h2
3 files changed, 39 insertions, 2 deletions
diff --git a/common/ec_comm.c b/common/ec_comm.c
index e24c2af94c..169e65eb55 100644
--- a/common/ec_comm.c
+++ b/common/ec_comm.c
@@ -322,6 +322,23 @@ static int command_ec_comm(int argc, char **argv)
return EC_ERROR_INVAL;
}
+ if (argc > 1) {
+#ifdef CR50_RELAXED
+ if (!strcasecmp(argv[1], "corrupt"))
+ ec_efs_corrupt_hash();
+ else if (!strcasecmp(argv[1], "reload"))
+ ec_efs_refresh();
+ else
+ return EC_ERROR_PARAM1;
+ /*
+ * let's keep processing so that we can see how the context
+ * values are changed.
+ */
+#else
+ return EC_ERROR_PARAM_COUNT;
+#endif
+ }
+
/*
* EC Packet Context
*/
@@ -343,5 +360,13 @@ static int command_ec_comm(int argc, char **argv)
return EC_SUCCESS;
}
-DECLARE_SAFE_CONSOLE_COMMAND(ec_comm, command_ec_comm, NULL,
- "Dump EC-CR50-comm status");
+DECLARE_SAFE_CONSOLE_COMMAND(ec_comm, command_ec_comm,
+#ifdef CR50_RELAXED
+ "[corrupt|reload]",
+ "Dump EC-CR50-comm status, or corrupt ECRW hash,"
+ "or reload it"
+#else
+ NULL,
+ "Dump EC-CR50-comm status"
+#endif
+);
diff --git a/common/ec_efs.c b/common/ec_efs.c
index 9cc4061882..9952e0bc1c 100644
--- a/common/ec_efs.c
+++ b/common/ec_efs.c
@@ -281,6 +281,16 @@ void ec_efs_print_status(void)
#endif
}
+#ifdef CR50_RELAXED
+void ec_efs_corrupt_hash(void)
+{
+ int i;
+
+ for (i = 0; i < SHA256_DIGEST_SIZE; i++)
+ ec_efs_ctx.hash[i] = ~ec_efs_ctx.hash[i] + 0x01;
+}
+#endif
+
#ifdef BOARD_HOST
uint8_t ec_efs_get_boot_mode(void)
{
diff --git a/include/ec_comm.h b/include/ec_comm.h
index dee31df4be..c599868488 100644
--- a/include/ec_comm.h
+++ b/include/ec_comm.h
@@ -41,6 +41,8 @@ uint16_t ec_efs_verify_hash(const char *hash_data, const uint8_t size);
void ec_efs_refresh(void);
/* print EC-EFS status */
void ec_efs_print_status(void);
+/* corrupt ECRW hash */
+void ec_efs_corrupt_hash(void);
#ifdef BOARD_HOST
/* return the current boot mode. For test purpose only. */