Here's what i did to get started using the AVR Dragon to program ATMEGA8 microcontrollers using ubuntu (This is aimed at beginners, I myself am also being a beginner, so any improvements from more experienced users are greatly appreciated).

After finally switching my laptop and computer over to ubuntu permanently, i found no software that would support my PIC microcontroller programmer and after a few vauge and useless attempts to reverse engineer it (i'm really not that good at electronics, i wake up in the night wondering why i'm not doing a degree to become a tree surgeon), i finally thought "sod it" and splashed out a bit of my student loan on an AVR Dragon after seeing there was an open source c compiler for AVR microcontrollers and supporting programming software, also there's some absolutely wicked projects people have done with them.

It then promptly got discarded in my box of bits for a couple of months (i like to think it was laying dormant in its lair......its a dragon, get the pun?)

so anyways, here's how i got it working, this will probably work with most flavours of ubuntu that use synaptic (you can probably do it on any version of linux if you compile it from source and whatnot, i like synaptic because its easy) and its more a collection of information from various sources, but should hopefully get you up and running!

I realise there are other instructables for getting started with avr microcontrollers, but i couldn't find anything that applied to my situation, so i hope this is at least a bit of help to somebody.

Step 1: Getting the Software

in this instructable i wont be using any IDE (integrated development environment, think netbeans or visual basic) or make files (i don't understand them, maybe one day i will), so its mainly gonna be done via the command line and the text editor of your choice.

there are 2 main pieces of software i'll be using

this is the gnu c cross compiler for avr microcntrollers. A cross compiler is needed because we're compiling code for a microcontroller on an architecture (personal computer) that cannot run the compiled code.
This will take the code you write in c and convert it into a "machine readable" format (loads of 1's and 0's) which can then be put onto a microcontroller.

This is what puts the code onto the microcontroller, it connects with the avr dragon and transfers the Hex file (the compiled code) onto the microcontroller.

to install these pieces of software go:
system -> administration -> Synaptic Package Manager
search for gcc-avr and then avrdude and mark them both for installation, then install! simple.

if you want to use the command line you could try
sudo apt-get install gcc-avr
sudo apt-get install avrdude
<p>what if there are multiple source files.</p>
<p>Thanks, very nice.</p>
that code only compiles with avr-libc installed! sudo apt-get install avr-libc maybe you could edit this in on step 1
<p>Thanks for pointing this out!</p>
wouldnt it be alot easier to use windows (like normal people) and use AVR studio 4. after all it was desgned for that. <br/><br/>anyway JTAG is like an emulator for PIC but it is in the chip. you connect the corresponding ports on the chip and then enable the JTAG in the programming and then using AVR studio you can view the states of the file, working and EEPROM registers as it advances through the program. this would help with debugging.<br/><br/>and also, dont you find Assembly code easier to write in, maybe its because i learnt it in assembly code. <br/><br/>if you want to learn more about AVR or PIC programming buy these books, they are fantastic, if you are interested you can learn it in a week! here are the links to amazon <a rel="nofollow" href="http://www.amazon.co.uk/AVR-Introductory-Course-John-Morton/dp/0750656352/ref=sr_1_3?ie=UTF8&s=books&qid=1218547473&sr=8-3">AVR</a> and for <a rel="nofollow" href="http://www.amazon.co.uk/PIC-Microcontroller-Personal-Introductory-Course/dp/0750666641/ref=sr_1_1?ie=UTF8&s=books&qid=1218547543&sr=1-1">PIC</a><br/><br/><em>Note: Written by same author. PIC book written when he was 16 and AVR book was written while at University at the age of 19</em><br/>
&gt;&quot;wouldnt it be alot easier to use windows (like normal people) &quot;<br><br>Is that a troll?<br><br>You do realize this community seems strongly open source, and you just don't get that in a Windows community. Windows doesn't even do anything until you spend a whole lot more buying shareware.<br><br>Besides, not all of us are so rich that we like buying new scanners and printers every time a new version of the OS comes out (can't tell you how many times I had to do that before I said enough was enough, no more Windows,).
<p>Really? I've never had that problem, most companies will release new driver software for the new OS within a few weeks unless that hardware you're talking about was 10-12 years old and thus outside of operating standards ususally</p>
It's nice to know that avrdude now works with USB in Linux (I've got a Dragon just sitting around, next to an unused STK500...) But I normally just use my $5 parport DAPA cable on a breadboard with Xubuntu. (We don't need no sinkin' dedicated programming boards...)
Yeah USB is icky for hacking!
On reflection parport was probably the way to go. i didnt know so much about AVR's when i got the dragon (had mainly been using PIC's). kinda of glad i got it now though, means i can use it on my laptop (doesn't have a parallel port). but still, it took a bit of effort to get it up and running.
That's a crucial point: my current desktop doesn't have a parport, either. And yours is the first demo (explicit, with photos) I've seen of using the ISP from the Dragon on an external board, AND making it work with Linux. So good job.
cheers :) whatever happened to the good old days of the parallel port? i remember writing Qbasic code on an IBM 100 to control a homemade drum plotter through the parallel port......golden times.
Unless you're using a specialized kernel driver, you should probably be able to do whatever you need with a USB-to-parport adaptor. I haven't needed one, but I did notice that there's at least one driver for them on Linux while I was doing the usual `make menuconfig`.
Is <a rel="nofollow" href="http://www.sparkfun.com/commerce/product_info.php?products_id=8391">this</a> + <a rel="nofollow" href="http://www.sparkfun.com/commerce/tutorial_info.php?tutorials_id=93">this</a> an easy way to get into AVRs?<br/>
That looks like a good start. The learning curve can be quite steep when first getting into micro-controller development but don't be discouraged! its well worth getting the basic principles down because you can build on them rapidly to produce some pretty awesome projects. If you need any further help feel free to PM me (I'll help as much as i can but can't promise to know everything) or check out the forums at avrfreaks.com (they are a fantastic bunch of people with a great wealth of knowledge and are generally fantastic at helping new people). Best of luck!
Thanks! I think I'm going to go with the USB programmer from atmel off of digikey for $35 instead of hunting for a computer with a parallel port. Are there any good AVR coding tutorials that you know of? Maybe one set up like the Arduino website's reference page, that one is handy.
You can get really good parallel port cards for about $15. I personally wouldn't use a built in parallel port on a machine if I was connecting prototype electronics circuits I'd made to it anyways. $15 parallel port cards are easier to replace than computers! Though knock on wood I haven't blown one up yet myself.<br> <br> <a href="http://img407.imageshack.us/img407/1168/stepbench.jpg">http://img407.imageshack.us/img407/1168/stepbench.jpg</a><br> <br> The gray sub D cable is plugged into one in the picture. Then signals from my home brewed buffer are running one of the worst loads out there, an inductive stepper motor controller running at a couple of amps.<br> <br> So as they say, it works here!<br> <br> <a href="http://www.youtube.com/watch?v=cgbeyNNBZ68">http://www.youtube.com/watch?v=cgbeyNNBZ68</a><br>
Good stuff .. But I see that running codevision under Wine is more easier BTW I'am going to give it a try
Thanks so much for the -B 10 note: I had exactly this problem, and couldn't work out what was going wrong.<br/><br/>This was the error message -- though the device signature would come back differently each time:<br/><br/>avrdude: Device signature = 0x3f00ff<br/>avrdude: Expected signature for ATMEGA168 is 1E 94 06<br/> Double check chip, or use -F to override this check.<br/><br/>NB: the wrong signature would always be runs of 1s and 0s, never completely random.<br/><br/>-B 10 fixed it straightaway.<br/><br/>Thanks again.<br/>
yhea, that -B 10 got me stumped for quite some time before i asked the kind people over at avrfreaks.com cheers for the vid! thats a great demo of what PWM does!
hi itch thanks for such clear help. attached is a video of the oscilloscope trace of the pulse-width changing. thanks again.
For AVRs, the KontrollerLab (http://www.cadmaniac.org/projectMain.php?projectName=kontrollerlab ) IDE is quite nice. It's KDE-based, and comes packaged as i386 RPMs and DEBs.<br/> }{itch, if you still have PICs lying around like me, check out <a rel="nofollow" href="http://home.pacbell.net/theposts/picmicro/.">http://home.pacbell.net/theposts/picmicro/.</a> There's programmer software there for the PICKit2, which is the cheapest &quot;official&quot; USB PIC programmer available from Microchip. Unfortunately, development has stalled, and the latest firmware for the programmer is only supported by the latest alpha of the software. It might be worth a try,though.<br/>
darn - missed the comment further down.
There is also KontrollerLab, which is a GUI program for AVR
Nice. I don't think i'll be doing pic anytime soon
Dang, looks difficult, but nice job.
cheers :) its really not so hard once you've gone through it. and well worth it too be able to begin programming microcontrollers (although there probably are simpler ways.... like using windows, but i'm stubborn and like to stick to linux :D )

About This Instructable




More by }{itch:How To Give Someone The Middle Finger Lo-Fi Guitar Mods Yet another lockpick instructable 
Add instructable to: