Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dist/tools/openocd: add OPENOCD_SERVER_ADDRESS variable #19724

Merged
merged 1 commit into from
Jun 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions dist/tools/openocd/openocd.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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:
#
Expand Down Expand Up @@ -97,14 +98,16 @@
: ${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)
: ${GDB:=gdb}
# 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.
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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}' \
Expand Down Expand Up @@ -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}' \
Expand Down Expand Up @@ -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' \
Expand Down
5 changes: 5 additions & 0 deletions makefiles/tools/openocd.inc.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down