From 12ae8f10b21d4ff320aa74863ad19ac4f5f09934 Mon Sep 17 00:00:00 2001 From: Mary Ruthven Date: Thu, 14 Apr 2022 09:04:58 -0700 Subject: gsctool: update apro boot cmd to support triggering ro verify gsctool is running out of short opts. This change replaces get_apro_boot_status to make it more flexible. We can add future ap ro vendor commands to this arg. Replace --get_apro_boot_status with '--apro_boot' to get the AP RO verification status. Add '--apro_boot start' to trigger AP RO verify. BUG=b:195693537 TEST=run 'gsctool -aB start' to trigger verification on hatch. Use 'gsctool -aB' to check the status. Change-Id: I7c8cb73dca8309a5cf61981f7e3154dc85e4590d Signed-off-by: Mary Ruthven Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3587153 Reviewed-by: Vadim Bendebury Commit-Queue: Vadim Bendebury (cherry picked from commit a5339d70a3bfbbbbc7c90b2dda66deaae872b064) Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3841047 Tested-by: Knox Chiou Auto-Submit: Knox Chiou Reviewed-by: Yu-An Wang Commit-Queue: Yu-An Wang --- extra/usb_updater/gsctool.c | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/extra/usb_updater/gsctool.c b/extra/usb_updater/gsctool.c index cf28976755..ea6c6b3d37 100644 --- a/extra/usb_updater/gsctool.c +++ b/extra/usb_updater/gsctool.c @@ -265,8 +265,8 @@ static const struct option_container cmd_line_options[] = { {{"any", no_argument, NULL, 'a'}, "Try any interfaces to find Cr50" " (-d, -s, -t are all ignored)"}, - {{"get_apro_boot_status", no_argument, NULL, 'B'}, - "get the stored ap ro boot state"}, + {{"apro_boot", optional_argument, NULL, 'B'}, + "[start] get the stored ap ro boot state or start ap ro verify"}, {{"binvers", no_argument, NULL, 'b'}, "Report versions of Cr50 image's " "RW and RO headers, do not update"}, @@ -2284,6 +2284,19 @@ static int process_get_apro_hash(struct transfer_descriptor *td) return 0; } +static int process_start_apro_verify(struct transfer_descriptor *td) +{ + int rv = 0; + + rv = send_vendor_command(td, VENDOR_CC_AP_RO_VALIDATE, NULL, 0, NULL, + NULL); + if (rv != VENDOR_RC_SUCCESS) { + fprintf(stderr, "Error %d starting RO verify\n", rv); + return update_error; + } + return 0; +} + static int process_get_apro_boot_status(struct transfer_descriptor *td) { size_t response_size; @@ -3039,6 +3052,7 @@ int main(int argc, char *argv[]) int tpm_mode = 0; int get_apro_hash = 0; int get_apro_boot_status = 0; + int start_apro_verify = 0; bool show_machine_output = false; int tstamp = 0; const char *tstamp_arg = NULL; @@ -3063,7 +3077,6 @@ int main(int argc, char *argv[]) */ const struct options_map omap[] = { { 'b', &binary_vers }, - { 'B', &get_apro_boot_status }, { 'c', &corrupt_inactive_rw }, { 'D', &is_dauntless }, { 'f', &show_fw_ver }, @@ -3119,6 +3132,12 @@ int main(int argc, char *argv[]) /* Try dev_xfer first. */ td.ep_type = dev_xfer; break; + case 'B': + if (optarg && !strcmp(optarg, "start")) + start_apro_verify = 1; + else + get_apro_boot_status = 1; + break; case 'd': if (!parse_vidpid(optarg, &vid, &pid)) { fprintf(stderr, @@ -3277,6 +3296,7 @@ int main(int argc, char *argv[]) !show_fw_ver && !sn_bits && !sn_inc_rma && + !start_apro_verify && !openbox_desc_file && !tstamp && !tpm_mode && @@ -3390,6 +3410,9 @@ int main(int argc, char *argv[]) if (get_apro_boot_status) exit(process_get_apro_boot_status(&td)); + if (start_apro_verify) + exit(process_start_apro_verify(&td)); + if (get_boot_mode) exit(process_get_boot_mode(&td)); -- cgit v1.2.1