VS Arduino
Visual Micro >> Usb/Serial/WiFi Debugging >> Debug using ST LINK V2
https://www.visualmicro.com/forums/YaBB.pl?num=1477238460

Message started by xmen on Oct 23rd, 2016 at 4:01pm

Title: Debug using ST LINK V2
Post by xmen on Oct 23rd, 2016 at 4:01pm
I have stm32f103 boards running arduino, connected to PC with ST LINK and can you tell me how can I debug it ?

Title: Re: Debug using ST LINK V2
Post by Visual Micro on Oct 23rd, 2016 at 4:22pm
Yes great (i hope) I have bought an st link but has not time to look at the config for it.

We have a facility to launch a program such as openOCD that waits on an IP port and also GDB which often uses the same port to communicate with GDB. STLink will be a similar mechanism but possibly some other program than OpenOCD.exe

So the question is what do we have to run to get the gdb debug to run. This can often initially be tested by experimentation using a cmd prompt.

I think it does work with OpenOCD so will dig out some visual micro test examples for you

Title: Re: Debug using ST LINK V2
Post by xmen on Oct 23rd, 2016 at 4:44pm
Thank you very much :)

Title: Re: Debug using ST LINK V2
Post by fboran on Oct 30th, 2016 at 10:20pm
Hi,
I'm able to debug over Visual Micro with the given serial connection and STM32mini board(STM32F103C8T6) which details given at that link
http://grauonline.de/wordpress/?page_id=1004
Both STLink(v2) and STMduino bootloader options works.

On the other hand,I tried to debug with GDB option but not success.

