Flashing the Due with an ST-Link using openocd

I'm trying to upload a program written in Rust to the Arduino Due.
I successfully uploaded my program using the bossa tool, which uses the USB-programming port. This is slow tedious unreliable and there's no option to debug your program.

This is why I'd like to use the JTAG/SWD connector. I have an ST-Link V3 as probe but I cannot find a way to successfully download the program to the SAM3X8E.

This is the openocd.cnf I'm using:

source [find /interface/stlink-v2-1.cfg]

#transport type SWD
transport select hla_swd

#swd frequency
adapter_khz 1800

#sam3x8e cpuid
set CPUTAPID 0x2ba01477

source [find target/at91sam3XXX.cfg]

This is the error I'm getting:

Info : 211 12 core.c:1386 adapter_init(): clock speed 480 kHz
Debug: 212 12 openocd.c:140 handle_init_command(): Debug Adapter init complete
Debug: 213 12 command.c:143 script_debug(): command - ocd_command ocd_command type ocd_transport init
Debug: 214 12 command.c:143 script_debug(): command - ocd_transport ocd_transport init
Debug: 216 12 transport.c:239 handle_transport_init(): handle_transport_init
Debug: 217 12 hla_transport.c:152 hl_transport_init(): hl_transport_init
Debug: 218 12 hla_transport.c:169 hl_transport_init(): current transport hla_swd
Debug: 219 12 hla_interface.c:42 hl_interface_open(): hl_interface_open
Debug: 220 12 hla_layout.c:40 hl_layout_open(): hl_layout_open
Debug: 221 12 stlink_usb.c:1642 stlink_usb_open(): stlink_usb_open
Debug: 222 12 stlink_usb.c:1659 stlink_usb_open(): transport: 1 vid: 0x0483 pid: 0x374b serial: 
Error: 223 27 stlink_usb.c:1672 stlink_usb_open(): open failed
Debug: 224 27 hla_layout.c:47 hl_layout_open(): failed
Debug: 225 27 command.c:626 run_command(): Command failed with error code -4
User : 226 27 command.c:687 command_run_line(): in procedure 'init' 
in procedure 'ocd_bouncer'
Debug: 227 27 command.c:626 run_command(): Command failed with error code -4
User : 228 27 command.c:687 command_run_line(): 
Debug: 229 27 hla_interface.c:117 hl_interface_quit(): hl_interface_quit

Using cargo-flash it seems to successfully switch to SWD but then it quits with an "JtagNoDeviceConnected".

Does anyone have experience in this area?

Thanks, but this obviously is using the samba protocol which I'm trying to avoid because of the aforementioned problems.

OK

Did you try uploading your code thru the Native USB port (much faster) ?

No, does that require a special boot-loader? Can I use debugging then (gdb)? Which program can I use to perform the uploading? openocd?

I only use the Arduino IDE. Select Arduino DUE(Native USB port), select the correct Com port and that’s it.

This thread is about NOT using the IDE.

I finally made this work using an STLink V2. The V3 seems to be more picky about non-STM targets.
More details here: https://forum.arduino.cc/index.php?topic=653892.0