Visual Studio Ide for Arduino
https://www.visualmicro.com/forums/YaBB.pl
Visual Micro >> Usb/Serial/Udp Debugging >> Re: Debug using ST LINK V2
https://www.visualmicro.com/forums/YaBB.pl?num=1578307451

Message started by Kabron on Jan 6th, 2020 at 10:44am

Title: Re: Debug using ST LINK V2
Post by Kabron on Jan 6th, 2020 at 10:44am
Hello, openocd, installed by VM(c:\ProgramData\VMicro\tools\openocd-0.10.0.1) does not see ST-LINK V2 at all. I.e. no any activities on SWCLK/SWDIO pins.
[code]
c:\ProgramData\VMicro\tools>openocd -f interface/stlink-v2.cfg -f board/st_nucleo_f4.cfg
Open On-Chip Debugger 0.10.0
Licensed under GNU GPL v2
For bug reports, read
        http://openocd.org/doc/doxygen/bugs.html
Warn : Interface already configured, ignoring
Error: already specified hl_layout stlink
Info : The selected transport took over low-level target control. The results might differ compared to plain JTAG/SWD
adapter speed: 2000 kHz
adapter_nsrst_delay: 100
none separate
srst_only separate srst_nogate srst_open_drain connect_deassert_srst
Info : Unable to match requested speed 2000 kHz, using 1800 kHz
Info : Unable to match requested speed 2000 kHz, using 1800 kHz
Info : clock speed 1800 kHz
Error: open failed
in procedure 'init'
in procedure 'ocd_bouncer'
[/code]
I found OpenOCD-20191216-0.10.0 from https://gnutoolchains.com/arm-eabi/openocd.
It works fine. I tried to substitute it the c:\ProgramData\VMicro\tools\openocd-0.10.0.1.
But VM discovered the wrong version and re-download it.
What do I need to do to make it work?

Thanks in advance,
Vladimir

Title: Re: Debug using ST LINK V2
Post by Simon Hopkinson on Jan 6th, 2020 at 11:25am
From your output "Error: open failed", it looks like OpenOCD cannot find the STLink device at the USB layer.

Have you updated the driver for the STLink Device using the Zadig tool?

A walk through of the driver element can be seen for a different debugger in this Instructable (and there is a video guide at the bottom too).

It is the same steps but select the "STM32 STLink" device.

Then you should see the output change from running OpenOCD from the Open Failed to the below:
[code]Info : clock speed 950 kHz
Info : STLINK v2 JTAG v29 API v2 SWIM v7 VID 0x0483 PID 0x3748
Info : using stlink api v2[/code]

Title: Re: Debug using ST LINK V2
Post by Kabron on Jan 6th, 2020 at 11:57am
No, I did not used Zadig. And I'm not sure that it'll help. At the moment I cheated VM by replacing only openocd.exe and scripts folder.
As a resutl I could now launch debug session on STM32F411CEU6 board with ST-LINK V2 and ST-LINK V3 MINI.
The only unsolved moment is that new openocd gives error "file.elf" not found during programming phase. But it also solved
by choosing STM32CubeProgrammer(SWD) for uploading.

Title: Re: Debug using ST LINK V2
Post by Simon Hopkinson on Jan 6th, 2020 at 12:10pm
It should help with the Visual Micro installed Open OCD due to the way it has been built, it will need these driver amendments.  The one you have manually installed may be built with different drivers, which is why it works without using Zadig.


Title: Re: Debug using ST LINK V2
Post by Kabron on Jan 6th, 2020 at 12:36pm
For the interest I tested all Zadig drivers and openocd-0.10.0.1. It does not work.

Title: Re: Debug using ST LINK V2
Post by Simon Hopkinson on Jan 6th, 2020 at 12:44pm
Would it be possible to paste in the OpenOCD output when it works with your customized OpenOCD (in case it reveals anything further)?

With Compile + Debug > Verbose enabled, could we have the output from the Build and Micro Debug windows, just so we have as much information as possible?

At present I cant understand why it doesn't work on your setup with the standard OpenOCD we ship as it does for others (myself included). 

Title: Re: Debug using ST LINK V2
Post by Kabron on Jan 6th, 2020 at 1:01pm
Files attached
https://www.visualmicro.com/forums/YaBB.pl?action=downloadfile;file=MicroBuildOut.txt (3 KB | )
https://www.visualmicro.com/forums/YaBB.pl?action=downloadfile;file=OpenocdTst.txt (1 KB | )

Title: Re: Debug using ST LINK V2
Post by Simon Hopkinson on Jan 6th, 2020 at 2:01pm
Thanks for the additional information, and the output looks as mine does for the STLinkV2 (same VidPid etc...)

(Apologies if you have already done the below)

At present all I can think to do is to remove the "C:\ProgramData\VMicro\tools\openocd-0.10.0.1" folder, and then try debugging in Visual Micro again to pull down a clean copy of our tools.

Now the USB Driver is installed for our version I would expect it would connect at least to the debugger as you have in the alternative version.  We haven't changed any of the OpenOCD files around this debugger, hence my current confusion.

Title: Re: Debug using ST LINK V2
Post by Kabron on Jan 6th, 2020 at 3:29pm
Thought I mentioned that VM re-installed openocd automatically and it is not work, I repeated the procedure with no success.
It does not find ST-LINK regardless all zadig drivers.

At the moment OpenOCD-20191216-0.10.0 is more reliable solution for me. And it works regardless installed/ininstalled zadig drivers.

Title: Re: Debug using ST LINK V2
Post by Simon Hopkinson on Mar 4th, 2020 at 12:51pm
The latest release of Visual Micro also contains an updated OpenOCD version, which may help with this problem as it is far more up to date than the one which was previously installed.

The updated OpenOCD download is available hereif you want to try it manually / command line.

Title: Re: Debug using ST LINK V2
Post by Kabron on Mar 4th, 2020 at 3:11pm
Thanks!

Visual Studio Ide for Arduino » Powered by YaBB 2.5.2!
YaBB Forum Software © 2000-2020. All Rights Reserved.