From d214c6b3dc06e1ff4c11438f2420a1d29bc35ee8 Mon Sep 17 00:00:00 2001 From: Keith Short Date: Fri, 12 Nov 2021 14:49:50 -0700 Subject: zephyr: fix CONSOLE_READ_NEXT Running "ectool console" from the AP uses the subcommand CONSOLE_READ_NEXT, but this never returned valid data. Fixed by setting the current snapshot head, to the current buffer head instead of current buffer tail. BUG=none BRANCH=none TEST=Run "ectool console", verify console data is shown. Signed-off-by: Keith Short Change-Id: I9cbd7c11f1a0695370454f1687c1be7205a2b4d2 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3278638 Reviewed-by: Jack Rosenthal Commit-Queue: Jack Rosenthal --- zephyr/shim/src/console_buffer.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/zephyr/shim/src/console_buffer.c b/zephyr/shim/src/console_buffer.c index 427ae47768..191306c80e 100644 --- a/zephyr/shim/src/console_buffer.c +++ b/zephyr/shim/src/console_buffer.c @@ -13,6 +13,7 @@ static char console_buf[CONFIG_PLATFORM_EC_HOSTCMD_CONSOLE_BUF_SIZE]; static uint32_t previous_snapshot_idx; static uint32_t current_snapshot_idx; +static uint32_t head_idx; static uint32_t tail_idx; static inline uint32_t next_idx(uint32_t cur_idx) @@ -42,6 +43,8 @@ void console_buf_notify_chars(const char *s, size_t len) /* Check if we are starting to overwrite our snapshot * heads */ + if (new_tail == head_idx) + head_idx = next_idx(head_idx); if (new_tail == previous_snapshot_idx) previous_snapshot_idx = next_idx(previous_snapshot_idx); @@ -62,7 +65,7 @@ enum ec_status uart_console_read_buffer_init(void) return EC_RES_TIMEOUT; previous_snapshot_idx = current_snapshot_idx; - current_snapshot_idx = tail_idx; + current_snapshot_idx = head_idx; k_mutex_unlock(&console_write_lock); -- cgit v1.2.1