- This topic has 1 reply, 1 voice, and was last updated 11 years, 6 months ago by .
Viewing 2 posts - 1 through 2 (of 2 total)
Viewing 2 posts - 1 through 2 (of 2 total)
- You must be logged in to reply to this topic.
|
Microcontroller › AVR › How to generate hex file using avr-gcc commands
hello,
I have written a coding for some project. I have compiled in avr-gcc commands for ATmega16. Till here its ok.. no error nothing…
from here i don’t knw how to continue and how to create .hex file and all…
please any one tell me….
hi,
at last i got how to generate .hex file and programing process in avr dude.
just follow these steps.
open a terminal and navigate to where the code is downloaded too. then run the following commands:
1.) avr-gcc -g -Os -mmcu=<mcu type> -c file_name.c
this produces an object file called flash.o which then needs to be linked using:
2.) avr-gcc -g -mmcu=<mcu type> -o file_name.elf file_name.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 file_name.elf file_name.hex
Note:mcu type can be ATmega8,ATmega16,ATmega328 etc in code written as
atmega8,atmega16 etc.
In the home folder you wull get your .hex file
Now programing to ic using avr-dude
follow these step
4.)avrdude -p <microcontroller> -P /dev/ttyACM0 -c stk500v2 -u -U flash:w:filename.hex
Microcontroller can be ATmega8,ATmega16,ATmega32,ATmega328, etc..
and is written in code as atmega8,atmega16,atmega32,etc..
Note: I checked this only in ISP programmer. also this only for avrdude.