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) GDB on nRF boards (Read 16478 times)
rml
Junior Member
**
Offline


Posts: 38
Joined: Aug 29th, 2016
GDB on nRF boards
Jan 8th, 2017 at 5:58pm
Print Post  
Hello,

I am using Visual Micro with Nordic's nRF boards, using the Arduino core at https://github.com/sandeepmistry/arduino-nRF5.

It works great! I just had to append a few lines at the bottom of the platform.txt (see below), and now I can enjoy all the convenience of VS/VM to easily program and debug those chips.
There is only one glitch: when starting a debugging session in VM, a window pops up telling me that there were some build errors, even though there are no such warnings when I directly upload the same code. I have to choose to "continue using the last successful build" in order to debug, then it all goes smoothly.

It seems similar to a problem I faced when debugging some ATSAMD21G18 with the Atmel ICE when selecting the Arduino Zero (Programming Port) as device. Looks like a Visual Studio / Visual Micro mismatch, error messages below. At the end of the day, it works, but it would be even better without those messages. Help or input welcome.
Thanks,

Armel

-------- error messages:
Error      MSB4018      The "VCMessage" task failed unexpectedly.
System.FormatException: Index (zero based) must be greater than or equal to zero and less than the size of the argument list.
   at System.Text.StringBuilder.AppendFormatHelper(IFormatProvider provider, String format, ParamsArray args)
   at System.String.FormatHelper(IFormatProvider provider, String format, ParamsArray args)
   at System.String.Format(IFormatProvider provider, String format, Object[] args)
   at Microsoft.Build.Shared.ResourceUtilities.FormatString(String unformatted, Object[] args)
   at Microsoft.Build.Utilities.TaskLoggingHelper.FormatString(String unformatted, Object[] args)
   at Microsoft.Build.Utilities.TaskLoggingHelper.FormatResourceString(String resourceName, Object[] args)
   at  messageResourceName, Object[] messageArgs)
   at Microsoft.Build.CPPTasks.VCMessage.Execute()
   at Host.Execute()
   at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__26.MoveNext()      Blink_nRF52DK      C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.Cpp.Platform.targets      57      Build      


-------- lines added in the platform.txt of the nRF5 core:
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.openocd.path={runtime.tools.openocd-0.10.0-dev.nrf5.path}
tools.gdb.openocd.params.verbose=-d2
tools.gdb.openocd.params.quiet=-d0

tools.gdb.openocd.intf={upload.interface}
tools.gdb.openocd.stp={upload.setup_command}
tools.gdb.openocd.pattern="{path}/{cmd}" -s "{path}/scripts/" -f "{path}/scripts/interface/{intf}.cfg" -c "{stp}" -f "{path}/scripts/target/{upload.target}.cfg"
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12071
Location: United Kingdom
Joined: Apr 10th, 2010
Re: GDB on nRF boards
Reply #1 - Jan 8th, 2017 at 6:29pm
Print Post  
This is great news and good to hear thanks.

I think you can avoid the error by opening "Build>Configuration Manager" and un-selecting the project from the Visual Studio build system. 

Visual Micro performs the build and only needs VS to launch the debugger, not perform a build. Visual Micro is supposed to be unselecting the project from the build process so I will look into why that is failing.

(similar also applies to atmel studio and ice)

ps:
I will add your platform.txt stuff to the platform for visual micro if it doesn't conflict. you can also put the same properties in a local project board.txt when testing and trying stuff out it can be easier.
« Last Edit: Jan 8th, 2017 at 6:33pm by Tim@Visual Micro »  
Back to top
WWW  
IP Logged
 
rml
Junior Member
**
Offline


Posts: 38
Joined: Aug 29th, 2016
Re: GDB on nRF boards
Reply #2 - Jan 8th, 2017 at 7:09pm
Print Post  
Thanks, just un-selected the project as suggested and the error messages are gone, both for the Atmel ICE and the nRF! Really cool.

I am wondering whether it is possible to debug using an external programmer (not the onboard debug chip of the dev kit).
I can already upload code to the nRF using an ST-Link in VM, but can't get it to debug unless I hard-code the value of "tools.gdb.openocd.intf" and "tools.gdb.openocd.stp" in platform.txt.

Do you know how I could get the details of the programmer being used, so that the new lines work both cases?

I tried using the 'program' variable instead of 'upload' but it didn't work (so
tools.gdb.openocd.intf={program.interface}
tools.gdb.openocd.stp={program.setup_command})

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


Posts: 12071
Location: United Kingdom
Joined: Apr 10th, 2010
Re: GDB on nRF boards
Reply #3 - Jan 8th, 2017 at 7:37pm
Print Post  
Great.

