Skip to content

Commit

Permalink
tools/pyocd: add option for image offset
Browse files Browse the repository at this point in the history
  • Loading branch information
aabadie committed Mar 24, 2019
1 parent e830462 commit e2a162b
Showing 1 changed file with 12 additions and 1 deletion.
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 e2a162b

Please sign in to comment.