From fa56e191dc154465eef793d381d348256ccca19c Mon Sep 17 00:00:00 2001 From: Cheng-Han Yang Date: Sun, 17 Mar 2019 18:12:23 +0800 Subject: gsctool: Add error code description if authcode fails. When doing RMA reset and the auth code is rejected, gsctool only reports the error code, which is not clear for the user. This CL adds the failure reason to make the message clearer. BUG=b:128801501 TEST=make gsctool; manually test on DUT BRANCH=none [Before fix] localhost $ gsctool -a -r "A" rma unlock failed, code 1 Processing response... localhost $ gsctool -a -r "ABCDEFGH" rma unlock failed, code 6 Processing response... [After fix] localhost $ gsctool -a -r "A" Processing response... rma unlock failed, code 1 (wrong authcode size) localhost $ gsctool -a -r "ABCDEFGH" Processing response... rma unlock failed, code 6 (authcode mismatch) Change-Id: I5db4d8f7cffe5b582f48fdc3b7fb27493b3715ff Signed-off-by: Cheng-Han Yang Reviewed-on: https://chromium-review.googlesource.com/1527905 Commit-Ready: Cheng-Han Yang Tested-by: Cheng-Han Yang Reviewed-by: Vadim Bendebury (cherry picked from commit 99b60956d4ae10cc44c346444fc0347d25ec3742) Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1985719 Reviewed-by: Cheng-Han Yang Commit-Queue: Cheng-Han Yang --- extra/usb_updater/gsctool.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/extra/usb_updater/gsctool.c b/extra/usb_updater/gsctool.c index 237b5c0494..77958fe920 100644 --- a/extra/usb_updater/gsctool.c +++ b/extra/usb_updater/gsctool.c @@ -1876,7 +1876,7 @@ static void process_rma(struct transfer_descriptor *td, const char *authcode) return; } - printf("Processing response..."); + printf("Processing response...\n"); auth_size = strlen(authcode); response_size = sizeof(rma_response); @@ -1885,8 +1885,19 @@ static void process_rma(struct transfer_descriptor *td, const char *authcode) rma_response, &response_size); if (response_size == 1) { - fprintf(stderr, "\nrma unlock failed, code %d\n", + fprintf(stderr, "\nrma unlock failed, code %d ", *rma_response); + switch (*rma_response) { + case VENDOR_RC_BOGUS_ARGS: + fprintf(stderr, "(wrong authcode size)\n"); + break; + case VENDOR_RC_INTERNAL_ERROR: + fprintf(stderr, "(authcode mismatch)\n"); + break; + default: + fprintf(stderr, "(unknown error)\n"); + break; + } if (td->ep_type == usb_xfer) shut_down(&td->uep); exit(update_error); -- cgit v1.2.1