If you have vMicro>Compiler>Show build properties switched on the you should see all the available {build_properties}. 

I can't recall what's in boards.txt, programmers.txt and platform.txt for the hardware you are using can you attach them in a zip or email to info[at]visualmicro.com with link to this post.

Thanks
  
Back to top
WWW  
IP Logged
 
rml
Junior Member
**
Offline


Posts: 38
Joined: Aug 29th, 2016
Re: GDB on nRF boards
Reply #4 - Jan 8th, 2017 at 8:21pm
Print Post  
Just sent you the docs.

Looking at the build properties, I can't find where the name of the programmer that will be used is stored.
Don't know whether/ how that could be made available when defining the tools.gdb.openocd pattern...
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12071
Location: United Kingdom
Joined: Apr 10th, 2010
Re: GDB on nRF boards
Reply #5 - Jan 10th, 2017 at 2:18pm
Print Post  
Sorry for the delay. I investigated and you are right. The selected upload programmer from programmers.txt is not merged into the build properties used by the gdb launcher.

I will try to implement that for the next release however my visual studio has stopped launching the debugger which is a pain. Prior to release I need to ensure that Microsoft hasn't changed and broken things during an update!

Therefore I will post a pre-release link here for you to try. It it doesn't work you will be able to drop back to the published version, if it does work I will publish it.

The GDB system from Microsoft is in a state of flux hence my caution. I expect it will settle down over the next few months after vs2017 is released but right now I have to walk a careful line Smiley
  
Back to top
WWW  
IP Logged
 
rml
Junior Member
**
Offline


Posts: 38
Joined: Aug 29th, 2016
Re: GDB on nRF boards
Reply #6 - Jan 10th, 2017 at 2:25pm
Print Post  
Great thanks - happy to be the guinea pig for this!
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12071
Location: United Kingdom
Joined: Apr 10th, 2010
Re: GDB on nRF boards
Reply #7 - Jan 10th, 2017 at 3:32pm
Print Post  
Thanks. I also fixed a hang when terminating debugging which required the microgdb.exe or openocd.exe processes to be terminated via task manager. Didn't always hang but was annoying
  
Back to top
WWW  
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12071
Location: United Kingdom
Joined: Apr 10th, 2010
Re: GDB on nRF boards
Reply #8 - Jan 16th, 2017 at 3:44pm
Print Post  
Sorry this took some time. The latest release should now include the program {params}

The problem I encountered seems more apparent when the tool bar is set to release mode. I found that every so often visual studio would not know which debugger to launch and showed an error. However it is not related to Visual Micro and doesn't sound like it's affecting you.

After debug upload, the release/debug folder below the project should contain an uploaded.boardinfo. These are the settings that are available to your gdb/ocd patterns
  
Back to top
WWW  
IP Logged
 
rml
Junior Member
**
Offline


Posts: 38
Joined: Aug 29th, 2016
Re: GDB on nRF boards
Reply #9 - Jan 16th, 2017 at 8:26pm
Print Post  
Thanks Tim!
I am now using the program params, and it works well.

However I am seeing new errors when at the start of the debug session: a window pops up, reading: "An unhandled Microsoft .NET Framework exception occurred in MicroGdb.exe [4180]." and offering me to select another debugger, namely "New instance of Microsoft Visual Studio 2015", which then fails as well.

I have experienced this on setups that used to work: nRF target debugged using the onboard J-Link and the previous platform.txt, and ATSAMD21G18 with Atmel Ice as "Arduino Zero (Programming Port)".

Best,

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


Posts: 12071
Location: United Kingdom
Joined: Apr 10th, 2010
Re: GDB on nRF boards
Reply #10 - Jan 16th, 2017 at 9:29pm
Print Post  
Maybe I left a debug command in by mistake. I will take a look.

Quote:
I have experienced this on setups that used to work: nRF target debugged using the onboard J-Link and the previous platform.txt, and ATSAMD21G18 with Atmel Ice as "Arduino Zero (Programming Port)".


This is because you have now switched on gdb so you will see the same for all boards that have gdb enabled in platform.txt. Zero has it by default and you just enabled it for the nRF
« Last Edit: Jan 16th, 2017 at 9:48pm by Tim@Visual Micro »  
Back to top
WWW  
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12071
Location: United Kingdom
Joined: Apr 10th, 2010
Re: GDB on nRF boards
Reply #11 - Jan 16th, 2017 at 9:49pm
Print Post  
I left a debug prompt in by mistake. You are not seeing a crash but a prompt for debug. If you click Cancel it should continue without crash?
  
Back to top
WWW  
IP Logged
 
rml
Junior Member
**
Offline


