Page tree
Skip to end of metadata
Go to start of metadata

First, start a GDB client and pass the path to the ELF as a command line argument. For example:

arm-none-eabi-gdb firmware.elf

Then, execute the following in the GDB's internal command line:

tar ext /dev/ttyACM0    # Or another port
mon swdp_scan
attach 1
load

You can use the following script to automate the process:

#!/bin/bash

PORT="$1"
elf="$2"

arm-none-eabi-size $elf || exit 1

tmpfile=.blackmagic_gdb.tmp
cat > $tmpfile <<EOF
target extended-remote $PORT
mon swdp_scan
attach 1
load
kill
EOF

arm-none-eabi-gdb $elf --batch -x $tmpfile

rm -f $tmpfile

Invoke it as follows:

upload.sh /dev/ttyACM0 firmware.elf