diff --git a/boards/blackpill-128kib/Makefile.include b/boards/blackpill-128kib/Makefile.include index 55be113c8b..58815734f3 100644 --- a/boards/blackpill-128kib/Makefile.include +++ b/boards/blackpill-128kib/Makefile.include @@ -1,3 +1,3 @@ -export OPENOCD_CONFIG ?= $(RIOTBOARD)/common/blxxxpill/dist/openocd-128kib.cfg +OPENOCD_CONFIG ?= $(RIOTBOARD)/common/blxxxpill/dist/openocd-128kib.cfg include $(RIOTBOARD)/common/blxxxpill/Makefile.include diff --git a/boards/blackpill/Makefile.include b/boards/blackpill/Makefile.include index e502f5c2a1..83cf6c73e1 100644 --- a/boards/blackpill/Makefile.include +++ b/boards/blackpill/Makefile.include @@ -1,3 +1,3 @@ -export OPENOCD_CONFIG ?= $(RIOTBOARD)/common/blxxxpill/dist/openocd.cfg +OPENOCD_CONFIG ?= $(RIOTBOARD)/common/blxxxpill/dist/openocd.cfg include $(RIOTBOARD)/common/blxxxpill/Makefile.include diff --git a/boards/bluepill-128kib/Makefile.include b/boards/bluepill-128kib/Makefile.include index 55be113c8b..58815734f3 100644 --- a/boards/bluepill-128kib/Makefile.include +++ b/boards/bluepill-128kib/Makefile.include @@ -1,3 +1,3 @@ -export OPENOCD_CONFIG ?= $(RIOTBOARD)/common/blxxxpill/dist/openocd-128kib.cfg +OPENOCD_CONFIG ?= $(RIOTBOARD)/common/blxxxpill/dist/openocd-128kib.cfg include $(RIOTBOARD)/common/blxxxpill/Makefile.include diff --git a/boards/bluepill/Makefile.include b/boards/bluepill/Makefile.include index e502f5c2a1..83cf6c73e1 100644 --- a/boards/bluepill/Makefile.include +++ b/boards/bluepill/Makefile.include @@ -1,3 +1,3 @@ -export OPENOCD_CONFIG ?= $(RIOTBOARD)/common/blxxxpill/dist/openocd.cfg +OPENOCD_CONFIG ?= $(RIOTBOARD)/common/blxxxpill/dist/openocd.cfg include $(RIOTBOARD)/common/blxxxpill/Makefile.include diff --git a/boards/common/frdm/Makefile.include b/boards/common/frdm/Makefile.include index 7769a8e6ed..d220f82f98 100644 --- a/boards/common/frdm/Makefile.include +++ b/boards/common/frdm/Makefile.include @@ -11,7 +11,7 @@ DEBUG_ADAPTER ?= dap # For KW41Z, an OpenOCD version built from source is required. The support for # kw41z was introduced in # https://github.com/ntfreak/openocd/2c8602ed9f084d6680cec7d0ca1d5dc71c865a5f -export OPENOCD_CONFIG ?= $(RIOTBOARD)/common/frdm/dist/openocd-$(CPU_FAMILY).cfg +OPENOCD_CONFIG ?= $(RIOTBOARD)/common/frdm/dist/openocd-$(CPU_FAMILY).cfg # Check the flash configuration field before flashing export PRE_FLASH_CHECK_SCRIPT = $(RIOTCPU)/$(CPU)/dist/check-fcfield.sh diff --git a/boards/common/iotlab/Makefile.include b/boards/common/iotlab/Makefile.include index fba8ff326e..137b5946c0 100644 --- a/boards/common/iotlab/Makefile.include +++ b/boards/common/iotlab/Makefile.include @@ -11,7 +11,7 @@ export OPENOCD_RESET_USE_CONNECT_ASSERT_SRST ?= 1 DEBUG_ADAPTER ?= iotlab -export OPENOCD_CONFIG ?= $(RIOTBOARD)/common/iotlab/dist/openocd.cfg +OPENOCD_CONFIG ?= $(RIOTBOARD)/common/iotlab/dist/openocd.cfg # this board uses openocd include $(RIOTMAKE)/tools/openocd.inc.mk diff --git a/boards/common/nrf51/Makefile.include b/boards/common/nrf51/Makefile.include index 397db2b567..6fd03b1055 100644 --- a/boards/common/nrf51/Makefile.include +++ b/boards/common/nrf51/Makefile.include @@ -11,7 +11,7 @@ endif ifeq ($(PROGRAMMER),openocd) # use common openocd configuration for nrf51 - export OPENOCD_CONFIG = $(RIOTBOARD)/common/nrf51/dist/openocd.cfg + OPENOCD_CONFIG = $(RIOTBOARD)/common/nrf51/dist/openocd.cfg include $(RIOTMAKE)/tools/openocd.inc.mk else ifeq ($(PROGRAMMER),jlink) # setup JLink for flashing diff --git a/boards/common/nrf52/Makefile.include b/boards/common/nrf52/Makefile.include index e0dc6c6067..351c70ae6f 100644 --- a/boards/common/nrf52/Makefile.include +++ b/boards/common/nrf52/Makefile.include @@ -58,6 +58,6 @@ else ifeq (openocd,$(PROGRAMMER)) $(BINDIR)/softdevice.hex: | $(ELFFILE) endif DEBUG_ADAPTER ?= jlink - export OPENOCD_CONFIG := $(RIOTBOARD)/common/nrf52/dist/openocd.cfg + OPENOCD_CONFIG = $(RIOTBOARD)/common/nrf52/dist/openocd.cfg include $(RIOTMAKE)/tools/openocd.inc.mk endif diff --git a/boards/hifive1/dist/flasher.sh b/boards/hifive1/dist/flasher.sh index 1f73cea801..8852179f59 100755 --- a/boards/hifive1/dist/flasher.sh +++ b/boards/hifive1/dist/flasher.sh @@ -35,8 +35,6 @@ # @author Hauke Peteresen # @author Joakim NohlgÄrd -# Default path to OpenOCD configuration file -: ${OPENOCD_CONFIG:=${RIOTBOARD}/${BOARD}/dist/openocd.cfg} # Default OpenOCD command : ${OPENOCD:=openocd} # This is an optional offset to the base address that can be used to flash an diff --git a/dist/tools/buildsystem_sanity_check/check.sh b/dist/tools/buildsystem_sanity_check/check.sh index f908aed561..43841a986b 100755 --- a/dist/tools/buildsystem_sanity_check/check.sh +++ b/dist/tools/buildsystem_sanity_check/check.sh @@ -81,6 +81,7 @@ UNEXPORTED_VARIABLES+=('PORT_LINUX' 'PORT_DARWIN') UNEXPORTED_VARIABLES+=('PORT[ ?=:]' 'PORT$') UNEXPORTED_VARIABLES+=('LINKFLAGS' 'LINKER_SCRIPT') UNEXPORTED_VARIABLES+=('USEMODULE_INCLUDES') +UNEXPORTED_VARIABLES+=('OPENOCD_CONFIG') EXPORTED_VARIABLES_ONLY_IN_VARS=() EXPORTED_VARIABLES_ONLY_IN_VARS+=('CPU_ARCH') diff --git a/dist/tools/openocd/openocd.sh b/dist/tools/openocd/openocd.sh index 39130b6fbb..91b4106aef 100755 --- a/dist/tools/openocd/openocd.sh +++ b/dist/tools/openocd/openocd.sh @@ -71,8 +71,6 @@ : ${TELNET_PORT:=4444} # Default TCL port, set to 0 to disable : ${TCL_PORT:=6333} -# Default path to OpenOCD configuration file -: ${OPENOCD_CONFIG:=${BOARDSDIR}/${BOARD}/dist/openocd.cfg} # Default OpenOCD command : ${OPENOCD:=openocd} # Extra board initialization commands to pass to OpenOCD diff --git a/makefiles/tools/openocd-adapters/stlink.inc.mk b/makefiles/tools/openocd-adapters/stlink.inc.mk index c86a691248..4dc8a870b9 100644 --- a/makefiles/tools/openocd-adapters/stlink.inc.mk +++ b/makefiles/tools/openocd-adapters/stlink.inc.mk @@ -19,6 +19,6 @@ ifeq (,$(OPENOCD_CONFIG)) # if no openocd default configuration is provided by the board, # use the STM32 common one ifeq (0,$(words $(wildcard $(BOARDSDIR)/$(BOARD)/dist/openocd.cfg))) - export OPENOCD_CONFIG := $(RIOTBASE)/boards/common/stm32/dist/$(CPU).cfg + OPENOCD_CONFIG = $(RIOTBASE)/boards/common/stm32/dist/$(CPU).cfg endif endif diff --git a/makefiles/tools/openocd.inc.mk b/makefiles/tools/openocd.inc.mk index b478ab2711..62cf574da0 100644 --- a/makefiles/tools/openocd.inc.mk +++ b/makefiles/tools/openocd.inc.mk @@ -12,3 +12,9 @@ RESET_FLAGS ?= reset ifneq (,$(DEBUG_ADAPTER)) include $(RIOTMAKE)/tools/openocd-adapters/$(DEBUG_ADAPTER).inc.mk endif + +OPENOCD_CONFIG ?= $(BOARDSDIR)/$(BOARD)/dist/openocd.cfg + +# Export OPENOCD_CONFIG to required targets +OPENOCD_TARGETS = debug% flash% reset +$(call target-export-variables,$(OPENOCD_TARGETS),OPENOCD_CONFIG)