mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2025-12-17 02:23:49 +01:00
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 <CPU_NAME>` 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
This commit is contained in:
parent
6deca8b87c
commit
aafc099a1c
1
dist/tools/mspdebug/.gitignore
vendored
Normal file
1
dist/tools/mspdebug/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
/mspdebug
|
||||
25
dist/tools/mspdebug/Makefile
vendored
Normal file
25
dist/tools/mspdebug/Makefile
vendored
Normal file
@ -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
|
||||
10
dist/tools/mspdebug/debug.sh
vendored
10
dist/tools/mspdebug/debug.sh
vendored
@ -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
|
||||
|
||||
4
dist/tools/mspdebug/debug_srv.sh
vendored
4
dist/tools/mspdebug/debug_srv.sh
vendored
@ -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
|
||||
|
||||
32
dist/tools/mspdebug/patches/6f507ddcd8a4db4b56bb4750ed837e505cb71abf.patch
vendored
Normal file
32
dist/tools/mspdebug/patches/6f507ddcd8a4db4b56bb4750ed837e505cb71abf.patch
vendored
Normal file
@ -0,0 +1,32 @@
|
||||
From 6f507ddcd8a4db4b56bb4750ed837e505cb71abf Mon Sep 17 00:00:00 2001
|
||||
From: Marian Buschsieweke <marian.buschsieweke@ovgu.de>
|
||||
Date: Thu, 25 May 2023 14:09:59 +0200
|
||||
Subject: [PATCH] drivers/fet_core.c: populate chip entry by detected CPU name
|
||||
|
||||
Fixes https://github.com/dlbeer/mspdebug/issues/124
|
||||
---
|
||||
drivers/fet_core.c | 4 ++++
|
||||
1 file changed, 4 insertions(+)
|
||||
|
||||
diff --git a/drivers/fet_core.c b/drivers/fet_core.c
|
||||
index 9f426ba..35695a7 100644
|
||||
--- a/drivers/fet_core.c
|
||||
+++ b/drivers/fet_core.c
|
||||
@@ -226,6 +226,8 @@ static int identify_new(struct fet_device *dev, const char *force_id)
|
||||
ramSize / 1024);
|
||||
|
||||
show_dev_info(r->name, dev);
|
||||
+ /* populate chip entry based on the detected name */
|
||||
+ dev->base.chip = chipinfo_find_by_name(r->name);
|
||||
|
||||
if (fet_proto_xfer(&dev->proto, C_IDENT3,
|
||||
r->msg2b_data, r->msg2b_len, 0) < 0)
|
||||
@@ -344,6 +346,8 @@ static int identify_olimex(struct fet_device *dev, const char *force_id)
|
||||
ramSize, ramSize / 1024);
|
||||
|
||||
show_dev_info(r->name, dev);
|
||||
+ /* populate chip entry based on the detected name */
|
||||
+ dev->base.chip = chipinfo_find_by_name(r->name);
|
||||
|
||||
if (fet_proto_xfer(&dev->proto, C_IDENT3,
|
||||
r->msg2b_data, r->msg2b_len, 0) < 0)
|
||||
90
dist/tools/mspdebug/patches/98a9522fd41402309a3c9f1fcff1b655c72dd795.patch
vendored
Normal file
90
dist/tools/mspdebug/patches/98a9522fd41402309a3c9f1fcff1b655c72dd795.patch
vendored
Normal file
@ -0,0 +1,90 @@
|
||||
From 98a9522fd41402309a3c9f1fcff1b655c72dd795 Mon Sep 17 00:00:00 2001
|
||||
From: Marian Buschsieweke <marian.buschsieweke@ovgu.de>
|
||||
Date: Thu, 25 May 2023 14:39:25 +0200
|
||||
Subject: [PATCH] ui/main.c: add --expect-id cmd line parameter
|
||||
|
||||
The new parameter is useful for integrating mspdebug into build systems
|
||||
that want to ensure that the firmware to flash is actually written
|
||||
to the matching hardware. This is helpful if the user mistyped the
|
||||
hardware to build for and flash, or confused similar looking hardware.
|
||||
---
|
||||
drivers/device.h | 1 +
|
||||
ui/main.c | 18 ++++++++++++++++++
|
||||
2 files changed, 19 insertions(+)
|
||||
|
||||
diff --git a/drivers/device.h b/drivers/device.h
|
||||
index 14c0654..dfb41d7 100644
|
||||
--- a/drivers/device.h
|
||||
+++ b/drivers/device.h
|
||||
@@ -82,6 +82,7 @@ struct device_args {
|
||||
int vcc_mv;
|
||||
const char *path;
|
||||
const char *forced_chip_id;
|
||||
+ const char *expect_chip_id;
|
||||
const char *requested_serial;
|
||||
const char *require_fwupdate;
|
||||
const char *bsl_entry_seq;
|
||||
diff --git a/ui/main.c b/ui/main.c
|
||||
index 073c848..1ebed73 100644
|
||||
--- a/ui/main.c
|
||||
+++ b/ui/main.c
|
||||
@@ -137,6 +137,8 @@ static void usage(const char *progname)
|
||||
" Show a list of devices supported by the FET driver.\n"
|
||||
" --fet-force-id string\n"
|
||||
" Override the device ID returned by the FET.\n"
|
||||
+" --expect-id string\n"
|
||||
+" Abort if the MCU detected is not matching the given string.\n"
|
||||
" --fet-skip-close\n"
|
||||
" Skip the JTAG close procedure when using the FET driver.\n"
|
||||
" --usb-list\n"
|
||||
@@ -297,6 +299,7 @@ static int parse_cmdline_args(int argc, char **argv,
|
||||
LOPT_HELP = 0x100,
|
||||
LOPT_FET_LIST,
|
||||
LOPT_FET_FORCE_ID,
|
||||
+ LOPT_EXPECT_ID,
|
||||
LOPT_FET_SKIP_CLOSE,
|
||||
LOPT_USB_LIST,
|
||||
LOPT_VERSION,
|
||||
@@ -315,6 +318,7 @@ static int parse_cmdline_args(int argc, char **argv,
|
||||
{"help", 0, 0, LOPT_HELP},
|
||||
{"fet-list", 0, 0, LOPT_FET_LIST},
|
||||
{"fet-force-id", 1, 0, LOPT_FET_FORCE_ID},
|
||||
+ {"expect-id", 1, 0, LOPT_EXPECT_ID},
|
||||
{"fet-skip-close", 0, 0, LOPT_FET_SKIP_CLOSE},
|
||||
{"usb-list", 0, 0, LOPT_USB_LIST},
|
||||
{"version", 0, 0, LOPT_VERSION},
|
||||
@@ -426,6 +430,10 @@ static int parse_cmdline_args(int argc, char **argv,
|
||||
args->devarg.forced_chip_id = optarg;
|
||||
break;
|
||||
|
||||
+ case LOPT_EXPECT_ID:
|
||||
+ args->devarg.expect_chip_id = optarg;
|
||||
+ break;
|
||||
+
|
||||
case LOPT_FET_SKIP_CLOSE:
|
||||
args->devarg.flags |= DEVICE_FLAG_SKIP_CLOSE;
|
||||
break;
|
||||
@@ -573,6 +581,15 @@ int main(int argc, char **argv)
|
||||
if (device_probe_id(device_default, args.devarg.forced_chip_id) < 0)
|
||||
printc_err("warning: device ID probe failed\n");
|
||||
|
||||
+ if (args.devarg.expect_chip_id) {
|
||||
+ if (strcmp(args.devarg.expect_chip_id, device_default->chip->name)) {
|
||||
+ printf("Detected %s, but %s was expected\n",
|
||||
+ device_default->chip->name, args.devarg.expect_chip_id);
|
||||
+ ret = -1;
|
||||
+ goto fail_expect_id;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
if (!(args.flags & OPT_NO_RC))
|
||||
process_rc_file(args.alt_config);
|
||||
|
||||
@@ -588,6 +605,7 @@ int main(int argc, char **argv)
|
||||
reader_loop();
|
||||
}
|
||||
|
||||
+fail_expect_id:
|
||||
simio_exit();
|
||||
device_destroy();
|
||||
stab_exit();
|
||||
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user