diff options
author | Shawn Nematbakhsh <shawnn@chromium.org> | 2015-02-11 19:32:15 -0800 |
---|---|---|
committer | ChromeOS Commit Bot <chromeos-commit-bot@chromium.org> | 2015-02-12 23:08:45 +0000 |
commit | 96536de3f4c2b942b5c40ac18a2a42d282f98dbf (patch) | |
tree | 3c63f70b667905fc65a66445553779ae71e5662e /util | |
parent | abbcf4152946c2a086bde85a2f56db0bbf54996f (diff) | |
download | chrome-ec-96536de3f4c2b942b5c40ac18a2a42d282f98dbf.tar.gz |
pd_log: Add command to request PD MCU to write a log
When we find that charging is in a wedged state, we may wish to write a
PD log entry, but the PD MCU cannot detect such a state on its own.
Therefore, add a new command to ask the PD MCU to write a log of a given
type, and add a new board-specific custom log event.
BUG=chrome-os-partner:36668
TEST=Manual on samus:
./ectool --dev=1 pdwritelog charge 0
./ectool --dev=1 pdwritelog charge 1
./ectool --dev=1 pdwritelog 1 0
./ectool --dev=1 pdwritelog 2 0
./ectool --dev=1 pdlog
Verify log output matches expectation:
2015-02-12 11:12:49.290 P0 SRC
2015-02-12 11:12:49.296 P1 SNK Charger PD 20286mV max 20000mV / 3000mA
2015-02-12 11:12:49.303 P0 New connection
2015-02-12 11:12:49.310 P0 Board-custom event
--- END OF LOG --
Also, verify kernel logging of wedged event:
[ 181.378420] PDLOG 2015/02/12 19:13:44.019 P0 Event 02 (0000) []
Also, trigger wedged state on Samus and verify log entry is written.
BRANCH=Samus
Change-Id: I55c7c839cf8300fcd3931dccdaaf16c1065e31a8
Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/248981
Reviewed-by: Alec Berg <alecaberg@chromium.org>
Diffstat (limited to 'util')
-rw-r--r-- | util/ectool.c | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/util/ectool.c b/util/ectool.c index 251e604b84..ed4787706f 100644 --- a/util/ectool.c +++ b/util/ectool.c @@ -141,6 +141,8 @@ const char help_str[] = " Whether or not the AP should pause in S5 on shutdown\n" " pdlog\n" " Prints the PD event log entries\n" + " pdwritelog <type> <port>\n" + " Writes a PD event log of the given <type>\n" " pdgetmode <port>\n" " Get All USB-PD alternate SVIDs and modes on <port>\n" " pdsetmode <port> <svid> <opos>\n" @@ -5469,6 +5471,10 @@ int cmd_pd_log(int argc, char *argv[]) >> CHARGE_FLAGS_TYPE_SHIFT; pinfo.max_power = 0; print_pd_power_info(&pinfo); + } else if (u.r.type == PD_EVENT_MCU_CONNECT) { + printf("New connection\n"); + } else if (u.r.type == PD_EVENT_MCU_BOARD_CUSTOM) { + printf("Board-custom event\n"); } else if (u.r.type == PD_EVENT_ACC_RW_FAIL) { printf("RW signature check failed\n"); } else if (u.r.type == PD_EVENT_PS_FAULT) { @@ -5503,6 +5509,36 @@ int cmd_pd_log(int argc, char *argv[]) return 0; } +int cmd_pd_write_log(int argc, char *argv[]) +{ + struct ec_params_pd_write_log_entry p; + char *e; + + if (argc < 3) { + fprintf(stderr, "Usage: %s <log_type> <port>\n", + argv[0]); + return -1; + } + + if (!strcasecmp(argv[1], "charge")) + p.type = PD_EVENT_MCU_CHARGE; + else { + p.type = strtol(argv[1], &e, 0); + if (e && *e) { + fprintf(stderr, "Bad log_type parameter.\n"); + return -1; + } + } + + p.port = strtol(argv[2], &e, 0); + if (e && *e) { + fprintf(stderr, "Bad port parameter.\n"); + return -1; + } + + return ec_command(EC_CMD_PD_WRITE_LOG_ENTRY, 0, &p, sizeof(p), NULL, 0); +} + /* NULL-terminated list of commands */ const struct command commands[] = { {"extpwrcurrentlimit", cmd_ext_power_current_limit}, @@ -5559,6 +5595,7 @@ const struct command commands[] = { {"pdsetmode", cmd_pd_set_amode}, {"port80read", cmd_port80_read}, {"pdlog", cmd_pd_log}, + {"pdwritelog", cmd_pd_write_log}, {"powerinfo", cmd_power_info}, {"protoinfo", cmd_proto_info}, {"pstoreinfo", cmd_pstore_info}, |