add swd reset script

This commit is contained in:
pstruebi
2025-09-29 13:31:51 +02:00
parent fd592b0db2
commit 00dd530f9d

49
reset_nrf54l.sh Normal file
View File

@@ -0,0 +1,49 @@
#!/bin/bash
# reset_nrf54l.sh — Reset nRF54L targets via OpenOCD using Raspberry Pi SWD
set -euo pipefail # Strict mode: exit on error, undefined vars, and pipe failures
# Print a helpful message on any error, preserving the failing exit code
trap 'rc=$?; echo "❌ nRF54L reset failed (exit $rc)." >&2; exit $rc' ERR
# Default values
INTERFACE="swd0"
usage() {
echo "Usage: $0 [-i swd0|swd1] [-h]"
echo
echo "Options:"
echo " -i <interface> SWD interface to use: swd0 (default) or swd1"
echo " -h Show this help message and exit"
exit 1
}
# Parse arguments
while getopts "i:h" opt; do
case "$opt" in
i)
INTERFACE="$OPTARG"
;;
h)
usage
;;
*)
usage
;;
esac
done
# Run OpenOCD reset command
sudo openocd \
-f ./raspberrypi-${INTERFACE}.cfg \
-f target/nordic/nrf54l.cfg \
-c "init" \
-c "reset run" \
-c "shutdown"
echo "✅ nRF54L reset issued on ${INTERFACE}."
# Success
exit 0
a