3 Simple Ways to
Share What You Make

With Instructables you can share what you make with the world — and tap into an ever-growing community of creative experts.

PhotosPhotos

Share one or more photos of a project, recipe, or whatever you've made, quickly and easily.

Step by StepStep-By-Step

Share your step-by-step photos with text instructions of what you made so others can do it too!

VideoVideo

Share your how-to video. You'll need your embed code from a video site such as YouTube.

Debugging AVR code in Linux with simavr

Debugging AVR code in Linux with simavr
I recently started programming AVR chips, namely the ATTiny85.  They can be programmed using C, compilers are readily available in Ubuntu, and you can do a LOT with them - just search for avr on this site!  Anyway, I was having some trouble with my project today - the LED wouldn't flash!  I couldn't figure out what was going on, as debugging these things is non-trivial.  That is, until I discovered simavr.

It's a simulator for AVR in Linux that can take your ELF or HEX code and run it as if it's actually on-chip, but gives you hooks and the possibility of dumping trace files.  I'll go through a simple example.
 
Remove these adsRemove these ads by Signing Up
 

Step 1Git it

Git it
There are a few dependencies on Ubuntu (which is what I use all the time):
sudo apt-get install avr-libc libelf-dev \
   libglut3-dev gtkwave git build-essential
I had to remove some crappy Mesa symlink for OpenGL in 10.10.  Only do this if you have problems compiling related to -lGL,
sudo rm /usr/lib/libGL.so
cd /usr/lib
sudo ln -s libGL.so.1 libGL.so
cd
Finally, use git to download the source code:
git clone git://gitorious.org/simavr/simavr.git
Now, build it.
cd simavr
make
If you get any errors, leave me a comment.  I'd be happy to help.  You should have a new program called run_avr in the simavr subdirectory once that completes.
« Previous StepDownload PDFView All StepsNext Step »
2 comments
Feb 6, 2012. 6:38 AMcelem says:
Quite amazing! Thank you. I have just started working with ATtiny85 and this may come in handy.
Dec 16, 2011. 1:34 PMnevdull says:
Great instructable. Gave me just the handle I needed to begin wrapping my head around this pretty cool AVR simulator. Super job!

Thanks!

Pro

Get More Out of Instructables

Already have an Account?

close

All Steps Viewing
View all steps of an Instructable on the same page when you're a Pro Member.

Upgrade to Pro today!
13
Followers
8
Author:hardwarehank(Schadenfreude)
Just a dude who reads a lot of Instructables.