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

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

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

  2. hello jkx.

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

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

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

  5. 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”).

  6. Hai, I have followed the steps as given in the site. But when I am launching ddd with the command specified above, I am getting an error in the console of ddd
    “gdbconfiles:No such file or directory” I have launched ddd in the directory where the code is present.
    Am I doing any mistake here?

  7. Also when I am doing the same thing in the directory where gdb.confiles is present, I am getting an error like Undefined command: “.”

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>