diff options
author | Wei-Han Chen <stimim@google.com> | 2018-08-16 15:29:48 +0800 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2018-09-03 08:50:35 -0700 |
commit | 6e853562c94698916c7f582df064a154b154f3d6 (patch) | |
tree | 03c73850fb25dc7179e3d9fd64982a50316b34e6 /common/usb_update.c | |
parent | 5cd66ffe1698b94cb83bb05732af01e95f2f2510 (diff) | |
download | chrome-ec-6e853562c94698916c7f582df064a154b154f3d6.tar.gz |
usb_update: add extra command "UPDATE_EXTRA_CMD_CONSOLE_READ_*"
Similar to corressponding host commands, we can read uart console buffer
by following ways:
A. Read from the beginning of buffer to the end of buffer:
# 1. set snapshot before reading
UPDATE_EXTRA_CMD_CONSOLE_READ_INIT
while (true) {
# 2. read 64 bytes back
UPDATE_EXTRA_CMD_CONSOLE_READ_NEXT CONSOLE_READ_NEXT
# 3. if (2) returns an empty string, break, otherwise, continue.
}
B. Mimic `dmesg -w` (keep reading new messages)
while (true) {
# 1. set snapshot before reading
UPDATE_EXTRA_CMD_CONSOLE_READ_INIT
while (true) {
# 2. read 64 bytes back
UPDATE_EXTRA_CMD_CONSOLE_READ_NEXT CONSOLE_READ_RECENT
# 3. if (2) returns an empty string, break, otherwise, continue.
}
}
Add argument `-l` to usb_updater2, which will perform (B). Note that
the update interface will be occupied while `usb_updater2 -l` is still
running, so you can't use other updater command at the same time.
BRANCH=none
BUG=b:112877237
TEST=test on whiskers
Signed-off-by: Wei-Han Chen <stimim@chromium.org>
Change-Id: I8d2010f84602ca6b84034a0cabe42ae7441614e0
Reviewed-on: https://chromium-review.googlesource.com/1177293
Commit-Ready: Wei-Han Chen <stimim@chromium.org>
Tested-by: Wei-Han Chen <stimim@chromium.org>
Reviewed-by: Nicolas Boichat <drinkcat@chromium.org>
Diffstat (limited to 'common/usb_update.c')
-rw-r--r-- | common/usb_update.c | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/common/usb_update.c b/common/usb_update.c index 0ab7a3e2c6..abf709ef61 100644 --- a/common/usb_update.c +++ b/common/usb_update.c @@ -16,6 +16,7 @@ #include "rwsig.h" #include "sha256.h" #include "system.h" +#include "uart.h" #include "update_fw.h" #include "usb-stream.h" #include "util.h" @@ -352,6 +353,37 @@ static int try_vendor_command(struct consumer const *consumer, size_t count) return 1; } #endif +#ifdef CONFIG_USB_CONSOLE_READ + /* + * TODO(b/112877237): move this to a new interface, so we can + * support reading log and other commands at the same time? + */ + case UPDATE_EXTRA_CMD_CONSOLE_READ_INIT: + response = uart_console_read_buffer_init(); + break; + case UPDATE_EXTRA_CMD_CONSOLE_READ_NEXT: { + uint8_t *data = buffer + header_size; + uint8_t output[64]; + uint16_t write_count = 0; + + if (data_count != 1) { + response = EC_RES_INVALID_PARAM; + break; + } + + response = uart_console_read_buffer( + data[0], + (char *)output, + MIN(sizeof(output), + queue_space(&update_to_usb)), + &write_count); + if (response != EC_RES_SUCCESS || write_count == 0) + break; + + QUEUE_ADD_UNITS(&update_to_usb, output, write_count); + return 1; + } +#endif default: response = EC_RES_INVALID_COMMAND; } |