1
\$\begingroup\$

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.

\$\endgroup\$
10
  • \$\begingroup\$ Which board? Which STM32? Have you connected MCU 3.3V to ST-Link Vref? \$\endgroup\$
    – Justme
    Commented Jun 19, 2020 at 20:26
  • \$\begingroup\$ @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. \$\endgroup\$ Commented Jun 19, 2020 at 20:52
  • \$\begingroup\$ So it does not work at all, or just does not work under Linux? Does it work with CubeProg? \$\endgroup\$
    – Justme
    Commented Jun 19, 2020 at 21:09
  • \$\begingroup\$ @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. \$\endgroup\$ Commented Jun 19, 2020 at 22:23
  • \$\begingroup\$ 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. \$\endgroup\$
    – Justme
    Commented Jun 19, 2020 at 22:29

1 Answer 1

2
\$\begingroup\$

Have you tried with the ST fork of openocd? They claim "STMicroelectronics is actively working at merging these modifications in the official OpenOCD". As of today, from my experience, you have to use the ST openocd if you need compatibility with stlink v3.

I am using ST openocd with stm32wl55. I used STM32CubeIDE to generate a valid openocd config for the F4 and for the L0 (STM32CubeIDE comes with openocd and openocd support).

openocd can run on top of stlink-server, if you need shared access:

st-link interface server

or run without stlink-server with exclusive access to the hardware:

st-link interface usb
\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.