From 43877394947e9a288af637067c12b943a9586fad Mon Sep 17 00:00:00 2001 From: chrysn Date: Mon, 26 Nov 2018 18:51:26 +0100 Subject: [PATCH 1/5] boards/stk3700: Allow selecting OpenOCD OpenOCD works well with those devices; the OpenOCD config is provided at the default location and only needs to refer to the setup that OpenOCD ships. --- boards/stk3700/Makefile.include | 12 +++++++++--- boards/stk3700/dist/openocd.cfg | 1 + 2 files changed, 10 insertions(+), 3 deletions(-) create mode 100644 boards/stk3700/dist/openocd.cfg diff --git a/boards/stk3700/Makefile.include b/boards/stk3700/Makefile.include index 4919d97c80..f992b0533a 100644 --- a/boards/stk3700/Makefile.include +++ b/boards/stk3700/Makefile.include @@ -5,9 +5,15 @@ PORT_DARWIN ?= $(firstword $(sort $(wildcard /dev/tty.usbmodem*))) # setup serial terminal include $(RIOTMAKE)/tools/serial.inc.mk -# setup JLink for flashing -export JLINK_DEVICE := $(CPU_MODEL) -include $(RIOTMAKE)/tools/jlink.inc.mk +PROGRAMMER ?= jlink + +ifeq ($(PROGRAMMER),jlink) + # setup JLink for flashing + export JLINK_DEVICE := $(CPU_MODEL) + include $(RIOTMAKE)/tools/jlink.inc.mk +else ifeq ($(PROGRAMMER),openocd) + include $(RIOTMAKE)/tools/openocd.inc.mk +endif # include board common include $(RIOTBOARD)/common/silabs/Makefile.include diff --git a/boards/stk3700/dist/openocd.cfg b/boards/stk3700/dist/openocd.cfg new file mode 100644 index 0000000000..21eb6e65b0 --- /dev/null +++ b/boards/stk3700/dist/openocd.cfg @@ -0,0 +1 @@ +source [find board/efm32.cfg] From ac8ed1eb138a4d0f68ba1a4afcc28fb71c86e3fc Mon Sep 17 00:00:00 2001 From: chrysn Date: Fri, 14 Feb 2020 09:24:25 +0100 Subject: [PATCH 2/5] openocd: Allow using OpenOCD-shipped configs OpenOCD already ships config files for the EFM32 and EFR32 family, no need to duplicate them in RIOT; this removes the "file exists" check for files that are clearly OpenOCD-shipped board configurations, as the script can't (and shouldn't) know OpenOCD's include paths. --- dist/tools/openocd/openocd.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/dist/tools/openocd/openocd.sh b/dist/tools/openocd/openocd.sh index 19ee9065ca..df45b6f6bd 100755 --- a/dist/tools/openocd/openocd.sh +++ b/dist/tools/openocd/openocd.sh @@ -4,7 +4,8 @@ # # This script is supposed to be called from RIOTs make system, # as it depends on certain environment variables. An OpenOCD -# configuration file must be present in a the boards dist folder. +# configuration file must be present in a the boards dist folder +# or be given as "board/[...].cfg" to use an OpenOCD shipped configuration. # # Any extra command line arguments after the command name are passed on the # openocd command line after the configuration file name but before any other @@ -133,7 +134,7 @@ fi # a couple of tests for certain configuration options # test_config() { - if [ ! -f "${OPENOCD_CONFIG}" ]; then + if [ ! -f "${OPENOCD_CONFIG}" ] && [[ ! "${OPENOCD_CONFIG}" == board/* ]] ; then echo "Error: Unable to locate OpenOCD configuration file" echo " (${OPENOCD_CONFIG})" exit 1 From 80167b8ba418675c8caf725821241903cb579de8 Mon Sep 17 00:00:00 2001 From: chrysn Date: Fri, 14 Feb 2020 09:29:32 +0100 Subject: [PATCH 3/5] boards/stk3700: Use OpenOCD-shipped board file --- boards/stk3700/Makefile.include | 1 + boards/stk3700/dist/openocd.cfg | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) delete mode 100644 boards/stk3700/dist/openocd.cfg diff --git a/boards/stk3700/Makefile.include b/boards/stk3700/Makefile.include index f992b0533a..f57f0372ba 100644 --- a/boards/stk3700/Makefile.include +++ b/boards/stk3700/Makefile.include @@ -12,6 +12,7 @@ ifeq ($(PROGRAMMER),jlink) export JLINK_DEVICE := $(CPU_MODEL) include $(RIOTMAKE)/tools/jlink.inc.mk else ifeq ($(PROGRAMMER),openocd) + export OPENOCD_CONFIG := board/efm32.cfg include $(RIOTMAKE)/tools/openocd.inc.mk endif diff --git a/boards/stk3700/dist/openocd.cfg b/boards/stk3700/dist/openocd.cfg deleted file mode 100644 index 21eb6e65b0..0000000000 --- a/boards/stk3700/dist/openocd.cfg +++ /dev/null @@ -1 +0,0 @@ -source [find board/efm32.cfg] From f4b1d60887d4c7f385d187e57b8be84153d0f974 Mon Sep 17 00:00:00 2001 From: chrysn Date: Fri, 14 Feb 2020 09:32:48 +0100 Subject: [PATCH 4/5] boards/*silabs: Move programmer selection to common This removes duplication for the jlink case (keeping only any non-default values in the board makefiles), and opens up STK3700's OpenOCD programmability for generic boards. --- boards/common/silabs/Makefile.include | 11 +++++++++++ boards/common/slwstk6000b/Makefile.include | 1 - boards/slstk3401a/Makefile.include | 2 -- boards/slstk3402a/Makefile.include | 2 -- boards/sltb001a/Makefile.include | 1 - boards/stk3600/Makefile.include | 4 ---- boards/stk3700/Makefile.include | 11 ----------- 7 files changed, 11 insertions(+), 21 deletions(-) diff --git a/boards/common/silabs/Makefile.include b/boards/common/silabs/Makefile.include index b3880891b6..1554e9b519 100644 --- a/boards/common/silabs/Makefile.include +++ b/boards/common/silabs/Makefile.include @@ -1,2 +1,13 @@ INCLUDES += -I$(RIOTBOARD)/common/silabs/include INCLUDES += -I$(RIOTBOARD)/common/silabs/drivers/include + +PROGRAMMER ?= jlink + +export JLINK_DEVICE ?= ${CPU_MODEL} +export OPENOCD_CONFIG ?= board/efm32.cfg + +ifeq ($(PROGRAMMER),jlink) + include $(RIOTMAKE)/tools/jlink.inc.mk +else ifeq ($(PROGRAMMER),openocd) + include $(RIOTMAKE)/tools/openocd.inc.mk +endif diff --git a/boards/common/slwstk6000b/Makefile.include b/boards/common/slwstk6000b/Makefile.include index 794400d9ec..c216f7d05f 100644 --- a/boards/common/slwstk6000b/Makefile.include +++ b/boards/common/slwstk6000b/Makefile.include @@ -13,7 +13,6 @@ include $(RIOTMAKE)/tools/serial.inc.mk # setup JLink for flashing export JLINK_DEVICE := $(MODULE_JLINK_DEVICE) -include $(RIOTMAKE)/tools/jlink.inc.mk # include board common include $(RIOTBOARD)/common/silabs/Makefile.include diff --git a/boards/slstk3401a/Makefile.include b/boards/slstk3401a/Makefile.include index 8b4181a33d..b6a443535b 100644 --- a/boards/slstk3401a/Makefile.include +++ b/boards/slstk3401a/Makefile.include @@ -6,9 +6,7 @@ PORT_DARWIN ?= $(firstword $(sort $(wildcard /dev/tty.usbmodem*))) include $(RIOTMAKE)/tools/serial.inc.mk # setup JLink for flashing -export JLINK_DEVICE := $(CPU_MODEL) export JLINK_PRE_FLASH = r -include $(RIOTMAKE)/tools/jlink.inc.mk # include board common include $(RIOTBOARD)/common/silabs/Makefile.include diff --git a/boards/slstk3402a/Makefile.include b/boards/slstk3402a/Makefile.include index 8b4181a33d..b6a443535b 100644 --- a/boards/slstk3402a/Makefile.include +++ b/boards/slstk3402a/Makefile.include @@ -6,9 +6,7 @@ PORT_DARWIN ?= $(firstword $(sort $(wildcard /dev/tty.usbmodem*))) include $(RIOTMAKE)/tools/serial.inc.mk # setup JLink for flashing -export JLINK_DEVICE := $(CPU_MODEL) export JLINK_PRE_FLASH = r -include $(RIOTMAKE)/tools/jlink.inc.mk # include board common include $(RIOTBOARD)/common/silabs/Makefile.include diff --git a/boards/sltb001a/Makefile.include b/boards/sltb001a/Makefile.include index 7b2297b56e..55148eb7e5 100644 --- a/boards/sltb001a/Makefile.include +++ b/boards/sltb001a/Makefile.include @@ -8,7 +8,6 @@ include $(RIOTMAKE)/tools/serial.inc.mk # setup JLink for flashing export JLINK_DEVICE := EFR32MG1PxxxF256 export JLINK_PRE_FLASH = r -include $(RIOTMAKE)/tools/jlink.inc.mk # include board common include $(RIOTBOARD)/common/silabs/Makefile.include diff --git a/boards/stk3600/Makefile.include b/boards/stk3600/Makefile.include index 4919d97c80..013639d645 100644 --- a/boards/stk3600/Makefile.include +++ b/boards/stk3600/Makefile.include @@ -5,9 +5,5 @@ PORT_DARWIN ?= $(firstword $(sort $(wildcard /dev/tty.usbmodem*))) # setup serial terminal include $(RIOTMAKE)/tools/serial.inc.mk -# setup JLink for flashing -export JLINK_DEVICE := $(CPU_MODEL) -include $(RIOTMAKE)/tools/jlink.inc.mk - # include board common include $(RIOTBOARD)/common/silabs/Makefile.include diff --git a/boards/stk3700/Makefile.include b/boards/stk3700/Makefile.include index f57f0372ba..013639d645 100644 --- a/boards/stk3700/Makefile.include +++ b/boards/stk3700/Makefile.include @@ -5,16 +5,5 @@ PORT_DARWIN ?= $(firstword $(sort $(wildcard /dev/tty.usbmodem*))) # setup serial terminal include $(RIOTMAKE)/tools/serial.inc.mk -PROGRAMMER ?= jlink - -ifeq ($(PROGRAMMER),jlink) - # setup JLink for flashing - export JLINK_DEVICE := $(CPU_MODEL) - include $(RIOTMAKE)/tools/jlink.inc.mk -else ifeq ($(PROGRAMMER),openocd) - export OPENOCD_CONFIG := board/efm32.cfg - include $(RIOTMAKE)/tools/openocd.inc.mk -endif - # include board common include $(RIOTBOARD)/common/silabs/Makefile.include From 1dbf07f92609460a24638d544c7fd47ec6e7a9d4 Mon Sep 17 00:00:00 2001 From: chrysn Date: Fri, 14 Feb 2020 09:40:03 +0100 Subject: [PATCH 5/5] openocd: Add instructions for overriding OPENOCD --- dist/tools/openocd/openocd.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/dist/tools/openocd/openocd.sh b/dist/tools/openocd/openocd.sh index df45b6f6bd..39130b6fbb 100755 --- a/dist/tools/openocd/openocd.sh +++ b/dist/tools/openocd/openocd.sh @@ -13,6 +13,11 @@ # # Global environment variables used: # OPENOCD: OpenOCD command name, default: "openocd" +# Care must be taken when specifying an OpenOCD version in +# its build directory, as it does not look up its own +# configuration files relative to the executable -- the +# scripts directory needs to be passed in like this: +# `OPENOCD="~/openocd/src/openocd -s ~/openocd/tcl"`. # OPENOCD_CONFIG: OpenOCD configuration file name, # default: "${BOARDSDIR}/${BOARD}/dist/openocd.cfg" #