After several trials, I note that the "GDB Enable" option (http://www.visualmicro.com/page/User-Guide.aspx?doc=Tools-Options-Reference.html) is not working and stuck in "False" somehow.
So, gdb related configuration is not triggered.


Just another note that I can debug with STM's Eclipse distribution(System Workbench for STM32) via OpenOCD interface with StlinkV2 via SWD type connection.

About cmd line debug I tried and got success as below. This might help.

I'm able to connect via cmd line from openocd to stlinkv2 like below that's given inside documentation of openocd:

openocd -f ..\scripts\interface\stlink-v2.cfg -c "transport select hla_swd" -f ..\scripts\board\stm32f103c8t6mini.cfg -c "tpiu config external uart off 24000000 12000000"

my stm32f103c8t6mini.cfg is below: you should create a instance inside scripts/boards folder of openocd.

# This is an STM32F103C8T6mini board with a single STM32F103C8Tx chip.
source [find interface/stlink-v2.cfg]
set WORKAREASIZE 0x5000
transport select "hla_swd"
source [find target/stm32f1x.cfg]
reset_config none

It's important to give "reset_config none" lines. otherwise the chip could not get the "reset halt" command over telnet.

after a successful connection of openocd I can connect via telnet and gdb and then successful command line debug with given link below.

https://fun-tech.se/stm32/OpenOCD/gdb.php

So, I'm waiting for support of Visual Micro gdb debug to this stm32 board,too 8-)

-------------------------------------------------
Here's my configuration of tools:
-------------------------------------------------
I'm using the Arduino 1.6.9 and lib.s which is the latest compatible version with STMduino git repo.
-------------------------------------------------
VS related installations and versions are below:
(MI debugger tools installed)
-------------------------------------------------
[code]Microsoft Visual Studio Enterprise 2015
Version 14.0.25431.01 Update 3
Microsoft .NET Framework
Version 4.6.01055

Installed Version: Enterprise

Architecture and Modeling Tools
Microsoft Architecture and Modeling Tools
   
UML® and Unified Modeling Language™ are trademarks or registered trademarks of the Object Management Group, Inc. in the United States and other countries.

Visual Basic 2015
Microsoft Visual Basic 2015

Visual C# 2015
Microsoft Visual C# 2015

Visual C++ 2015
Microsoft Visual C++ 2015

Application Insights Tools for Visual Studio Package   7.0.20622.1
Application Insights Tools for Visual Studio

Arduino for Visual Studio   1.0
Arduino extension for Visual Studio. For more information please see docs, faq and forum at http://www.visualmicro.com

Common Azure Tools   1.7
Provides common services for use by Azure Mobile Services and Microsoft Azure Tools.

JavaScript Language Service   2.0
JavaScript Language Service

JavaScript Project System   2.0
JavaScript Project System

KofePackagePackage Extension   1.0
KofePackagePackage Visual Studio Extension Detailed Info

Microsoft Azure Mobile Services Tools   1.4
Microsoft Azure Mobile Services Tools

Microsoft MI-Based Debugger   1.0
Provides support for connecting Visual Studio to MI compatible debuggers

NuGet Package Manager   3.4.0
NuGet Package Manager in Visual Studio. For more information about NuGet, visit http://docs.nuget.org/.

PreEmptive Analytics Visualizer   1.2
Microsoft Visual Studio extension to visualize aggregated summaries from the PreEmptive Analytics product.

TypeScript   1.8.36.0
TypeScript tools for Visual Studio

Visual C++ for Cross Platform Mobile Development (Android)   14.0.25401.00
Visual C++ for Cross Platform Mobile Development (Android)[/code]


Thanks

Title: Re: Debug using ST LINK V2
Post by xmen on Oct 31st, 2016 at 2:27am
So you are saying you were able to debug using St Link?

Title: Re: Debug using ST LINK V2
Post by fboran on Nov 2nd, 2016 at 5:02pm
serial debugging works. stlink used for uploading image. 2 pin ftdi serial connection used for debugging in this case.

But gdb debug(direct debug via stlink) with openocd is currently not supported i think.

Title: Re: Debug using ST LINK V2
Post by Visual Micro on Nov 2nd, 2016 at 6:54pm
Hi fboran

Thanks for the info which looks like it is what I needed. I will be looking into the gdb over the next few days. Normally it would be easy to try it out but I read an article that suggests the openocd and gdb communicate on Ip port 4444 when normally we have used 3333. If that is the case the solution might involve a visual micro update.

Title: Re: Debug using ST LINK V2
Post by Visual Micro on Nov 5th, 2016 at 1:58pm
There is an update (1611.5) with gdb fixes but the .cfg mentioned previously has also been added to the openocd that ships with visual micro.

The release notes gives a hint as to the entries you can put in a local project board.txt to try out gdb

If you encounter issues then look in \configName\logs for gdb logs (ie: "project_folder\debug\logs")

tip

If not sure of the [board_id] then look in the boards.txt in the hardware folder. You can use the visual micro explorer to view the hardware folder for your board

Title: Re: Debug using ST LINK V2
Post by xmen on Nov 6th, 2016 at 6:46am
I don't understand, the topic is about debugging through St Link. Is it possible?

Title: Re: Debug using ST LINK V2
Post by Visual Micro on Nov 6th, 2016 at 9:59pm
Hi, xmen. Yet this is instruction for you to add config to test gdb. You need to have installed the android tools for visual studio. if not sure how to do that please open another thread

Then create a board.txt in the current project with something like this based on fborans earlier post in this thread

[code]build.openocdscript=board/stm32f103c8t6mini.cfg
debug.tool=gdb
tools.gdb.pre_init.tool=openocd
tools.gdb.cmd=arm­none­eabi­gdb.exe
tools.gdb.path={runtime.tools.arm­none­eabi­gcc.path}/bin
tools.gdb.pattern="{path}/{cmd}" ­interpreter=mi ­d "{build.project_path}"
tools.gdb.openocd.cmd=bin/openocd.exe
tools.gdb.tcp=localhost:3333
tools.gdb.openocd.path={runtime.vm.ide.platforms.path}/default/tools/openocd­0.9.0
tools.gdb.openocd.params.verbose=­d2
tools.gdb.openocd.params.quiet=­d0
tools.gdb.openocd.pattern="{path}/{cmd}" -f "{path}\scripts\interface\stlink-v2.cfg" -c "transport select hla_swd" ­s "{path}/scripts/" ­f "{path}/scripts/{build.openocdscript}" -c "tpiu config external uart off 24000000 12000000"[/code]

When you have a script like this the "vMicro>Debugger>Use Visual Studio Debugger" option will appear and can be enabled. Then if gdb is installed it will be used instead of serial debug.

Title: Re: Debug using ST LINK V2
Post by xmen on Nov 7th, 2016 at 5:29am
Wow so you are using Android tools for debugging, that's so cool.  :D

Title: Re: Debug using ST LINK V2
Post by Visual Micro on Nov 7th, 2016 at 12:52pm
Well it just so happens the Android tools install the Microsoft MI Debugger. It's the MI debugger that we use.

Title: Re: Debug using ST LINK V2
Post by fboran on Nov 13th, 2016 at 9:34pm
Hi,

I have installed and tried the latest version of visual micro but got problem about gdb debug with stm32 board.

Briefly:
I put the config file(stm32f103c8t6mini.cfg) to following path:
C:\Users\PC\AppData\Local\VisualGDB\EmbeddedDebugPackages\com.sysprogs.arm.openocd\share\openocd\scripts\board\stm32f103c8t6mini.cfg

and put the given board.txt file to the same path with Arduino .ino file(Arduino project folder)

After activating vMicro->Debugger->Microsoft GDB Debugger and start debugging with F5 (Debug->Start with Debug) I got an error like the link(vmicro crashes)
http://www.visualmicro.com/forums/YaBB.pl?num=1468416233.

I attach the vMicro build log and sample project,too.




https://www.visualmicro.com/forums/YaBB.pl?action=downloadfile;file=Blinkstm32_build_log.zip ( 4 KB | 1 Download )
https://www.visualmicro.com/forums/YaBB.pl?action=downloadfile;file=Blinkstm32.zip ( 41 KB | 1 Download )

Title: Re: Debug using ST LINK V2
Post by Visual Micro on Nov 13th, 2016 at 9:55pm
Sorry for the confusion. you don't need to move or change the arduino boards.txt and you don't need to use any VisualGDB stuff.

The OpenOCD is installed with Visual Micro. That's where a .cfg needs to go.

You can use a local project board.txt to test with

There is a guide here

http://www.visualmicro.com/post/2016/01/17/3rd-Party-Hardware-GDB-Configuration-Guide.aspx

Hope that makes sense

Title: Re: Debug using ST LINK V2
Post by Visual Micro on Nov 13th, 2016 at 9:56pm
ps: I've just seen your local project board.txt. It's looks about right although I don't know about the switches.


Title: Re: Debug using ST LINK V2
Post by Visual Micro on Nov 13th, 2016 at 9:59pm
pps: the build log looks fine. The error you will be getting is when gdb attempts to launch.

There will be trace files for gdb in

[configuration name]\logs\gdb

which means

debug\logs\gdb

or

release\logs\gdb

If you click Project>Build you will see build without attempt to launch gdb

Title: Re: Debug using ST LINK V2
Post by fboran on Nov 13th, 2016 at 11:22pm
The error logs as below: Also I sent via mail.

Open On-Chip Debugger 0.9.0 (2015-05-19-12:06)
Licensed under GNU GPL v2
For bug reports, read
     http://openocd.org/doc/doxygen/bugs.html
embedded:startup.tcl:60: Error: Can't find D:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\Extensions\1mytjp2i.y41\Micro Platforms/default/tools/openocd-0.9.0/scripts/{build.openocdscript}
in procedure 'script'
at file "embedded:startup.tcl", line 60

Looks like {build.openocdscript} is not changing at runtime with board/stm32f103c8t6mini.cfg somehow. I put the .cfg file manually to the folder but it could find by the gdb startup script I think.
D:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\Extensions\1mytjp2i.y41\Micro Platforms\default\tools\openocd-0.9.0\scripts\board

I add the following line to the boards.txt file, too:
genericSTM32F103C.build.openocdscript=board/stm32f103c8t6mini.cfg

Also I changed the board.txt file encoding to UTF-8. If not, there will be strange characters inside board.buildinfo when creating.

Title: Re: Debug using ST LINK V2
Post by fboran on Nov 14th, 2016 at 12:21am
The problem is copy&paste of the board.txt section below.
In my PC, it creates some strange characters when converting it to UTF-8. I think build file uses this encoding.

After converting board.txt to UTF-8 and cleaning strange characters I am able to debug ;D

Thanks

Title: Re: Debug using ST LINK V2
Post by Visual Micro on Nov 14th, 2016 at 12:22am
You can hard code the cfg property for now.

Change the {build.openocdscript} in the pattern to board/stm32f103c8t6mini.cfg

tools.gdb.openocd.pattern="{path}/{cmd}" -f "{path}\scripts\interface\stlink-v2.cfg" -c "transport select hla_swd" ­s "{path}/scripts/" ­f "{path}/scripts/{build.openocdscript}"


tools.gdb.openocd.pattern="{path}/{cmd}" -f "{path}\scripts\interface\stlink-v2.cfg" -c "transport select hla_swd" ­s "{path}/scripts/" ­f "{path}/scripts/board/stm32f103c8t6mini.cfg"

Then build.openocdscript is not used


note: if openocd stops trying to start then terminate the microgdb.exe and openocd.exe processes with task manager. this can happen when experimenting with these settings


Title: Re: Debug using ST LINK V2
Post by cdia on Dec 20th, 2016 at 9:02am
I am trying to debug with st-link also
@fboran can you please upload a working project with configuration and everything?

Thanks

Title: Re: Debug using ST LINK V2
Post by cdia on Dec 20th, 2016 at 5:48pm
Could You please help me with this. I've tried attaching the project zip but I'm not allowed to do so.

The funny thing is that once the board.txt file is added to project dir, no log will be written in dir BlinkStm32\Debug\logs\gdb\. But it will write logs with no board.txt file added to project.

Thanks.

Title: Re: Debug using ST LINK V2
Post by Visual Micro on Dec 20th, 2016 at 6:56pm
please attach again thanks

Title: Re: Debug using ST LINK V2
Post by cdia on Dec 21st, 2016 at 5:48am
To summarize what I have done so far:
All files are UTF-8 encoded, Windows EOL carriages

1) I have added file
...\VisualStudio\...\tools\openocd-0.9.0\scripts\board\stm32f103c8t6mini.cfg
with content from your post in this thread

2) I have added the board.txt file in project dir with content which can be found in attachment

3) I have tried to hard-code all the paths inside board.txt file with no success

4) Without the board.txt file odb creates log file inside Debug dir but with board.txt file it will not create any log

5) I've verified that openocd runs with the created config file:
in a cmd:

Code (]bin\openocd.exe -f scripts\board\stm32f103c8t6mini.cfg[/code):
and device connected

than in another cmd:
[code]telnet localhost 4444
> reset halt
> flash probe 0
> stm32f1x mass_erase 0
> reset halt
and everything went smoothly

I think this should be the short version of attempts I have done so far.

Thanks.
https://www.visualmicro.com/forums/YaBB.pl?action=downloadfile;file=BlinkStm32_001.zip ( 29 KB | 1 Download )

Title: Re: Debug using ST LINK V2
Post by Visual Micro on Jan 6th, 2020 at 11:26am
New/different conversation moved to here

VS Arduino » Powered by YaBB 2.6.12!
YaBB Forum Software © 2000-2024. All Rights Reserved.