Step 2Compiling the code with gcc-avr
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 Step | Download PDFView All Steps | Next Step » |
1
comment
|
Add Comment
|
![]() |
Add Comment
|













































