1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00
RIOT/dist/tools/edbg/edbg.sh
Marian Buschsieweke 485a98bd6e
tools/edbg: fix make reset
Likely a change in the command line interface of EDBG broke the
`make reset` integration. This adds the missing flag.

Note: Since the binary is build on demand with our build system, we
      can in fact rely on every using the same version of EDBG. Hence,
      we don't need to be backwards compatible with the flag.
2023-12-14 09:17:19 +01:00

52 lines
924 B
Bash
Executable File

#!/usr/bin/env bash
# Default edbg command
: "${EDBG:=edbg}"
# Edbg command base arguments
: "${EDBG_ARGS:=}"
test_imagefile() {
if [ ! -f "${IMAGE_FILE}" ]; then
echo "Error: Unable to locate IMAGE_FILE"
echo " (${IMAGE_FILE})"
exit 1
fi
}
do_flash() {
IMAGE_FILE=$1
test_imagefile
# Configure edbg flash flags
local _fflags="${EDBG_ARGS} --verbose --file ${IMAGE_FILE} --verify"
# flash device
sh -c "${EDBG} ${_fflags} || ${EDBG} ${_fflags} --program" && echo 'Done flashing'
}
do_reset() {
sh -c "${EDBG} ${EDBG_ARGS} -x 10"
}
#
# parameter dispatching
#
ACTION="$1"
shift # pop $1 from $@
case "${ACTION}" in
flash)
echo "### Flashing Target ###"
do_flash "$@"
;;
reset)
echo "### Resetting Target ###"
do_reset
;;
*)
echo "Usage: $0 {flash|reset}"
echo " flash <flashfile>"
exit 2
;;
esac