OpenOCD: enabling SWD on STLINK-V3

I am starting with a simple STM32 board that has only SWD (i.e., SWDIO, SWCLK, SWO, and NRST) and 3V power supply. (Yes, I have double-checked the connections of all of the above pins, both on the schematic, and with a continuity tester on the actual soldered board. But I don't think the configuration issue I'm running into has anything to do with these connections).

I compiled openocd with --enable-stlink and set up USB udev rules. When I run it, it makes the lights on my STLINK-V3 blink. Target current briefly drops from 13mA to 0mA, so maybe reset is working.

However, it appears that the SWD (or even reading target voltage) is not working. I tried various transport select; here is my openocd.cfg:

# Should work with all STM32L4 Nucleo Dev Boards.
# http://www.st.com/en/evaluation-tools/stm32-mcu-nucleo.html

source [find interface/stlink.cfg]

#transport select hla_swd
# This causes JTAG access, not SWD access

transport select dapdirect_swd
# This SHOULD be the right setting, per the docs:
#     http://openocd.org/doc/html/Debug-Adapter-Configuration.html
# But causes "Error: Debug adapter doesn't support 'dapdirect_swd' transport"

source [find target/stm32l4x.cfg]

# use hardware reset
reset_config srst_only srst_nogate


How do I enable STLINK-V3 SWD?

Update I looked in the MCU manual again, and noticed that entering SWD mode actually involves a JTAG sequence on the SWD pins. So maybe hla_swd is actually trying to do the right thing. I might see if an EVB is offered that would rule out board issues.

The specific error I get with openocd -d3 and hla_swd in the config file is:

Debug: 252 12 stlink_usb.c:515 jtag_libusb_bulk_transfer_n(): ERROR, transfer 0 failed, error -9
Debug: 253 12 stlink_usb.c:515 jtag_libusb_bulk_transfer_n(): ERROR, transfer 1 failed, error -9
Debug: 254 1560 stlink_usb.c:515 jtag_libusb_bulk_transfer_n(): ERROR, transfer 0 failed, error -9
Debug: 255 1560 stlink_usb.c:515 jtag_libusb_bulk_transfer_n(): ERROR, transfer 1 failed, error -9
Error: 256 1560 stlink_usb.c:2882 stlink_usb_open(): read version failed


I see the reset pin toggling; I'm not sure about SWDIO/SWCLK (I should get a better scope). I don't understand why it's trying to do a bulk transfer without even reporting the target voltage first.

• Which board? Which STM32? Have you connected MCU 3.3V to ST-Link Vref? – Justme Jun 19 at 20:26
• @Justme It is a trivial custom board with STM32L431CCT6. I am using the STDC14 connector on the STLINK-V3MINI. The Vref pin is called T_VCC (pin 3) and yes of course I have connected it to the MCU 3.3V. OpenOCD isn't getting as far as reporting a voltage (or lack thereof) so there is a more basic software configuration issue. – personal_cloud Jun 19 at 20:52
• So it does not work at all, or just does not work under Linux? Does it work with CubeProg? – Justme Jun 19 at 21:09
• @justme. So far, I am getting furthest with OpenOCD. At least it can blink the LEDs on the STLINK-V3MINI. CubeProg gives me DEV_USB_COMM_ERR. Windows 10 gives me driver headaches. – personal_cloud Jun 19 at 22:23
• You might want to complain to ST about that on the ST forums when their products do not work and ask help there. Lately, I've had zero issues using ST-Link/V2 on any Windows 7, Windows 10, or Linux system I have tried. However I don't have ST-Link/V3 so I can't comment on that. – Justme Jun 19 at 22:29