Once again: Debugging with GDB

Go To Last Post
166 posts / 0 new

Pages

Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

Freaks!

 

 

 

I'm pondering taking a new stab (far-fetched pun intended) on finding a complete development environment for AVRs other than Atmel Studio. The critical thing is on-chip debugging. The goal is to move away from Windows before the only viable Windows-alternative is the dreaded Windows 10.

 

I'm thinking of this as a multi-stage rocket. To begin with I will work on Windows to have a setup that does not rely on Studio, but will use things that came with the Studio install (toolchain, system libs and headers...).

 

My IDE of choice to begin with will likely be NetBeans. I already have it working with the C compiler targeting Windows (i.e. to write programs that executes on Windows). I am confident I will get it working with the Atmel toolchain that came with Atmel Studio.

 

Programming/debugging hardware will be an Atmel-ICE (and, if that is too new for AVRDUDE, then I can fall back to a Dragon).

 

Starting out:

 

1. Get NetBeans working with the toolchain from the Studio install to build an ELF.

 

2. Convince NetBeans to create the Intel Hex file from the ELF.

 

Flash programming:

 

3. I am content with running AVRDUDE from the command line to begin with.

 

Debugging:

 

4. Get a debugging stack running, with ATBACKEND as the "driver" for the Atmel-ICE. I'm hoping to be able to connect to a target system running code downloaded with AVRDUDE. (This is, of-course an intermediary solution.)

 

5. Get the same debugging stack running with AVARICE as the driver. Possible sub-steps:
5a) Get GDB-AVARICE-AtmelICE-target working. Check with simple GDB commands.
5b) Get NetBeans to talk to the stack from 5a.

 

6. Flash programming as first step of debugging session: Get AVARICE to program the firmware when starting a debug session.

 

7. Explore actual debugging possibilities with this setup. How do you watch a variable? A SFR? Breakpoints. Stepping. Etc etc..

 

Once this is working, I might consider moving from Windows to GNU/Linux. At this stage I'm hoping to be familiar with the ins and outs of setting up the stack, and what I can expect of the debugging experience.

The subject has been raised many times here at AVRfreaks, several times by me. I have done some searches for previous threads and found some of them, but not all. I am convinced there was a thread where someone described, in detail, how to set this up, but I'm stumped trying to locate it again.

 

Any hands-on info on how to go about this, explanations on how such a debug stack actually fits together (roles, parameters, ports talked on, etc etc) will be gratefully accepted!

 

I have lost an old list of links to relevant threads on the subject. If anyone has links that are not in my list below, I'm happy if you post them.

 

War-cry: No Windows 10 for me!! I can gladly accept that the debugging experience will not be as "smooth" as in Atmel Studio, if that is what it takes to avoid Windows 10.

 

Promise: If I get this working in any reasonable way I promise I will write and publish a guide/howto on the subject for others to prosper from.

 

Any advice or hard facts that will help me conquer this beast is welcome!

 

[Grovel version: Help! Please...]

 

 



APPENDIX - Some previous threads
 

(Long list!)

 

For any-ones reference, below is a bunch of threads I've found.

 

Format:

    <date> <author>
    <title>
    <link>

    <resume, notes etc>

 


2014-10-03 johanekdahl (me!)
Atmel AVR 8-bitters debugging and GDB
http://www.avrfreaks.net/forum/a...

 

Where I ask questions about how to run a debugging session with GDB, and Morten gives some sweeping "politically correct" answers. [Morten, please don't take that as offensive! I fully understand the position you're in ;-) ]


2017-05-10 mojo-chan
Debugger
http://www.avrfreaks.net/forum/l...

 

Where mojo-chan and clawson has an interesting discussion on debugging on Linux with a stack like <Some IDE> - <avr-gdb> - <avarice> - <debug dongle> - <target AVR>. I chime in with some brou-ha-ha. 

