diff options
author | Keith Short <keithshort@chromium.org> | 2021-11-12 14:49:50 -0700 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2021-11-12 23:25:27 +0000 |
commit | d214c6b3dc06e1ff4c11438f2420a1d29bc35ee8 (patch) | |
tree | d36e33f1bca2b2ace6ba0dbd787d3ab794195d4e | |
parent | 99e0cf6844fa96d006fcdaae151f4f5c70f9c9ca (diff) | |
download | chrome-ec-d214c6b3dc06e1ff4c11438f2420a1d29bc35ee8.tar.gz |
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 <keithshort@chromium.org>
Change-Id: I9cbd7c11f1a0695370454f1687c1be7205a2b4d2
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3278638
Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
Commit-Queue: Jack Rosenthal <jrosenth@chromium.org>
-rw-r--r-- | zephyr/shim/src/console_buffer.c | 5 |
1 files changed, 4 insertions, 1 deletions
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); |