diff --git a/boards/b-l072z-lrwan1/Makefile.include b/boards/b-l072z-lrwan1/Makefile.include index 6ffa293ea0220d7e1e677d95686023c3b7e17b30..6b3cc1daa543a0ea4771072c93db4e3cca2d6371 100644 --- a/boards/b-l072z-lrwan1/Makefile.include +++ b/boards/b-l072z-lrwan1/Makefile.include @@ -12,5 +12,8 @@ include $(RIOTMAKE)/tools/serial.inc.mk export DEBUG_ADAPTER ?= stlink export STLINK_VERSION ?= 2-1 +# call a 'reset halt' command before starting the debugger +export OPENOCD_DBG_START_CMD = -c 'reset halt' + # this board uses openocd include $(RIOTMAKE)/tools/openocd.inc.mk diff --git a/dist/tools/openocd/openocd.sh b/dist/tools/openocd/openocd.sh index 14de9fd164d853d786931afb480e5a8bda07cfe1..6af7165c42c1f1b76bdd5b6c31af0c616449912d 100755 --- a/dist/tools/openocd/openocd.sh +++ b/dist/tools/openocd/openocd.sh @@ -83,6 +83,10 @@ # Debugger flags, will be passed to sh -c, remember to escape any quotation signs. # Use ${DBG_DEFAULT_FLAGS} to insert the default flags anywhere in the string : ${DBG_FLAGS:=${DBG_DEFAULT_FLAGS} ${DBG_EXTRA_FLAGS}} +# Initial target state when using debug, by default a 'halt' request is sent to +# the target when starting a debug session. 'reset halt' can also be used +# depending on the type of target. +: ${OPENOCD_DBG_START_CMD:=-c 'halt'} # This is an optional offset to the base address that can be used to flash an # image in a different location than it is linked at. This feature can be useful # when flashing images for firmware swapping/remapping boot loaders. @@ -201,7 +205,7 @@ do_debug() { -c 'gdb_port ${GDB_PORT}' \ -c 'init' \ -c 'targets' \ - -c 'halt' \ + ${OPENOCD_DBG_START_CMD} \ -l /dev/null & \ echo \$! > $OCD_PIDFILE" & # Export to be able to access these from the sh -c command lines, may be