I want to burn a hex file to a custom ATmega2560 board. I use this USBasp programmer for flashing (firmware version 1.01) on my Mac OS X 10.12.6 system. All hex files are compiled with avr-gcc (GCC) 4.9.2.
I use this command to burn fuses (without bootloader):
/Applications/Arduino.app/Contents/Java/hardware/tools/avr/bin/avrdude -C/Applications/Arduino.app/Contents/Java/hardware/tools/avr/etc/avrdude.conf -v -patmega2560 -cusbasp -Pusb -U lfuse:w:0xff:m -U hfuse:w:0xd9:m -U efuse:w:0xfd:m -s -F
What is working fine: I can flash smaller (43,266 bytes) programs and they work straight away without bootloader. If I flash bigger programs (99,986 bytes) they do not run. I can verify if the program runs because they spit out data via TTL. The smaller program does work but the bigger one does not produce anything.
I turned on "Code verify" and I can see for smaller programs:
avrdude: 43264 bytes of flash verified
avrdude: verification error, first mismatch at byte 0x0001 0x90 != 0x94 avrdude: verification error; content mismatch
Any hints on this side?
Secondly: after deleting the whole flash, when I flash a custom bootloader (from Atmel Studio - fuses are Ext. 0xFD, High: 0xD2, Low: 0xFF), command:
/Applications/Arduino.app/Contents/Java/hardware/tools/avr/bin/avrdude -C/Applications/Arduino.app/Contents/Java/hardware/tools/avr/etc/avrdude.conf -v -patmega2560 -cusbasp -Pusb -U flash:w:ATmega_Example.hex:i
and afterwards read the flash, the bootloader ended up in several blocks within the flash.
From the readout hexfile (data blocks):
All the flash is 0xFF until Line 1921
Some more data until Line 1995.
All the flash is 0xFF until Line 3970.
Some more data until Line 4044.
And so on... I can find similar data 4 times in the file.
Is this a problem with the flashing or with reading the data from the chip?
Let me know if you need more information to help me here.