Howto use AVR Dragon Jtag on Linux (Avarice + avr-gdb +DDD)

I bought a couple of months ago a little AVR Dragon card. My initial plan was to use it for debuging programs with the embbeded JTAG. But I run into several issue with that, mainly because the lack of doc on this topic. So, here we are ;)

The AVR Dragon is nice because you can use it as a small developpement device without any other requirement: Simply drop the needed ATMega on the board, some little wrapping for : Jtag + power supply.

As you can see, this is compact and nothing else is needed. The power supply come from the USB port, and I soldered a DIP on the board.. and that’s it.

I use the Jtag connector, so now I can use a real debugger instead of playing with the UART. Simply put a breakpoint, and enjoy :) By this way, I figure out that most of the time I simply push some stuff in arrays, and inspect them with debugger. This is really efficient. For example, last week I need to fix a timing issue with a IR sensor, simply wrap the little board, and push all interrupts in a array with the related timing. Of course, this can be done with a serial connection too, but it will take more time, and even worst if you encounter a bug, you will have to find where is it (the UART printf, or the code itself) ..

So, how to use this with a Linux OS ?

First you need to use AVaRICE to program the ATMega with a command like this :

avarice -g -j usb --erase --program --file main.hex :4242

Here the result:

AVaRICE flash the hex file to the ATMega, and wait for a GDB connection on port 4242. GDB is fine, but not really visual ;)

Let’s take a look at DDD

To use DDD with avr-gdb (the gdb for AVR), you need to edit a config file, for example gdb.conf and put this in :

file main.out
target remote localhost:4242

And the final command, just launch DDD like this :

ddd --debugger "avr-gdb -x gdb.conf"

Next step: Simply place some breakpoint, and the press “Cont” inue button in DDD. Et voilà :

I hope this little tuto will help people looking for a nice AVR debuger for the AVR on Linux (or any OSS system). The AVR Dragon is definitively a must have for low budget user in AVR scene.

Enjoy bug ? :)

Related posts :

admin November 30th, 2008


10 Responses to “Howto use AVR Dragon Jtag on Linux (Avarice + avr-gdb +DDD)”

  1. adminon 30 Nov 2008 at 5:52 pm

    Somebody tell me that, we can do the same with Eclipse. If somebody know how, please post here ..

  2. Rene Dudfieldon 01 Dec 2008 at 12:31 am

    Awesome article! Thanks.

  3. adminon 01 Dec 2008 at 12:56 am

    Thanks :)

  4. Jejeon 19 Jan 2009 at 12:38 pm

    hello jkx.

    OFFTOPIC:
    I like the window style on these pictures.
    What WM and theme are You using?

  5. adminon 19 Jan 2009 at 1:41 pm

    OT: The WM is the xfce one, aka xfwm4, with Gaudy theme.

  6. Miguelon 05 Feb 2009 at 9:20 pm

    Hi all,

    I have been trying out gdb with avarice but I got some errors when debugging. The fact is that I get no errors if I don’t use any functions in my code but it just doesn’t read the proper values if I do use them.

    Anyone has had any problems about the same issue?

    Thanks in advance!!

    Miguel.

    PS: I had disabled optimization code parameters already in gcc-avr

  7. Miguelon 05 Feb 2009 at 9:31 pm

    by the way, how did you compile your code?

    this is my compilation command:

    avr-gcc -g -mmcu=atmega16 -c adcTest.c;avr-gcc -g -mmcu=atmega16 -o adcTest.elf adcTest.o;avr-objcopy -j .text -j .data -O ihex adcTest.elf adcTest.hex

    Am I missing any flags?

    I hope that helps.

    Miguel.

  8. adminon 19 Feb 2009 at 10:45 pm

    Miguel, your flag looks good. I don’t see the issue

  9. WinGDBon 01 Sep 2009 at 12:43 am

    Hello,

    If somebody would be interested in debugging with use of gdb under VisualStudio, then please check our site http://www.wingdb.com.

    Kind regards,
    WinGDB team

  10. stefancton 12 May 2011 at 6:31 pm

    an important detail: you need to program the debugWire fuse to enable dW before using avarice (e.g. with avrdude).
    avarice can’t enable it itself.

    if you try with an unprogrammed DWEN fuse you will get the error message “set paramater command failed” (with verbode/debug output ‘-d’ you will also see “response: AC”).

Comments RSS

Leave a Reply