diff --git a/tools/bootutil/Makefile b/tools/bootutil/Makefile index bb33446c..24c67ed8 100644 --- a/tools/bootutil/Makefile +++ b/tools/bootutil/Makefile @@ -1,7 +1,9 @@ TARGET = bootutil -LIBS = -lncurses CC = gcc CFLAGS = -g -Wall +ifneq ($(OS),Windows_NT) # ncurses support limited to *NIX for now +LIBS = -lncurses +endif .PHONY: default all clean diff --git a/tools/bootutil/binaries/osx/bootutil b/tools/bootutil/binaries/osx/bootutil index 122b5ecc..ea8e8b82 100755 Binary files a/tools/bootutil/binaries/osx/bootutil and b/tools/bootutil/binaries/osx/bootutil differ diff --git a/tools/bootutil/commands.c b/tools/bootutil/commands.c index 399ce3f4..fce74fdd 100644 --- a/tools/bootutil/commands.c +++ b/tools/bootutil/commands.c @@ -6,6 +6,8 @@ #include "serialport.h" #include "infohelper.h" +extern int g_bootutil_gui_mode; /* Defined in main.c */ + /* static int commands_stol(char *param_val, long min, long max, long *output, uint8_t b) @@ -40,8 +42,10 @@ commands_err_unknown_arg(char *arg_name) int commands_cmd_reset(void) { - // Can't log data w/GUI since it kills ncurses with -g option - //LOGINFO("attempting to reset (toggling DTR)\n"); + /* Can't log data with -g option since stdout use kills ncurses */ + if (g_bootutil_gui_mode == 0) { + LOGINFO("attempting to reset (toggling DTR)\n"); + } /* Toggle the DTR line to provoke a reset */ serialport_set_dtr(1); diff --git a/tools/bootutil/gui.c b/tools/bootutil/gui.c index 1f5e628d..b7ae468a 100644 --- a/tools/bootutil/gui.c +++ b/tools/bootutil/gui.c @@ -1,3 +1,5 @@ +#ifndef _WIN32 + #include #include #include @@ -241,3 +243,5 @@ cleanup: return EXIT_SUCCESS; } + +#endif /* _WIN32 */ diff --git a/tools/bootutil/gui.h b/tools/bootutil/gui.h index 95bc4fa0..eb9f856d 100644 --- a/tools/bootutil/gui.h +++ b/tools/bootutil/gui.h @@ -1,6 +1,10 @@ #ifndef __GUI_H__ #define __GUI_H__ +#ifndef _WIN32 + int gui_init(const char *ttyname); +#endif /* _WIN32 */ + #endif diff --git a/tools/bootutil/main.c b/tools/bootutil/main.c index 5cc4428e..654c8532 100644 --- a/tools/bootutil/main.c +++ b/tools/bootutil/main.c @@ -6,8 +6,10 @@ #include #include "serialport.h" #include "infohelper.h" -#include "gui.h" #include "commands.h" +#ifndef _WIN32 +#include "gui.h" +#endif #ifdef _WIN32 char *progname = "bootutil.exe"; @@ -15,7 +17,12 @@ char *progname = "bootutil.exe"; char *progname = "bootutil"; #endif -static volatile int g_bootutil_serport_open = 0; +#define BOOTUTIL_VER_MAJOR (0U) +#define BOOTUTIL_VER_MINOR (0U) +#define BOOTUTIL_VER_REVISION (1U) + +volatile int g_bootutil_serport_open = 0; +volatile int g_bootutil_gui_mode = 0; static int bootutil_err_too_many_instances(char *arg_name) @@ -45,13 +52,22 @@ static void bootutil_help(int rc) { printf("Bootloader utility for the Adafruit nRF52 board family.\n"); + printf("Version: %u.%u.%u\n", BOOTUTIL_VER_MAJOR, + BOOTUTIL_VER_MINOR, + BOOTUTIL_VER_REVISION); printf("\n"); +#ifndef _WIN32 printf("Usage: %s -d [-c ] [-ghrv]\n", progname); +#else + printf("Usage: %s -d [-c ] [-hrv]\n", progname); +#endif printf("\n"); printf(" -d : serial/tty port name (mandatory)\n"); printf(" -c : execute the specified command\n"); printf(" reset : perform a system reset (toggle DTR)\n"); +#ifndef _WIN32 printf(" -g : show GUI\n"); +#endif printf(" -h : show help\n"); printf(" -r : perform a system reset (toggle DTR)\n"); printf(" -v : verbose output\n"); @@ -97,7 +113,6 @@ main(int argc, char **argv) int ttyflag = 0; int rstflag = 0; int cmdflag = 0; - int guiflag = 0; int vrbflag = 0; char cmd[256]; char tty[PATH_MAX + NAME_MAX]; @@ -135,9 +150,11 @@ main(int argc, char **argv) cmdflag = 1; strncpy(cmd, optarg, sizeof(cmd)-1); break; +#ifndef _WIN32 case 'g': - guiflag = 1; + g_bootutil_gui_mode = 1; break; +#endif case 'r': rstflag = 1; break; @@ -152,7 +169,7 @@ main(int argc, char **argv) } /* Make sure we have something to do first */ - if ((!rstflag) && (!cmdflag) && (!guiflag)) { + if ((!rstflag) && (!cmdflag) && (!g_bootutil_gui_mode)) { LOGERR("no action requested\n"); } @@ -191,13 +208,15 @@ main(int argc, char **argv) } } +#ifndef _WIN32 /* GUI handler */ - if (guiflag) { + if (g_bootutil_gui_mode) { rc = gui_init(tty); if (rc != 0) { goto error; } } +#endif /* Give an error warning for any unhandled errors */ if (rc != 0) {