AVR/Arduino Hardware Debugger on the Cheap

I’ve developed an Arduino sketch that runs on one Arduino and allows it to control and debug another Arduino, or an AVR-Series micro-controller such as an ATTiny85. With some limitations, you can use the controlling Arduino to disassemble code, single step code, inspect the current value of registers. I/O ports and SRAM and run code with a hardware breakpoint set.

You can read more about my project at AVR/Arduino Hardware Debugger on the Cheap - Wayne's Tinkering Page and/or watch a short demo video at https://youtu.be/kI_Z78a_0y0


Appreciate the work you put into this.
Thanks for sharing.

Takes me back to the days of assembler programming on the 6809.

I really like that you wrote this as an Arduino sketch. That just makes it so accessible. I've been thinking a lot about getting a debugger in the last few days so this definitely hit home with me.

I'm curious why you didn't publish your code on GitHub. That would make it easy for us to follow any revisions you make to the code and also make it simple for people to collaborate on the project.

Have you tested it with ATmega328P yet? I think that part would be interesting to a larger group of Arduino users than the ATtiny85.

Thanks of the feedback!

This is still a work in progress but I may eventually put it up on Github as part of another project of mine you can read about here. I'm posting about here mostly to get early feedback on how useful people think this might be and to solicit suggestions on what I might need to add to make it more useful.

Using it to debug a ATmega328P-based system is a bit tricky, but I plan to work on that next. One issue is the 100nF capacitor the Arduino has connected to the RESET line. This interferes with using the RESET line for the debugWire interface and will have to be removed. Also, as I mentioned in my article, an Arduino running at 16 MHz will require my OnePinSerial library to work at 125,000 baud and I'm concerned that it may not work reliably at this rate, or may require some special tweaks. I'm still experimenting with how to deal with this, but I plan do to another writeup and video when I get all the details figured out.


I actually had checked out your ATtiny10 IDE earlier after you posted about it on the Developers mailing list and that was what prompted my question about GitHub. Yesterday when I looked at the debugger project I thought I hoped to see a link to GitHub but figured you probably just didn't have an account.

Since you're looking for feedback I'll go ahead and give my $0.02 but I actually know practically nothing about on-chip debugging so it's not worth that. Over the last week I've been listening to a lot of episodes of Embedded Podcast and they seem to have been on a campaign to get people using debuggers lately. I've always thought that the combination of AVR microcontrollers, the Arduino IDE, and a poor hobbyist's budget were not a good match for on-chip debugging but this made me want to have a closer look at what it would take for me to do this. I discovered they are selling JTAGICE clones on eBay for $5 USD! This made me want to just hit the "Buy" button and give it a try. Looking closer it seems this debugger only supports a limited set of AVRs which does not include my primary target (ATmega1284P), and I'm back to considering a >$50 investment. So I'm very undecided whether I want to spend $5 just to get my feet wet (I do have one of MCUdude's nice dev boards with ATmega32 and a JTAG breakout) or whether I should put that money towards the "real debugger" fund instead.

To me, your project is very cool because it takes something that seemed quite proprietary and commercialized and opens it up to anyone with even a small amount of experience with microcontrollers and hardware they already own. As far as being practically useful to me, well my current goal is to use GDB with ATmega1284P so probably not so much but that's just me. Obviously your project is for chips that have debugWire and that's likely to be a hard limit. As for GDB support, I have no clue whether that would ever be a possibility.

What would really make this incredibly useful is if it would support the low level commands used by gdbmon.
That way you could use gdb to provide full source level debugging.
And with ddd on top of gdb you have GUI based source level debugging.
I've done all this with the AVR dragon on chips like the tiny45/85 using debugwire, but this would be a cheaper alternative.

--- bill

Thanks. Several other people have contacted me to make the same suggestion. Unfortunately, I'm not currently familiar with gdb, so I'e have to do some research to determine how feasible this might be. For the moment I'm focused on getting the code logic to work with target processors running at higher clock speeds. But, perhaps a future project.


I’ve posted a new, part 3 article on my debugger project, along with new code and an overview video. The new code is now able debug an Arduino UNO running at 16 MHz and also includes some bug fixes and enhancements.