From cbfe502cc64e1fb9cd66666d5ebc4a8e96c80917 Mon Sep 17 00:00:00 2001 From: Erik Ekman Date: Tue, 28 Sep 2021 22:32:18 +0200 Subject: [PATCH] cpu/esp32: Reset when starting debugging To avoid 'Target not examined yet' error --- cpu/esp32/Makefile.include | 2 ++ makefiles/tools/openocd.inc.mk | 9 ++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/cpu/esp32/Makefile.include b/cpu/esp32/Makefile.include index f8dd0b2fcb..229687157f 100644 --- a/cpu/esp32/Makefile.include +++ b/cpu/esp32/Makefile.include @@ -90,4 +90,6 @@ ifneq (,$(filter esp_jtag,$(USEMODULE))) IMAGE_OFFSET = 0x10000 # Flash checksumming not supported on xtensa OPENOCD_SKIP_VERIFY = yes + # Without resets debug target fails with 'Target not examined yet' + OPENOCD_DBG_EXTRA_CMD += -c 'reset halt' endif diff --git a/makefiles/tools/openocd.inc.mk b/makefiles/tools/openocd.inc.mk index 2f23225e03..14c7cc1c60 100644 --- a/makefiles/tools/openocd.inc.mk +++ b/makefiles/tools/openocd.inc.mk @@ -49,7 +49,14 @@ ifneq (,$(OPENOCD_CMD_RESET_RUN)) $(call target-export-variables,reset,OPENOCD_CMD_RESET_RUN) endif -OPENOCD_FLASH_TARGETS = flash flash-only +OPENOCD_DEBUG_TARGETS = debug debugr debug-server + +ifneq (,$(OPENOCD_DBG_EXTRA_CMD)) + # Export OPENOCD_DBG_EXTRA_CMD only to the flash/flash-only target + $(call target-export-variables,$(OPENOCD_DEBUG_TARGETS),OPENOCD_DBG_EXTRA_CMD) +endif + +OPENOCD_FLASH_TARGETS = flash flash-only flashr ifneq (,$(IMAGE_OFFSET)) # Export IMAGE_OFFSET only to the flash/flash-only target