diff options
author | Matt Vertescher <mvertescher@google.com> | 2022-12-16 09:47:10 -0800 |
---|---|---|
committer | Chromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com> | 2022-12-20 21:47:28 +0000 |
commit | ceea780fa94360688f72aaa37d058d019a486825 (patch) | |
tree | c80b1cec7d0ab833131a42d03a2126f5fee5f47e | |
parent | d32f7258650ea0e444598051aa39c55e709f07da (diff) | |
download | chrome-ec-stabilize-15300.B-cr50_stab.tar.gz |
gsctool: Add a command to perform a GSC resetstabilize-15301.B-cr50_stabstabilize-15300.B-cr50_stab
To help with AP RO verification testing, it would be convenient to
expose a `gsctool` command rather than point users at a cryptic
`trunks_send --raw` command. This patch adds a new `--reboot` flag
with an optional reset timeout parameter in milliseconds that sends the
TPMV reset immediate message to the GSC.
BUG=b:261857287
TEST=Ran the new command against the latest Ti50
```
$ gsctool -D --reboot
...
$ gsctool -D --reboot 1000
...
$ gsctool -D --reboot 1001
Error 1 sending immediate reset command
```
Signed-off-by: Matt Vertescher <mvertescher@google.com>
Change-Id: I5c101f37579e37b5ee7dc9241b6fbff07cff6947
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4114560
Reviewed-by: Jett Rink <jettrink@chromium.org>
Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
-rw-r--r-- | extra/usb_updater/gsctool.c | 41 |
1 files changed, 40 insertions, 1 deletions
diff --git a/extra/usb_updater/gsctool.c b/extra/usb_updater/gsctool.c index 611d8754d2..c007692b32 100644 --- a/extra/usb_updater/gsctool.c +++ b/extra/usb_updater/gsctool.c @@ -519,7 +519,10 @@ static const struct option_container cmd_line_options[] = { {{"version", no_argument, NULL, 'v'}, "Report this utility version"}, {{"wp", optional_argument, NULL, 'w'}, - "[enable] Get the current WP setting or enable WP"} + "[enable] Get the current WP setting or enable WP"}, + {{"reboot", optional_argument, NULL, 'z'}, + "Tell the GSC to reboot with an optional reset timeout parameter " + "in milliseconds"} }; /* Helper to print debug messages when verbose flag is specified. */ @@ -3717,6 +3720,27 @@ static int process_tstamp(struct transfer_descriptor *td, return 0; } +static int process_reboot_gsc(struct transfer_descriptor *td, + size_t timeout_ms) +{ + /* Reboot timeout in milliseconds. + * Maximum value is 1000ms on Ti50. + */ + uint16_t msg = htobe16((uint16_t) timeout_ms); + int rv = 0; + + rv = send_vendor_command(td, VENDOR_CC_IMMEDIATE_RESET, &msg, + sizeof(msg), NULL, 0); + if (rv != VENDOR_RC_SUCCESS) { + fprintf(stderr, + "Error %d sending immediate reset command\n", + rv); + return update_error; + } + + return 0; +} + /* * Search the passed in zero terminated array of options_map structures for * option 'option'. @@ -3897,6 +3921,8 @@ int main(int argc, char *argv[]) int is_dauntless = 0; int set_capability = 0; const char *capability_parameter = ""; + bool reboot_gsc = false; + size_t reboot_gsc_timeout = 0; /* * All options which result in setting a Boolean flag to True, along @@ -4124,6 +4150,15 @@ int main(int argc, char *argv[]) fprintf(stderr, "Illegal wp option \"%s\"\n", optarg); errorcnt++; break; + case 'z': + reboot_gsc = true; + /* Set a 1ms default reboot time to avoid libusb errors + * when the GSC resets too quickly. + */ + reboot_gsc_timeout = 1; + if (optarg) + reboot_gsc_timeout = strtoul(optarg, NULL, 0); + break; case 0: /* auto-handled option */ break; case '?': @@ -4175,6 +4210,7 @@ int main(int argc, char *argv[]) !factory_mode && !erase_ap_ro_hash && !password && + !reboot_gsc && !rma && !set_capability && !show_fw_ver && @@ -4319,6 +4355,9 @@ int main(int argc, char *argv[]) arv_config_wpsr_choice, &arv_config_wpds)); + if (reboot_gsc) + exit(process_reboot_gsc(&td, reboot_gsc_timeout)); + if (data || show_fw_ver) { setup_connection(&td); |