mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
makefiles: Refactor openocd tool handling
Attempt to decouple board configuration from debugger interface configuration by specifying the DEBUG_IFACE variable for the debug hardware interface to use.
This commit is contained in:
parent
63783ffe6c
commit
57de166ea1
20
dist/tools/openocd/openocd.sh
vendored
20
dist/tools/openocd/openocd.sh
vendored
@ -66,6 +66,10 @@
|
||||
: ${OPENOCD_CONFIG:=${RIOTBOARD}/${BOARD}/dist/openocd.cfg}
|
||||
# Default OpenOCD command
|
||||
: ${OPENOCD:=openocd}
|
||||
# Extra board initialization commands to pass to OpenOCD
|
||||
: ${OPENOCD_EXTRA_INIT:=}
|
||||
# Debugger interface initialization commands to pass to OpenOCD
|
||||
: ${OPENOCD_ADAPTER_INIT:=}
|
||||
# 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)
|
||||
@ -152,7 +156,9 @@ do_flash() {
|
||||
fi
|
||||
fi
|
||||
# flash device
|
||||
sh -c "${OPENOCD} -f '${OPENOCD_CONFIG}' \
|
||||
sh -c "${OPENOCD} \
|
||||
${OPENOCD_ADAPTER_INIT} \
|
||||
-f '${OPENOCD_CONFIG}' \
|
||||
${OPENOCD_EXTRA_INIT} \
|
||||
-c 'tcl_port 0' \
|
||||
-c 'telnet_port 0' \
|
||||
@ -186,7 +192,9 @@ do_debug() {
|
||||
# don't trap on Ctrl+C, because GDB keeps running
|
||||
trap '' INT
|
||||
# start OpenOCD as GDB server
|
||||
${SETSID} sh -c "${OPENOCD} -f '${OPENOCD_CONFIG}' \
|
||||
${SETSID} sh -c "${OPENOCD} \
|
||||
${OPENOCD_ADAPTER_INIT} \
|
||||
-f '${OPENOCD_CONFIG}' \
|
||||
${OPENOCD_EXTRA_INIT} \
|
||||
-c 'tcl_port ${TCL_PORT}' \
|
||||
-c 'telnet_port ${TELNET_PORT}' \
|
||||
@ -211,7 +219,9 @@ do_debug() {
|
||||
do_debugserver() {
|
||||
test_config
|
||||
# start OpenOCD as GDB server
|
||||
sh -c "${OPENOCD} -f '${OPENOCD_CONFIG}' \
|
||||
sh -c "${OPENOCD} \
|
||||
${OPENOCD_ADAPTER_INIT} \
|
||||
-f '${OPENOCD_CONFIG}' \
|
||||
${OPENOCD_EXTRA_INIT} \
|
||||
-c 'tcl_port ${TCL_PORT}' \
|
||||
-c 'telnet_port ${TELNET_PORT}' \
|
||||
@ -224,7 +234,9 @@ do_debugserver() {
|
||||
do_reset() {
|
||||
test_config
|
||||
# start OpenOCD and invoke board reset
|
||||
sh -c "${OPENOCD} -f '${OPENOCD_CONFIG}' \
|
||||
sh -c "${OPENOCD} \
|
||||
${OPENOCD_ADAPTER_INIT} \
|
||||
-f '${OPENOCD_CONFIG}' \
|
||||
${OPENOCD_EXTRA_INIT} \
|
||||
-c 'tcl_port 0' \
|
||||
-c 'telnet_port 0' \
|
||||
|
2
makefiles/tools/openocd-adapters/README.md
Normal file
2
makefiles/tools/openocd-adapters/README.md
Normal file
@ -0,0 +1,2 @@
|
||||
This directory contains definitions of debugger hardware interfaces to be used
|
||||
by the OpenOCD integration.
|
7
makefiles/tools/openocd-adapters/dap.inc.mk
Normal file
7
makefiles/tools/openocd-adapters/dap.inc.mk
Normal file
@ -0,0 +1,7 @@
|
||||
# CMSIS DAP debug adapter
|
||||
OPENOCD_ADAPTER_INIT ?= -c 'source [find interface/cmsis-dap.cfg]'
|
||||
# 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)'
|
||||
endif
|
||||
export OPENOCD_ADAPTER_INIT
|
7
makefiles/tools/openocd-adapters/jlink.inc.mk
Normal file
7
makefiles/tools/openocd-adapters/jlink.inc.mk
Normal file
@ -0,0 +1,7 @@
|
||||
# Segger J-Link debug adapter
|
||||
OPENOCD_ADAPTER_INIT ?= -c 'source [find interface/jlink.cfg]'
|
||||
# Add serial matching command, only if DEBUG_ADAPTER_ID was specified
|
||||
ifneq (,$(DEBUG_ADAPTER_ID))
|
||||
OPENOCD_ADAPTER_INIT += -c 'jlink serial $(DEBUG_ADAPTER_ID)'
|
||||
endif
|
||||
export OPENOCD_ADAPTER_INIT
|
33
makefiles/tools/openocd-adapters/mulle.inc.mk
Normal file
33
makefiles/tools/openocd-adapters/mulle.inc.mk
Normal file
@ -0,0 +1,33 @@
|
||||
# OpenOCD settings for Mulle programmer board.
|
||||
# Try to determine which OpenOCD config file we should use based on the
|
||||
# programmer board serial number.
|
||||
|
||||
# Fall back to PROGRAMMER_SERIAL for backwards compatibility
|
||||
export DEBUG_ADAPTER_ID ?= $(PROGRAMMER_SERIAL)
|
||||
|
||||
ifneq (,$(DEBUG_ADAPTER_ID))
|
||||
# Makefile-way of comparing numbers, using lexicographical sorting since we
|
||||
# don't have any arithmetic comparisons.
|
||||
# Programmers with serial 100 -- 148 are version 0.60
|
||||
# Programmers with serial 301 -- 330 are version 0.70
|
||||
ifeq "100" "$(word 1, $(sort 100 $(DEBUG_ADAPTER_ID)))"
|
||||
# >= 100
|
||||
ifneq "149" "$(word 1, $(sort 149 $(DEBUG_ADAPTER_ID)))"
|
||||
# < 149
|
||||
PROGRAMMER_VERSION = 0.60
|
||||
else
|
||||
# >= 149
|
||||
PROGRAMMER_VERSION = 0.70
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
# Default to version 0.70 programmer
|
||||
PROGRAMMER_VERSION ?= 0.70
|
||||
|
||||
OPENOCD_ADAPTER_INIT ?= -f '$(RIOTBASE)/boards/mulle/dist/openocd/mulle-programmer-$(PROGRAMMER_VERSION).cfg'
|
||||
|
||||
# Add serial matching command, only if DEBUG_ADAPTER_ID was specified
|
||||
ifneq (,$(DEBUG_ADAPTER_ID))
|
||||
OPENOCD_ADAPTER_INIT += -c 'ftdi_serial $(DEBUG_ADAPTER_ID)'
|
||||
endif
|
||||
export OPENOCD_ADAPTER_INIT
|
10
makefiles/tools/openocd-adapters/stlink.inc.mk
Normal file
10
makefiles/tools/openocd-adapters/stlink.inc.mk
Normal file
@ -0,0 +1,10 @@
|
||||
# ST-Link debug adapter
|
||||
# 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'
|
||||
# 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
|
||||
export OPENOCD_ADAPTER_INIT
|
@ -8,3 +8,7 @@ export FFLAGS ?= flash
|
||||
export DEBUGGER_FLAGS ?= debug
|
||||
export DEBUGSERVER_FLAGS ?= debug-server
|
||||
export RESET_FLAGS ?= reset
|
||||
|
||||
ifneq (,$(DEBUG_ADAPTER))
|
||||
include $(RIOTMAKE)/tools/openocd-adapters/$(DEBUG_ADAPTER).inc.mk
|
||||
endif
|
||||
|
Loading…
Reference in New Issue
Block a user