diff options
-rw-r--r-- | extra/usb_updater/.gitignore | 1 | ||||
-rw-r--r-- | extra/usb_updater/Makefile | 7 | ||||
-rw-r--r-- | extra/usb_updater/gsctool.c | 22 |
3 files changed, 26 insertions, 4 deletions
diff --git a/extra/usb_updater/.gitignore b/extra/usb_updater/.gitignore index 2e16c2ff2a..37c3bd3808 100644 --- a/extra/usb_updater/.gitignore +++ b/extra/usb_updater/.gitignore @@ -1,3 +1,4 @@ +generated_version.h gsctool usb_updater2 *.d diff --git a/extra/usb_updater/Makefile b/extra/usb_updater/Makefile index 93284d6fef..e56331f110 100644 --- a/extra/usb_updater/Makefile +++ b/extra/usb_updater/Makefile @@ -52,14 +52,19 @@ gsctool: $(GSCTOOL_OBJS) Makefile %.o: %.c $(CC) $(CFLAGS) $(CFLAGS_g) -c -MMD -MF $(basename $@).d -o $@ $< +gsctool.o: generated_version.h + # common EC code USB updater usb_updater2: usb_updater2.c Makefile $(CC) $(CFLAGS) $< $(LFLAGS) $(LIBS) $(LIBS_common) -o $@ .PHONY: clean +generated_version.h: $(GSCTOOL_SOURCES) + @../../util/getversion.sh > $@ + clean: - rm -rf $(PROGRAMS) *~ *.o *.d dp + rm -rf $(PROGRAMS) *~ *.o *.d dp generated_version.h parser_debug: desc_parser.c gcc -g -O0 -DTEST_PARSER desc_parser.c -o dp diff --git a/extra/usb_updater/gsctool.c b/extra/usb_updater/gsctool.c index d751cc0bc7..10f3bbefe6 100644 --- a/extra/usb_updater/gsctool.c +++ b/extra/usb_updater/gsctool.c @@ -24,6 +24,7 @@ #include "ccd_config.h" #include "compile_time_macros.h" +#include "generated_version.h" #include "gsctool.h" #include "misc_util.h" #include "signed_header.h" @@ -194,7 +195,7 @@ struct upgrade_pkt { static uint32_t protocol_version; static char *progname; -static char *short_opts = "abcd:fhIikO:oPprstUu"; +static char *short_opts = "abcd:fhIikO:oPprstUuv"; static const struct option long_opts[] = { /* name hasarg *flag val */ {"any", 0, NULL, 'a'}, @@ -214,6 +215,7 @@ static const struct option long_opts[] = { {"rma_auth", 2, NULL, 'r'}, {"systemdev", 0, NULL, 's'}, {"trunks_send", 0, NULL, 't'}, + {"version", 0, NULL, 'v'}, {"upstart", 0, NULL, 'u'}, {}, }; @@ -503,11 +505,12 @@ static void usage(int errs) "\n" " -a,--any Try any interfaces to find Cr50" " (-d, -s, -t are all ignored)\n" - " -b,--binvers Report versions of image's " + " -b,--binvers Report versions of Cr50 image's " "RW and RO headers, do not update\n" " -c,--corrupt Corrupt the inactive rw\n" " -d,--device VID:PID USB device (default %04x:%04x)\n" - " -f,--fwver Report running firmware versions\n" + " -f,--fwver " + "Report running Cr50 firmware versions\n" " -h,--help Show this message\n" " -I,--ccd_info Get information about CCD state\n" " -i,--board_id [ID[:FLAGS]]\n" @@ -533,6 +536,7 @@ static void usage(int errs) " -U,--ccd_unlock Start CCD unlock sequence\n" " -u,--upstart " "Upstart mode (strict header checks)\n" + " -v,--version Report this utility version\n" "\n", progname, VID, PID); exit(errs ? update_error : noop); @@ -1884,6 +1888,15 @@ static void process_rma(struct transfer_descriptor *td, const char *authcode) printf("RMA unlock succeeded.\n"); } +static void report_version(void) +{ + /* Get version from the generated file, ignore the underscore prefix. */ + const char *v = VERSION + 1; + + printf("Version: %s, built on %s by %s\n", v, DATE, BUILDER); + exit(0); +} + int main(int argc, char *argv[]) { struct transfer_descriptor td; @@ -2017,6 +2030,9 @@ int main(int argc, char *argv[]) case 'u': td.upstart_mode = 1; break; + case 'v': + report_version(); /* This will call exit(). */ + break; case 0: /* auto-handled option */ break; case '?': |