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:

>simulavr

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

Uncompress and apparently 3 steps install so say the instructions:

>./configure

Goes fine.

>make

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 @@

#ifndef SIM_INTVECTS_H

#define SIM_INTVECTS_H

+#include <stddef.h>

+

enum _sleep_modes

{

SLEEP_MODE_IDLE,

@@ -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:

>avr-gdb

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!

About these ads
  • Trackback are closed
  • Comments (0)

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: