From 17d0e586c5b0a876480d54b450774b263c429a18 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabian=20H=C3=BC=C3=9Fler?= Date: Fri, 9 Jun 2023 23:52:01 +0200 Subject: [PATCH] dist/tools/openocd: add OPENOCD_SERVER_ADDRESS variable --- dist/tools/openocd/openocd.sh | 10 ++++++++-- makefiles/tools/openocd.inc.mk | 5 +++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/dist/tools/openocd/openocd.sh b/dist/tools/openocd/openocd.sh index 91b0bf554e..675d318f19 100755 --- a/dist/tools/openocd/openocd.sh +++ b/dist/tools/openocd/openocd.sh @@ -20,6 +20,7 @@ # `OPENOCD="~/openocd/src/openocd -s ~/openocd/tcl"`. # OPENOCD_CONFIG: OpenOCD configuration file name, # default: "${BOARDSDIR}/${BOARD}/dist/openocd.cfg" +# OPENOCD_SERVER_ADDRESS: OpenOCD server bind address, default: "localhost" # # The script supports the following actions: # @@ -97,6 +98,8 @@ : ${OPENOCD_ADAPTER_INIT:=} # If set to 1 'reset_config' will use 'connect_assert_srst' before 'flash' or 'reset. : ${OPENOCD_RESET_USE_CONNECT_ASSERT_SRST:=} +# Default bind address for OpenOCD +: ${OPENOCD_SERVER_ADDRESS:=localhost} # The setsid command is needed so that Ctrl+C in GDB doesn't kill OpenOCD : ${SETSID:=setsid} # GDB command, usually a separate command for each platform (e.g. arm-none-eabi-gdb) @@ -104,7 +107,7 @@ # Debugger client command, can be used to wrap GDB in a front-end : ${DBG:=${GDB}} # Default debugger flags, -: ${DBG_DEFAULT_FLAGS:=-q -ex \"tar ext :$(( GDB_PORT + GDB_PORT_CORE_OFFSET ))\"} +: ${DBG_DEFAULT_FLAGS:=-q -ex \"tar ext ${OPENOCD_SERVER_ADDRESS}:$(( GDB_PORT + GDB_PORT_CORE_OFFSET ))\"} # Extra debugger flags, added by the user : ${DBG_EXTRA_FLAGS:=} # Debugger flags, will be passed to sh -c, remember to escape any quotation signs. @@ -137,7 +140,7 @@ # default terminal frontend _OPENOCD_TERMPROG=${RIOTTOOLS}/pyterm/pyterm -_OPENOCD_TERMFLAGS="-ts ${RTT_PORT} ${PYTERMFLAGS}" +_OPENOCD_TERMFLAGS="-ts ${OPENOCD_SERVER_ADDRESS}:${RTT_PORT} ${PYTERMFLAGS}" # # Examples of alternative debugger configurations @@ -371,6 +374,7 @@ do_debug() { ${OPENOCD_ADAPTER_INIT} \ -f '${OPENOCD_CONFIG}' \ ${OPENOCD_EXTRA_INIT} \ + -c 'bindto ${OPENOCD_SERVER_ADDRESS}' \ -c 'tcl_port ${TCL_PORT}' \ -c 'telnet_port ${TELNET_PORT}' \ -c 'gdb_port ${GDB_PORT}' \ @@ -399,6 +403,7 @@ do_debugserver() { ${OPENOCD_ADAPTER_INIT} \ -f '${OPENOCD_CONFIG}' \ ${OPENOCD_EXTRA_INIT} \ + -c 'bindto ${OPENOCD_SERVER_ADDRESS}' \ -c 'tcl_port ${TCL_PORT}' \ -c 'telnet_port ${TELNET_PORT}' \ -c 'gdb_port ${GDB_PORT}' \ @@ -448,6 +453,7 @@ do_term() { ${OPENOCD_ADAPTER_INIT} \ -f '${OPENOCD_CONFIG}' \ ${OPENOCD_EXTRA_INIT} \ + -c 'bindto ${OPENOCD_SERVER_ADDRESS}' \ -c 'tcl_port 0' \ -c 'telnet_port 0' \ -c 'gdb_port 0' \ diff --git a/makefiles/tools/openocd.inc.mk b/makefiles/tools/openocd.inc.mk index b5d3e36244..0b7c63ee59 100644 --- a/makefiles/tools/openocd.inc.mk +++ b/makefiles/tools/openocd.inc.mk @@ -33,6 +33,11 @@ $(call target-export-variables,$(OPENOCD_TARGETS),OPENOCD_ADAPTER_INIT) # Export OPENOCD_RESET_USE_CONNECT_ASSERT_SRST to required targets $(call target-export-variables,$(OPENOCD_TARGETS),OPENOCD_RESET_USE_CONNECT_ASSERT_SRST) +ifneq (,$(OPENOCD_SERVER_ADDRESS)) +# Export OPENOCD_SERVER_ADDRESS to required targets + $(call target-export-variables,$(OPENOCD_TARGETS),OPENOCD_SERVER_ADDRESS) +endif + ifneq (,$(OPENOCD_CMD_RESET_RUN)) # Export OPENOCD_CMD_RESET_RUN only to the reset target $(call target-export-variables,reset,OPENOCD_CMD_RESET_RUN)