Flashing works.

This commit is contained in:
Pbopbo
2026-04-09 12:16:42 +02:00
parent 83c986e0a9
commit 19a0d38ae2
5 changed files with 13142 additions and 88 deletions

View File

@@ -1,98 +1,40 @@
#!/bin/bash
set -e
# flash.sh — Flash nRF54 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"
echo "Usage: $0 -f <hex_file> [-i swd0|swd1]"
exit 1
}
# Parse arguments
while getopts "f:i:h" opt; do
case "$opt" in
f)
HEX_FILE="$OPTARG"
;;
f) HEX_FILE="$OPTARG" ;;
i)
if [[ "$OPTARG" == "swd0" || "$OPTARG" == "swd1" ]]; then
INTERFACE="$OPTARG"
else
echo "Invalid interface: $OPTARG"
usage
fi
;;
h)
usage
;;
*)
usage
;;
h) usage ;;
*) usage ;;
esac
done
# Verify HEX file is provided
if [[ -z "$HEX_FILE" ]]; then
echo "Error: HEX file not specified."
usage
fi
[[ -n "$HEX_FILE" ]] || usage
[[ -f "$HEX_FILE" ]] || { echo "HEX file not found: $HEX_FILE"; exit 1; }
# 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/nordic/nrf54l.cfg \
-c "init" \
-c "reset halt" \
-c "flash write_image erase $HEX_FILE" \
-c "reset init" \
-c "flash banks" \
-c "flash write_image $HEX_FILE" \
-c "verify_image $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/nordic/nrf54l.cfg \
-c "init" \
-c "reset halt" \
-c "flash write_image erase $HEX_FILE" \
-c "reset run" \
-c "shutdown"
echo "✅ Flashing complete."
echo "Flashing complete."

13111
merged.hex Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -5,4 +5,9 @@ adapter gpio swdio 26
#adapter gpio trst 26
#reset_config trst_only
source [find target/nordic/nrf54l.cfg]
flash bank $_CHIPNAME.flash nrf54 0x00000000 0 0 0 $_TARGETNAME
adapter speed 1000

View File

@@ -5,4 +5,9 @@ adapter gpio swdio 24
#adapter gpio trst 27
#reset_config trst_only
source [find target/nordic/nrf54l.cfg]
flash bank $_CHIPNAME.flash nrf54 0x00000000 0 0 0 $_TARGETNAME
adapter speed 1000

View File

@@ -1,20 +1,6 @@
# erase
bash erase_all.sh -i swd0
# flash
bash flash.sh -i swd0 -f blinky_nrf52dongl_no_bootloader.hex
# hex
number in hexfile is uart baud rate
- blinky_nrf52dongle_no_bootloader.hex is blinky without a bootloader
- blinky_nrf52dongle_gpio_uart.hex is blinky with uart terminal on P0.13 and P0.15
- blinky_nrf52_rtscts_115200.hex blinky with uart terminal with flow control
- blinky_nrf52_rtscts_1M.hex blinky with uart terminal with flow control
# connect with minicom
- minicom -D /dev/ttyAMA2 -b 1000000 -s
# build openocd on cm4:
```
sudo apt update
sudo apt upgrade -y
sudo apt install git build-essential libtool autoconf texinfo libusb-1.0-0-dev libftdi1-dev libhidapi-dev pkg-config -y
@@ -23,10 +9,15 @@ sudo apt-get install pkg-config libjim-dev -y
git clone https://github.com/openocd-org/openocd.git
cd openocd
git fetch https://review.openocd.org/openocd refs/changes/18/8818/10 && git checkout -b change-8818 FETCH_HEAD
./bootstrap
./configure --enable-bcm2835gpio --enable-sysfsgpio
make
sudo make install
```
# test read/write nrf54l15 - does not work yet
sudo openocd -f ./raspberrypi-swd0.cfg -f target/nordic/nrf54l.cfg -c "init" -c "reset halt" -c "mdb 0x00000000 2" -c "shutdown"
# Flash the radios
bash flash.sh -i swd0 -f merged.hex
bash flash.sh -i swd1 -f merged.hex