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] 3  Send TopicPrint
Very Hot Topic (More than 25 Replies) Using JTAG Programmer (Read 25300 times)
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12076
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Using JTAG Programmer
Reply #20 - Jan 29th, 2018 at 5:14pm
Print Post  
Okay makes sense to get gdb working outside of any ide to start with. The upload issue is something for both visual micro and the arduino ide, one solution will work for both but not required right now.

I don't have facility to build openOCD and don't know it very well.

I assume you tried version 9 which is the one most things/articles appear to work with.

Instead of trying to fix it I would put the usb drivers back to default.

Then post the full error test you see when trying to connect to the jlink.

Also confirm which firmware version is installed on the jlink adapter and what command line you are using.

« Last Edit: Jan 29th, 2018 at 5:16pm by Tim@Visual Micro »  
Back to top
WWW  
IP Logged
 
Al
Junior Member
**
Offline


Posts: 24
Location: Florida
Joined: Oct 13th, 2012
Re: Using JTAG Programmer
Reply #21 - Jan 29th, 2018 at 6:03pm
Print Post  
Yes, tried version 9 as installed by Visual Micro.  Jlink firmware is the latest.  I didn't change any USB drivers for the reasons I said in my last post.  I can connect and control the jlink module using Jlink Commander and, in fact, can flash within Visual Micro using the command line version of it.  This means the jlink hardware and jlink usb driver are fine.   

The full attempt to connect to jlink by OpenOCD is below.  I am using the jlink.cfg that comes with OpenOCD and created the MK20Board.cfg and k20.cfg (which uses kx.cfg that comes with OpenOCD).

MK20Board.cfg (don't know if flash banks are properly defined but will fix that later, if req'd):
Code
Select All
#
# MK20 Board

source [find target/k20.cfg]

$_TARGETNAME configure -event reset-init {
	puts "-event reset-init occured"
}

# Bank definition for the 'program flash' (instructions and/or data)
flash bank pflash.0 kinetis 0x00000000 0x40000 0 4 $_TARGETNAME
flash bank pflash.1 kinetis 0x00040000 0x40000 0 4 $_TARGETNAME
 



K20.cfg:
Code
Select All
# Freescale Kinetis K20 devices

set CHIPNAME k20
source [find target/kx.cfg]
 


error results for command: openocd -f interface/jlink.cfg -f board/MK20Board.cfg 
Code
Select All
C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\Extensions\3vu3t
p0o.aov\Micro Platforms\default\tools\openocd-0.9.0\bin-x64>openocd -f interface
/jlink.cfg -f board/MK20Board.cfg
Open On-Chip Debugger 0.9.0 (2015-05-19-12:09)
Licensed under GNU GPL v2
For bug reports, read
        http://openocd.org/doc/doxygen/bugs.html
Info : auto-selecting first available session transport "jtag". To override use
'transport select <transport>'.
Info : add flash_bank kinetis k20.flash
adapter speed: 1000 kHz
none separate
cortex_m reset_config sysresetreq
Info : add flash_bank kinetis pflash.0
Info : add flash_bank kinetis pflash.1
Error: libusb_open() failed with LIBUSB_ERROR_NOT_SUPPORTED
Error: Cannot find jlink Interface! Please check connection and permissions.
 



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


Posts: 12076
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Using JTAG Programmer
Reply #22 - Jan 29th, 2018 at 6:46pm
Print Post  
I have read about the usb driver issues with jlink. It seems to have broken since they release new firmware with bug fixes. Uggh Smiley

It needs the winUSB driver. Some blogs recommend using this product to install the driver.

http://zadig.akeo.ie/
  
Back to top
WWW  
IP Logged
 
Al
Junior Member
**
Offline


Posts: 24
Location: Florida
Joined: Oct 13th, 2012
Re: Using JTAG Programmer
Reply #23 - Jan 29th, 2018 at 7:47pm
Print Post  
I had another thought...

JLink comes with it's own GBD server.  Can this be used instead and simplify all of this???  Segger JLink is a very popular programmer/debugger module and now with the EDU version it is very affordable at $29.95 (non-commercial use).

It seems Visual Micro should support it directly!
  
Back to top
 
IP Logged
 
Al
Junior Member
**
Offline


Posts: 24
Location: Florida
Joined: Oct 13th, 2012
Re: Using JTAG Programmer
Reply #24 - Jan 29th, 2018 at 8:02pm
Print Post  
Tim@Visual Micro wrote on Jan 29th, 2018 at 6:46pm:
I have read about the usb driver issues with jlink. It needs the winUSB driver. Some blogs recommend using this product to install the driver.

http://zadig.akeo.ie/

If I did that I still have the problem of what to use in the programmer.txt file to create a definition, i.e. what program and commandline parameters to call when it is invoked.

Would I do the following as a programmer definition???

