-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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
- Loading branch information
Showing
8 changed files
with
172 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/mspdebug |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
dist/tools/mspdebug/patches/6f507ddcd8a4db4b56bb4750ed837e505cb71abf.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
From 6f507ddcd8a4db4b56bb4750ed837e505cb71abf Mon Sep 17 00:00:00 2001 | ||
From: Marian Buschsieweke <[email protected]> | ||
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 changes: 90 additions & 0 deletions
90
dist/tools/mspdebug/patches/98a9522fd41402309a3c9f1fcff1b655c72dd795.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
From 98a9522fd41402309a3c9f1fcff1b655c72dd795 Mon Sep 17 00:00:00 2001 | ||
From: Marian Buschsieweke <[email protected]> | ||
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(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters