Assuming a previous installation of AVR CrossPack and working Eclipse environment one will need 2 things:
- Hardware for in chip debugging or a chip simulator;
- 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:
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 0.1.2.6.
Uncompress and apparently 3 steps install so say the instructions:
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-0.1.2.6/src/intvects.h.old 2011-04-13 02:26:29.000000000 +0000
+++ src/simulavr-0.1.2.6/src/intvects.h 2011-04-13 02:27:37.000000000 +0000
@@ -26,6 +26,8 @@
@@ -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:
Now it should work:
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!