diff options
Diffstat (limited to 'util')
-rwxr-xr-x | util/getversion.sh | 3 | ||||
-rw-r--r-- | util/stm32mon.c | 19 |
2 files changed, 20 insertions, 2 deletions
diff --git a/util/getversion.sh b/util/getversion.sh index 765571492e..19e79814c4 100755 --- a/util/getversion.sh +++ b/util/getversion.sh @@ -131,6 +131,9 @@ main() { echo "/* Version string for ectool. */" echo "#define CROS_ECTOOL_VERSION \"${tool_ver}\"" + echo "/* Version string for stm32mon. */" + echo "#define CROS_STM32MON_VERSION \"${tool_ver}\"" + echo "/* Sub-fields for use in Makefile.rules and to form build info string" echo " * in common/version.c. */" echo "#define VERSION \"${ver}\"" diff --git a/util/stm32mon.c b/util/stm32mon.c index 05788b9189..3cef97db4b 100644 --- a/util/stm32mon.c +++ b/util/stm32mon.c @@ -37,6 +37,8 @@ #include <time.h> #include <unistd.h> +#include "ec_version.h" + #define KBYTES_TO_BYTES 1024 /* @@ -1355,6 +1357,7 @@ static const struct option longopts[] = { {"read", 1, 0, 'r'}, {"spi", 1, 0, 's'}, {"unprotect", 0, 0, 'u'}, + {"version", 0, 0, 'v'}, {"write", 1, 0, 'w'}, {NULL, 0, 0, 0} }; @@ -1365,7 +1368,7 @@ void display_usage(char *program) "Usage: %s [-a <i2c_adapter> [-l address ]] | [-s]" " [-d <tty>] [-b <baudrate>]] [-u] [-e] [-U]" " [-r <file>] [-w <file>] [-o offset] [-n length] [-g] [-p]" - " [-L <log_file>] [-c]\n", + " [-L <log_file>] [-c] [-v]\n", program); fprintf(stderr, "Can access the controller via serial port or i2c\n"); fprintf(stderr, "Serial port mode:\n"); @@ -1393,10 +1396,17 @@ void display_usage(char *program) "in a log file\n"); fprintf(stderr, "-c[r50_mode] : consider device to be a Cr50 interface," " no need to set UART port attributes\n"); + fprintf(stderr, "--v[ersion] : print version and exit\n"); exit(2); } +void display_version(const char *exe_name) +{ + printf("%s version: %s %s %s\n", exe_name, CROS_STM32MON_VERSION, DATE, + BUILDER); +} + speed_t parse_baudrate(const char *value) { int rate = atoi(value); @@ -1425,7 +1435,7 @@ int parse_parameters(int argc, char **argv) int flags = 0; const char *log_file_name = NULL; - while ((opt = getopt_long(argc, argv, "a:l:b:cd:eghL:n:o:pr:s:w:uU?", + while ((opt = getopt_long(argc, argv, "a:l:b:cd:eghL:n:o:pr:s:w:uUv?", longopts, &idx)) != -1) { switch (opt) { case 'a': @@ -1483,6 +1493,9 @@ int parse_parameters(int argc, char **argv) case 'U': flags |= FLAG_READ_UNPROTECT; break; + case 'v': + display_version(argv[0]); + exit(0); } } @@ -1524,6 +1537,8 @@ int main(int argc, char **argv) /* Parse command line options */ flags = parse_parameters(argc, argv); + display_version(argv[0]); + retry_on_damaged_ack = !!(flags & FLAG_CR50_MODE); switch (mode) { |