1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

Merge pull request #18526 from chrysn-pull-requests/openocd-rtt

makefiles: Add openocd-rtt
This commit is contained in:
chrysn 2022-08-30 09:44:50 +02:00 committed by GitHub
commit 2c9e853aae
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 55 additions and 1 deletions

View File

@ -859,7 +859,7 @@ termdeps: $(TERMDEPS)
term: $(TERMDEPS)
$(call check_cmd,$(TERMPROG),Terminal program)
$(TERMPROG) $(TERMFLAGS) $(TERMTEE)
${TERMENV} $(TERMPROG) $(TERMFLAGS) $(TERMTEE)
# Term without the pyterm added logging
# PYTERMFLAGS must be exported for `jlink.sh term-rtt`.

View File

@ -71,6 +71,8 @@
#
# reset: triggers a hardware reset of the target board
#
# term-rtt: opens a serial terminal using RTT (Real-Time Transfer)
#
# @author Hauke Peteresen <hauke.petersen@fu-berlin.de>
# @author Joakim Nohlgård <joakim.nohlgard@eistec.se>
@ -126,6 +128,10 @@
# Valid values: elf, hex, s19, bin (see OpenOCD manual for more information)
: ${IMAGE_TYPE:=}
# default terminal frontend
_OPENOCD_TERMPROG=${RIOTTOOLS}/pyterm/pyterm
_OPENOCD_TERMFLAGS="-ts 9999 ${PYTERMFLAGS}"
#
# Examples of alternative debugger configurations
#
@ -445,6 +451,44 @@ do_reset() {
-c 'shutdown'"
}
do_term() {
test_config
# temporary file that save the OpenOCD pid
OPENOCD_PIDFILE=$(mktemp -t "openocd_pid.XXXXXXXXXX")
# will be called by trap
cleanup() {
if [ -f $OPENOCD_PIDFILE ]; then
OPENOCD_PID="$(cat ${OPENOCD_PIDFILE})"
kill ${OPENOCD_PID}
rm -r "${OPENOCD_PIDFILE}"
fi
exit 0
}
# cleanup after script terminates
trap "cleanup ${OPENOCD_PIDFILE}" EXIT INT
set -x
echo test
# start OpenOCD as RTT server for channel 0
sh -x -c "${OPENOCD} \
${OPENOCD_ADAPTER_INIT} \
-f '${OPENOCD_CONFIG}' \
${OPENOCD_EXTRA_INIT} \
-c 'tcl_port 0' \
-c 'telnet_port 0' \
-c 'gdb_port 0' \
-c init \
-c 'rtt setup '${RAM_START_ADDR}' '${RAM_LEN}' \"SEGGER RTT\"' \
-c 'rtt start' \
-c 'rtt server start 9999 0' \
>/dev/null & \
echo \$! > $OPENOCD_PIDFILE" &
sleep 1
${OPENOCD_TERMPROG:-${_OPENOCD_TERMPROG}} ${OPENOCD_TERMFLAGS:-${_OPENOCD_TERMFLAGS}}
}
#
# parameter dispatching
#
@ -481,6 +525,10 @@ case "${ACTION}" in
echo "### Resetting Target ###"
do_reset
;;
term-rtt)
echo "### Starting RTT terminal ###"
do_term
;;
*)
echo "Usage: $0 {flash|debug|debug-server|reset}"
echo " flash <flashfile>"

View File

@ -101,6 +101,7 @@ info-build:
@echo ''
@echo 'TERMPROG: $(TERMPROG)'
@echo 'TERMFLAGS: $(TERMFLAGS)'
@echo 'TERMENV: $(TERMENV)'
@echo 'PORT: $(PORT)'
@echo 'PROG_DEV: $(PROG_DEV)'
@echo ''

View File

@ -47,4 +47,8 @@ else ifeq ($(RIOT_TERMINAL),semihosting)
TERMFLAGS = $(DEBUGGER_FLAGS)
OPENOCD_DBG_EXTRA_CMD += -c 'arm semihosting enable'
$(call target-export-variables,term cleanterm,OPENOCD_DBG_EXTRA_CMD)
else ifeq (${RIOT_TERMINAL},openocd-rtt)
TERMENV = RAM_START_ADDR=${RAM_START_ADDR} RAM_LEN=${RAM_LEN}
TERMPROG = $(RIOTTOOLS)/openocd/openocd.sh
TERMFLAGS = term-rtt
endif

View File

@ -97,6 +97,7 @@ export WPEDANTIC # Issue all (extensive) compiler warnings demanded
export FLASH_ADDR # Define an offset to flash code into ROM memory.
# TERMPROG # The command to call on "make term".
# TERMFLAGS # Additional parameters to supply to TERMPROG.
# TERMENV # Environment variables passed to TERMPROG
# TERMLOG # Optional file to log "make term" output to.
# TERMTEE # Optional pipe to redirect "make term" output. Default: '| tee -a ${TERMLOG}' when TERMLOG is defined else undefined.
# PORT # The port to connect the TERMPROG to.