diff options
author | Wei-Han Chen <stimim@google.com> | 2018-08-15 10:53:27 +0800 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2018-08-15 08:47:00 -0700 |
commit | 402428583940d25708deb637554f32f6dc16edca (patch) | |
tree | 5ea9dfe130ad0164d4548d95b73cee783e1a0d78 /extra | |
parent | 0143da797b853660f1dc08fff46f8a6b89257bb7 (diff) | |
download | chrome-ec-402428583940d25708deb637554f32f6dc16edca.tar.gz |
usb_updater2: pretty print touchpad_info
e.g. on whiskers, the command will behave like:
> usb_updater2 -d 18d1:5030 --tp_info
< ...
< status: 0x00
< vendor: 0x0483
< fw_address: 0x80000000
< fw_size: 0x00020000
< allowed_fw_hash:
< 20 0f eb 01 98 34 cf 86 8b 4e 94 1f 51 41 e7 64
< e1 0c 4f ac 88 bd 97 1c 79 ae c5 74 e3 0b 14 6d
< id: 0x3936
< fw_version: 0x0011
< fw_fw_checksum: 0xb49f
BRANCH=none
BUG=b:70482333
TEST=manually on device
Signed-off-by: Wei-Han Chen <stimim@chromium.org>
Change-Id: Iffe6720eec33cc57498cdab15ac2e132fdd76808
Reviewed-on: https://chromium-review.googlesource.com/1175506
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 'extra')
-rw-r--r-- | extra/usb_updater/usb_updater2.c | 44 |
1 files changed, 42 insertions, 2 deletions
diff --git a/extra/usb_updater/usb_updater2.c b/extra/usb_updater/usb_updater2.c index 0c5f30581c..e31770b40e 100644 --- a/extra/usb_updater/usb_updater2.c +++ b/extra/usb_updater/usb_updater2.c @@ -176,6 +176,40 @@ static void hexdump(const uint8_t *data, int len) printf("\n"); } +static void dump_touchpad_info(const uint8_t *data, int len) +{ + const struct touchpad_info *info = (const struct touchpad_info *)data; + + if (len != sizeof(struct touchpad_info)) { + fprintf(stderr, "Hex string length is not %zu", + sizeof(struct touchpad_info)); + hexdump(data, len); + return; + } + + printf("\n"); + printf("status: 0x%02x\n", info->status); + printf("vendor: 0x%04x\n", info->vendor); + printf("fw_address: 0x%08x\n", info->fw_address); + printf("fw_size: 0x%08x\n", info->fw_size); + + printf("allowed_fw_hash:\n"); + hexdump(info->allowed_fw_hash, sizeof(info->allowed_fw_hash)); + + switch (info->vendor) { + case 0x04f3: /* ELAN */ + case 0x0483: /* ST */ + printf("id: 0x%04x\n", info->elan.id); + printf("fw_version: 0x%04x\n", info->elan.fw_version); + printf("fw_fw_checksum: 0x%04x\n", info->elan.fw_checksum); + break; + default: + fprintf(stderr, "Unknown vendor, vendor specific data:\n"); + hexdump((const uint8_t *)&info->elan, sizeof(info->elan)); + break; + } +} + /* Read file into buffer */ static uint8_t *get_file_or_die(const char *filename, size_t *len_ptr) { @@ -1132,9 +1166,15 @@ int main(int argc, char *argv[]) extra_command_data, extra_command_data_len, extra_command_answer, extra_command_answer_len); - if (extra_command == UPDATE_EXTRA_CMD_TOUCHPAD_INFO || - extra_command == UPDATE_EXTRA_CMD_TOUCHPAD_DEBUG) + switch (extra_command) { + case UPDATE_EXTRA_CMD_TOUCHPAD_INFO: + dump_touchpad_info(extra_command_answer, + extra_command_answer_len); + break; + case UPDATE_EXTRA_CMD_TOUCHPAD_DEBUG: hexdump(extra_command_answer, extra_command_answer_len); + break; + } } libusb_close(td.uep.devh); |