Then Morten mentions a "debug adapter for Visual Studio Code". VSC can run on other platforms than Windows, but the "debug adapter" only talks to atbackend so that seems to be a dead end for Linux. (Besides, I'm after something that plugs into any of the cross-platform IDES like Eclipse, NetBeans, CodeBlocks...)

THere are hints of a Linux build of atbackend being built and existing inside Atmel/Microchip, but again (fully understandably) Morten is secretive.

Morten then goes into specifics about the atbackend "upwards" protocol - its based on TCF (an open Eclipse standard - http://www.eclipse.org/tcf/ ). I'm not sure what to make out of that. Yet..


2016-03-03 sq5rix 
Atmel-ICE, avarice, Eclipse and debugging in Ubuntu
http://www.avrfreaks.net/forum/a...

 

sq5rix has built AVARICE on GNU/Linux, and got the connection between AVARICE and GDB working. He then runs Eclipse but fails to start a debugging session. I have not dug into what he's experiencing - I'm just to inexperienced with this to "get it".


PDF: Howto develop AVR programs using the Code:Blocks IDE
http://www.avrfreaks.net/sites/d...

 

I'm sure that there is a link to this PDF in some thread, but have not been able to locate it...

And I have still to read it.


2007-04-23 nleahcim
debugging with winAVR?
http://www.avrfreaks.net/forum/d...

 

An older discussion where debugging is touched upon. INcluded here just because Cliff uses the term "Porcine aviation" which I find wonderful.. ;-)


2013-08-10 Microgala
AVR GCC Debug in Eclipse
http://www.avrfreaks.net/forum/a...

 

In post #28 I (!) claim to have a stack of <GDB>-<AVARICE>-<Dragon> up and running. I have no memory whatsoever about doing that! (But can see no point in lying about it so I suppose it's true - this was shortly after I did some work on LuminaryStellaris, and wrestled with integrating OpenOCD and GDB in a stack beneath Eclipse, so I might have known something then that I've forgotten by now..) In the post I speculate about using stuff from the WinAVR distribution, so no good way forward now..


2011-08-31 johanekdahl (me!)
Anyone actually using AVaRice?
http://www.avrfreaks.net/forum/a...

 

A rather old thread, talking about using stuff in WinAVR. Not a path to go down now...


2012-12-22 martinus26
AVR eclipse linux hw debug
http://www.avrfreaks.net/forum/a...

 

An attempt at <Eclipse>-<GDB>-<AVARICE>-<Dragon> . Fails in Eclipse "at 97%"..


2015-10-04 Vcros
Debugging Atmega128 in NetBeans IDE
http://www.avrfreaks.net/forum/d...

 

Asking about debugging using NetBeans.

I answer in general terms. Comes to nothing..


2016-03-02 PaulVdBergh
Debugging with Dragon in Eclipse under Debian 8
http://www.avrfreaks.net/forum/d...

 

Paul asks the eternal question. Does not come to anything specific..


2015-12-05 dallas_clement
debugging SAM D21 with gdb / openocd
http://www.avrfreaks.net/forum/d...

 

Talks about debugging SAM D21 using OPENOCD. Not re AVRs as such, but included here as it might hint to the general structure of the "stack setup".


jps 2010-10-20
Debugging with AVR plugin for Eclipse
http://www.avrfreaks.net/forum/d...

 

Claims successful - using "AVR plugin for Eclipse". See  http://avr-eclipse.sourceforge.n... ! A detailed description of involved software and setup.

I have still to read this in detail..


END OF LIST

 

"He used to carry his guitar in a gunny sack, or sit beneath the tree by the railroad track. Oh the engineers would see him sitting in the shade, Strumming with the rhythm that the drivers made. People passing by, they would stop and say, "Oh, my, what that little country boy could play!" [Chuck Berry]

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

More power to you, Johan!

 

Jim

Jim Wagner Oregon Research Electronics, Consulting Div. Tangent, OR, USA http://www.orelectronics.net

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Following with anticipation!

"Experience is what enables you to recognise a mistake the second time you make it."

"Good judgement comes from experience.  Experience comes from bad judgement."

"When you hear hoofbeats, think horses, not unicorns."

"Fast.  Cheap.  Good.  Pick two."

"Read a lot.  Write a lot."

"We see a lot of arses on handlebars around here." - [J Ekdahl]

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

May you create joy!

 

JohanEkdahl wrote:
Programming/debugging hardware will be an Atmel-ICE (and, if that is too new for AVRDUDE, then ...
Atmel-ICE is in AVRDUDE 6.3 and AVaRICE (post 2.13, r358 and subsequent)

AVaRICE r347 (post 2.13) has JTAGICE3.

JohanEkdahl wrote:
4. Get a debugging stack running, with ATBACKEND as the "driver" for the Atmel-ICE.
In the interim, acceptable to operate a virtual machine?  (macOS or Linux host, Windows guest running atbackend.exe)

Reasons :

  • zero price Windows 10 virtual machines; not zero cost due to watermarks, nags, and periodic re-installs of Atmel Studio 7.
  • zero price Windows 8.1 virtual machines

JohanEkdahl wrote:
5a) Get GDB-AVARICE-AtmelICE-target working.
Eclipse-GDB-AVaRICE-JTAGICE3-Arduino should work via PlatformIO 2 but:

  • AVR GDB was removed from PlatformIO 3 replaced by a unified debugger for ARM Cortex-M and TI MSP430.
  • PlatformIO is for a subset of AVR (some megaAVR, some tinyAVR, no XMEGA AVR)

 

P.S.

JohanEkdahl wrote:
The goal is to move away from Windows before the only viable Windows-alternative is the dreaded Windows 10.
There are ways to put Windows 10 in its place.

Otherwise, by operating Windows 8.1 one can kick the can down the road to 2023-Jan.

macOS has greater desktop and notebook usage than Linux; someone could likewise create for macOS (not me for I'm not a macOS operator)

AVaRICE 2.13 (AVR JTAGICE2, AVR Dragon) is in CrossPack AVR with a macOS Xcode 5 integration.

AVRDUDE 6.3 is in macOS Homebrew.

Xcode apparently has a command line GDB interface.

more at http://www.avrfreaks.net/forum/avr-studio-mac-linux

 


AVR Downloader/UploaDEr - News: AVRDUDE 6.3 released

http://savannah.nongnu.org/forum/forum.php?forum_id=8461

...

 

* New programmers supported:

...

- Atmel-ICE (ARM/AVR), JTAG, PDI, debugWIRE, ISP modi

 

...

https://sourceforge.net/p/avarice/code/commit_browser

https://packages.debian.org/stretch/avarice (Debian, stable, AVaRICE, 2.13+svn347-4)

Microsoft

Microsoft

Windows app development

Download a Windows 10 virtual machine

https://developer.microsoft.com/en-us/windows/downloads/virtual-machines

Discover Vagrant Boxes

https://app.vagrantup.com/boxes/search?utf8=%E2%9C%93&sort=downloads&provider=&q=Windows+8.1

via

Vagrant by HashiCorp

https://www.vagrantup.com/

(Find Boxes button)

http://www.ikravets.com/computer-life/programming/2014/06/20/building-and-debugging-atmel-avr-arduino-based-project-using-eclipse-ideplatformio 

PlatformIO Unified Debugger

http://docs.platformio.org/en/latest/plus/debugging.html

Texas Instruments

MSPDS MSP Debug Stack

http://www.ti.com/tool/mspds

http://docs.platformio.org/en/latest/platforms/atmelavr.html#packages 

http://docs.platformio.org/en/latest/ide/netbeans.html

Microsoft

Microsoft

Support Lifecycle

Windows 8.1 Pro

https://support.microsoft.com/en-us/lifecycle/search/17648

https://github.com/obdev/CrossPack-AVR

http://braumeister.org/formula/avrdude (macOS, Homebrew packages, AVRDUDE)

Apple

Developer

GDB and LLDB Command Examples

https://developer.apple.com/library/content/documentation/IDEs/Conceptual/gdb_to_lldb_transition_guide/document/lldb-command-examples.html

 

"Dare to be naïve." - Buckminster Fuller

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Everyone: Thank you for the cheers!

 


 

I've been trawling the net a lot, and my trawl-fu has not been good. I hoped for some tutorial'/article/whatever that explains a GDB stack in general (not necessarily specific to AVRs), and how things fit together in detail. What to configure. What kind of traffic goes where. What "format" it has.

 

It seems there is a bunch of people "in the know" who never  talk to us that are not in the know.

 

Frustrating. I need to understand this thoroughly in order to work with it..

 


 

gchapman wrote:
There are ways to put Windows 10 in its place.

[Perhaps, but

1) MS seems to invent new cushions for those kicks, as evident by several posts here, making this an eternal kick-boxing fight, and

2) I'm not interested in kick-boxing with Windows10

Please keep that discussion out of here. Lets focus on the ultimate goal of having a truly cross platform debugging setup.

 

I'm starting out on Windows, trying to get debugging going, just to not have too many variables changing at one time. Once/if I get a non-Studio debugging solution up and running it'll be time to move it to GNU/Linux. (Just following my own "small steps" advice..)

 

Likewise, using ATBACKEND is such an intermediary step - just for the learning experience. Interim Windows<whatever> in virtual machines are not contributing to any learning experience.

 

quote=gchapman]macOS has greater desktop and notebook usage than Linux

 

Since all recent Mac OSes are Unix/BSD based then I anticipate a GNU/Linux solution would not be that hard to carry over to Macs.

 

"He used to carry his guitar in a gunny sack, or sit beneath the tree by the railroad track. Oh the engineers would see him sitting in the shade, Strumming with the rhythm that the drivers made. People passing by, they would stop and say, "Oh, my, what that little country boy could play!" [Chuck Berry]

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

6 - don't.
.
Avarice actually says "do the programming with (maintained) avrdude, not this"

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Status report:

 

  • Searching the net, reading, thinking and trying to create a "knowledge map" so that I can get some structure to this. I am still in somewhat of a mist here..
  • Fiddling with NetBeans to get it to build an avr-gcc project. I have a problem with make not behaving. Could be something with incompatible versions, NetBeans emitting a makefile that my Make does not like. Sorry no details, but this one does not scare me much. I'll get that sorted.
  • When the Make issue is sorted, I'll turn to generating the .hex file. I am confident I'll get that sorted too - i.e. run objcopy with fitting switches and parameters.

 

Doing the build in NetBeans is not something that is strictly necessary for getting debugging going - but it would be nice. If I, for some weird reason, does not get the build working in NetBeans I can fall back to e.g. running Make on the command line. Again, I'm not worried about Make per se, and the wonderful MFile utility makes this easy.. (-:

 

