summaryrefslogtreecommitdiff
path: root/extra
diff options
context:
space:
mode:
authorNamyoon Woo <namyoon@chromium.org>2020-02-14 18:12:24 -0800
committerCommit Bot <commit-bot@chromium.org>2020-03-06 01:32:51 +0000
commitb0423c58bb73ceed621802039886cd0a8e40d528 (patch)
treeb282bb6f50eddf3847fdd0829ea22a1f9a6ce45a /extra
parentb5ca19dc6b20cbad5283f250f50e1dd177b4f258 (diff)
downloadchrome-ec-b0423c58bb73ceed621802039886cd0a8e40d528.tar.gz
gsctool: get the current system boot mode
gsctool -g or --getbootmode can get the current system boot mode. BUG=b:141578322 BRANCH=cr50 TEST=ran on helios. $ ./extra/usb_updater/gsctool --getbootmode finding_device 18d1:5014 Found device. found interface 3 endpoint 4, chunk_len 64 READY ------- Boot mode = 0x00: NORMAL $ ./extra/usb_updater/gsctool -g finding_device 18d1:5014 Found device. found interface 3 endpoint 4, chunk_len 64 READY ------- Getting boot mode Boot mode = 0x00: NORMAL Change-Id: Id024ac94fb08b680bd5e190bc7eeb2de301b70a2 Signed-off-by: Namyoon Woo <namyoon@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2058128 Reviewed-by: Mary Ruthven <mruthven@chromium.org> Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
Diffstat (limited to 'extra')
-rw-r--r--extra/usb_updater/gsctool.c49
1 files changed, 47 insertions, 2 deletions
diff --git a/extra/usb_updater/gsctool.c b/extra/usb_updater/gsctool.c
index 4540814e56..a65bd909eb 100644
--- a/extra/usb_updater/gsctool.c
+++ b/extra/usb_updater/gsctool.c
@@ -268,6 +268,8 @@ static const struct option_container cmd_line_options[] = {
"Report running Cr50 firmware versions"},
{{"factory", required_argument, NULL, 'F'},
"[enable|disable]%Control factory mode"},
+ {{"getbootmode", no_argument, NULL, 'g'},
+ "Get the system boot mode"},
{{"help", no_argument, NULL, 'h'},
"Show this message"},
{{"ccd_info", no_argument, NULL, 'I'},
@@ -2003,6 +2005,43 @@ static void process_wp(struct transfer_descriptor *td)
"forced disabled");
}
+static int process_get_boot_mode(struct transfer_descriptor *td)
+{
+ size_t response_size;
+ uint8_t response;
+ const char * const desc = "Getting boot mode";
+ int rv = 0;
+
+ response_size = sizeof(response);
+
+ rv = send_vendor_command(td, VENDOR_CC_GET_BOOT_MODE, NULL, 0,
+ &response, &response_size);
+ if (rv != VENDOR_RC_SUCCESS) {
+ fprintf(stderr, "Error %d in %s\n", rv, desc);
+ return update_error;
+ }
+ if (response_size != 1) {
+ fprintf(stderr, "Unexpected response size %zd while %s\n",
+ response_size, desc);
+ return update_error;
+ }
+
+ /* Print the response and meaning, as in 'enum boot_mode'. */
+ printf("Boot mode = 0x%02x: ", response);
+ switch (response) {
+ case 0x00:
+ printf("NORMAL\n");
+ break;
+ case 0x01:
+ printf("NO_BOOT\n");
+ break;
+ default:
+ fprintf(stderr, "unknown boot mode\n");
+ return update_error;
+ }
+
+ return 0;
+}
void process_bid(struct transfer_descriptor *td,
enum board_id_action bid_action,
@@ -2644,6 +2683,7 @@ int main(int argc, char *argv[])
int get_flog = 0;
uint32_t prev_log_entry = 0;
int wp = 0;
+ int get_boot_mode = 0;
int try_all_transfer = 0;
int tpm_mode = 0;
bool show_machine_output = false;
@@ -2671,6 +2711,7 @@ int main(int argc, char *argv[])
{ 'b', &binary_vers },
{ 'c', &corrupt_inactive_rw },
{ 'f', &show_fw_ver },
+ { 'g', &get_boot_mode},
{ 'I', &ccd_info },
{ 'k', &ccd_lock },
{ 'o', &ccd_open },
@@ -2855,6 +2896,7 @@ int main(int argc, char *argv[])
!ccd_open &&
!ccd_unlock &&
!corrupt_inactive_rw &&
+ !get_boot_mode &&
!get_flog &&
!get_endorsement_seed &&
!factory_mode &&
@@ -2894,11 +2936,11 @@ int main(int argc, char *argv[])
if (((bid_action != bid_none) + !!rma + !!password + !!ccd_open +
!!ccd_unlock + !!ccd_lock + !!ccd_info + !!get_flog +
- !!openbox_desc_file + !!factory_mode + !!wp +
+ !!get_boot_mode + !!openbox_desc_file + !!factory_mode + !!wp +
!!get_endorsement_seed) > 1) {
fprintf(stderr,
"ERROR: options"
- "-e, -F, -I, -i, -k, -L, -O, -o, -P, -r, -U and -w "
+ "-e, -F, -g, -I, -i, -k, -L, -O, -o, -P, -r, -U and -w "
"are mutually exclusive\n");
exit(update_error);
}
@@ -2961,6 +3003,9 @@ int main(int argc, char *argv[])
if (sn_inc_rma)
process_sn_inc_rma(&td, sn_inc_rma_arg);
+ if (get_boot_mode)
+ exit(process_get_boot_mode(&td));
+
if (get_flog)
process_get_flog(&td, prev_log_entry);