summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVadim Bendebury <vbendeb@chromium.org>2018-04-30 17:10:52 -0700
committerChromeOS Commit Bot <chromeos-commit-bot@chromium.org>2018-12-05 00:50:15 +0000
commit585d17ae924327f5b072afc3952a9422e53aae39 (patch)
tree249e268db89edb644fb68e62064227a1fdce5c82
parent631e8aba1beb3cee4330c6c2ac014b2f00c1be55 (diff)
downloadchrome-ec-585d17ae924327f5b072afc3952a9422e53aae39.tar.gz
gsctool: add version command line option
Use the same script the rest of the EC codebase uses to generate the version string. BRANCH=none BUG=none TEST=built the new image and tried: $ ./extra/usb_updater/gsctool -v Version: v1.1.8258+6097a64f0, built on 2018-05-01 17:04:14 by ... Change-Id: I63d2411872bbd38188f66f51b7ca8508fc74fa8f Signed-off-by: Vadim Bendebury <vbendeb@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1036741 Reviewed-by: Mary Ruthven <mruthven@chromium.org> Reviewed-by: Andrey Pronin <apronin@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/1333226 Reviewed-by: Marco Chen <marcochen@chromium.org> Commit-Queue: Marco Chen <marcochen@chromium.org> Tested-by: Marco Chen <marcochen@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/1359948 Reviewed-by: Chia-Hsiu Chang <chia-hsiu.chang@quanta.corp-partner.google.com> Tested-by: Chia-Hsiu Chang <chia-hsiu.chang@quanta.corp-partner.google.com> Commit-Queue: Chia-Hsiu Chang <chia-hsiu.chang@quanta.corp-partner.google.com>
-rw-r--r--extra/usb_updater/.gitignore1
-rw-r--r--extra/usb_updater/Makefile7
-rw-r--r--extra/usb_updater/gsctool.c22
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 2c6baf84f9..42ff2bfdb2 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 c180482b76..c9c5439045 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);
@@ -1890,6 +1894,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;
@@ -2023,6 +2036,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 '?':