I am looking for someone who guide me to solve the below error in AVR Micro controller (OS:Debian 32 bit) .
/* checkio.c*/
#ifndef F_CPU
#define F_CPU 16000000UL
#endif
#include<avr/io.h>
#include<util/delay.h>
#include<avr/fuse.h>
int main()
{
DDRA=0xFF;
PORTA=0;
while(1)
{
PORTA=0xFF;
_delay_ms(1000);
PORTA=0;
_delay_ms(1000);
}
return 0;
}
AND related make file is :
CFLAGS1=-g -mmcu=atmega32 -c
CFLAGS2=-g -mmcu=atmega32 -o
GFLAGS3=-j .text -j .data ihex
checkio.hex:checkio.elf
avr-objcopy $(CFLAGS3) checkio.elf checkio.hex
checkio.elf:checkio.o
avr-gcc $(CFLAGS2) checkio.elf checkio.o
checkio.o:checkio.c
avr-gcc $(CFLAGS1) checkio.c
burn:
sudo /home/poonam/proj_utility/avr_dude/install/bin/avrdude -p atmega32 -P /dev/bus/usb/002/004 -c usbasp -u -U flash:w:checkio.hex
clean:
rm *.elf *.hex *.o
avrdude: warning: cannot set sck period. please check for usbasp firmware update.
avrdude: AVR device initialized and ready to accept instructions
Reading | ################################################## | 100% 0.01s
avrdude: Device signature = 0x1e9502
avrdude: NOTE: "flash" memory has been specified, an erase cycle will be performed To disable this feature, specify the -D option.
avrdude: erasing chip
avrdude: warning: cannot set sck period. please check for usbasp firmware update.
avrdude: reading input file "checkio.hex"
avrdude: input file checkio.hex auto detected as ELF
avrdude: can't handle ELF file checkio.hex, ELF file support was not compiled in
avrdude: read from file 'checkio.hex' failed
avrdude done. Thank you.
The bug is not that avrdude cannot handle elf files, but rather that your .hex file is an elf file rather then a hex file in the first instance.
Your objcopy command should specify the output file format:
avr-objcopy -O ihex checkio.elf checkio.hex
^^^^^^^
Perhaps the apparent typo: GFLAGS3
instead of CFLAGS3
is the cause of this, but you still need the -O ihex
rather then just ihex
:
CFLAGS3=-j .text -j .data -O ihex
checkio.hex:checkio.elf
avr-objcopy $(CFLAGS3) checkio.elf checkio.hex