@oliof I have no document for the public, but for internal use only and it's still not very advanced, but it works for our configuration and purpose. Some settings are dependant of which type of SBC you are using - in our case a CM4 module on an IO board - and which GPIO pins are free on the SBC. The SWD pins SWDIO, SWCLK, RESET and GND need to be connected to the SBC, and the GPIOs need to be configured as output in /boot/config.txt.
This is the sequence of commands I use for flashing the firmware via the SWD interface (GPIO18 is connected to RESET in our case):
raspi-gpio set 18 dl
openocd -f ocd.cfg -c "init; halt; flash protect 0 0 last off"
openocd -f ocd.cfg -c "init; halt; flash write_image erase Duet3Firmware_MB6HC.bin 0x00400000"
openocd -f ocd.cfg -c "init; halt; reset run"
raspi-gpio set 18 dh
Executing an openocd command holds the connection and need to be terminated with CTRL+C after it has done its task. I still did not find a way to do this all in one line.
content of ocd.cfg:
adapter driver bcm2835gpio
bcm2835gpio peripheral_base 0xFE000000
bcm2835gpio speed_coeffs 236181 60
adapter gpio swclk 23
adapter gpio swdio 24
adapter gpio srst 18
transport select swd
set CHIPNAME atsame70q20
source [find target/atsamv.cfg]
reset_config srst_only srst_push_pull
adapter speed 1000
peripheral_base and speed_coeffs are dependant of which SBC you have