17
votes

I'm using Launchpad's gcc-arm-none-eabi 4.9-2015q2 to compile for an STM32F0, and now I'd like to debug using arm-none-eabi-gdb from that collection. My ST-Link v2 is part of a Nucleo F411RE board, with external hardware (the STM32F0 target) attached. Flashing the F0 works fine, so I conclude that my SWD connections are good.

Now I want to start OpenOCD, but it fails:

$ openocd -f interface/stlink-v2.cfg -f target/stm32f0x.cfg
Open On-Chip Debugger 0.9.0 (2015-07-26-16:02)
Licensed under GNU GPL v2
For bug reports, read
    http://openocd.org/doc/doxygen/bugs.html
Info : auto-selecting first available session transport "hla_swd". To override use 'transport select <transport>'.
Info : The selected transport took over low-level target control. The results might differ compared to plain JTAG/SWD
adapter speed: 1000 kHz
adapter_nsrst_delay: 100
none separate
Info : Unable to match requested speed 1000 kHz, using 950 kHz
Info : Unable to match requested speed 1000 kHz, using 950 kHz
Info : clock speed 950 kHz
Error: open failed
in procedure 'init'
in procedure 'ocd_bouncer'

What might be wrong here?

I also couldn't establish a connection using st-util, which reported timeouts and in the end always crashed with a segmentation fault.

5
it seems that is a problem with stlink usb connection. first check USB cable, try another USB port, or look into dmesg if you are in linux, for windows maybe it is problem that you don't have drivers from ST.vlk
This question came up as a result on a search for an identical problem with the STM32F4-DISCO board. It seems like at some point, ST switched to using the STLink V2-1 (see @sprhawk's answer) on that board. Noting this for anyone who finds themselves here for that reason.rjp
Setting to software reset worked for me. See link : openstm32.org/forumthread418#threadId5193bot1131357
Had a similar problem: wanted to debug stm32f429 chip with stm32f0discovery and it didn't work with -f board/stm32f0discovery.cfg no matter if I used -f interface/stlink-{v2,v2-1}.cfg but finally just using -f board/stm32f429discovery.cfg and -f interface/stlink-v2.cfg worked. So maybe it depends on the target (here an stm32f429x chip)?mondaugen

5 Answers

16
votes

Nucleo F411RE embedded a stlink v2-1 not stlink v2

so change the script file like this:

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

transport select hla_swd

source [find target/stm32f4x.cfg]

reset_config srst_only
4
votes

The file stlink-v2.cfg might be ok. You probably should use stlink-v2-1.cfg file (inside that file is hla_vid_pid 0x0483 0x3748).

2
votes

In my case I also got Error: open failed but all the configuration was OK. Then I did dmesg | grep usb to see why it cannot connect via USB (on Ubuntu). The dmesg told me that there are power issues and perhaps the cable is faulty. As I had used the same cable earlier the same day and some LEDs still flashed on the board, I first ignored the message. But then I finally decided to try, bought another cable and lo and behold! It was a faulty cable - with the new one everything works. So, not always a software problem after all.

Though if you do lsusb (or use device manager in Windows) and the board is nicely listed, it will probably not be a cable issue. If it is missing, it might be.

1
votes

I found a fix. The VID/PID pair in stlink-v2.cfg was wrong. They had this:

hla_vid_pid 0x0483 0x3748

but it should be this:

hla_vid_pid 0x0483 0x374B

letter "B", not the digit "8".

0
votes

1.in eclipse ide-->project-->inc --> {project_name} debug.cfg ->source [find interface/stlink.cfg]

check your interface debugger whether stlink.cfg or stlink-v2.cfg or stlink-v2-1.cfg and change [find interface/stlink.cfg]

{or}TRY

2.C:\Ac6\SystemWorkbench\plugins\fr.ac6.mcu.debug_2.5.0.201904120827\resources\openocd\st_scripts\interface\stlink.cfg(or stlink-v2.cfg or stlink-v2-1.cfg)

add hla_vid_pid 0