jlink-JATG.name=JLINK-(JTAG SWD)
jlink-JATG.communication=usb
jlink-JATG.protocol=swd
jlink-JATG.program.protocol=openocd
jlink-JATG.program.tool= <path to openocd bin folder>openocd.exe
jlink-JATG.program.extra_params=-f interface/jlink.cfg  -f board/MK20Board.cfg 

If that has a potential to work I could try changing the driver.
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12076
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Using JTAG Programmer
Reply #25 - Jan 29th, 2018 at 9:16pm
Print Post  
Hi,

Adding an arduino 3rd party programmer

For the programmer I would open arduno ide and find the "Upload using programmer" has an issue with your definition. Then it is okay to ask for help on the http://forum.arduino.cc where they have people who can help.

When you have that working I can easily help you tune it or make it more flexible but they know their own spec for programmers much better than I do.


j-Links owns GDB

I have a j-link but never had time to use it. If you can find the direct calls then we can certainly look at using it instead. You will see that you can configure in the visual micro gdb settings which programs it needs to run to launch a gdb session..
  
Back to top
WWW  
IP Logged
 
Al
Junior Member
**
Offline


Posts: 24
Location: Florida
Joined: Oct 13th, 2012
Re: Using JTAG Programmer
Reply #26 - Jan 29th, 2018 at 9:44pm
Print Post  
It seems that the standard GDB is implemented plus multiple extensions.  The J-Link Manual (UM08001) is here and has a GDB section:

https://www.segger.com/downloads/jlink

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


Posts: 12076
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Using JTAG Programmer
Reply #27 - Jan 29th, 2018 at 9:54pm
Print Post  
So in theory just specify the gdb.path or just hard code the entire .pattern to start with. This assumes no openOCD

debug.tool=gdb

tools.gdb.pre_init.tool=openocd

tools.gdb.cmd=[hardware tool chain gdb.exe]

