Before logging an issue, please update to the latest release of Visual Micro from the Downloads Page.

When Logging a Support Issue in the Forum, please ensure you have also:-

  • Enabled vMicro > Compiler > Show Build Properties
  • Re-Compile your program with these settings enabled
 
Save the new Output to a Text File and....
  • Click the Reply button and attach as .txt file OR
  • Click here to Email us with the file attached, and a link to your post
Support requests without the output above may be impossible to answer, so please help us to help you
 
Page Index Toggle Pages: [1] 2  Send TopicPrint
Hot Topic (More than 8 Replies) Debug using ST LINK V2 (Read 27153 times)
xmen
Junior Member
**
Offline


Posts: 50
Joined: Aug 22nd, 2016
Debug using ST LINK V2
Oct 23rd, 2016 at 4:01pm
Print Post  
I have stm32f103 boards running arduino, connected to PC with ST LINK and can you tell me how can I debug it ?
« Last Edit: Oct 23rd, 2016 at 4:02pm by xmen »  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12071
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Debug using ST LINK V2
Reply #1 - Oct 23rd, 2016 at 4:22pm
Print Post  
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
  
Back to top
WWW  
IP Logged
 
xmen
Junior Member
**
Offline


Posts: 50
Joined: Aug 22nd, 2016
Re: Debug using ST LINK V2
Reply #2 - Oct 23rd, 2016 at 4:44pm
Print Post  
Thank you very much Smiley
  
Back to top
 
IP Logged
 
fboran
Newbies
*
Offline


Posts: 5
Joined: Oct 30th, 2016
Re: Debug using ST LINK V2
Reply #3 - Oct 30th, 2016 at 10:20pm
Print Post  
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 Cool

-------------------------------------------------
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
Select All
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) 




Thanks
« Last Edit: Oct 31st, 2016 at 5:32pm by Tim@Visual Micro »  
Back to top
 
IP Logged
 
xmen
Junior Member
**
Offline


Posts: 50
Joined: Aug 22nd, 2016
Re: Debug using ST LINK V2
Reply #4 - Oct 31st, 2016 at 2:27am
Print Post  
So you are saying you were able to debug using St Link?
  
Back to top
 
IP Logged
 
fboran
Newbies
*
Offline


Posts: 5
Joined: Oct 30th, 2016
Re: Debug using ST LINK V2
Reply #5 - Nov 2nd, 2016 at 5:02pm
Print Post  
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.
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12071
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Debug using ST LINK V2
Reply #6 - Nov 2nd, 2016 at 6:54pm
Print Post  
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.
  
Back to top
WWW  
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12071
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Debug using ST LINK V2
Reply #7 - Nov 5th, 2016 at 1:58pm
Print Post  
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
  
Back to top
WWW  
IP Logged
 
xmen
Junior Member
**
Offline


Posts: 50
Joined: Aug 22nd, 2016
Re: Debug using ST LINK V2
Reply #8 - Nov 6th, 2016 at 6:46am
Print Post  
I don't understand, the topic is about debugging through St Link. Is it possible?
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12071
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Debug using ST LINK V2
Reply #9 - Nov 6th, 2016 at 9:59pm
Print Post  
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
Select All
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
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" 



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.
« Last Edit: Nov 6th, 2016 at 10:03pm by Tim@Visual Micro »  
Back to top
WWW  
IP Logged
 
xmen
Junior Member
**
Offline


Posts: 50
Joined: Aug 22nd, 2016
Re: Debug using ST LINK V2
Reply #10 - Nov 7th, 2016 at 5:29am
Print Post  
Wow so you are using Android tools for debugging, that's so cool.  Cheesy
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12071
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Debug using ST LINK V2
Reply #11 - Nov 7th, 2016 at 12:52pm
Print Post  
Well it just so happens the Android tools install the Microsoft MI Debugger. It's the MI debugger that we use.
  
Back to top
WWW  
IP Logged
 
fboran
Newbies
*
Offline


Posts: 5
Joined: Oct 30th, 2016
Re: Debug using ST LINK V2
Reply #12 - Nov 13th, 2016 at 9:34pm
Print Post  
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:
cd\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. 



  

Please Register or Login to the Forum to see File Attachments
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12071
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Debug using ST LINK V2
Reply #13 - Nov 13th, 2016 at 9:55pm
Print Post  
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-...

Hope that makes sense
  
Back to top
WWW  
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12071
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Debug using ST LINK V2
Reply #14 - Nov 13th, 2016 at 9:56pm
Print Post  
ps: I've just seen your local project board.txt. It's looks about right although I don't know about the switches.

  
Back to top
WWW  
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12071
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Debug using ST LINK V2
Reply #15 - Nov 13th, 2016 at 9:59pm
Print Post  
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
« Last Edit: Nov 13th, 2016 at 10:00pm by Tim@Visual Micro »  
Back to top
WWW  
IP Logged
 
fboran
Newbies
*
Offline


Posts: 5
Joined: Oct 30th, 2016
Re: Debug using ST LINK V2
Reply #16 - Nov 13th, 2016 at 11:22pm
Print Post  
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.
  
Back to top
 
IP Logged
 
fboran
Newbies
*
Offline


Posts: 5
Joined: Oct 30th, 2016
Re: Debug using ST LINK V2
Reply #17 - Nov 14th, 2016 at 12:21am
Print Post  
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 Grin

Thanks
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12071
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Debug using ST LINK V2
Reply #18 - Nov 14th, 2016 at 12:22am
Print Post  
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

« Last Edit: Nov 14th, 2016 at 12:26am by Tim@Visual Micro »  
Back to top
WWW  
IP Logged
 
cdia
Newbies
*
Offline


Posts: 3
Joined: Dec 20th, 2016
Re: Debug using ST LINK V2
Reply #19 - Dec 20th, 2016 at 9:02am
Print Post  
I am trying to debug with st-link also
@fboran can you please upload a working project with configuration and everything?

Thanks
« Last Edit: Dec 20th, 2016 at 9:03am by cdia »  
Back to top
 
IP Logged
 
Page Index Toggle Pages: [1] 2 
Send TopicPrint