summaryrefslogtreecommitdiff
path: root/util
diff options
context:
space:
mode:
authorRandall Spangler <rspangler@chromium.org>2012-08-09 15:17:24 -0700
committerGerrit <chrome-bot@google.com>2012-08-09 17:40:38 -0700
commit6cd9e1124b2432f7b6d8693cc4bd170514cfd689 (patch)
treed418d284bd196d476426287c472dec8e5142ab43 /util
parent371d06bbfdf56fad142539c9a72759e53d5bc26a (diff)
downloadchrome-ec-6cd9e1124b2432f7b6d8693cc4bd170514cfd689.tar.gz
Add ectool command to read snapshot of EC's console output
BUG=chrome-os-partner:12483 TEST=from root shell, 'ectool console', then on the ec console, type 'help list' a few times to generate lots of debug output, then repeat 'ectool console'. Then on EC console, 'syslock', and then 'ectool console' should fail. Change-Id: Ie1c74c7e35d6b8228615d20192fd90093977de64 Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/29825 Reviewed-by: Bill Richardson <wfrichar@chromium.org>
Diffstat (limited to 'util')
-rw-r--r--util/ectool.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/util/ectool.c b/util/ectool.c
index b0375c1e56..7478fa86c0 100644
--- a/util/ectool.c
+++ b/util/ectool.c
@@ -36,6 +36,8 @@ const char help_str[] =
" Prints chip info\n"
" cmdversions <cmd>\n"
" Prints supported version mask for a command number\n"
+ " console\n"
+ " Prints the last output to the EC debug console\n"
" echash [CMDS]\n"
" Various EC hash commands\n"
" eventclear <mask>\n"
@@ -2072,6 +2074,34 @@ int cmd_rtc_set(int argc, char *argv[])
return 0;
}
+int cmd_console(int argc, char *argv[])
+{
+ char out[EC_HOST_PARAM_SIZE];
+ int rv;
+
+ /* Snapshot the EC console */
+ rv = ec_command(EC_CMD_CONSOLE_SNAPSHOT, 0, NULL, 0, NULL, 0);
+ if (rv < 0)
+ return rv;
+
+ /* Loop and read from the snapshot until it's done */
+ while (1) {
+ rv = ec_command(EC_CMD_CONSOLE_READ, 0,
+ NULL, 0, out, sizeof(out));
+ if (rv < 0)
+ return rv;
+
+ if (rv == 0)
+ break; /* Empty response means done */
+
+ /* Make sure output is null-terminated, then dump it */
+ out[sizeof(out) - 1] = '\0';
+ fputs(out, stdout);
+ }
+ printf("\n");
+ return 0;
+}
+
struct command {
const char *name;
@@ -2086,6 +2116,7 @@ const struct command commands[] = {
{"chargeforceidle", cmd_charge_force_idle},
{"chipinfo", cmd_chipinfo},
{"cmdversions", cmd_cmdversions},
+ {"console", cmd_console},
{"echash", cmd_ec_hash},
{"eventclear", cmd_host_event_clear},
{"eventclearb", cmd_host_event_clear_b},