Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cpu/nRF52: Always recover Device before Flashing #20970

Merged
merged 2 commits into from
Nov 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
mguetschow marked this conversation as resolved.
Show resolved Hide resolved
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 @@ -98,23 +98,23 @@
# Default OpenOCD command
: ${OPENOCD:=openocd}
# Extra board initialization commands to pass to OpenOCD
: ${OPENOCD_EXTRA_INIT:=}

Check warning on line 101 in dist/tools/openocd/openocd.sh

View workflow job for this annotation

GitHub Actions / static-tests

This default assignment may cause DoS due to globbing. Quote it. [SC2223]
# Debugger interface initialization commands to pass to OpenOCD
: ${OPENOCD_ADAPTER_INIT:=}

Check warning on line 103 in dist/tools/openocd/openocd.sh

View workflow job for this annotation

GitHub Actions / static-tests

This default assignment may cause DoS due to globbing. Quote it. [SC2223]
# If set to 1 'reset_config' will use 'connect_assert_srst' before 'flash' or 'reset.
: ${OPENOCD_RESET_USE_CONNECT_ASSERT_SRST:=}

Check warning on line 105 in dist/tools/openocd/openocd.sh

View workflow job for this annotation

GitHub Actions / static-tests

This default assignment may cause DoS due to globbing. Quote it. [SC2223]
# Default bind address for OpenOCD
: ${OPENOCD_SERVER_ADDRESS:=localhost}

Check warning on line 107 in dist/tools/openocd/openocd.sh

View workflow job for this annotation

GitHub Actions / static-tests

This default assignment may cause DoS due to globbing. Quote it. [SC2223]
# The setsid command is needed so that Ctrl+C in GDB doesn't kill OpenOCD
: ${SETSID:=setsid}

Check warning on line 109 in dist/tools/openocd/openocd.sh

View workflow job for this annotation

GitHub Actions / static-tests

This default assignment may cause DoS due to globbing. Quote it. [SC2223]
# GDB command, usually a separate command for each platform (e.g. arm-none-eabi-gdb)
: ${GDB:=gdb}

Check warning on line 111 in dist/tools/openocd/openocd.sh

View workflow job for this annotation

GitHub Actions / static-tests

This default assignment may cause DoS due to globbing. Quote it. [SC2223]
# Debugger client command, can be used to wrap GDB in a front-end
: ${DBG:=${GDB}}

Check warning on line 113 in dist/tools/openocd/openocd.sh

View workflow job for this annotation

GitHub Actions / static-tests

This default assignment may cause DoS due to globbing. Quote it. [SC2223]
# Default debugger flags,
: ${DBG_DEFAULT_FLAGS:=-q -ex \"tar ext ${OPENOCD_SERVER_ADDRESS}:$(( GDB_PORT + GDB_PORT_CORE_OFFSET ))\"}

Check warning on line 115 in dist/tools/openocd/openocd.sh

View workflow job for this annotation

GitHub Actions / static-tests

Quotes/backslashes will be treated literally. Use an array. [SC2089]

Check warning on line 115 in dist/tools/openocd/openocd.sh

View workflow job for this annotation

GitHub Actions / static-tests

This default assignment may cause DoS due to globbing. Quote it. [SC2223]
# Extra debugger flags, added by the user
: ${DBG_EXTRA_FLAGS:=}

Check warning on line 117 in dist/tools/openocd/openocd.sh

View workflow job for this annotation

GitHub Actions / static-tests

This default assignment may cause DoS due to globbing. Quote it. [SC2223]
# 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}}
Expand Down Expand Up @@ -346,6 +346,7 @@
-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
Loading