diff --git a/dist/tools/mspdebug/.gitignore b/dist/tools/mspdebug/.gitignore new file mode 100644 index 0000000000..599bbebea7 --- /dev/null +++ b/dist/tools/mspdebug/.gitignore @@ -0,0 +1 @@ +/mspdebug diff --git a/dist/tools/mspdebug/Makefile b/dist/tools/mspdebug/Makefile new file mode 100644 index 0000000000..c99d3d1a77 --- /dev/null +++ b/dist/tools/mspdebug/Makefile @@ -0,0 +1,25 @@ +PKG_NAME := mspdebug +PKG_URL := https://github.com/dlbeer/mspdebug +PKG_VERSION := 985b390ba22f4229aeca9f02e273a54eb4a76a9a +PKG_LICENSE := GPL-2.0-only + +# manually set some RIOT env vars, so this Makefile can be called stand-alone +RIOTBASE ?= $(CURDIR)/../../.. +RIOTTOOLS ?= $(CURDIR)/.. + +PKG_SOURCE_DIR = $(CURDIR)/bin +PKG_BUILD_OUT_OF_SOURCE = 0 + +include $(RIOTBASE)/pkg/pkg.mk + +all: $(CURDIR)/mspdebug + +$(CURDIR)/mspdebug: +# Start mspdebug build in a clean environment, so variables set by RIOT's build process +# for cross compiling a specific target platform are reset and mspdebug can +# be built cleanly for the native platform. + env -i PATH="$(PATH)" TERM="$(TERM)" "$(MAKE)" -C "$(PKG_BUILD_DIR)" + mv $(PKG_BUILD_DIR)/mspdebug . + +clean:: + rm -f $(CURDIR)/mspdebug diff --git a/dist/tools/mspdebug/debug.sh b/dist/tools/mspdebug/debug.sh index 7031154be4..af45682af8 100755 --- a/dist/tools/mspdebug/debug.sh +++ b/dist/tools/mspdebug/debug.sh @@ -5,10 +5,11 @@ MSPDEBUG_PROGRAMMER="$2" PROTOCOL="$3" MSPDEBUG_TTY="$4" DEBUG_ADAPTER_ID="$5" -GDBPORT="$6" -ELFFILE="$7" -PREFIX="$8" -RIOTBASE="$9" +DEBUG_TARGET_ID="$6" +GDBPORT="$7" +ELFFILE="$8" +PREFIX="$9" +RIOTBASE="$10" # The setsid command is needed so that Ctrl+C in GDB doesn't kill mspdebug : "${SETSID:=setsid}" @@ -28,6 +29,7 @@ fi sleep 2 args=() +args+=("--expect-id" "$DEBUG_TARGET_ID") if [ "JTAG" = "${PROTOCOL}" ]; then args+=("-j") elif [ "Spy-Bi-Wire" != "${PROTOCOL}" ]; then diff --git a/dist/tools/mspdebug/debug_srv.sh b/dist/tools/mspdebug/debug_srv.sh index 734c18a13f..3a6df06b22 100755 --- a/dist/tools/mspdebug/debug_srv.sh +++ b/dist/tools/mspdebug/debug_srv.sh @@ -5,13 +5,15 @@ MSPDEBUG_PROGRAMMER="$2" PROTOCOL="$3" MSPDEBUG_TTY="$4" DEBUG_ADAPTER_ID="$5" -GDBPORT="$6" +DEBUG_TARGET_ID="$6" +GDBPORT="$7" if [ -z "${MSPDEBUG_PROGRAMMER}" ]; then echo "MSPDEBUG_PROGRAMMER unset, cannot use mspdebug" fi args=() +args+=("--expect-id" "$DEBUG_TARGET_ID") if [ "JTAG" = "${PROTOCOL}" ]; then args+=("-j") else diff --git a/dist/tools/mspdebug/patches/6f507ddcd8a4db4b56bb4750ed837e505cb71abf.patch b/dist/tools/mspdebug/patches/6f507ddcd8a4db4b56bb4750ed837e505cb71abf.patch new file mode 100644 index 0000000000..24cdb29037 Binary files /dev/null and b/dist/tools/mspdebug/patches/6f507ddcd8a4db4b56bb4750ed837e505cb71abf.patch differ diff --git a/dist/tools/mspdebug/patches/98a9522fd41402309a3c9f1fcff1b655c72dd795.patch b/dist/tools/mspdebug/patches/98a9522fd41402309a3c9f1fcff1b655c72dd795.patch new file mode 100644 index 0000000000..03fc95b3b9 Binary files /dev/null and b/dist/tools/mspdebug/patches/98a9522fd41402309a3c9f1fcff1b655c72dd795.patch differ diff --git a/makefiles/tools/mspdebug.inc.mk b/makefiles/tools/mspdebug.inc.mk index 53a946ddec..9cfc51742a 100644 --- a/makefiles/tools/mspdebug.inc.mk +++ b/makefiles/tools/mspdebug.inc.mk @@ -1,12 +1,16 @@ -FLASHER ?= mspdebug FLASHFILE ?= $(HEXFILE) MSPDEBUG_PROGRAMMER ?= olimex +MSPDEBUG ?= $(RIOTTOOLS)/mspdebug/mspdebug +FLASHER ?= $(MSPDEBUG) +FLASHDEPS += $(MSPDEBUG) DEBUGSERVER_PORT ?= 2000 DEBUGGER := $(RIOTTOOLS)/mspdebug/debug.sh MSPDEBUG_PROTOCOL ?= JTAG MSPDEBUG_TTY ?= +DEBUG_TARGET := $(call uppercase_and_underscore,$(CPU_MODEL)) + ifeq (JTAG,$(strip $(MSPDEBUG_PROTOCOL))) FFLAGS += -j endif @@ -16,12 +20,13 @@ endif ifneq (,$(strip $(DEBUG_ADAPTER_ID))) FFLAGS += -s "$(DEBUG_ADAPTER_ID)" endif +FFLAGS += --expect-id "$(DEBUG_TARGET)" FFLAGS += $(MSPDEBUG_PROGRAMMER) "prog $(FLASHFILE)" -DEBUGGER_FLAGS = $(FLASHER) $(MSPDEBUG_PROGRAMMER) $(MSPDEBUG_PROTOCOL) "$(MSPDEBUG_TTY)" "$(DEBUG_ADAPTER_ID)" $(DEBUGSERVER_PORT) $(ELFFILE) $(PREFIX) $(RIOTBASE) +DEBUGGER_FLAGS = $(MSPDEBUG) $(MSPDEBUG_PROGRAMMER) $(MSPDEBUG_PROTOCOL) "$(MSPDEBUG_TTY)" "$(DEBUG_ADAPTER_ID)" "$(DEBUG_TARGET)" $(DEBUGSERVER_PORT) $(ELFFILE) $(PREFIX) $(RIOTBASE) DEBUGSERVER := $(RIOTTOOLS)/mspdebug/debug_srv.sh -DEBUGSERVER_FLAGS = $(FLASHER) $(MSPDEBUG_PROGRAMMER) $(MSPDEBUG_PROTOCOL) "$(MSPDEBUG_TTY)" "$(DEBUG_ADAPTER_ID)" $(DEBUGSERVER_PORT) +DEBUGSERVER_FLAGS = $(MSPDEBUG) $(MSPDEBUG_PROGRAMMER) $(MSPDEBUG_PROTOCOL) "$(MSPDEBUG_TTY)" "$(DEBUG_ADAPTER_ID)" "$(DEBUG_TARGET)" $(DEBUGSERVER_PORT) # setup reset tool -RESET ?= mspdebug +RESET ?= $(MSPDEBUG) RESET_FLAGS ?= -j $(MSPDEBUG_PROGRAMMER) reset diff --git a/makefiles/tools/targets.inc.mk b/makefiles/tools/targets.inc.mk index de5447938f..f1322b9d55 100644 --- a/makefiles/tools/targets.inc.mk +++ b/makefiles/tools/targets.inc.mk @@ -32,6 +32,12 @@ $(RIOTTOOLS)/edbg/edbg: $(RIOTTOOLS)/edbg/Makefile CC= CFLAGS= $(MAKE) -C $(RIOTTOOLS)/edbg @echo "[INFO] edbg binary successfully built!" +$(RIOTTOOLS)/mspdebug/mspdebug: $(RIOTTOOLS)/mspdebug/Makefile + @echo "[INFO] mspdebug binary not found - building it from source now" + @echo "[INFO] mspdebug requires readline and libusb-compat headers to build" + CC= CFLAGS= $(MAKE) -C $(RIOTTOOLS)/mspdebug + @echo "[INFO] mspdebug binary successfully built!" + $(RIOTTOOLS)/mosquitto_rsmb/mosquitto_rsmb: @echo "[INFO] rsmb binary not found - building it from source now" @$(MAKE) -C $(RIOTTOOLS)/mosquitto_rsmb