I will probably let this rest for a day or two no, as I have some unrelated stuff to tend to.

 

But if you have anything to contribute, then please do so. I can use all the help I can get! (-:

 

clawson wrote:
6 - don't. . Avarice actually says "do the programming with (maintained) avrdude, not this"

Noted. I was hoping that starting AVaRICE with the "correct" parameters would be a one-stop for getting the firmware flashed and the session started... So now it looks like

  1. Flash with AVRDUDE
  2. Start AVaRICE
  3. "Attach" GDB
  4. Test debugging with the GDB command line.
     
  5. When that works, move to getting an IDE (e.g. NetBeans) on top of this and debugging from there.

 

This last step is the one I'm excited and curious about. What will the experience be? Can I effortlessly watch variables? Can I watch registers (both GP/CPU and SF/IO)?

"He used to carry his guitar in a gunny sack, or sit beneath the tree by the railroad track. Oh the engineers would see him sitting in the shade, Strumming with the rhythm that the drivers made. People passing by, they would stop and say, "Oh, my, what that little country boy could play!" [Chuck Berry]

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]

Last Edited: Sun. Jul 2, 2017 - 04:29 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Johan. You do know that there is a switch in AS7 where you can switch between their debugger and avr-gdb? If you switch that in theory you don't actually see any difference in the top level debugging experience. So the bottom line is that, if done right, it shouldn't really feel any different whether AS7 or Eclipse or NetBeans etc. (though I guess each is subtly different in their UI?)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Yes Cliff, but it's more about what the IDE caters for the experience than what GDB offers. It's obvious that Atmel has put a lot of code into getting some of the debug views nice. Processor and the SFR views especially. I'm just curious re how it will look in another IDE that knows nothing specific about AVRs.

"He used to carry his guitar in a gunny sack, or sit beneath the tree by the railroad track. Oh the engineers would see him sitting in the shade, Strumming with the rhythm that the drivers made. People passing by, they would stop and say, "Oh, my, what that little country boy could play!" [Chuck Berry]

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Oh you can't expect SFR/IO like views in non-AS7. What's more you are going to see RAM vars as 0x800060 based (or whatever)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

clawson wrote:
Oh you can't expect SFR/IO like views in non-AS7.
Microsoft Visual Studio has been extended to add some AVR IO :

VisualGDB

Developing firmware for AVR devices with Visual Studio

April 1, 2016

https://visualgdb.com/tutorials/avr/

...

13. You can use the Hardware Registers window to view and quickly change the values of various registers. ...

...

"Dare to be naïve." - Buckminster Fuller

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

clawson wrote:
Oh you can't expect SFR/IO like views in non-AS7.

I understand that. I'm till curious as to how/what I actually can see.

 

gchapman wrote:
Microsoft Visual Studio has been extended to add some AVR IO

Yes, gchapman, but I'm not interested in Visual Studio. Can we please keep it out of this thread? Please?

"He used to carry his guitar in a gunny sack, or sit beneath the tree by the railroad track. Oh the engineers would see him sitting in the shade, Strumming with the rhythm that the drivers made. People passing by, they would stop and say, "Oh, my, what that little country boy could play!" [Chuck Berry]

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

gchapman wrote:

Microsoft Visual Studio has been extended to add some AVR IO :

JohanEkdahl wrote:

Lets focus on the ultimate goal of having a truly cross platform debugging setup.

Is MVS available for non-Windows platforms (other than Mac)?

 

Never mind...  I have to read/type faster ;-)

"Experience is what enables you to recognise a mistake the second time you make it."

"Good judgement comes from experience.  Experience comes from bad judgement."

"When you hear hoofbeats, think horses, not unicorns."

"Fast.  Cheap.  Good.  Pick two."

"Read a lot.  Write a lot."

"We see a lot of arses on handlebars around here." - [J Ekdahl]

 

Last Edited: Sun. Jul 2, 2017 - 06:43 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I have only a very limited knowledge of GDB But I'm running linux exlusively now for several years.

I'm not much into all the "sophisitaded stuff" and still use self written make files.

Not because I like them, but because of the flexibility they offer.

They let me easily switch between whatever IDE I fancy at any given time without much reconfiburing.

I'm not programming much lately, but I like QT creator for AVR development.

 

Maybe I should update it someday, but this version caters for my needs:

Qt Creator 3.0.1
Based on Qt 5.2.1 (GCC 4.8.2, 64 bit)
Built on Apr 9 2014 at 09:12:59
Copyright 2008-2014 Digia Plc. All rights reserved.

GDB is divided in front ends and back ends, which communicate to each other over a tcp/ip port.

They can both be on localhost, but there can also be a long cable between them for remote debugging.

You can interact with GDB via the command line (handy for testing) but it's usually done via some graphical / mouse clickable  -interface.

Some ide's have direct support for GDB, but you can also use it standalone.

 

My only dabble with debugging an AVR was via a clone of the original avr jtag V1 a long time ago.

