diff --git a/dist/tools/openocd/adapters/stlink.cfg b/dist/tools/openocd/adapters/stlink.cfg new file mode 100644 index 0000000000..d19d6e6265 --- /dev/null +++ b/dist/tools/openocd/adapters/stlink.cfg @@ -0,0 +1,12 @@ +# OpenOCD currently uses a single configuration file for all ST-Link +# adapters. However not all supported distributions use the latest +# OpenOCD. +# If the default script isn't available then use the old method via +# specifying the correct version. +try { + source [find interface/stlink.cfg] +} on error {} { + puts "WARNING: using old version of OpenOCD" + puts "Using STLINK_VERSION $stlink_version" + source [find interface/stlink-v${stlink_version}.cfg] +} diff --git a/makefiles/tools/openocd-adapters/stlink.inc.mk b/makefiles/tools/openocd-adapters/stlink.inc.mk index 19ba25d8b9..9c586a9579 100644 --- a/makefiles/tools/openocd-adapters/stlink.inc.mk +++ b/makefiles/tools/openocd-adapters/stlink.inc.mk @@ -1,9 +1,11 @@ # ST-Link debug adapter -# Use st-link v2-1 by default + +# Set the default version for the old OpenOCD versions STLINK_VERSION ?= 2-1 -# Use STLINK_VERSION to select which stlink version is used -OPENOCD_ADAPTER_INIT ?= -c 'source [find interface/stlink-v$(STLINK_VERSION).cfg]' +# Determine which configuration file to use for OpenOCD. +# Also pass the correct version of the ST-Link adapter to the script. +OPENOCD_ADAPTER_INIT ?= -c 'set stlink_version $(STLINK_VERSION);source $(RIOTBASE)/dist/tools/openocd/adapters/stlink.cfg' # If swd / jtag is selected by the board, prefix it with hla_ ifneq (,$(filter swd jtag,$(OPENOCD_TRANSPORT)))