add openocd interface config for nrf52
This commit is contained in:
2463
blinky_nrf52dongl_no_bootloader.hex
Normal file
2463
blinky_nrf52dongl_no_bootloader.hex
Normal file
File diff suppressed because it is too large
Load Diff
39
erase_all.sh
Normal file
39
erase_all.sh
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# erase_all.sh — Erase entire Flash on nRF52 via OpenOCD
|
||||||
|
|
||||||
|
set -e # Exit on error
|
||||||
|
|
||||||
|
# Default interface is swd0
|
||||||
|
INTERFACE="swd0"
|
||||||
|
|
||||||
|
# Parse command line argument for SWD interface
|
||||||
|
while getopts "i:" opt; do
|
||||||
|
case "$opt" in
|
||||||
|
i)
|
||||||
|
if [[ "$OPTARG" == "swd0" || "$OPTARG" == "swd1" ]]; then
|
||||||
|
INTERFACE="$OPTARG"
|
||||||
|
else
|
||||||
|
echo "Invalid interface: $OPTARG"
|
||||||
|
echo "Usage: $0 [-i swd0|swd1]"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "Usage: $0 [-i swd0|swd1]"
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
# Run OpenOCD command for full chip erase
|
||||||
|
sudo openocd \
|
||||||
|
-f ./raspberrypi-${INTERFACE}.cfg \
|
||||||
|
-f target/nrf52.cfg \
|
||||||
|
-c "init" \
|
||||||
|
-c "nrf52_recover" \
|
||||||
|
-c "reset halt" \
|
||||||
|
-c "nrf5 mass_erase" \
|
||||||
|
-c "shutdown"
|
||||||
|
|
||||||
|
echo "✅ Device erase complete."
|
||||||
98
flash.sh
Normal file
98
flash.sh
Normal file
@@ -0,0 +1,98 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# flash.sh — Flash nRF52 Dongle using OpenOCD via Raspberry Pi SWD
|
||||||
|
|
||||||
|
set -e # Exit on error
|
||||||
|
|
||||||
|
# Default values
|
||||||
|
INTERFACE="swd0"
|
||||||
|
HEX_FILE=""
|
||||||
|
|
||||||
|
# Help message
|
||||||
|
usage() {
|
||||||
|
echo "Usage: $0 -f <hex_file> [-i swd0|swd1] [-h]"
|
||||||
|
echo
|
||||||
|
echo "Options:"
|
||||||
|
echo " -f <hex_file> Path to the HEX file to flash (required)"
|
||||||
|
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 "f:i:h" opt; do
|
||||||
|
case "$opt" in
|
||||||
|
f)
|
||||||
|
HEX_FILE="$OPTARG"
|
||||||
|
;;
|
||||||
|
i)
|
||||||
|
if [[ "$OPTARG" == "swd0" || "$OPTARG" == "swd1" ]]; then
|
||||||
|
INTERFACE="$OPTARG"
|
||||||
|
else
|
||||||
|
echo "Invalid interface: $OPTARG"
|
||||||
|
usage
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
h)
|
||||||
|
usage
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
usage
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
# Verify HEX file is provided
|
||||||
|
if [[ -z "$HEX_FILE" ]]; then
|
||||||
|
echo "Error: HEX file not specified."
|
||||||
|
usage
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Check if HEX file exists
|
||||||
|
if [[ ! -f "$HEX_FILE" ]]; then
|
||||||
|
echo "Error: HEX file '$HEX_FILE' not found!"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Run OpenOCD flashing command
|
||||||
|
sudo openocd \
|
||||||
|
-f ./raspberrypi-${INTERFACE}.cfg \
|
||||||
|
-f target/nrf52.cfg \
|
||||||
|
-c "init" \
|
||||||
|
-c "reset halt" \
|
||||||
|
-c "flash write_image erase $HEX_FILE" \
|
||||||
|
-c "reset run" \
|
||||||
|
-c "shutdown"
|
||||||
|
|
||||||
|
echo "✅ Flashing complete."
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
i)
|
||||||
|
if [[ "$OPTARG" == "swd0" || "$OPTARG" == "swd1" ]]; then
|
||||||
|
INTERFACE="$OPTARG"
|
||||||
|
else
|
||||||
|
echo "Invalid interface: $OPTARG"
|
||||||
|
usage
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
h)
|
||||||
|
usage
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
usage
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
|
||||||
|
# Run OpenOCD flashing command
|
||||||
|
sudo openocd \
|
||||||
|
-f ./raspberrypi-${INTERFACE}.cfg \
|
||||||
|
-f target/nrf52.cfg \
|
||||||
|
-c "init" \
|
||||||
|
-c "reset halt" \
|
||||||
|
-c "flash write_image erase $HEX_FILE" \
|
||||||
|
-c "reset run" \
|
||||||
|
-c "shutdown"
|
||||||
|
|
||||||
|
echo "✅ Flashing complete."
|
||||||
8
raspberrypi-swd0.cfg
Normal file
8
raspberrypi-swd0.cfg
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
adapter driver bcm2835gpio
|
||||||
|
transport select swd
|
||||||
|
adapter gpio swclk 17
|
||||||
|
adapter gpio swdio 18
|
||||||
|
#adapter gpio trst 26
|
||||||
|
#reset_config trst_only
|
||||||
|
|
||||||
|
adapter speed 1000
|
||||||
8
raspberrypi-swd1.cfg
Normal file
8
raspberrypi-swd1.cfg
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
adapter driver bcm2835gpio
|
||||||
|
transport select swd
|
||||||
|
adapter gpio swclk 24
|
||||||
|
adapter gpio swdio 23
|
||||||
|
#adapter gpio trst 27
|
||||||
|
#reset_config trst_only
|
||||||
|
|
||||||
|
adapter speed 1000
|
||||||
Reference in New Issue
Block a user