Never got it to work (But I also didn't try very hard).

 

Over a year ago I was experimenting a bit with STM32.

I followed the tutorial from "pandafruits", which I truly find marvellous.

A part of the tutorial was getting GDB to connect to the uC via ST-Link V2.

I got this part working in 10 minutes or so.

Unfortunately I haven't had a good project to put these skills to use and most of my knowledge has faded a lot.

I haven't yet tried to connect to it from the QT Creator IDE.

Paul van der Hoeven.
Bunch of old projects with AVR's:
http://www.hoevendesign.com

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

This would be really great! I've always used CLI with avrdude and custom Makefiles after the fall of WinAVR, but keeping the toolchain updated is tricky. Moving from AVR to ARM has caused me to use Atmel Studio to get a feel for things, meaning Windows instead of Linux, and AS7 crashes constantly and doesn't play well with my preferred directory structure. I've done my best to make some crazy Make chains based on Dean's DMBS that auto generate libraries for various architectures and such, cross- compatible with mega and tiny chips... testing with cortex-M0 now.

Respectfully,
Kurt E. Clothier

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

kurt.e.clothier wrote:
but keeping the toolchain updated is tricky
But Atmel keep making "Atmel Toolchain for Linux" available as .tar.gz, what's "tricky" about taking those updates?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

clawson wrote:

kurt.e.clothier wrote:
but keeping the toolchain updated is tricky
But Atmel keep making "Atmel Toolchain for Linux" available as .tar.gz, what's "tricky" about taking those updates?

 

Here: http://www.atmel.com/tools/ATMEL...

"He used to carry his guitar in a gunny sack, or sit beneath the tree by the railroad track. Oh the engineers would see him sitting in the shade, Strumming with the rhythm that the drivers made. People passing by, they would stop and say, "Oh, my, what that little country boy could play!" [Chuck Berry]

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Just found something interesting. If you follow the link back to "source" you get to all the stuff for 3.5.4 but if you go up one level from there you get to:

 

http://distribute.atmel.no/tools...

 

and that has a 3.6.0 here:

 

http://distribute.atmel.no/tools...

 

which might be preferable.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Sorry, not tricky to get the updates... tricky to remember to get the updates.

Respectfully,
Kurt E. Clothier

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

OK, this has been resting for a few days.. I'm thinking of two "experiments" to understand how things fit together - and to get something working, to gsin some self-confidence re the subject.

 

I need any help or tips I can get on on these:

 

1. Run GDB on top of ATBACKEND

As I understand it, these two are enough for getting a rudimentary debug stack up'n'running. I'm content with getting thi to work to the point where I can give any GDB command respond in a reasonable way - to see that this setup works.

 

Does anyone know how to start ATBACKEND. The help is terse, to say the least.

- Will it "discover" my Atmel-ICE by itself, or do I need to tell it something?

 

- Will it discover the target AVR by itself or do I need to tell it something?

 

- I believe it communicates upward (e.g with GDB on a TCP port. Is that correct? Do I need to tell ATBACKEND which port it shall use or is there a standard? Anything else?

 

When I start GDB;

 

- Do I need to tell it on which port it should communicate "downwards" with ATBACKEND?

 

- Do I need to tell it anything about the target AVR?

 

- What is a good first command to GDB to test if the whole chain is working?

 

2. Run GDB on top of AVaRICE

 

I'll start with this simple question:

 

- Where can I get a Windows build (a "binary") of AVaRICE? (I suppose I could extract one out of WinAVR but that would be 7.5 years old by now. Does anything newer exists.

 

If I get my hands on an AVaRICE binary for Windows, then the follow-up questions will more or less be the same as for ATBACKEND.

 

Driver needed?

 

Do I need a driver "beneath" ATBACKEND and/or AVaRICE? Which one?

 

Remember..

These tests are just a first step for understanding the general "infrastructure". The ultimate goal is to run GDB - AVaRICE - (driver?) - JTAGdongle - targetAVR on GNU/Linux.

"He used to carry his guitar in a gunny sack, or sit beneath the tree by the railroad track. Oh the engineers would see him sitting in the shade, Strumming with the rhythm that the drivers made. People passing by, they would stop and say, "Oh, my, what that little country boy could play!" [Chuck Berry]

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The only avarice.exe I know of is that Winavr one. I doubt there's much demand for non-Studio debugging in Windows. Avarice comes into its own in Linux where it's basically the only option. 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

JohanEkdahl wrote:
- Where can I get a Windows build (a "binary") of AVaRICE?
A Cygwin version is available on the official AVaRICE page http://avarice.sourceforge.net/

Go to the file download area and there at the top (above the table) is a download link for the latest Cygwin build.

Stefan Ernst

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thank you both!

 

@clawson: I'd like to not complicate things, so building a recent AVaRICE for windows is out of the question. I might resort to getting a Dragon out of th box with oldish stuff and use the WinAVR build of AVaRICE.

 

@sternst: I'm not a CygWin person. I've learned to avoid if at all possible. too meny times in the distant path I was hit by different incompatible versions of cygwin1.dll. These days I prefer MinGW/MSYS.

 

Repeat: Anyone with advice or hints on how to actually start up ATBACKEND/AVaRICE and GDB in an orderly manner? Any tips or web links to material to get started? I usually get along well searching The Web but here I've sort of come out stumped..

"He used to carry his guitar in a gunny sack, or sit beneath the tree by the railroad track. Oh the engineers would see him sitting in the shade, Strumming with the rhythm that the drivers made. People passing by, they would stop and say, "Oh, my, what that little country boy could play!" [Chuck Berry]

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Try running procexp from sysinternals when AS7 has spawned the backend. I'm pretty sure it will reveal the command line that invoked it.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Nice tip, Cliff! (-:

"He used to carry his guitar in a gunny sack, or sit beneath the tree by the railroad track. Oh the engineers would see him sitting in the shade, Strumming with the rhythm that the drivers made. People passing by, they would stop and say, "Oh, my, what that little country boy could play!" [Chuck Berry]

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Recently I switched most of my development work back from Linux to Windows. It is a very poor development environment for a professional programmer but one of the true highlights for me are the Mark Russinovich tools from SysInternals (later assimilated by M$). They are a shining beacon in helping you understand Windows and its operation.

Last Edited: Sat. Jul 8, 2017 - 07:10 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I have got debugging working with NetBeans, OpenOCD and Atmel-ICE.  This is using the ATSAM3X8E (custom Arduino DUE) not an AVR though.  I am going to have a look at doing the same for the AVR's as next.  I'll let you know how I get on.  I'm also using Makefiles as well.  The Makefile is for Arduino based projects.

 

I was using AS7 and Visual Micro previously but it wasn't possible to have real debugging with this set up.  My preference is Linux and I prefer cross platform tools where possible.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

@TT_ZX: Is it possible for you to give a short intro to how you get the NetBeans - GCC -OpenOCD - Atmel-ICE - SAM stack up and running? PLEASE!?! I plead, grovel and bow in humbleness! ;-)

 

(On the table ATM is an Atmel ICE and a SAM D20 Xplained board. I am looking for all learning experiences I can possibly find and be successful in!)

 

Re makefiles, I have no problems with that. Not an obstacle.

 

 

"He used to carry his guitar in a gunny sack, or sit beneath the tree by the railroad track. Oh the engineers would see him sitting in the shade, Strumming with the rhythm that the drivers made. People passing by, they would stop and say, "Oh, my, what that little country boy could play!" [Chuck Berry]

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I am using Gentoo and have installed openocd-0.10.0.  Create a project folder for you source files and create a config file for OpenOCD:

 

#filename openocd.cfg

# Atmel-ICE JTAG/SWD in-circuit debugger.
interface cmsis-dap
cmsis_dap_vid_pid 0x03eb 0x2141

# Chip info
set CHIPNAME at91sam3x8e
source [find target/at91sam3ax_8x.cfg]

$_TARGETNAME configure -event gdb-attach {
  halt
}

$_TARGETNAME configure -event gdb-attach {
  reset init
}
 

Adjust to suit your chip (atmel_samd20_xplained_pro.cfg I think).  Not attach you Atmel ICE and run openocd in a terminal from inside your project folder.  You should get something like this:

 

Open On-Chip Debugger 0.10.0
Licensed under GNU GPL v2
For bug reports, read
        http://openocd.org/doc/doxygen/b...
Info : auto-selecting first available session transport "swd". To override use 'transport select <transport>'.
adapter speed: 500 kHz
adapter_nsrst_delay: 100
cortex_m reset_config sysresetreq
Info : CMSIS-DAP: SWD  Supported
Info : CMSIS-DAP: JTAG Supported
Info : CMSIS-DAP: Interface Initialised (SWD)
Info : CMSIS-DAP: FW Version = 01.26.0081
Info : SWCLK/TCK = 1 SWDIO/TMS = 1 TDI = 1 TDO = 0 nTRST = 0 nRESET = 1
Info : CMSIS-DAP: Interface ready
Info : clock speed 500 kHz
Info : SWD DPIDR 0x2ba01477
Info : at91sam3x8e.cpu: hardware has 6 breakpoints, 4 watchpoints

 

That's the first step so get that working and I'll most the next steps soon.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

TT_ZX wrote:
That's the first step

THANK YOU! I am most grateful! This is the first hard advice/help I've seen on how to get going with non-Windows debugging.

I will test it soon(ish).

 

The OpenOCD/SAM case is just as interesting as the AVaRICE/AVR case:

1) I've recently started dabbling with the SAM D family, and

2) There's enough common structure here so that understanding one helps understanding the other.

 

