summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorYuval Peress <peress@chromium.org>2021-02-25 22:23:02 -0700
committerCommit Bot <commit-bot@chromium.org>2021-02-26 23:46:36 +0000
commita464b4de0a54387300f336c629ad63125915b4ee (patch)
tree2460458dff69a1d8e412beb308473376db8d0545 /common
parent8a5a03850faabdc12c4d9b7552071c444c709ea0 (diff)
downloadchrome-ec-a464b4de0a54387300f336c629ad63125915b4ee.tar.gz
zephyr: efs2: Enable EFS2 for volteer
Enable efs2 running at boot for volteer using the CONFIG_PLATFORM_EC_VBOOT flag. When enabled, prior to starting any tasks, the RO image will compute the hash of the RW image and send it to the cr50 for verification. Note that the cr50 verification will fail right now until we update chromeos-bootimage-0.0.3.ebuild's add_ec() function to compute the hash using the zephyr build's output. This final change will be needed because zmake does not produce build/${BOARD}/R(O|W)/ec.R(O|W).flat BRANCH=none BUG=b:164421798 TEST=zmake testall TEST=build volteer, flash, see TX data to cr50 and correct response. Signed-off-by: Yuval Peress <peress@chromium.org> Change-Id: I2c8b3f726a843297cec3fc08306d8edaaa1999f7 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2721498 Commit-Queue: Keith Short <keithshort@chromium.org> Reviewed-by: Keith Short <keithshort@chromium.org>
Diffstat (limited to 'common')
-rw-r--r--common/vboot/efs2.c29
1 files changed, 24 insertions, 5 deletions
diff --git a/common/vboot/efs2.c b/common/vboot/efs2.c
index c196c75d99..b01b82bf8c 100644
--- a/common/vboot/efs2.c
+++ b/common/vboot/efs2.c
@@ -62,6 +62,7 @@ static enum cr50_comm_err send_to_cr50(const uint8_t *data, size_t size)
{
timestamp_t until;
int i, timeout = 0;
+ uint32_t lock_key;
struct cr50_comm_response res = {};
/* This will wake up (if it's sleeping) and interrupt Cr50. */
@@ -70,6 +71,8 @@ static enum cr50_comm_err send_to_cr50(const uint8_t *data, size_t size)
uart_flush_output();
uart_clear_input();
+ uart_shell_stop();
+
/*
* Send packet. No traffic control, assuming Cr50 consumes stream much
* faster. TX buffer shouldn't overflow because it's cleared above and
@@ -78,9 +81,9 @@ static enum cr50_comm_err send_to_cr50(const uint8_t *data, size_t size)
* Disable interrupts so that the data frame will be stored in the Tx
* buffer in one piece.
*/
- interrupt_disable();
+ lock_key = irq_lock();
uart_put_raw(data, size);
- interrupt_enable();
+ irq_unlock(lock_key);
uart_flush_output();
@@ -90,8 +93,10 @@ static enum cr50_comm_err send_to_cr50(const uint8_t *data, size_t size)
* Make sure console task won't steal the response in case we exchange
* packets after tasks start.
*/
+#ifndef CONFIG_ZEPHYR
if (task_start_called())
task_disable_task(TASK_ID_CONSOLE);
+#endif /* !CONFIG_ZEPHYR */
/* Wait for response from Cr50 */
for (i = 0; i < sizeof(res); i++) {
@@ -101,24 +106,38 @@ static enum cr50_comm_err send_to_cr50(const uint8_t *data, size_t size)
res.error = res.error | c << (i*8);
break;
}
- msleep(1);
+ /*
+ * TODO(b:181352041) Implement proper RX buffering.
+ * Zephyr's shell (even when "stopped") can steal some
+ * bytes from the uart RX. Skipping the sleep here
+ * appears to always let us capture the response. Once
+ * we're able to fork the shell RX, we'll be able to
+ * buffer the response and add the sleep back into the
+ * Zephyr builds here (or alternatively use event
+ * signals).
+ */
+ if (!IS_ENABLED(CONFIG_ZEPHYR))
+ msleep(1);
timeout = timestamp_expired(until, NULL);
}
}
+ uart_shell_start();
+#ifndef CONFIG_ZEPHYR
if (task_start_called())
task_enable_task(TASK_ID_CONSOLE);
+#endif /* CONFIG_ZEPHYR */
/* Exit packet mode */
enable_packet_mode(false);
+ CPRINTS("Received 0x%04x", res.error);
+
if (timeout) {
CPRINTS("Timeout");
return CR50_COMM_ERR_TIMEOUT;
}
- CPRINTS("Received 0x%04x", res.error);
-
return res.error;
}