Archive for the ‘ osx ’ Category

AVR debug on Eclipse

Assuming a previous installation of AVR CrossPack and working Eclipse environment one will need 2 things:

  1. Hardware for in chip debugging or a chip simulator;
  2. The gdb debugger.

In my case, since I don’t have a JTAG interface, the choice goes for the chip simulator. The solution is called simulavr and is already included in the AVR CrossPack. It can be called by issuing:


Now, according to these guys, this should show me a list of supported chips:

>simulavr -L

But my version doesn’t know this command…I think the version included with AVR CrossPack is older. According to their release notes it’s version 0.9. But what version is this that I can’t find it in simulavr releases? Anyway I get the latest (from 2009…apparently the recent development is done on a git repository if anybody wants the latest of the latest) package and that is

Uncompress and apparently 3 steps install so say the instructions:


Goes fine.


Gives me: ‘adc.c:270: warning: cast from pointer to integer of different size’. Throwing it at Google I find the solution here. Luckily someone already made a patch to correct this:

— src/simulavr- 2011-04-13 02:26:29.000000000 +0000

+++ src/simulavr- 2011-04-13 02:27:37.000000000 +0000

@@ -26,6 +26,8 @@



+#include <stddef.h>


enum _sleep_modes



@@ -83,7 +85,7 @@ struct _IntVect

an index enumeration. */

#define irq_vect_table_index(vect) \

– ( ((unsigned int) (&( ((IntVectTable *)(0)) -> vect))) / sizeof(IntVect) )

+ ( offsetof(IntVectTable, vect) / sizeof(IntVect) )

/* No device will have all of these vectors, but must define a structure which

has a slot for each interrupt. If the device doesn’t support the

and it can be applied like this:

>patch -p2 -i offsetof.diff

And then proceed with the installation:

>make install

Now it should work:

>simulavr -L

at90s1200 at90s2313 at90s4414 at90s8515 atmega8 (Yay!) atmega16  atmega32 atmega103 atmega128 at43usb351 at43usb353 at43usb355 at43usb320 at43usb325 at43usb326

Cool, so my chip is in the list.

As for gdb, it is also included in the AVR CrossPack:


Now I’m ready to follow this tutorial on debugging an AVR with Eclipse.

First set the chip simulator:

Don’t forget the port set here, we’ll need this to tell avr-gdb where to connect. Next we set the debug tool:

And that’s it! To run, first start the simulator and then the debugger. Don’t forget to set some breakpoints!