Skip to content

Commit

Permalink
Merge pull request #20970 from crasbe/pr/nRF_OpenOCD
Browse files Browse the repository at this point in the history
cpu/nRF52: Always recover Device before Flashing
  • Loading branch information
mguetschow authored Nov 11, 2024
2 parents 5d76abf + 168829f commit d86738f
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
10 changes: 7 additions & 3 deletions boards/common/nrf52/Makefile.include
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,12 @@ else
PROGRAMMER ?= openocd
endif

# setup OpenOCD for flashing. Version 0.10 of OpenOCD doesn't contain support
# for nrf52dk and nrf52840dk boards. To use OpenOCD with these a version
# build from source (master > 2018, August the 13rd) is required.
# Setup OpenOCD for flashing. The nRF52 series is supported from OpenOCD v0.11
# onwards.
OPENOCD_DEBUG_ADAPTER ?= jlink
OPENOCD_CONFIG = $(RIOTBOARD)/common/nrf52/dist/openocd.cfg

# From Build Code Fxx and later, the nRF52 device is automatically locked after
# a power cycle and has to be recovered with a separate command after the
# initialization. Otherwise the Flash can not be accessed.
OPENOCD_POST_INIT_CMDS = -c 'nrf52_recover'
1 change: 1 addition & 0 deletions dist/tools/openocd/openocd.sh
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,7 @@ do_flash() {
-c 'telnet_port 0' \
-c 'gdb_port 0' \
-c 'init' \
${OPENOCD_POST_INIT_CMDS} \
-c 'targets' \
${OPENOCD_CMD_RESET_HALT} \
${OPENOCD_PRE_FLASH_CMDS} \
Expand Down
11 changes: 11 additions & 0 deletions makefiles/tools/openocd.inc.mk
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@ $(call target-export-variables,$(OPENOCD_TARGETS),OPENOCD_CORE)
# Export OPENOCD_ADAPTER_INIT to required targets
$(call target-export-variables,$(OPENOCD_TARGETS),OPENOCD_ADAPTER_INIT)

# Export OPENOCD_EXTRA_INIT to required targets
$(call target-export-variables,$(OPENOCD_TARGETS),OPENOCD_EXTRA_INIT)

# Export OPENOCD_EXTRA_RESET_INIT to required targets
$(call target-export-variables,$(OPENOCD_TARGETS),OPENOCD_EXTRA_RESET_INIT)

# Export OPENOCD_RESET_USE_CONNECT_ASSERT_SRST to required targets
$(call target-export-variables,$(OPENOCD_TARGETS),OPENOCD_RESET_USE_CONNECT_ASSERT_SRST)

Expand Down Expand Up @@ -67,6 +73,11 @@ ifneq (,$(IMAGE_OFFSET))
$(call target-export-variables,$(OPENOCD_FLASH_TARGETS),IMAGE_OFFSET)
endif

ifneq (,$(OPENOCD_POST_INIT_CMDS))
# Export OPENOCD_POST_INIT_CMDS only to the flash/flash-only target
$(call target-export-variables,$(OPENOCD_FLASH_TARGETS),OPENOCD_POST_INIT_CMDS)
endif

ifneq (,$(OPENOCD_PRE_VERIFY_CMDS))
# Export OPENOCD_PRE_VERIFY_CMDS only to the flash/flash-only target
$(call target-export-variables,$(OPENOCD_FLASH_TARGETS),OPENOCD_PRE_VERIFY_CMDS)
Expand Down

0 comments on commit d86738f

Please sign in to comment.