From aafc099a1cc359c9931f4d8e883337d53e19f65c Mon Sep 17 00:00:00 2001 From: Marian Buschsieweke Date: Tue, 6 Feb 2024 15:23:02 +0100 Subject: [PATCH] dist/tools/mspdebug: build from source This adds mspdebug as package, similar to EDBG, so that the programmer/debugger is build from source. This has the advantage that we can indeed provide patches of our own. The first patch fixes a bug with the CPU detection of `mspdebug` in combination with the Olimex MSP430-JTAG-TINY-V2. The second adds the `--expect-id ` argument. The RIOT integration is updated to directly make use of the `--expect-id` parameter. No more spending time debugging why firmware the firmware for the `olimex-msp430-h2618` doesn't run when flashed on the `olimex-msp430h1611` hardware :D --- dist/tools/mspdebug/.gitignore | 1 + dist/tools/mspdebug/Makefile | 25 ++++++++++++++++++ dist/tools/mspdebug/debug.sh | 10 ++++--- dist/tools/mspdebug/debug_srv.sh | 4 ++- ...7ddcd8a4db4b56bb4750ed837e505cb71abf.patch | Bin 0 -> 1192 bytes ...522fd41402309a3c9f1fcff1b655c72dd795.patch | Bin 0 -> 3102 bytes makefiles/tools/mspdebug.inc.mk | 13 ++++++--- makefiles/tools/targets.inc.mk | 6 +++++ 8 files changed, 50 insertions(+), 9 deletions(-) create mode 100644 dist/tools/mspdebug/.gitignore create mode 100644 dist/tools/mspdebug/Makefile create mode 100644 dist/tools/mspdebug/patches/6f507ddcd8a4db4b56bb4750ed837e505cb71abf.patch create mode 100644 dist/tools/mspdebug/patches/98a9522fd41402309a3c9f1fcff1b655c72dd795.patch 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 0000000000000000000000000000000000000000..24cdb29037a2e6a7a7d1ef157f498b45ec38768b GIT binary patch literal 1192 zcmd^7$&S-N5Is+SMV(L<@3Ec44AH<0BRC8iDZ>dNtJ__U8{$RX?JS6or))qV5pm&& zWx3^Y)vLGoUbi)*WfCl62c%z9hK_aO4 z=ei$MR0)$oP^Vkl=BE<%4`_q1>ZJ)*@sfXIJ;-DBfG gFokP+u))Z#`5dBR4im8AUK1hYsVI4_~IJTU)bz&n@f&y(pEXk#`F-0=mr4+--fA0(r zk+j?vMFm>c4rkuXzBzU;(|8S&F`Eo~y}%#X1FP4!CamvG0z2@6z;;iDLvPgc{n2Cy z@8byOJOO(ImNm^E=vkJnUn0yD-m_G&2;OAUTS>vU{EoxRbuR3>4dLr}v&_0aKh-ao z;!{|xG6Q-D&+ZYf*9Utr?N6pCIkpg9pJ(nD?x`vKetWh!fA=S3;`y41sOwFE`97E? z|CXSFDSYtOK7=CTkg$}kx#Fp=FIF5PzO6+dBxI5YSqMR#f`}Afrc8-w32T}7+|8CG zjKR%B=!3kMim#=vR!qT`MGEj0k7Sl|$Yly01R`B;8A)OYLMB(_gn24sVR#SQR4BzG z9bc02nkjEZ?p7@I$*PMapguk;9wro+2y#sfGljK~>OSEBF(mUS{1P~=bG=olM3f%W<|nB$&t0>}700$fU!W}bp#&kjqM5*~EWFyWe}Z9LCe zZ(iUUIh2aFm1^2i!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