If you are a Windows user Atmel Studio provides a complete IDE for programming and debugging of Atmel microcontrollers. Unfortunately there is no complete toolchain available for Linux users. The Snowfox framework can be built for both Windows and Linux where the lack of official tooling makes development for the AVR platform cumbersome.

This article details the steps necessary in order to perform graphical debugging of the ATMEGA328P via its debugWIRE interface which is otherwise provided by the Atmel Studio on Windows. A Arduino Uno is used as a device under test (DUT) and a AVR Dragon is used as a debugging adapter.

If you have never used your AVR Dragon with Linux before you need the proper udev rules which allow to use you AVR Dragon without sudo. Create a file 99-avr-dragon.rules with the following content:

ATTR{idVendor}=='03eb', ATTR{idProduct}=='2107', MODE='660', GROUP='plugdev'

which you then copy to /etc/udev/rules.d/ .

cp 99-avr-dragon.rules /etc/udev/rules.d/

In order to enable debugWire-Debugging for the Arduino Uno the ceramic condensator C5 needs to be removed.

Next connect the ISP-Connector of the Arduino Uno with the ISP-Connector of the AVR Dragon. The position of pin #1 on both boards is marked in both figures with a red 1.

Read the current content of the HFUSE to determine whether or not the DebugWIRE fuse is set:

avrdude -c dragon_isp -p atmega328p -U hfuse:r:-:h

Next you need to upload the desired application to the flash of the ATMEGA328P.

avrdude -p atmega328p -c dragon_isp -e -U flash:w:build/hal-atmega328p-digital-out-pin

Power-Cycle your microcontroller board before starting avarice which provides a GDB server for the avr-gdb client to connect to.

avarice --file build/hal-atmega328p-digital-out-pin --dragon --debugwire :2222

Start ddd as graphical debugging tool:

ddd --debugger avr-gdb build/hal-atmega328p-digital-out-pin

Once ddd is started enter the following command to connect to the GDB server port exposed by avarice:

target remote localhost:2222

As an alternative this command can be stored in a gdb.conf file and passed to ddd as a parameter:

ddd --debugger avr-gdb build/hal-atmega328p-digital-out-pin -x gdb.conf

Now you are ready to debug your code with ddd: