diff options
author | Todd Broch <tbroch@chromium.org> | 2014-08-26 13:33:49 -0700 |
---|---|---|
committer | chrome-internal-fetch <chrome-internal-fetch@google.com> | 2014-09-11 19:59:59 +0000 |
commit | d9c6380a66930b5bf22f25399491219756ec56e0 (patch) | |
tree | b338b61b32832b74c1476bbd6d8f774ecf04741d /util | |
parent | 0d6b9ad7bd4c1ea40c76508644ee3253e6ea86a5 (diff) | |
download | chrome-ec-d9c6380a66930b5bf22f25399491219756ec56e0.tar.gz |
samus: Add host command to store USB PD device id & rw_hash entry.
PD accessories that are RW update-able will broadcast their rw_hash
SHA1 digest upon connection and remain in RO briefly for a response.
In order to speed-up the response and decouple common case of
accessory is up-to-date, the PD MCU will keep a small 4 entry table of
PD accessory device ids and their corresponding RW hashes for quick
lookup.
The AP will be the source of new updates and their corresponding
device id's and RW hashes and therefore needs a method to update the
PD MCU table.
This CL creates the table, host command & ectool command to facilitate
future driver / daemon to update the RW hash entries.
BRANCH=none
BUG=chrome-os-partner:31361
TEST=manual,
# from AP
for i in `seq 1 8` ; do
ectool --dev=1 --interface=lpc rwhashpd $i $i $i $i $i $i
done
# from samus_pd console
pd rwhash
Device:5 Hash: 0x00000005 0x00000005 0x00000005 0x00000005 0x00000005
Device:6 Hash: 0x00000006 0x00000006 0x00000006 0x00000006 0x00000006
Device:7 Hash: 0x00000007 0x00000007 0x00000007 0x00000007 0x00000007
Device:8 Hash: 0x00000008 0x00000008 0x00000008 0x00000008 0x00000008
Change-Id: Ibe87b3594793cd5215eba42160489b26974aadbc
Signed-off-by: Todd Broch <tbroch@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/214366
Reviewed-by: Alec Berg <alecaberg@chromium.org>
Diffstat (limited to 'util')
-rw-r--r-- | util/ectool.c | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/util/ectool.c b/util/ectool.c index 8f722f974d..0d380c0e78 100644 --- a/util/ectool.c +++ b/util/ectool.c @@ -160,6 +160,8 @@ const char help_str[] = " Print real-time clock\n" " rtcset <time>\n" " Set real-time clock\n" + " rwhashpd <dev_id> <SHA1[0] ... <SHA1[4]>\n" + " Set entry in PD MCU's device rw_hash table.\n" " sertest\n" " Serial output test for COM2\n" " switches\n" @@ -778,6 +780,38 @@ int cmd_flash_protect(int argc, char *argv[]) return 0; } +int cmd_rw_hash_pd(int argc, char *argv[]) +{ + struct ec_params_usb_pd_rw_hash_entry *p = + (struct ec_params_usb_pd_rw_hash_entry *)ec_outbuf; + int i, rv; + char *e; + + if (argc < 7) { + fprintf(stderr, "Usage: %s <dev_id> <SHA1[0]> ... <SHA1[4]>\n", + argv[0]); + return -1; + } + + p->dev_id = strtol(argv[1], &e, 0); + if (e && *e) { + fprintf(stderr, "Bad device ID\n"); + return -1; + } + + for (i = 2; i < 7; i++) { + p->dev_rw_hash.w[i - 2] = strtol(argv[i], &e, 0); + if (e && *e) { + fprintf(stderr, "Bad SHA1 digest\n"); + return -1; + } + } + rv = ec_command(EC_CMD_USB_PD_RW_HASH_ENTRY, 0, p, sizeof(*p), NULL, 0); + + return rv; +} + + /* PD image size is 16k minus 32 bits for the RW hash */ #define PD_RW_IMAGE_SIZE (16 * 1024 - 32) static struct sha1_ctx ctx; @@ -4729,6 +4763,7 @@ const struct command commands[] = { {"reboot_ec", cmd_reboot_ec}, {"rtcget", cmd_rtc_get}, {"rtcset", cmd_rtc_set}, + {"rwhashpd", cmd_rw_hash_pd}, {"sertest", cmd_serial_test}, {"port80flood", cmd_port_80_flood}, {"switches", cmd_switches}, |