Posts: 38
Joined: Aug 29th, 2016
Re: GDB on nRF boards
Reply #12 - Jan 20th, 2017 at 6:58pm
Print Post  
Hi Tim,

Just tried with the latest version of VM: the new error message is gone, however I am unable to debug using st-link.

I changed my platform.txt from:

tools.gdb.openocd.intf={upload.interface}
tools.gdb.openocd.stp={upload.setup_command}
tools.gdb.openocd.pattern="{path}/{cmd}" -s "{path}/scripts/" -f "{path}/scripts/interface/{intf}.cfg" -c "{stp}" -f "{path}/scripts/target/{upload.target}.cfg"

to

tools.gdb.openocd.intf={program.interface}
tools.gdb.openocd.stp={program.setup_command}
tools.gdb.openocd.pattern="{path}/{cmd}" -s "{path}/scripts/" -f "{path}/scripts/interface/{intf}.cfg" -c "{stp}" -f "{path}/scripts/target/{upload.target}.cfg"

but I am getting an error message reading "Unable to start debugging. Cannot access a disposed object. Object name: 'Debugger'.". Upload works fine.

I guess ideally what I would need is a XXX so that I can write
tools.gdb.openocd.intf={XXX.interface}
tools.gdb.openocd.stp={XXX.setup_command}
and it would work regardless of whether I am using the onboard J-Link or an external debugger.
Thanks!
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12071
Location: United Kingdom
Joined: Apr 10th, 2010
Re: GDB on nRF boards
Reply #13 - Jan 20th, 2017 at 7:16pm
Print Post  
Yes thanks I wondered about that. I guess xxx needs to be upload or program?

Maybe we need an upload.method=
  
Back to top
WWW  
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12071
Location: United Kingdom
Joined: Apr 10th, 2010
Re: GDB on nRF boards
Reply #14 - Jan 20th, 2017 at 7:17pm
Print Post  
Or maybe a menu item to select the debugger programmer?
  
Back to top
WWW  
IP Logged
 
rml
Junior Member
**
Offline


Posts: 38
Joined: Aug 29th, 2016
Re: GDB on nRF boards
Reply #15 - Jan 20th, 2017 at 7:32pm
Print Post  
Yes the XXX would have the same values as 'upload' or 'program' depending on the case (actually I am not sure why Arduino handles them differently).

It would be fair to assume that if the user is using an external programmer to upload, he will want to use it to debug as well, so maybe the only change would to the menu caption "Aways Use Programmer for Upload and Debugging (Instead of Port/IP)", without adding a new menu item.
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12071
Location: United Kingdom
Joined: Apr 10th, 2010
Re: GDB on nRF boards
Reply #16 - Jan 20th, 2017 at 9:06pm
Print Post  
I've had a thought. I think it might optionally be more flexible to allow gdb to be defined per programmer

Something like this defined for each programmer

program.gdb.openocd.intf={program.interface}
program.gdb.openocd.stp={program.setup_command}
program.gdb.openocd.pattern="{path}/{cmd}" -s "{path}/scripts/" -f "{path}/scripts/interface/{intf}.cfg" -c "{stp}" -f "{path}/scripts/target/{upload.target}.cfg"

The default tools. would be used if a specific definition does not exist.
  
Back to top
WWW  
IP Logged
 
rml
Junior Member
**
Offline


Posts: 38
Joined: Aug 29th, 2016
Re: GDB on nRF boards
Reply #17 - Jan 20th, 2017 at 9:27pm
Print Post  
I am not sure if the 'interface' and 'setup_command' of a given programmer (say J-Link) is different when it is used for programming or for uploading.
  
Back to top
 
IP Logged
 
rml
Junior Member
**
Offline


Posts: 38
Joined: Aug 29th, 2016
Re: GDB on nRF boards
Reply #18 - Jan 20th, 2017 at 9:33pm
Print Post  
It seems to me (based on my limited understanding of all the details !) that the programmers / uploaders are already well defined, but the difficult part is to get hold of their parameters to correctly launch the debug session
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12071
Location: United Kingdom
Joined: Apr 10th, 2010
Re: GDB on nRF boards
Reply #19 - Jan 27th, 2017 at 12:46pm
Print Post  
Yes however its possible that different or additional info is required for some programmers

There is a new property in the next release with "upload" or "program" in it. I will publish the name in the release notes. 

It might solve your requirement and no reason not to allow additional config per programmer in the future.

{deploy.transport_type}

deploy.transport_type=upload
deploy.transport_type=program
« Last Edit: Jan 28th, 2017 at 2:16pm by Tim@Visual Micro »  
Back to top
WWW  
IP Logged
 
Page Index Toggle Pages: [1] 2 
Send TopicPrint