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.

Getting started with ubuntu and the AVR dragon

Step 2Compiling the code with gcc-avr

compiling the code with gcc-avr
before we build any hardware well get the code all nice and compiled and ready to go.
i'll be using some c code from this website:
http://www.nongnu.org/avr-libc/user-manual/group__demo__project.html
its under a beer-ware license so i guess i'm good to include it here.
also needed is iocompat.h which just makes sure the code is compatible with the microcontroller we'll be using. ( an ATMEGA8-16PU, although i reckon most of the atmega8 range should be ok)
so go ahead and download the code from below and put the flash.c and the iocompat.h into the same folder.

now for the compiling!

open a terminal and navigate to where the code is downloaded too. then run the following commands:

1.) avr-gcc -g -Os -mmcu=atmega8 -c flash.c

this produces an object file called flash.o which then needs to be linked using:

2.) avr-gcc -g -mmcu=atmega8 -o flash.elf flash.o

this has now produced a binary file called flash.elf, which is a GNU executable file. we gotta mess with it a bit more and grab some bits out of it to make the hex file

3.) avr-objcopy -j .text -j .data -O ihex flash.elf flash.hex

we now have a hex file which is suitable for putting onto the atmega8, we'll be coming back to this in a bit.
(for a more detailed description of what each of the commands and options do see here:
http://www.nongnu.org/avr-libc/user-manual/group__demo__project.html )

lets get the hardware sorted!
« Previous StepDownload PDFView All StepsNext Step »
1 comment
Feb 8, 2009. 5:29 AMOuZo says:
that code only compiles with avr-libc installed! sudo apt-get install avr-libc maybe you could edit this in on step 1

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!
60
Followers
10
Author:}{itch