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
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.