Once again: Debugging with GDB

Go To Last Post
166 posts / 0 new

Pages

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

canbeany1 wrote:
One question though, did you remove the reset circuit on the arduino before trying debugwire?

canbeany1 wrote:
just bricked one [Arduino] (I think) because of the reset capacitor that I forgot to remove before programming DWEN..

Tell me more. Up til now I've not ever programmed the DWEN fuse on any Arduino, so I'm ignorant..

 

I have an ATmeega88 sitting on the STK500 so I will proceed with testing the DWEN hypothesis on that.

 

canbeany1 wrote:
I gave up earlier and ordered an Olimex MK2, for a hopefully easier debugging setup in linux.

Isn't that just a programmer? I.e. not a debugger. My main "fight" is with AVaRICE for debugging.

 

If it's only programming you're after then note that I've come as far as having AVRDUDE working with both Dragon and Atmel-ICE. I would suspect it should work just fine with other programmers too. Somewhere I have a stash of USBasp's lying around, and I will test those eventually.

As of January 15, 2018, Site fix-up work has begun! Now do your part and report any bugs or deficiencies here

No guarantees, but if we don't report problems they won't get much of  a chance to be fixed! Details/discussions at link given just above.

 

"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

You are completely right.. It was after a long day I ordered it, I probably did mistake it for a JTAG ICE MKII clone :(

 

I made a bash script for changing fuses, but have not tested it successfully yet.

It set the DWEN fuse like it should, but I was unable to disable debugwire again.

It was probably because of the reset capacitor though, as I have debugged a UNO in AS7, and that time I removed the capacitor before starting.

 

#!/bin/bash
if [ "$1" = -e ]; # enable dw fuse
then
    avrdude -q -q -pm328p -catmelice_isp -U hfuse:r:hfuse.bfdw:h
    hfuse=$(cat hfuse.bfdw)
    echo Fuse was: "$hfuse"
    let "hfuse -=64"
    dwfuse=$(printf '%x\n' "$hfuse")
    newhex=0x"$dwfuse"
    echo Fuse now: "$newhex"
    avrdude -p m328p -catmelice_isp -U hfuse:w:"$newhex":m

elif [ "$1" = -d ]; # disable dw fuse
then
    avrdude -q -q -pm328p -catmelice_isp -U hfuse:r:hfuse.afdw:h
    hfuse=$(cat hfuse.afdw)
    echo Fuse was: "$hfuse"
    let "hfuse +=64"
    disdwfuse=$(printf '%x\n' "$hfuse")
    newhex=0x"$disdwfuse"
    echo Fuse now: "$newhex"
    avrdude -p m328p -catmelice_isp -U hfuse:w:"$newhex":m

elif [ "$1" = -r ]; # read fuses
then
    echo "Reading fuses"
    avrdude -p m328p -catmelice_isp -U hfuse:r:-:h

fi

If you *comment the avrdude write commands, you can compare fuse results with a fuse calculator.

Gonna look for a working m328p in the next hour. Was going to test a 1284P with JTAG, but I haven't ordered an adapter board for the ICE so I am not able to test JTAG just yet.

 

USBasp works great for programming, that's what I have been using since windows forcefully updated my win7 install with 6 hours of unsaved work open.. No more microsoft in this house! (I know me not saving is stupid.. but..argh!)

 

*edit* rewrote the bash script a little, I can now enable/disable debugwire with no hitch.

 

BUT.. 

a@debian:~$ avarice --edbg --debugwire --ignore-intr :4242
AVaRICE version 2.13svn20160229, Sep 10 2017 10:43:55

a@debian:~$ 

and thats all she said.. Will try again after a reboot of the system, been on for a while now.

Last Edited: Sun. Sep 10, 2017 - 02:19 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Tell me more. Up til now I've not ever programmed the DWEN fuse on any Arduino, so I'm ignorant..

There is a capacitor on the reset line of the AVR on your UNO.  It interferes with the DW communications.

 

"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."

"Wisdom is always wont to arrive late, and to be a little approximate on first possession."

"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: Mon. Sep 11, 2017 - 12:02 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Sorry to hijack.

1.  the Olimex MK2 is a programmer ad not a debugger.

2.  you open the solder-bridge on a genuine Uno to disable the DTR capacitor.   Make the solder-bridge and Burn Bootloader when you have finished the debugWIRE project.

3.  some Chinese clones do not have a solder-bridge.   You have to cut the pcb trace.

 

@Johan,

I admire your patience.   I just expect to "Wash and Go".   If I have to pay a modest sum for a hobbyist licence,  it is worth it.   e.g. Rowley for ARM.  Rowley for AVR (which does not support modern AVRs)

 

David.

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

Fellows!

 

Sideshow re debugWire session ending, and the DWEN fuse, here: https://www.avrfreaks.net/forum/h...

 


 

Status: Got held up by other things so nothing done since #141.

 

I was looking for something else, and stumbled on my JTAGICE3 (that has been tucked away since I got the Atmel-ICE). So now have three dongles on the table... [rolling eyes]

 


 

david.prentice wrote:
I admire your patience. 

Well, I just hate it when I don't understand something and/or get beaten by technology. And I like "tinkering", investigating and learning. I can get quite frustrated but I've learned to spot this, and know that it is "walk-away-for-a-while" time. The big motivation now is to leave Windows-as-a-primary-OS behind me on my private computer(s). (At work it's a different thing altogether..)

 

david.prentice wrote:
f I have to pay a modest sum for a hobbyist licence,  it is worth it.

Well, as hinted at above. Part of my hobby is to understand, learn and get things to work. E.g. AVaRICE+GDB. It might not seems so at the moment, but I've learned heaps over the summer. And I am in good spirit!

 

An ultimate vision/goal could be to have one IDE where I do most of my development: C++/C targeting the laptop OS, Java development, Web programming using Groovy/Grails, AVR C++/C development and (eventually) SAM ARM C++/C development. Yes, that more or less implies either Eclipse or NetBeans as the IDE...

As of January 15, 2018, Site fix-up work has begun! Now do your part and report any bugs or deficiencies here

No guarantees, but if we don't report problems they won't get much of  a chance to be fixed! Details/discussions at link given just above.

 

"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. Sep 10, 2017 - 10:49 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Not sure why you are having problems with debugWire with AVaRICE.  This is what I get when with a atmega328p on a STK500 and an Atmel-ICE:

AVaRICE version 2.13svn20160229, Jul 31 2017 22:47:47

JTAG config starting.
Found a device, serial number: J41800025596
Reported device ID: 0x950F
Configured for device ID: 0x950F atmega328p -- Matched with atmega328p
JTAG config complete.
Preparing the target device for On Chip Debugging.
Waiting for connection on port 3333.

Is this what is failing for you?

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

The command I used was:

avarice -2 -g -w -4 -P atmega328p :3333

 

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

Nice to see you here, TT_ZX!

 

I'm about to hit the bed and am posting from the pad so I'll be terse: I don't get why you have both - 2 and - 4 in your command.. Both jtagmkII AND atmelice!? 

 

And no, I don't get Waiting for connection... ".

For debugWire it reports it can not start a debugWire session. (Could be fuses. Could be something with circuitry on reset pin. It happens on the STK500 too.)

For Atmel-ICE using JTAG AVaRICE just silently exits.

See post #141. 

As of January 15, 2018, Site fix-up work has begun! Now do your part and report any bugs or deficiencies here

No guarantees, but if we don't report problems they won't get much of  a chance to be fixed! Details/discussions at link given just above.

 

"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 wrote:

I don't get why you have both - 2 and - 4 in your command.. Both jtagmkII AND atmelice!? 

 

My bad, just -4 works fine.  I have the reset jumper removed on the STK500.  This is what I am setting the fuses to:

# Fuses
LOW_FUSES=0xFF
HIGH_FUSES=0xDA
EXTENDED_FUSES=0xFD
LOCK_FUSES=0x3F

 

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

@joeymorin: Thanks for the schematics! There are a lot of them around. Can you link to the one you show a part of above?

 

But.. I don't understand the circuit between C5 and the RESET pin: I assume the "thing" called RESET-EN is a "strap" ("solder bridge", or whatever it is called), but it makes no sense to me the way it is done. How can it matter whether it is open or closed? There is still a connection between C5 and RESET, in parallel with RESET-EN.

As of January 15, 2018, Site fix-up work has begun! Now do your part and report any bugs or deficiencies here

No guarantees, but if we don't report problems they won't get much of  a chance to be fixed! Details/discussions at link given just above.

 

"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 have always assumed that the reason for this as to show that the default state of the solder-bridge was "closed".

i.e. when you open the box,  RESET_EN has a fine copper link between the solder-bridge pads.

 

You cut this copper with a Stanley knife to break it first time.  Subsequently:

 

Restore of Arduino functionality:  disable DWEN at end of DEBUG.  make the bridge with soldering iron.   Burn Bootloader.

New DEBUG session:  break the bridge with soldering iron.   Remove BOOTRST fuse.  Start AS7 DEBUG session (which prompts for DWEN)

 

Rowley is slightly different:  you can always program fuses whether in debugWIRE mode or not.

1.   Restore Arduino by clearing DWEN fuse.  Make solder-bridge. Burn Bootloader.

2.   New DEBUG session: Break solder-bridge.   Disable BOOTRST.  Enable DWEN fuse.   Start Rowley debug.

 

Yes,  Atmel could make everything as smooth as Rowley.

No,   punters would never read instructions about debugWIRE hardware.   i.e. pullup and capacitor.

Atmel gets less grief by keeping it "magical"

 

David.

Last Edited: Mon. Sep 11, 2017 - 08:59 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

@joeymorin: Thanks for the schematics! There are a lot of them around. Can you link to the one you show a part of above?

Should have done that before ;-)

https://www.arduino.cc/en/uploads/Main/Arduino_Uno_Rev3-schematic.pdf

"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."

"Wisdom is always wont to arrive late, and to be a little approximate on first possession."

"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

It works.. But, does not stop by itself on break. Have to run until it hits, then CTRL + c.

DDD was a really nice GUI for GDB by the way.

Attachment(s): 

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

canbeany1 wrote:
DDD was a really nice GUI for GDB
+1

 

It was the first interface I used with gdb when I first started to use Linux the best part of 20 years ago.

 

It throws away all the other complexity of a complete "IDE" to just have a GUI wrapping for the GDB bit. I think it helps to sort the wood form the trees!

 

Talking of DDD. One of my most recent uses for it was here:

 

https://www.avrfreaks.net/comment...

 

That thread is fairly self explanatory - for those using gdb you might want to consider using that header scheme as it should make the entire AVR register set more "visible" in the debugger.

Last Edited: Mon. Sep 11, 2017 - 01:12 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

clawson wrote:

Talking of DDD. One of my most recent uses for it was here:

 

https://www.avrfreaks.net/comment...

 

That thread is fairly self explanatory - for those using gdb you might want to consider using that header scheme as it should make the entire AVR register set more "visible" in the debugger.

 

Wow! Going to read that thread thoroughly tomorrow. Great job!

So much to learn off this forum! :D

Pages