TT_ZX wrote:
I'll [post] the next steps soon

No big hurry - take your time. I have some family business and stuff coming up the next few days and need to get that out of the way first.

 

As promised in my OP, if/when I get stuff like this working I will make the best write-up I can of it. So, no need for you to be nitpicking - as long as I understand and can use what you post, that 's enough!

 

Once again: THANK YOU!

 

Did I say?: THANK YOU!

"He used to carry his guitar in a gunny sack, or sit beneath the tree by the railroad track. Oh the engineers would see him sitting in the shade, Strumming with the rhythm that the drivers made. People passing by, they would stop and say, "Oh, my, what that little country boy could play!" [Chuck Berry]

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]

Last Edited: Tue. Jul 11, 2017 - 07:33 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

This what I use for my toolchain:

https://launchpad.net/gcc-arm-embedded

 

Download the latest version and extract it somewhere convenient.  Now run this command:

path_to_tool_chain/gcc-arm-none-eabi-5_4-2016q3/bin/arm-none-eabi-gdb -iex "target extended-remote localhost:3333"

 

You should get something like this:

 

GNU gdb (GNU Tools for ARM Embedded Processors) 7.10.1.20160923-cvs
Copyright (C) 2015 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "--host=i686-linux-gnu --target=arm-none-eabi".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/....
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/....
For help, type "help".
Type "apropos word" to search for commands related to "word".
Remote debugging using localhost:3333
0x0008076c in ?? ()
(gdb)

 

If you got that then the OpenOCD is working.  Now time to make it work in NetBeans.

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

As I'm currently on Windows I am hoping to get something going on that platform as a first learning experience.

 

I've found these Windows builds of OpenOCD and hope they will work: http://www.freddiechopin.info/en...

 

The release notes talks about support for Cortex-M3, and although there is no talk about supporting the D20 Xplained Pro board there is support for other Xplained boards so I'm having my fingers crossed.

 

The OpenOCD documentation (Users Guide) seems to cover a lot (172 pages!) and is included in these downloads. I'd rather have to much to read than too little! (-:

 


 

Don't get this wrong. The plan is to get this working on GNU/Linux, but I don't have a GNU/Linux machine handy ATM (apart form Virtual Box machines, and I don't want to have any guest/host USB problems in play, at least starting out). The "intermediate plan" is to get a boot'able GNU/Linux onto a USB stick or some such and run from there - until I can allocate and set up a physical machine with GNU/Linux. But first a try to get this running on Windoze. If that fails, I'll go for the intermediate USB stick GNU/Linux.

"He used to carry his guitar in a gunny sack, or sit beneath the tree by the railroad track. Oh the engineers would see him sitting in the shade, Strumming with the rhythm that the drivers made. People passing by, they would stop and say, "Oh, my, what that little country boy could play!" [Chuck Berry]

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Ok, let's give some specifics then smiley...

PS > .\atbackend.exe /h
usage: atbackend OPTIONS
Atmel Backend.

/clean                     Start with clean code cache.
/bundles=paths             Specify a semicolon-separated list of bundles or
                           bundle repositories.
/help                      display help information on command line arguments
/config-file=file          load configuration data from a file
/connection-port=port      port used to listen for TCF connections
/websocket-port=port       port used for websocket connections
/start-discovery           start discovery protocol
/no-stdin                  obsolete
/wait                      Wait for a keypress before exiting
/avr8-gdb-ports=ports      Listen for incoming avr8-gdb connections on
                           specified port
/armM-gdb-ports=ports      Listen for incoming cortex M/R arm-gdb connections
                           on specified port
/armA-gdb-ports=ports      Listen for incoming cortex A arm-gdb connections on
                           specified port
/exit                      Exits immediately. Most often used with /clean.
/listen-on-any-ip-address  Listen on any IP address. Default is
                           localhost(127.0.0.1).
/version                   Exits immediately.

The ones you want to have a look at is the -gdb-ports set. Choose the one for the target you want (avr8 or armM). Run atbackend with this set to something (4712 in my case)

PS > .\atbackend.exe /avr8-gdb-ports=4712

Now, for the gdb client. Find the path to the correct one, avr-gdb-py in my case 'cause i'm cool (remember, new terminal, atbackend needs to run somewhere)

"C:\Program Files (x86)\Atmel\Studio\7.0\toolchain\avr8\avr8-gnu-toolchain\bin\avr-gdb-py.exe" -iex "target remote :4712"

Note the -iex part, this is just 'some command to run when gdb has started'. You can drop it and type it into gdb once it has started as well. The line tells gdb to connect to a target on the remote protocol on local port 4712. Some gobbeldygook later, the terminal says

Remote debugging using :4712
0x00000000 in ?? ()
(gdb)

You're now connected to atbackend acting as a gdb-server. Note that this is just a proof-of-concept implementation and it may go completely nuts at any time :) If your atbackend is set up to log (I run debug versions so it's a lot of logs), you'll see the raw GDB packets being sent in the atbackend terminal.

 

Wait, how do you give the tool, interface, device etc? This is done using monitor commands. In your trusty gdb terminal, type monitor help

(gdb) monitor help
Remote command help:
help       This help text
set        Set debug level
reset      Reset target
tool       Select debug connection
device     Select device to debug
pins       Set pins
props      Set target properties
reg        Set register
mode       Set session mode
(gdb)

Everything that is prefixed with 'monitor' in gdb is sent directly to the gdb-server (atbackend). So, this are the special gdb commands that atbackend implements. 

 

All commands self-document

(gdb) monitor tool
Usage: tool TOOLTYPE [SERIALNUMBER]
  or:  tool list
(gdb)

Let's set up on the simulator

(gdb) monitor tool list
com.atmel.avrdbg.tool.simulator
(gdb) monitor tool simulator

Set the device

(gdb) monitor device
Usage: device DEVICENAME [INTERFACE [INTERFACE_CLOCK_SPEED_IN_HZ]]
(gdb) monitor device ATmega2560

Almost ready for liftoff now, let's load in a elf file

(gdb) file "m2560.elf"
A program is being debugged already.
Are you sure you want to change the file? (y or n) y
Reading symbols from m2560.elf...done.
(gdb)

And, since this is embedded, the normal 'run' command doesn't really work. Let's set a breakpoint on main, reset the device, and run to the breakpoint.

(gdb) break main
Breakpoint 1 at 0xfa: file .././main.c, line 12.
(gdb) monitor reset
(gdb) continue
Continuing.

Breakpoint 1, main () at .././main.c:12
12      {
(gdb) list
7
8       #include <avr/io.h>
9
10
11      int main(void)
12      {
13          /* Replace with your application code */
14          while (1)
15          {
16          }
(gdb) backtrace
#0  main () at .././main.c:12
(gdb) 

(everything after (gdb) is something I write, if that wasn't obvious by now).

 

So, again, this was made inhouse as a complete proof of concept. If your debugger catches fire or the simulator initiates the new skynet, it will be your problem smiley

 

:: Morten

 

(yes, I work for Atmel, yes, I do this in my spare time, now stop sending PMs)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Morten!

 

THANK YOU! You're a gentleman and our savior on many occasions! All the best!

 

As I said, I'm having some upcoming family business (the more pleasant kind!) mid-week, and I'm hunting for my next job (everyday business as a consultant/contractor..) so prolly won't find the opportunity to test this for the next few days. But towards the week-end I should find the time so nothing you said, or will say, is wasted.

 

THANK YOU!

 

meolsen wrote:
If your debugger catches fire

Oh, they're all original Atmel devices.. Sturdy as hell! E.g can't pry off the USB connectors with a nuclear device if you tried.. Mind you, dropping the AVR One! from 30K feet would probably damage similar to Fat Man, and that (or a paper press) is the only use of it nowadays I suppose.. cheeky

 

Current inventory (IIRC) is 2 Atmel-ICE, 1 JTAGICE-3, 4 AVR Dragon (2nd generation), 1 AVR One!. So, I have backups if smoke emerges.

 

Not that it will, but I get the message in your disclaimer wink

 

Did I say?: THANK YOU!

"He used to carry his guitar in a gunny sack, or sit beneath the tree by the railroad track. Oh the engineers would see him sitting in the shade, Strumming with the rhythm that the drivers made. People passing by, they would stop and say, "Oh, my, what that little country boy could play!" [Chuck Berry]

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

@JohanEkdahl: I don't expect you to have any problems getting this working on Windoze.  I plan to do this as well so we'll see who gets to it first wink.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Once you have NetBeans installed you'll need to install plugins, C/C++ and Gdbserver, which may not be installed by default.  Now you need to set up your toolchain by going to Tools/Options.  On the C/C++ tab, add a new Tool Collection and fill in the paths to the toolchain you extracted earlier:

 

You will obviously need to adjust the paths to suit.  I'm not sure what is required for Make and Cmake on Windoze.  Maybe you will already have these installed.

 

Now click the Versions button to confirm all the required libraries are available.  This is what I get:

 

To be able to build and program via the Atmel ICE got to Run/Set Program Configuration/Customize.  Now go to Manage Configurations and add a new configuration.  Select the new configuration go to Build.  For Tool Collection, set this to the Tool Collection you just added.  Set Configuration Type to Make File.  Go to Run and enter 'openocd -f openocd.cfg -c  "program ${OUTPUT_PATH} verify reset exit"' without the single quotes.

 

Now you just have to hit the Run Project button and watch the magic happen (if you have the OpenOCD running in the backgroud, you will need to kill this first).  Your project will be compiled and them flashed onto the CPU with the Atmel ICE.  Or if not, you'll have to find what I've missed cheeky.

 

 

Last Edited: Tue. Jul 11, 2017 - 10:12 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

To start a debug session run OpenOCD in a terminal and leave it running.  Go to Debug/Attach Debugger.  In the Debugger drop down select gdbserver.  Set Target to "ext: 3333" without quotes.  The Target box appears greyed out to me but I could still type this in.

Now click OK.  You should now be attached to your debugger and should get these lines in the terminal you have OpenOCD running:

 

Info : accepting 'gdb' connection on tcp/3333
target halted due to debug-request, current mode: Thread 
xPSR: 0x01000000 pc: 0x0008076c msp: 0x20088000

 

 

You can now Pause, Step read and manipulate variables and all the good stuff I've never had the opportunity to do until recently.

 

So the one gotcha I haven't worked out is how to start and attach to the GDB server by just hitting the Debug Project button.  I not sure this is possible because of how the gdbserver plugin is implemented.  It's not a big deal but it would be nice.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hmmm. Lost a long post here.. Short version:

 

You guys are stellar!

 

 

@TT_ZX: Tell me if you're  preparing a serious/ambitious/long writeup. I have an embryo for such, and enjoy writing. But if you're already ahead of me there then I'll rather do other stuff. Aga in, I enjoy writing stuff. Just don't wanna double work, so let me know. (-:

 

My embryo will have four parts:

 

Part 1 : Introduction, overview, document info

Part 2: Shortest possible cook-books/recipes. If they work the user/reader is lucky and can hop to Part 4. If not, Part 3 applies.

Part 3: Details about the components/modules/softwares involved, what they do, how they interact with other parts, and everything I have learned about fault-seeking them.

Part 4: When everything works, how do you use it? What can you do? Etc.

 

I'm off for the family gathering tomorrow. Might not be here again until the week-end. And am I looking forward to trying all this out!

 

Thanks, for now!

"He used to carry his guitar in a gunny sack, or sit beneath the tree by the railroad track. Oh the engineers would see him sitting in the shade, Strumming with the rhythm that the drivers made. People passing by, they would stop and say, "Oh, my, what that little country boy could play!" [Chuck Berry]

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

@JohanEkdahl: I'm not planning on doing any write ups.  TBH I'm not very good at it even though English is my first language.  I just wanted to share the info I've found mostly trawling the net and by trial and error.  I look forward to seeing your write up though.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Well, well.. I actually started out testing this yesterday late evening. Didn't come far though. The gdbserver plug in crashed my NetBeans install. Tried to both disable the plugin and uninstall it, to no avail..

Mind you, my NB is a bleeding edge development version - IIRC I needed that for some Groovy/Grails stuff I was playing with a few months ago. Let's hope an un/re-install solves it. But now it'll have to wait until the weekend.

I'll be back!

"He used to carry his guitar in a gunny sack, or sit beneath the tree by the railroad track. Oh the engineers would see him sitting in the shade, Strumming with the rhythm that the drivers made. People passing by, they would stop and say, "Oh, my, what that little country boy could play!" [Chuck Berry]

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Just to let you know I haven't abandoned this, and any of your efforts above was wasted..

 

Status report:

 

I'm on to this again.

 

Yesterday I fixed my broke NetBeans setup(s). Yes, I've set up two - one (the "bleeding edge", for Groovy/Grails development) and one stock 8.2 for C/C++ and eventually AVR development and debugging tests. Last time the gdbplugin to NetBeans broke my NBs. (This time I'll run my hard disk imaging before trying anything.. ;-) )

 

Today my primary goal is to set up and verify hardware for the experiments. It'll likely be an ATmega2560 (on an STK600) and a Dragon (2nd gen). Both needed firmware updates. [1] I'm also tempted to do some similar tests for the SAM D20 (with OpenOCD in place of AVaRICE.

 

Then (today? tomorrow?) it's on to actually testing some of the stuff from TT_ZK and Morten above. Wish me luck..

 


 

There's one thing I worry about:

 

I've managed to keep away from "semi-bricking" AVRs with debugWire (not exiting debug session in proper way etc...). So, how is this leaving the debug session done "at the low-level". Is this about some specific GDB command, or what?

 

As I said above, I'm starting out with an ATmega2560 ... for a good reason. It's JTAG (not debugWire) so the above problem is not an immediate one.

 

Still, if someone has any light to shed on the "exit a debugWire session properly" subject, I'm all ears..

 


 

[1] The one trouble so far is that the Device Programming dialog in Studio hangs occasionally when using the Dragon from there. In case Morten is still around and is interested, here's what I get:

 

 

If I choose Wait 1 more minute the dialog hangs, and eventually I get that message again. Never stops, it seems.. Gotta kill Studio with Task Manager. Then I of-course forgot that Studio can leave its droppings as running processes, i.e. ATBACKEND. Gotta kill that one too, or Studio just keeps on acting up when started again.. There is some serious mis-design - or lack thereof - here, Atmel.

"He used to carry his guitar in a gunny sack, or sit beneath the tree by the railroad track. Oh the engineers would see him sitting in the shade, Strumming with the rhythm that the drivers made. People passing by, they would stop and say, "Oh, my, what that little country boy could play!" [Chuck Berry]

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]

Last Edited: Sun. Jul 16, 2017 - 10:58 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Morten, if you're here...

 

Heres my startup of the ATBACKEND:

 

C:\Users\JohnDoe>"c:\Program Files (x86)\Atmel\Studio\7.0\atbackend\atbackend.exe" /avr8-gdb-ports=4712

And, in a new terminal window, I start up GDB:

 

C:\Users\JohnDoe\My Documents\Atmel Studio\7.0\OCD\STK600Blinky\Debug>"C:\Program Files (x86)\Atmel\Studio\7.0\toolchain\avr8\avr8-gnu-toolchain\bin\avr-gdb.exe" -iex "target remote :4712"
GNU gdb (AVR_8_bit_GNU_Toolchain_3.6.0_1734) 7.8
Copyright (C) 2014 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "--host=i686-w64-mingw32 --target=avr".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.atmel.com>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word".
Remote debugging using :4712
0x00000000 in ?? ()

(gdb) monitor tool
Usage: tool TOOLTYPE [SERIALNUMBER]
  or:  tool list

(gdb) monitor tool list
com.atmel.avrdbg.tool.simulator
com.atmel.avrdbg.tool.stk600    0048395C6FB2
com.atmel.avrdbg.tool.avrdragon 00A200014633

(gdb) monitor tool avrdragon

(gdb) monitor device ATmega2560

(gdb) file "STK600Blinky.elf"
A program is being debugged already.
Are you sure you want to change the file? (y or n) y
Reading symbols from STK600Blinky.elf...done.

(gdb) break main
Breakpoint 1 at 0xfa: file .././main.c, line 16.

(gdb) monitor reset

(gdb) continue
Continuing.

At this point it crashes:

 

 

The problem details are:

 

Problem signature:

  Problem Event Name: APPCRASH

  Application Name: atbackend.exe

  Application Version: 1.13.0.4749

  Application Timestamp: 58bd8897

  Fault Module Name: com_atmel_debugger_core.dll

  Fault Module Version: 1.13.0.4749

  Fault Module Timestamp: 58bd88ef

  Exception Code: c0000005

  Exception Offset: 00121844

  OS Version: 6.1.7601.2.1.0.256.48

  Locale ID: 1053

  Additional Information 1: 0a9e

  Additional Information 2: 0a9e372d3b4ad19135b953a78882e789

  Additional Information 3: 0a9e

  Additional Information 4: 0a9e372d3b4ad19135b953a78882e789

 

Read our privacy statement online:

  http://go.microsoft.com/fwlink/?...

 

If the online privacy statement is not available, please read our privacy statement offline:

  C:\Windows\system32\en-US\erofflps.txt

 

Any ideas?

"He used to carry his guitar in a gunny sack, or sit beneath the tree by the railroad track. Oh the engineers would see him sitting in the shade, Strumming with the rhythm that the drivers made. People passing by, they would stop and say, "Oh, my, what that little country boy could play!" [Chuck Berry]

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]

Last Edited: Sun. Jul 16, 2017 - 01:13 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Debug interface and speed at least... Think it's set in the device command.

Re debugWire, there's no magic done. If the device is in debugWire mode (from studio for instance), then it should just launch. Enabling/disabling debugWire would need atprogram to set up the device correctly.

:: Morten

 

(yes, I work for Atmel, yes, I do this in my spare time, now stop sending PMs)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Morten! I am fully aware of your "position" and respect that not everything can be talked about. Proceed at will.. ;-)

 

