From 0d59e7dc6e6883c3ab560e4e2cd0f0af4ff07b46 Mon Sep 17 00:00:00 2001 From: Benjamin Valentin Date: Thu, 9 Jul 2020 17:03:15 +0200 Subject: [PATCH] makefiles/tools/openocd-adapters: default to SWD, but make it configurable --- makefiles/tools/openocd-adapters/dap.inc.mk | 4 ++++ makefiles/tools/openocd-adapters/iotlab.inc.mk | 3 +++ makefiles/tools/openocd-adapters/jlink.inc.mk | 4 ++++ makefiles/tools/openocd-adapters/mulle.inc.mk | 3 +++ makefiles/tools/openocd-adapters/raspi.inc.mk | 6 ++++-- makefiles/tools/openocd-adapters/stlink.inc.mk | 14 ++++++++++---- makefiles/tools/openocd-adapters/sysfs_gpio.inc.mk | 4 +++- makefiles/tools/openocd.inc.mk | 1 + 8 files changed, 32 insertions(+), 7 deletions(-) diff --git a/makefiles/tools/openocd-adapters/dap.inc.mk b/makefiles/tools/openocd-adapters/dap.inc.mk index e3a2c691a5..fbb85ced66 100644 --- a/makefiles/tools/openocd-adapters/dap.inc.mk +++ b/makefiles/tools/openocd-adapters/dap.inc.mk @@ -1,5 +1,9 @@ # CMSIS DAP debug adapter OPENOCD_ADAPTER_INIT ?= -c 'source [find interface/cmsis-dap.cfg]' + +# default to SWD +OPENOCD_TRANSPORT ?= swd + # Add serial matching command, only if DEBUG_ADAPTER_ID was specified ifneq (,$(DEBUG_ADAPTER_ID)) OPENOCD_ADAPTER_INIT += -c 'cmsis_dap_serial $(DEBUG_ADAPTER_ID)' diff --git a/makefiles/tools/openocd-adapters/iotlab.inc.mk b/makefiles/tools/openocd-adapters/iotlab.inc.mk index dfd77d4e00..3e4b8ed13b 100644 --- a/makefiles/tools/openocd-adapters/iotlab.inc.mk +++ b/makefiles/tools/openocd-adapters/iotlab.inc.mk @@ -1,6 +1,9 @@ # iotlab-usb debug adapter OPENOCD_ADAPTER_INIT ?= -c 'source [find interface/ftdi/iotlab-usb.cfg]' +# default to SWD +OPENOCD_TRANSPORT ?= swd + # Add serial matching command, only if DEBUG_ADAPTER_ID was specified ifneq (,$(DEBUG_ADAPTER_ID)) OPENOCD_ADAPTER_INIT += -c 'ftdi_serial $(DEBUG_ADAPTER_ID)' diff --git a/makefiles/tools/openocd-adapters/jlink.inc.mk b/makefiles/tools/openocd-adapters/jlink.inc.mk index ce7137fbc0..b073a153e8 100644 --- a/makefiles/tools/openocd-adapters/jlink.inc.mk +++ b/makefiles/tools/openocd-adapters/jlink.inc.mk @@ -1,5 +1,9 @@ # Segger J-Link debug adapter OPENOCD_ADAPTER_INIT ?= -c 'source [find interface/jlink.cfg]' + +# default to SWD +OPENOCD_TRANSPORT ?= swd + # Add serial matching command, only if DEBUG_ADAPTER_ID was specified ifneq (,$(DEBUG_ADAPTER_ID)) OPENOCD_ADAPTER_INIT += -c 'jlink serial $(DEBUG_ADAPTER_ID)' diff --git a/makefiles/tools/openocd-adapters/mulle.inc.mk b/makefiles/tools/openocd-adapters/mulle.inc.mk index 347d83a17c..e7e7fc017d 100644 --- a/makefiles/tools/openocd-adapters/mulle.inc.mk +++ b/makefiles/tools/openocd-adapters/mulle.inc.mk @@ -26,6 +26,9 @@ PROGRAMMER_VERSION ?= 0.70 OPENOCD_ADAPTER_INIT ?= -f '$(RIOTBASE)/boards/mulle/dist/openocd/mulle-programmer-$(PROGRAMMER_VERSION).cfg' +# Default to SWD +OPENOCD_TRANSPORT ?= swd + # Add serial matching command, only if DEBUG_ADAPTER_ID was specified ifneq (,$(DEBUG_ADAPTER_ID)) OPENOCD_ADAPTER_INIT += -c 'ftdi_serial $(DEBUG_ADAPTER_ID)' diff --git a/makefiles/tools/openocd-adapters/raspi.inc.mk b/makefiles/tools/openocd-adapters/raspi.inc.mk index 0a996378b5..6891e588ca 100644 --- a/makefiles/tools/openocd-adapters/raspi.inc.mk +++ b/makefiles/tools/openocd-adapters/raspi.inc.mk @@ -29,8 +29,10 @@ OPENOCD_ADAPTER_INIT ?= \ -c 'bcm2835gpio_peripheral_base $(PERIPH_BASE)' \ -c 'bcm2835gpio_speed_coeffs $(SPEED_COEFF) $(SPEED_OFFSET)' \ -c 'bcm2835gpio_swd_nums $(SWCLK_PIN ) $(SWDIO_PIN)' \ - -c 'bcm2835gpio_srst_num $(SRST_PIN)' \ - -c 'transport select swd' + -c 'bcm2835gpio_srst_num $(SRST_PIN)' + +# Default to SWD +OPENOCD_TRANSPORT ?= swd # bcm2835gpio needs access to /dev/mem export OPENOCD ?= sudo -E openocd diff --git a/makefiles/tools/openocd-adapters/stlink.inc.mk b/makefiles/tools/openocd-adapters/stlink.inc.mk index 8ab05f56fc..19ba25d8b9 100644 --- a/makefiles/tools/openocd-adapters/stlink.inc.mk +++ b/makefiles/tools/openocd-adapters/stlink.inc.mk @@ -3,15 +3,21 @@ 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]' \ - -c 'transport select hla_swd' +OPENOCD_ADAPTER_INIT ?= -c 'source [find interface/stlink-v$(STLINK_VERSION).cfg]' + +# If swd / jtag is selected by the board, prefix it with hla_ +ifneq (,$(filter swd jtag,$(OPENOCD_TRANSPORT))) + OPENOCD_TRANSPORT := hla_$(OPENOCD_TRANSPORT) +endif + +# All ST-Link adapters support hla_swd, so use that for simplicity +OPENOCD_TRANSPORT ?= hla_swd + # Add serial matching command, only if DEBUG_ADAPTER_ID was specified ifneq (,$(DEBUG_ADAPTER_ID)) OPENOCD_ADAPTER_INIT += -c 'hla_serial $(DEBUG_ADAPTER_ID)' endif - # Some stlink clones cannot signal reset properly, # In this case, use SRST=none ifneq (,$(SRST)) diff --git a/makefiles/tools/openocd-adapters/sysfs_gpio.inc.mk b/makefiles/tools/openocd-adapters/sysfs_gpio.inc.mk index 8a221832a5..c63c273c58 100644 --- a/makefiles/tools/openocd-adapters/sysfs_gpio.inc.mk +++ b/makefiles/tools/openocd-adapters/sysfs_gpio.inc.mk @@ -6,8 +6,10 @@ SRST_PIN ?= 16 OPENOCD_ADAPTER_INIT ?= \ -c 'interface sysfsgpio' \ - -c 'transport select swd' \ -c 'sysfsgpio_swd_nums $(SWCLK_PIN) $(SWDIO_PIN)' \ -c 'sysfsgpio_srst_num $(SRST_PIN)' \ -c 'adapter_nsrst_delay 100' \ -c 'adapter_nsrst_assert_width 100' + +# default to SWD +OPENOCD_TRANSPORT ?= swd diff --git a/makefiles/tools/openocd.inc.mk b/makefiles/tools/openocd.inc.mk index 945dbcc3d1..25ce37915b 100644 --- a/makefiles/tools/openocd.inc.mk +++ b/makefiles/tools/openocd.inc.mk @@ -11,6 +11,7 @@ RESET_FLAGS ?= reset ifneq (,$(DEBUG_ADAPTER)) include $(RIOTMAKE)/tools/openocd-adapters/$(DEBUG_ADAPTER).inc.mk + OPENOCD_ADAPTER_INIT += -c 'transport select $(OPENOCD_TRANSPORT)' endif OPENOCD_CONFIG ?= $(BOARDDIR)/dist/openocd.cfg