Using Raspberry Pi as AVR debugger

I've seen threads and blog posts about using a Raspberry Pi as an ISP, which made me wonder: is ti possible to use a Raspberry Pi as a hardware debugger, like Atmel's Dragon?

I've tried looking to see if anyone else has asked this question, but didn't find anything. I had a Pi laying around for months and just dug it out, so it would be cool to use my Uno and Pi together in some way.

sjheiss:
I had a Pi laying around for months and just dug it out, so it would be cool to use my Uno and Pi together in some way.

You could use it as a RFXduino gateway. (Check out the gateway "BYO" kit option.).

One of the reasons I decided to use the Raspberry Pi as the server for the project was because I suspected there more than a few "under-employed" RPis that people had bought but hadn't got around to doing anything with yet.

Cool idea, but not really within my realm of interest.

And the main question of this thread was using the Pi as a debugger; the last sentence was just an afterthought. :wink:

sjheiss:
Cool idea, but not really within my realm of interest.

Really? Some people!

sjheiss:
And the main question of this thread was using the Pi as a debugger; the last sentence was just an afterthought. :wink:

With some effort, you might be able to turn it into a serial programmer, a la “Arduino as a programmer”.

With a usbasp costing <$10, one might ask “why”?

As for any of the avrdragon advanced functions, e.g. HVPP, DebugWire… not a chance.

I have both a dragon and (several) RPis. The most similar things about them is their price. Dragons, like RPis are great bang for buck devices, no doubt about it. But the similarities end about there.

Ok, that's all I wanted to know. Would've been fun to mess with if it were possible, but I don't need it. :slight_smile:

As far as debugging goes, you will need to have a debugwire interface to the chip.
As of today Atmel has not released the debug wire interface spec.
While I'm betting it wouldn't be that hard to reverse engineer, to date nobody has taken the time to do it.
Complicating matters, it appears that the debug wire interface is not "standarized" even across the
various atmel parts. i.e. it will be different for m328 vs attiny84 etc...

And even if you do have a device that supports debug wire such as a dragon,
it isn't straight forward to actually use for debugging since the IDE doesn't provide a way to talk to talk it
nor set up the environment to make it easy to use GNU source level debugger tools.
I've manually set things up a few times to allow ddd (GUI) to run on top of gdb which then runs on top of
AVaRice .
It's very cool to have full GUI source level debugging of Arduino code running on
a small 8 pin chip (attiny85 in my case), but it is a pain to get setup since the Arduino IDE
is so Hostile to command line tools.

The added capabilities in the Arduino 1.5x IDE platform and board files
will make some of the setup easier since you can
patch the tools to use some wrapper scripts to automate the process.

I did all this on linux. On Windows it would be more difficult
as Windows is also very hostile to the command line tools so there will added
difficulties to get things like ddd and gdb up and running.

--- bill

What hardware do you use to debug? Dragon? JTAG ICE?

Well, even if I were to somehow reverse engineer it, I'd need the hardware in the first place, so that would be defeating the purpose of not buying a dedicated debugger.

I was wondering if the Pi could interface with the Arduino in any way to debug it (without reverse engineering anything), but it doesn't appear to be the case. Oh well, no big deal. I don't need a debugger, not right now anyway, just thought it would be cool to test out if it were possible.

I used a dragon.

While you couldn’t do any source level debugging without debug wire or JTAG (on bigger AVRs),
you could hook up a pi to the serial port pins
or the ISP pins. (would have to use level shifters if not running the AVR at 3v).

That would allow you to communicate with the AVR or re-program it.

NOTE:
It is possible to do source level debugging with only a serial port.
(like it is often done in other non hardvard architecture embedded environments)
I’ve had it as a project on my “like to do” list for quite some time.
It requires linking in some special code or using a special bootloader along
with stealing a high level interrupt.
It also requires using a slightly modified version of gdb.
It creates break points by re-writing the flash with a special instruction that traps
back into the debugger code inside the AVR using a pin change interrupt.

I’ve got all the pieces to do it, just haven’t got focused enough to actually complete it…

— bill

That's a very good idea with interrupts.

I'd love to try implementing something like that myself, but I don't know if my coding abilities are that good yet.