tools.gdb.path={runtime.tools.[hardware tool chain 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
« Last Edit: Jan 29th, 2018 at 9:55pm by Tim@Visual Micro »  
Back to top
WWW  
IP Logged
 
Al
Junior Member
**
Offline


Posts: 24
Location: Florida
Joined: Oct 13th, 2012
Re: Using JTAG Programmer
Reply #28 - Jan 29th, 2018 at 10:21pm
Print Post  
That still uses openOCD which can't connect to the jLink.

I think I need to get openOCD to connect with Jlink.  Way back in this adventure I was able to get the upload to happen in Visual Micro using JLink Commander on a command line basis.  Then the debugging session would fail with the Unable to start debugging. Cannot access a disposed object. Object name: 'Debugger' error from Visual Studio.

Maybe the problem was same problem of not connecting with the jlink.

  
Back to top
 
IP Logged
 
Al
Junior Member
**
Offline


Posts: 24
Location: Florida
Joined: Oct 13th, 2012
Re: Using JTAG Programmer
Reply #29 - Jan 30th, 2018 at 4:42pm
Print Post  
I'm making progress and can now use OpenOCD to flash and restart my board.  I changed the JLink USB driver to winUSB and it now connects and works.  I created an OpenOCD script  based on a GitHub script I found which includes a program() and attach() procedure using SWD.  I found it here:
https://github.com/geomatsi/stm32-tests/tree/master/boards/stm32f103-mini/script...

It works to load my hex file and restart the MCU. It is hardcoded to the hex file path right now but this should be straightforward to pass in platform.txt (maybe... everything has been a battle thus far!).  I haven't tried the attach function at this point.

The script follows and is called to flash the device with this command:
    openocd -f setup_MK20.cfg -c "program ()"

Code
Select All
# openocd setup for MK20

source [find interface/jlink.cfg]
transport select swd

source [find target/k20.cfg]

# write image and restart target
proc program () {
	init
	reset init
	halt
	flash write_image erase "C:\\Users\\Al Testani\\Documents\\Arduino\\Blink2\\Debug\\Blink2.hex"
	reset run
	shutdown
}

# reset target and attach to debug
proc attach () {
	init
	reset run
}
 



« Last Edit: Jan 30th, 2018 at 7:30pm by Al »  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12076
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Using JTAG Programmer
Reply #30 - Jan 30th, 2018 at 6:53pm
Print Post  
useful to know thanks
  
Back to top
WWW  
IP Logged
 
Al
Junior Member
**
Offline


Posts: 24
Location: Florida
Joined: Oct 13th, 2012
Re: Using JTAG Programmer
Reply #31 - Jan 31st, 2018 at 4:31pm
Print Post  
Where are the "runtime.vm." path values defined?  I am looking for the one that is the openocd BIN path, i.e. I  want the one that points to here (on my machine):

C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\Extensions\3vu3tp0o.aov\Micro Platforms\default\tools\openocd-0.9.0

In "Arduino 3rd Party Hardware GDB Configuration Guide", the sample platform.txt uses:

.9.0

I can't find where {runtime.vm.ide.platforms.path} is pointing to. 

I need to know where the "real" openocd folder is as I want to add some cfg files to the scripts folder.

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


Posts: 12076
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Using JTAG Programmer
Reply #32 - Jan 31st, 2018 at 6:55pm
Print Post  
Have you switch on "show build properties" then run a build and searched the output?
  
Back to top
WWW  
IP Logged
 
Al
Junior Member
**
Offline


Posts: 24
Location: Florida
Joined: Oct 13th, 2012
Re: Using JTAG Programmer
Reply #33 - Jan 31st, 2018 at 7:05pm
Print Post  
Yes have done that countless times.  It doesn't expand the paths I am concerned with.   

I can hard code the paths and get it to work but it isn't clear how this will work on other computers I have.  That is why I am looking for the {} paths.
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12076
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Using JTAG Programmer
Reply #34 - Jan 31st, 2018 at 9:28pm
Print Post  
ah so you are testing outside the ide and have not added anything the users the property yet

add this to local board.txt or hardware>platform.txt

pathtest1={runtime.vm.ide.platforms.path}

Then save (rescan if using platform.txt) and build

  
Back to top
WWW  
IP Logged
 
Al
Junior Member
**
Offline


Posts: 24
Location: Florida
Joined: Oct 13th, 2012
Re: Using JTAG Programmer
Reply #35 - Jan 31st, 2018 at 10:10pm
Print Post  
I *am* testing in the IDE and editing platform.txt.  I am looking for what {runtime.vm.ide.platforms.path} actually points to as it is not where I can find it and it doesn't point to where VM is installing openocd.  

This works if I hardcode the path to:
C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\Extensions\3vu3tp0o.aov\Micro Platforms\default\tools\openocd-0.9.0

but not with {runtime.vm.ide.platforms.path}

What I really want is what the equivalent {runtime.vm.xxx.xxx.path} is for the hardcoded path above.

My alternative is to install openocd at C:\openocd so I know for certain where it is and where my scripts are. 

« Last Edit: Jan 31st, 2018 at 10:11pm by Al »  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12076
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Using JTAG Programmer
Reply #36 - Jan 31st, 2018 at 10:24pm
Print Post  
it's a runtime property similar to project_name. Platform.txt doesn't contain any full paths they are all runtime.

So add a property as in my example and build and the path will then be in the build output.
  
Back to top
WWW  
IP Logged
 
Al
Junior Member
**
Offline


Posts: 24
Location: Florida
Joined: Oct 13th, 2012
Re: Using JTAG Programmer
Reply #37 - Feb 1st, 2018 at 1:14am
Print Post  
I guess I am not making myself clear.  I think I know what it is and how it is a "shortcut" to an actual path. If this is incorrect, please let me know.

On my main development machine the Visual Micro extensions seems to be in:
C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\Extensions\3vu3tp0o.aov\...

In there, is the openocd folder where scripts (inc. mine) are stored and the executable lives

The 3vu3tp0o.aov folder is not present on my notebook so the equivalent folder is *somewhere* in the VS Extensions folder.  So, if I want all this to work on any machine where I do development, I want the path shortcut to be transportable and, obviously, hardcoding the path isn't.   

So the question is if I use pathtest1 = {runtime.vm.ide.platforms.path}, what is the REAL path that pathtest1 represents?
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12076
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Using JTAG Programmer
Reply #38 - Feb 1st, 2018 at 1:01pm
Print Post  
I am not making myself clear

pathtest1={runtime.vm.ide.platforms.path}

ADDING THE ABOVE TO PLATFORM.TXT AND THEN BUILDING WILL SHOW YOU, IN THE BUILD OUTPUT, PATHTEST1=????SOME PATH THAT YOU WANT TO SEE ??

If you do as I ask ten inspect the output you will see pathtest= states the path you are asking about.



  
Back to top
WWW  
IP Logged
 
Al
Junior Member
**
Offline


Posts: 24
Location: Florida
Joined: Oct 13th, 2012
Re: Using JTAG Programmer
Reply #39 - Feb 1st, 2018 at 2:50pm
Print Post  
This does not work.

I even did a project "Clean" and Rebuild to see everything and only the one line in platform.txt where I put the pathtest1={} line shows up. I am attaching the build output so you can see for yourself.

I do see a couple of openocd paths but neither is the one in the VM extension folder.  I also see this line:

vm.platform.root.path=C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\Extensions\i5drq5bg.rqa\Micro Platforms\arduino16x

Backing up one level, there is a \default\tools\openocd path so possibly this is where the scripts are being search for.

The fact is that I still have no clue which openocd folder is being used and likely the reason I am having trouble and frustration.  I am going to put my own openocd folder at C:\openocd so I know definitively where it is.

  

Please Register or Login to the Forum to see File Attachments
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1 [2] 3 
Send TopicPrint