diff --git a/.gitignore b/.gitignore index 162d624..a40d44d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +src/include/version.h blackmagic *.bin *.hex diff --git a/scripts/setlocalversion b/scripts/setlocalversion deleted file mode 100755 index 46989b8..0000000 --- a/scripts/setlocalversion +++ /dev/null @@ -1,82 +0,0 @@ -#!/bin/sh -# -# This scripts adds local version information from the version -# control systems git, mercurial (hg) and subversion (svn). -# -# If something goes wrong, send a mail the kernel build mailinglist -# (see MAINTAINERS) and CC Nico Schottelius -# . -# -# - -usage() { - echo "Usage: $0 [srctree]" >&2 - exit 1 -} - -cd "${1:-.}" || usage - -# Check for git and a git repo. -if head=`git rev-parse --verify --short HEAD 2>/dev/null`; then - - # If we are at a tagged commit (like "v2.6.30-rc6"), we ignore it, - # because this version is defined in the top level Makefile. - if [ -z "`git describe --exact-match 2>/dev/null`" ]; then - - # If we are past a tagged commit (like "v2.6.30-rc5-302-g72357d5"), - # we pretty print it. - if atag="`git describe 2>/dev/null`"; then - echo "$atag" | awk -F- '{printf("-%05d-%s", $(NF-1),$(NF))}' - - # If we don't have a tag at all we print -g{commitish}. - else - printf '%s%s' -g $head - fi - fi - - # Is this git on svn? - if git config --get svn-remote.svn.url >/dev/null; then - printf -- '-svn%s' "`git svn find-rev $head`" - fi - - # Update index only on r/w media - [ -w . ] && git update-index --refresh --unmerged > /dev/null - - # Check for uncommitted changes - if git diff-index --name-only HEAD | grep -v "^scripts/package" \ - | read dummy; then - printf '%s' -dirty - fi - - # All done with git - exit -fi - -# Check for mercurial and a mercurial repo. -if hgid=`hg id 2>/dev/null`; then - tag=`printf '%s' "$hgid" | cut -d' ' -f2` - - # Do we have an untagged version? - if [ -z "$tag" -o "$tag" = tip ]; then - id=`printf '%s' "$hgid" | sed 's/[+ ].*//'` - printf '%s%s' -hg "$id" - fi - - # Are there uncommitted changes? - # These are represented by + after the changeset id. - case "$hgid" in - *+|*+\ *) printf '%s' -dirty ;; - esac - - # All done with mercurial - exit -fi - -# Check for svn and a svn repo. -if rev=`svn info 2>/dev/null | grep '^Last Changed Rev'`; then - rev=`echo $rev | awk '{print $NF}'` - printf -- '-svn%s' "$rev" - - # All done with svn - exit -fi diff --git a/src/Makefile b/src/Makefile index f76ea74..3d879ef 100644 --- a/src/Makefile +++ b/src/Makefile @@ -7,14 +7,11 @@ MAKEFLAGS += --no-print-dir Q := @ endif -BUILDDATE := `date +"%Y%m%d"` - OPT_FLAGS ?= -O2 CFLAGS += -Wall -Wextra -Werror -Wno-char-subscripts\ - $(OPT_FLAGS) -std=gnu99 -g3 -DBUILDDATE=\"$(BUILDDATE)\"\ + $(OPT_FLAGS) -std=gnu99 -g3 -MD \ -I. -Iinclude -Iplatforms/common -I$(PLATFORM_DIR) \ - -DVERSION_SUFFIX=\"`../scripts/setlocalversion`\" -MD SRC = \ adiv5.c \ @@ -50,9 +47,9 @@ include $(PLATFORM_DIR)/Makefile.inc OBJ = $(SRC:.c=.o) -blackmagic: $(OBJ) +blackmagic: include/version.h $(OBJ) @echo " LD $@" - $(Q)$(CC) -o $@ $^ $(LDFLAGS) + $(Q)$(CC) -o $@ $(OBJ) $(LDFLAGS) %.o: %.c @echo " CC $<" @@ -66,7 +63,7 @@ blackmagic: $(OBJ) @echo " OBJCOPY $@" $(Q)$(OBJCOPY) -O ihex $^ $@ -.PHONY: clean host_clean all_platforms +.PHONY: clean host_clean all_platforms FORCE clean: host_clean $(Q)echo " CLEAN" @@ -87,5 +84,9 @@ all_platforms: fi ;\ done +include/version.h: FORCE + $(Q)echo " GIT include/version.h" + $(Q)echo "#define FIRMWARE_VERSION \"`git describe --dirty`\"" > $@ + -include *.d diff --git a/src/command.c b/src/command.c index 2c2a198..8e20960 100644 --- a/src/command.c +++ b/src/command.c @@ -30,6 +30,7 @@ #include "target.h" #include "morse.h" #include "adiv5.h" +#include "version.h" #ifdef PLATFORM_HAS_TRACESWO # include "traceswo.h" @@ -107,8 +108,8 @@ int command_process(target *t, char *cmd) bool cmd_version(void) { - gdb_out("Black Magic Probe (Firmware 1.5" VERSION_SUFFIX ", build " BUILDDATE ")\n"); - gdb_out("Copyright (C) 2011 Black Sphere Technologies Ltd.\n"); + gdb_out("Black Magic Probe (Firmware " FIRMWARE_VERSION ")\n"); + gdb_out("Copyright (C) 2015 Black Sphere Technologies Ltd.\n"); gdb_out("License GPLv3+: GNU GPL version 3 or later " "\n\n"); diff --git a/src/platforms/f4discovery/Makefile.inc b/src/platforms/f4discovery/Makefile.inc index e2bebfd..e57bb0e 100644 --- a/src/platforms/f4discovery/Makefile.inc +++ b/src/platforms/f4discovery/Makefile.inc @@ -16,7 +16,6 @@ LDFLAGS = -lopencm3_stm32f4 -Wl,--defsym,_stack=0x20006000 \ VPATH += platforms/stm32 SRC += cdcacm.c \ - platform.c \ traceswo.c \ usbuart.c \ serialno.c \ diff --git a/src/platforms/f4discovery/platform.h b/src/platforms/f4discovery/platform.h index 92ae046..16bd169 100644 --- a/src/platforms/f4discovery/platform.h +++ b/src/platforms/f4discovery/platform.h @@ -26,12 +26,13 @@ #include "gpio.h" #include "timing.h" +#include "version.h" #include #define PLATFORM_HAS_TRACESWO -#define BOARD_IDENT "Black Magic Probe (F4Discovery), (Firmware 1.5" VERSION_SUFFIX ", build " BUILDDATE ")" -#define BOARD_IDENT_DFU "Black Magic (Upgrade) for F4Discovery, (Firmware 1.5" VERSION_SUFFIX ", build " BUILDDATE ")" +#define BOARD_IDENT "Black Magic Probe (F4Discovery), (Firmware " FIRMWARE_VERSION ")" +#define BOARD_IDENT_DFU "Black Magic (Upgrade) for F4Discovery, (Firmware " FIRMWARE_VERSION ")" #define DFU_IDENT "Black Magic Firmware Upgrade (F4Discovery" #define DFU_IFACE_STRING "@Internal Flash /0x08000000/1*016Ka,3*016Kg,1*064Kg,7*128Kg" diff --git a/src/platforms/launchpad-icdi/platform.h b/src/platforms/launchpad-icdi/platform.h index c13172f..52b963e 100644 --- a/src/platforms/launchpad-icdi/platform.h +++ b/src/platforms/launchpad-icdi/platform.h @@ -20,8 +20,10 @@ #include #include -#define BOARD_IDENT "Black Magic Probe (Launchpad ICDI), (Firmware 1.5" VERSION_SUFFIX ", build " BUILDDATE ")" -#define BOARD_IDENT_DFU "Black Magic (Upgrade) for Launchpad, (Firmware 1.5" VERSION_SUFFIX ", build " BUILDDATE ")" +#include "version.h" + +#define BOARD_IDENT "Black Magic Probe (Launchpad ICDI), (Firmware " FIRMWARE_VERSION ")" +#define BOARD_IDENT_DFU "Black Magic (Upgrade) for Launchpad, (Firmware " FIRMWARE_VERSION ")" #define DFU_IDENT "Black Magic Firmware Upgrade (Launchpad)" #define DFU_IFACE_STRING "lolwut" diff --git a/src/platforms/libftdi/platform.c b/src/platforms/libftdi/platform.c index 3062698..37f876b 100644 --- a/src/platforms/libftdi/platform.c +++ b/src/platforms/libftdi/platform.c @@ -19,6 +19,7 @@ */ #include "general.h" #include "gdb_if.h" +#include "version.h" #include #include @@ -158,6 +159,11 @@ void platform_init(int argc, char **argv) if(cable_desc[index].cbus_ddr) ftdi_init[8]= cable_desc[index].cbus_ddr; + printf("\nBlack Magic Probe (" FIRMWARE_VERSION ")\n"); + printf("Copyright (C) 2015 Black Sphere Technologies Ltd.\n"); + printf("License GPLv3+: GNU GPL version 3 or later " + "\n\n"); + if(ftdic) { ftdi_usb_close(ftdic); ftdi_free(ftdic); diff --git a/src/platforms/native/Makefile.inc b/src/platforms/native/Makefile.inc index 6ec60b1..8365555 100644 --- a/src/platforms/native/Makefile.inc +++ b/src/platforms/native/Makefile.inc @@ -15,7 +15,6 @@ LDFLAGS = $(LDFLAGS_BOOT) -Wl,-Ttext=0x8002000 VPATH += platforms/stm32 SRC += cdcacm.c \ - platform.c \ traceswo.c \ usbuart.c \ serialno.c \ diff --git a/src/platforms/stlink/Makefile.inc b/src/platforms/stlink/Makefile.inc index 689c11e..fdee700 100644 --- a/src/platforms/stlink/Makefile.inc +++ b/src/platforms/stlink/Makefile.inc @@ -16,7 +16,6 @@ LDFLAGS = $(LDFLAGS_BOOT) -Wl,-Ttext=0x8002000 VPATH += platforms/stm32 SRC += cdcacm.c \ - platform.c \ usbuart.c \ serialno.c \ timing.c \ diff --git a/src/platforms/stlink/platform.h b/src/platforms/stlink/platform.h index aa02ac0..498e512 100644 --- a/src/platforms/stlink/platform.h +++ b/src/platforms/stlink/platform.h @@ -26,14 +26,15 @@ #include "gpio.h" #include "timing.h" +#include "version.h" #include #include #include -#define BOARD_IDENT "Black Magic Probe (STLINK), (Firmware 1.5" VERSION_SUFFIX ", build " BUILDDATE ")" -#define BOARD_IDENT_DFU "Black Magic (Upgrade) for STLink/Discovery, (Firmware 1.5" VERSION_SUFFIX ", build " BUILDDATE ")" -#define BOARD_IDENT_UPD "Black Magic (DFU Upgrade) for STLink/Discovery, (Firmware 1.5" VERSION_SUFFIX ", build " BUILDDATE ")" +#define BOARD_IDENT "Black Magic Probe (STLINK), (Firmware " FIRMWARE_VERSION ")" +#define BOARD_IDENT_DFU "Black Magic (Upgrade) for STLink/Discovery, (Firmware " FIRMWARE_VERSION ")" +#define BOARD_IDENT_UPD "Black Magic (DFU Upgrade) for STLink/Discovery, (Firmware " FIRMWARE_VERSION ")" #define DFU_IDENT "Black Magic Firmware Upgrade (STLINK)" #define DFU_IFACE_STRING "@Internal Flash /0x08000000/8*001Ka,56*001Kg" #define UPD_IFACE_STRING "@Internal Flash /0x08000000/8*001Kg" diff --git a/src/platforms/swlink/Makefile.inc b/src/platforms/swlink/Makefile.inc index 0ca2a3b..62f90bb 100644 --- a/src/platforms/swlink/Makefile.inc +++ b/src/platforms/swlink/Makefile.inc @@ -16,7 +16,6 @@ LDFLAGS = $(LDFLAGS_BOOT) -Wl,-Ttext=0x8002000 VPATH += platforms/stm32 SRC += cdcacm.c \ - platform.c \ usbuart.c \ serialno.c \ timing.c \ diff --git a/src/platforms/swlink/platform.h b/src/platforms/swlink/platform.h index 2c6fb76..e31f543 100644 --- a/src/platforms/swlink/platform.h +++ b/src/platforms/swlink/platform.h @@ -26,10 +26,11 @@ #include "gpio.h" #include "timing.h" +#include "version.h" -#define BOARD_IDENT "Black Magic Probe (SWLINK), (Firmware 1.5" VERSION_SUFFIX ", build " BUILDDATE ")" -#define BOARD_IDENT_DFU "Black Magic (Upgrade), STM8S Discovery, (Firmware 1.5" VERSION_SUFFIX ", build " BUILDDATE ")" -#define BOARD_IDENT_UPD "Black Magic (DFU Upgrade), STM8S Discovery, (Firmware 1.5" VERSION_SUFFIX ", build " BUILDDATE ")" +#define BOARD_IDENT "Black Magic Probe (SWLINK), (Firmware " FIRMWARE_VERSION ")" +#define BOARD_IDENT_DFU "Black Magic (Upgrade), STM8S Discovery, (Firmware " FIRMWARE_VERSION ")" +#define BOARD_IDENT_UPD "Black Magic (DFU Upgrade), STM8S Discovery, (Firmware " FIRMWARE_VERSION ")" #define DFU_IDENT "Black Magic Firmware Upgrade (SWLINK)" #define DFU_IFACE_STRING "@Internal Flash /0x08000000/8*001Ka,56*001Kg" #define UPD_IFACE_STRING "@Internal Flash /0x08000000/8*001Kg"