aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortstellanova <tstellanova+github@gmail.com>2013-09-06 10:18:08 -0700
committertstellanova <tstellanova+github@gmail.com>2013-09-06 10:18:08 -0700
commit23a355644b69585d11011954f1d4cbc9e04a8f3b (patch)
treeb175d820943e67fbe90aca48187229e3a49d542f
parent3d821b8131f762836051b01bc8b2af145d99ebee (diff)
downloadpx4-firmware-23a355644b69585d11011954f1d4cbc9e04a8f3b.tar.gz
px4-firmware-23a355644b69585d11011954f1d4cbc9e04a8f3b.tar.bz2
px4-firmware-23a355644b69585d11011954f1d4cbc9e04a8f3b.zip
grab the git hash and inject it into every log file header
-rw-r--r--Makefile11
-rw-r--r--makefiles/firmware.mk8
-rw-r--r--src/modules/sdlog2/sdlog2_messages.h19
3 files changed, 38 insertions, 0 deletions
diff --git a/Makefile b/Makefile
index 83a6f3ce9..0a8562251 100644
--- a/Makefile
+++ b/Makefile
@@ -40,6 +40,17 @@ export PX4_BASE := $(realpath $(dir $(lastword $(MAKEFILE_LIST))))/
include $(PX4_BASE)makefiles/setup.mk
#
+# Get a version string provided by git
+# This assumes that git command is available and that
+# the directory holding this file also contains .git directory
+#
+GIT_DESC := $(shell git log -1 --pretty=format:%H)
+ifneq ($(words $(GIT_DESC)),1)
+ GIT_DESC := "unknown_git_version"
+endif
+export GIT_DESC
+
+#
# Canned firmware configurations that we (know how to) build.
#
KNOWN_CONFIGS := $(subst config_,,$(basename $(notdir $(wildcard $(PX4_MK_DIR)config_*.mk))))
diff --git a/makefiles/firmware.mk b/makefiles/firmware.mk
index b3e50501c..cb20d9cd1 100644
--- a/makefiles/firmware.mk
+++ b/makefiles/firmware.mk
@@ -110,6 +110,8 @@ ifneq ($(words $(PX4_BASE)),1)
$(error Cannot build when the PX4_BASE path contains one or more space characters.)
endif
+$(info % GIT_DESC = $(GIT_DESC))
+
#
# Set a default target so that included makefiles or errors here don't
# cause confusion.
@@ -177,6 +179,12 @@ GLOBAL_DEPS += $(MAKEFILE_LIST)
#
EXTRA_CLEANS =
+
+#
+# Extra defines for compilation
+#
+export EXTRADEFINES := -DGIT_VERSION=$(GIT_DESC)
+
#
# Append the per-board driver directory to the header search path.
#
diff --git a/src/modules/sdlog2/sdlog2_messages.h b/src/modules/sdlog2/sdlog2_messages.h
index 4eeb65a87..1343bb3d0 100644
--- a/src/modules/sdlog2/sdlog2_messages.h
+++ b/src/modules/sdlog2/sdlog2_messages.h
@@ -250,8 +250,26 @@ struct log_GVSP_s {
float vz;
};
+/* --- FWRV - FIRMWARE REVISION --- */
+#define LOG_FWRV_MSG 20
+struct log_FWRV_s {
+ char fw_revision[64];
+};
+
#pragma pack(pop)
+
+/*
+ GIT_VERSION is defined at build time via a Makefile call to the
+ git command line. We create a fake log message format for
+ the firmware revision "FWRV" that is written to every log
+ header. This makes it easier to determine which version
+ of the firmware was running when a log was created.
+ */
+#define FREEZE_STR(s) #s
+#define STRINGIFY(s) FREEZE_STR(s)
+#define FW_VERSION_STR STRINGIFY(GIT_VERSION)
+
/* construct list of all message formats */
static const struct log_format_s log_formats[] = {
@@ -274,6 +292,7 @@ static const struct log_format_s log_formats[] = {
LOG_FORMAT(GPSP, "BLLfffbBffff", "AltRel,Lat,Lon,Alt,Yaw,LoiterR,LoiterDir,NavCmd,P1,P2,P3,P4"),
LOG_FORMAT(ESC, "HBBBHHHHHHfH", "Counter,NumESC,Conn,N,Ver,Adr,Volt,Amp,RPM,Temp,SetP,SetPRAW"),
LOG_FORMAT(GVSP, "fff", "VX,VY,VZ"),
+ LOG_FORMAT(FWRV,"Z",FW_VERSION_STR),
};
static const int log_formats_num = sizeof(log_formats) / sizeof(struct log_format_s);