Skip to content

Commit

Permalink
Merge pull request #11253 from aabadie/pr/tools_pyocd_offset
Browse files Browse the repository at this point in the history
tools/pyocd: add option for image offset
  • Loading branch information
aabadie authored Mar 24, 2019
2 parents 6bbd3a5 + e2a162b commit 930dd0a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
2 changes: 1 addition & 1 deletion boards/nrf52840-mdk/Makefile.include
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ PROGRAMMER ?= pyocd
ifeq (pyocd,$(PROGRAMMER))
# The board is not recognized automatically by pyocd, so the CPU target
# option is passed explicitly
export FLASH_TARGET_TYPE ?= -t $(CPU)
export FLASH_TARGET_TYPE ?= -t nrf52840
include $(RIOTMAKE)/tools/pyocd.inc.mk
else ifeq (openocd,$(PROGRAMMER))
DEBUG_ADAPTER = dap
Expand Down
13 changes: 12 additions & 1 deletion dist/tools/pyocd/pyocd.sh
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,12 @@
# CPU Target type.
# Use `-t` followed by value. Example: -t nrf51
: ${FLASH_TARGET_TYPE:=}
# 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.
# Default offset is 0, meaning the image will be flashed at the address that it
# was linked at.
: ${IMAGE_OFFSET:=0}

#
# Examples of alternative debugger configurations
Expand Down Expand Up @@ -112,8 +118,13 @@ test_hexfile() {
do_flash() {
HEX_FILE=$1
test_hexfile

if [ "${IMAGE_OFFSET}" != "0" ]; then
echo "Flashing with IMAGE_OFFSET: ${IMAGE_OFFSET}"
fi

# flash device
sh -c "${PYOCD_FLASH} ${FLASH_TARGET_TYPE} \"${HEX_FILE}\"" &&
sh -c "${PYOCD_FLASH} ${FLASH_TARGET_TYPE} -a ${IMAGE_OFFSET} \"${HEX_FILE}\"" &&
echo 'Done flashing'
}

Expand Down

0 comments on commit 930dd0a

Please sign in to comment.