summaryrefslogtreecommitdiff
path: root/extra/usb_updater/gsctool.c
diff options
context:
space:
mode:
Diffstat (limited to 'extra/usb_updater/gsctool.c')
-rw-r--r--extra/usb_updater/gsctool.c38
1 files changed, 27 insertions, 11 deletions
diff --git a/extra/usb_updater/gsctool.c b/extra/usb_updater/gsctool.c
index ce7c62d234..66bf91156c 100644
--- a/extra/usb_updater/gsctool.c
+++ b/extra/usb_updater/gsctool.c
@@ -541,7 +541,7 @@ static void usage(int errs)
"character string.\n"
" -k,--ccd_lock Lock CCD\n"
" -M,--machine Output in a machine-friendly way. "
- "Effective with -f and -b only.\n"
+ "Effective with -b, -f, -i, and -O.\n"
" -O,--openbox_rma <desc_file>\n"
" Verify other device's RO integrity\n"
" using information provided in "
@@ -1889,7 +1889,8 @@ static void process_ccd_state(struct transfer_descriptor *td, int ccd_unlock,
void process_bid(struct transfer_descriptor *td,
enum board_id_action bid_action,
- struct board_id *bid)
+ struct board_id *bid,
+ bool show_machine_output)
{
size_t response_size;
@@ -1900,16 +1901,31 @@ void process_bid(struct transfer_descriptor *td,
bid, sizeof(*bid),
bid, &response_size);
- if (response_size == sizeof(*bid)) {
+ if (response_size != sizeof(*bid)) {
+ fprintf(stderr,
+ "Error reading board ID: response size %zd, "
+ "first byte %#02x\n",
+ response_size,
+ response_size ? *(uint8_t *)&bid : -1);
+ exit(update_error);
+ }
+
+ if (show_machine_output) {
+ print_machine_output(
+ "BID_TYPE", "%08x", be32toh(bid->type));
+ print_machine_output(
+ "BID_TYPE_INV", "%08x", be32toh(bid->type_inv));
+ print_machine_output(
+ "BID_FLAGS", "%08x", be32toh(bid->flags));
+
+ } else {
printf("Board ID space: %08x:%08x:%08x\n",
- be32toh(bid->type), be32toh(bid->type_inv),
+ be32toh(bid->type),
+ be32toh(bid->type_inv),
be32toh(bid->flags));
- return;
}
- fprintf(stderr, "Error reading board ID: response size %zd,"
- " first byte %#02x\n", response_size,
- response_size ? *(uint8_t *)&bid : -1);
- exit(update_error);
+
+ return;
}
if (bid_action == bid_set) {
@@ -2300,7 +2316,7 @@ int main(int argc, char *argv[])
}
if (openbox_desc_file)
- return verify_ro(&td, openbox_desc_file);
+ return verify_ro(&td, openbox_desc_file, show_machine_output);
if (ccd_unlock || ccd_open || ccd_lock || ccd_info)
process_ccd_state(&td, ccd_unlock, ccd_open,
@@ -2310,7 +2326,7 @@ int main(int argc, char *argv[])
process_password(&td);
if (bid_action != bid_none)
- process_bid(&td, bid_action, &bid);
+ process_bid(&td, bid_action, &bid, show_machine_output);
if (rma)
process_rma(&td, rma_auth_code);