From b4bef6e7c3b125b507dc583283b9f0639f0eb10c Mon Sep 17 00:00:00 2001 From: phl0 Date: Wed, 12 Apr 2017 10:13:44 +0200 Subject: [PATCH 1/5] Add GitVersion.h to Makefile --- Makefile | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Makefile b/Makefile index a97316d..5706009 100644 --- a/Makefile +++ b/Makefile @@ -171,3 +171,11 @@ endif ifneq ($(wildcard /opt/openocd/bin/openocd),) /opt/openocd/bin/openocd -f /opt/openocd/share/openocd/scripts/board/stm32f4discovery.cfg -c "program bin/$(BINELF) verify reset exit" endif + +# Export the current git version if the index file exists, else 000... +GitVersion.h: +ifneq ("$(wildcard .git/index)","") + echo "const char *gitversion = \"$(shell git rev-parse HEAD)\";" > $@ +else + echo "const char *gitversion = \"0000000000000000000000000000000000000000\";" > $@ +endif From 23228a002710afe3ae5a9700d0c2c8a1fdc25cda Mon Sep 17 00:00:00 2001 From: phl0 Date: Wed, 12 Apr 2017 10:15:05 +0200 Subject: [PATCH 2/5] Add GitVersion.h to clean command --- Makefile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 5706009..cc6b4ee 100644 --- a/Makefile +++ b/Makefile @@ -36,19 +36,19 @@ ifdef SYSTEMROOT ASOURCES=$(shell dir /S /B *.s) CSOURCES=$(shell dir /S /B *.c) CXXSOURCES=$(shell dir /S /B *.cpp) - CLEANCMD=del /S *.o *.hex *.bin *.elf + CLEANCMD=del /S *.o *.hex *.bin *.elf GitVersion.h MDBIN=md $@ else ifdef SystemRoot ASOURCES=$(shell dir /S /B *.s) CSOURCES=$(shell dir /S /B *.c) CXXSOURCES=$(shell dir /S /B *.cpp) - CLEANCMD=del /S *.o *.hex *.bin *.elf + CLEANCMD=del /S *.o *.hex *.bin *.elf GitVersion.h MDBIN=md $@ else ASOURCES=$(shell find . -name '*.s') CSOURCES=$(shell find . -name '*.c') CXXSOURCES=$(shell find . -name '*.cpp') - CLEANCMD=rm -f $(OBJECTS) $(BINDIR)/$(BINELF) $(BINDIR)/$(BINHEX) $(BINDIR)/$(BINBIN) + CLEANCMD=rm -f $(OBJECTS) $(BINDIR)/$(BINELF) $(BINDIR)/$(BINHEX) $(BINDIR)/$(BINBIN) GitVersion.h MDBIN=mkdir $@ endif From 696964a3a495d522ff370145cb5521ade33fcfdd Mon Sep 17 00:00:00 2001 From: phl0 Date: Wed, 12 Apr 2017 10:15:47 +0200 Subject: [PATCH 3/5] Add GitVersion.h to .gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 46b5953..ca38dc6 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ obj/ bin/ STM32F4XX_Lib/ +GitVersion.h From 61a86b7f062c54b4c166fdef8abc2bcae9564ce0 Mon Sep 17 00:00:00 2001 From: phl0 Date: Wed, 12 Apr 2017 11:12:50 +0200 Subject: [PATCH 4/5] Make GITVERSION a macro and make before nucleo --- Makefile | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index cc6b4ee..8c93c7a 100644 --- a/Makefile +++ b/Makefile @@ -109,6 +109,7 @@ pi: CXXFLAGS+=$(DEFS_PI) -Os -fno-exceptions -ffunction-sections -fdata-sections pi: LDFLAGS+=-Os --specs=nano.specs pi: release +nucleo: GitVersion.h nucleo: CFLAGS+=$(DEFS_NUCLEO) -Os -ffunction-sections -fdata-sections -fno-builtin -Wno-implicit -DCUSTOM_NEW -DNO_EXCEPTIONS nucleo: CXXFLAGS+=$(DEFS_NUCLEO) -Os -fno-exceptions -ffunction-sections -fdata-sections -fno-builtin -fno-rtti -DCUSTOM_NEW -DNO_EXCEPTIONS nucleo: LDFLAGS+=-Os --specs=nano.specs @@ -175,7 +176,7 @@ endif # Export the current git version if the index file exists, else 000... GitVersion.h: ifneq ("$(wildcard .git/index)","") - echo "const char *gitversion = \"$(shell git rev-parse HEAD)\";" > $@ + echo "#define GITVERSION \"$(shell git rev-parse --short HEAD)\"" > $@ else - echo "const char *gitversion = \"0000000000000000000000000000000000000000\";" > $@ + echo "#define GITVERSION \"0000000\"" > $@ endif From 53f51820faebd9ce9758d9f620c26a12a81e07be Mon Sep 17 00:00:00 2001 From: phl0 Date: Wed, 12 Apr 2017 11:51:28 +0200 Subject: [PATCH 5/5] Include GitID of Modem firmware --- SerialPort.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/SerialPort.cpp b/SerialPort.cpp index db7e1ed..4b64bd0 100644 --- a/SerialPort.cpp +++ b/SerialPort.cpp @@ -22,6 +22,11 @@ #include "Config.h" #include "Globals.h" +#if defined(STM32F4XX) || defined(STM32F4) +#include "GitVersion.h" +#endif + + #include "SerialPort.h" const uint8_t MMDVM_FRAME_START = 0xE0U; @@ -74,8 +79,14 @@ const uint8_t MMDVM_DEBUG5 = 0xF5U; #else #define DESCRIPTION "MMDVM 20170406 (D-Star/DMR/System Fusion/P25/RSSI/CW Id)" #endif + +#if defined(GITVERSION) +#define concat(a, b) a " GitID #"b"" +const char HARDWARE[] = concat(DESCRIPTION, GITVERSION); +#else #define concat(a, b, c) a " (Build: " b " " c ")" const char HARDWARE[] = concat(DESCRIPTION, __TIME__, __DATE__); +#endif const uint8_t PROTOCOL_VERSION = 1U;