meolsen wrote:
Debug interface and speed at least... Think it's set in the device command.

I think I can investigate how to handle "speed", but "Debug interface" in very generic. Too generic for my current knowledge level. Can you be more specific?

 

meolsen wrote:
Re debugWire, there's no magic done. If the device is in debugWire mode (from studio for instance), then it should just launch. Enabling/disabling debugWire would need atprogram to set up the device correctly.

Can you be more specific about what "correctly" might be?

 


 

Meanwhile, I tried running using the simulator rather than the Dragon and it works slightly better. I can actually single step, but while doing that I seem to just fall out of my main loop. Here's my code:

 

[The web-site code editor is acting up again. So, you'll get it as text. I at least managed to change to a non-proportional font..]

 

#include <avr/io.h>
#define F_CPU 8000000UL
#include <util/delay.h>

int main(void)
{
  DDRD = 0xFF;
  while (1) 
  {
    PORTD = 0x00;
    PORTD = 0xFF;      
  }
}

 

So, I start ATBACKEND and then (yes, in a new command window) I will start GDB. In a command file (settings.gdb) I have the first things to be done:

 

monitor tool simulator
monitor device ATmega2560
file "STK600Blinky.elf"
break main
monitor reset
continue

 

Starting up GDB:

 

C:\Users\johan\Documents\Atmel Studio\7.0\OCD\STK600Blinky\Debug>"C:\Program Files (x86)\Atmel\Studio\7.0\toolchain\avr8\avr8-gnu-toolchain\bin\avr-gdb.exe" -iex "target remote:4712"
GNU gdb (AVR_8_bit_GNU_Toolchain_3.6.0_1734) 7.8
Copyright (C) 2014 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "--host=i686-w64-mingw32 --target=avr".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.atmel.com>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/....
For help, type "help".
Type "apropos word" to search for commands related to "word".
Remote debugging using :4712
0x00000000 in ?? ()
(gdb)

 

Running my startup commands from the file:

 

(gdb) source -v settings.gdb
setup.gdb: No such file or directory.
(gdb) source -v settings.gdb
+monitor tool simulator
+monitor device ATmega2560
+file "STK600Blinky.elf"
+break main
Breakpoint 1 at 0xfa: file .././main.c, line 7.
+monitor reset
+continue

Breakpoint 1, main () at .././main.c:7
7         DDRD = 0xFF;
(gdb)

 

Now watch me step a few times...

 

(gdb) step
10          PORTD = 0x00;
(gdb) step
11          PORTD = 0xFF;
(gdb) step
0x00000104 in exit ()
(gdb)

 

Now, that looks to me like I'm falling out of the loop. I tried stepping further but it is clear that I've fallen out of the loop.

 

I'm stumped.. And worried. It seems to me that all the components are talking to each other, but GDB and/or the simulator is simply not behaving.

 

EDIT: I've verified that when stepping the code in Studio I do not fall out of the loop.

"He used to carry his guitar in a gunny sack, or sit beneath the tree by the railroad track. Oh the engineers would see him sitting in the shade, Strumming with the rhythm that the drivers made. People passing by, they would stop and say, "Oh, my, what that little country boy could play!" [Chuck Berry]

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]

Last Edited: Sun. Jul 16, 2017 - 05:35 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

monitor device ATmega2560 JTAG 250 ish... Use the help command...

:: Morten

 

(yes, I work for Atmel, yes, I do this in my spare time, now stop sending PMs)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

@TT_ZX if you're still around!

@Morten, with the usual "you have the right to remain silent" and if you still can bear with me..

 

BACKGROUND:

I tore down the ATmega setup and pulled out the SAM D20 Xplained board to see if my luck would turn. After meddling a while with how to point to the .cfg file I ended up with this, where I at least can get OpenOCD started and the openocd.cfg file is read:

 

<projet-root>
  |
  +--main.c (and other source files)
  |
  +--astudio
       |
       +--openocd.cfg
       |
       +--openocd-0.10.0
            |
            +--bin-x64
            |     |
            |     +-- openocd.exe
            |
            +--scripts
                 |
                 +--board
                      |
                      +-- atmel_samd20_xplained_pro.cfg

This project setup looks, and is, a bit weird IMO. But it works, e.g. building and running/debugging in Atmel Studio. It's a project setup that avoids all ASF goo, with minimal startup code and a simple HAL to handle I/O ports. I'll work on converting this to a more "standard" project later. I mention this because you will see some partial paths below and without this info you will probably be confused..

 

Point is, it works.  And I get a bit on the way with OpenOCD. Here goes..

 

My openocd.cfg looks like this:

#filename openocd.cfg
# Atmel-ICE JTAG/SWD in-circuit debugger. 
interface cmsis-dap
cmsis_dap_vid_pid 0x03eb 0x2141
# Chip info
set CHIPNAME atsamd20j18
source [find ./openocd-0.10.0/scripts/board/atmel_samd20_xplained_pro.cfg]
# C:/Users/johan/Documents/Atmel Studio/7.0/OCD/Taradov/astudio/openocd-0.10.0/scripts/board
$_TARGETNAME configure -event gdb-attach {
  halt
}
$_TARGETNAME configure -event gdb-attach {
  reset init
}

I now start OpenOCD:

C:\Users\johan\Documents\Atmel Studio\7.0\OCD\Taradov\astudio>openocd-0.10.0\bin\openocd.exe
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
Info : auto-selecting first available session transport "swd". To override use 'transport select <transport>'.
none separate
adapter speed: 400 kHz
cortex_m reset_config sysresetreq
Error: unable to find CMSIS-DAP device

I know that OpenOCD manages to read the .cfg file - before sorting out the source line in it I got an error because OpenOCD could not find the .cfg file.

 

BUT... Look at the last line: "Error: unable to find CMSIS-DAP device".

 

I am clueless about what to make of that.

- I have closed Atmel Studio.

- I have disconnected and reconnected the Xplained board. 

- There is no ATBACKEND running (my understanding is that it should NOT be running when using OpenOCD).

- Looking in Windows Device Manager there is a "EDBG Virtual COM Port (COM3)".

 

QUESTIONS:

Do you see anything obvious?

Do I need to tell OpenOCD where to find the EDBG device? Tips on how?

 

Yes, I am on my way into the OpenOCD documentation. Tomorrow. I'm old enough to know when to stop, e.g.

- When you're too tired

- When you've made no progress for a long time ("sleep on it..")

- When you're frustrated ("not a productive state of mind")

Right now I qualify on all three counts, so I'll call it a day.

 

"He used to carry his guitar in a gunny sack, or sit beneath the tree by the railroad track. Oh the engineers would see him sitting in the shade, Strumming with the rhythm that the drivers made. People passing by, they would stop and say, "Oh, my, what that little country boy could play!" [Chuck Berry]

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

meolsen wrote:
monitor device ATmega2560 JTAG 250 ish... Use the help command...

 

OK, I'm officially "daft".

 

"the help command" where? I wasn't expecting

(gdb) help monitor device

to work, but tried it anyway. Of-course it didn't say more than "Send a command to the remote monitor (remote targets only)." , i.e. as if I asked

(gdb) help monitor

Either my help command is ill formed, or I'm asking at the wrong place. I suspect the latter. The alternative would be ATBACKEND, but...

> "C:\Program Files (x86)\Atmel\Studio\7.0\atbackend\atbackend.exe" /help

usage: atbackend OPTIONS
Atmel Backend.

/clean                     Start with clean code cache.
/bundles=paths             Specify a semicolon-separated list of bundles or
                           bundle repositories.
/help                      display help information on command line arguments
/config-file=file          load configuration data from a file
/connection-port=port      port used to listen for TCF connections
/websocket-port=port       port used for websocket connections
/start-discovery           start discovery protocol
/no-stdin                  obsolete
/wait                      Wait for a keypress before exiting
/avr8-gdb-ports=ports      Listen for incoming avr8-gdb connections on
                           specified port
/armM-gdb-ports=ports      Listen for incoming cortex M/R arm-gdb connections
                           on specified port
/armA-gdb-ports=ports      Listen for incoming cortex A arm-gdb connections on
                           specified port
/exit                      Exits immediately. Most often used with /clean.
/listen-on-any-ip-address  Listen on any IP address. Default is
                           localhost(127.0.0.1).
/version                   Exits immediately.

> "C:\Program Files (x86)\Atmel\Studio\7.0\atbackend\atbackend.exe" /help device

..same output as above..

 

"He used to carry his guitar in a gunny sack, or sit beneath the tree by the railroad track. Oh the engineers would see him sitting in the shade, Strumming with the rhythm that the drivers made. People passing by, they would stop and say, "Oh, my, what that little country boy could play!" [Chuck Berry]

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

BUT... Look at the last line: "Error: unable to find CMSIS-DAP device".

The PID of an EDBG is (usually) 0x2111, not 0x2140

 

"the help command" where? I wasn't expecting

(gdb) monitor help

Remember, monitor means 'send everything to the remote target', in this case atbackend. 

 

I think 

(gdb) monitor device

Should return its syntax...

:: Morten

 

(yes, I work for Atmel, yes, I do this in my spare time, now stop sending PMs)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks, Morten! 

 

Re the help, I obviously need to sleep on it.. ;-)

 

Re the PID .. likewise, but even if I would realize it was the PID that was wrong I'm not sure how I would have found the correct PID out without you telling me. You probably saved me many hours right there. (I won't test it tonight, though. I'm old enough to...)

 


 

Any thoughts on the "falling out of the loop"? Or are you suggesting that also to be a consequence of bad "Debug interface and speed" things?

 

"He used to carry his guitar in a gunny sack, or sit beneath the tree by the railroad track. Oh the engineers would see him sitting in the shade, Strumming with the rhythm that the drivers made. People passing by, they would stop and say, "Oh, my, what that little country boy could play!" [Chuck Berry]

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

To find the VID:PID, go to device manager/HID-compliant device. Then go to Details/Property/Hardware Ids.

You can see my Atmel-ICE is 03EB:2141.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Any thoughts on the "falling out of the loop"? Or are you suggesting that also to be a consequence of bad "Debug interface and speed" things?

No, if that was the case you wouldn't be able to debug at all. Did you try another step, did it loop back or did it continue into _exit?

 

You can see my Atmel-ICE is 03EB:2141.

Or, you can look in the \tools\{toolname}\{toolname}.xml file. EDBG for instance:

  <Connection type="USB" name="com.atmel.avrdbg.connection.cmsis-dap">
    <VendorId>0x03EB</VendorId>
    <ProductIds>
      <ProductId>0x2111</ProductId>
      <ProductId>0x213A</ProductId>
      <ProductId>0x2157</ProductId>
    </ProductIds>
  </Connection>

 

:: Morten

 

(yes, I work for Atmel, yes, I do this in my spare time, now stop sending PMs)

Pages