1

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.

personal_cloud
  • 317
  • 4
  • 11
  • Which board? Which STM32? Have you connected MCU 3.3V to ST-Link Vref? – Justme Jun 19 '20 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 '20 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 '20 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](https://electronics.stackexchange.com/questions/506476/stlink-v3-windows-setup). – personal_cloud Jun 19 '20 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 '20 at 22:29
  • ST-Link is a high level adapter, it probably wouldn't support a "dapdirect" command. Have a look in target/swj-dp.tcl and note how hla is special cased – Chris Stratton Jun 20 '20 at 00:58
  • How other than doing a transfer do you think it would report anything? – Chris Stratton Jun 21 '20 at 02:21
  • In practical terms you have a combination of disadvantages here, on the one hand you are unfamiliar with these open source tools, on the other in using the relatively new STLINK/V3 you are dealing with something the open source community has far less experience with than the V2. If you can find or downgrade to a V2 that might drastically simplify things. – Chris Stratton Jun 21 '20 at 02:32
  • does openocd support the v3 stlink? for the same money you could have a nucleo board with a debugger up front that works great with st and other branded parts. Have you tried other stlnks with this board/part and this stlink with other boards parts? divide the problem in half. – old_timer Jun 21 '20 at 11:07
  • openocde has an stlink-dap.cfg which mgiht be what you are looking for – PlasmaHH Jun 26 '23 at 10:47

1 Answers1

2

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
Hugo Elbzh
  • 21
  • 3