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

If you want to upload a flat binary, it needs to be converted to an ELF first. In order to do that, use this script: https://gist.github.com/pavel-kirienko/6835194423df07f6160af19f7ea33a4d

Now you have your ELF. To upload it, 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