user11150: 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

big programs: 
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):
Line 1
>:20000000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF00

All the flash is 0xFF until Line 1921

:20F0000077C000009BC0000099C0000097C0000095C0000093C0000091C000008FC0000066

Some more data until Line 1995.

:20F940000895F894FFCF65300000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF31

All the flash is 0xFF until Line 3970.

:20F0000077C000009BC0000099C0000097C0000095C0000093C0000091C000008FC0000066

Some more data until Line 4044.

:20F940000895F894FFCF65300000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF31

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.

user40578: Personally I use AVRDUDESS for uploading sketch on atmega328p and attiny85. Try to use it and run detect.
I answer this because AVRDUDESS is very easy to use and it can help you to show more info of your error.
I think you maybe have a bad wiring or a defect cable.

user34529: I'm not certain that it's going to fix your problem, but few years ago I had similar issue. I was trying to upload program to ATTiny13A using cheap e-bay USPasp and got verification errors. One step of my solution was changing programmer id from "-c usbasp" to "-c usbasp-clone"
More here: https://www.nongnu.org/avrdude/user-manual/avrdude_4.html
 

user23644: I am familiar with that issue. I don't have an USBasp but an USBtinyISP but I think the problem is the same.
The USBtinyISP cannot read or write past 64kiB. Since AVR are 8-bit machines with 16-bit addressing they cannot address past 64kiB on their own. A special addressing schema is used on runtime and also during flash. (I think it was larger page sizes during flash.)
I could manage to get around the issue by using an original Atmel AVRISP mkII.

11150: <p>I want to burn a hex file to a custom ATmega2560 board. I use <a href="https://www.ebay.de/itm/311719627217" rel="nofollow noreferrer">this USBasp programmer</a> 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.</p>

<p>I use this command to burn fuses (without bootloader):</p>



<pre class="lang-none prettyprint-override"><code>/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
</code></pre>

<p>What is working fine: I can flash smaller (43,266 bytes) programs and they work straight away without bootloader. If I flash <strong>bigger programs (99,986 bytes)</strong> 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.</p>

<p>I turned on "Code verify" and I can see for smaller programs:</p>

<pre class="lang-none prettyprint-override"><code>avrdude: 43264 bytes of flash verified
</code></pre>

<p>big programs: </p>

<pre class="lang-none prettyprint-override"><code>avrdude: verification error, first mismatch at byte 0x0001
         0x90 != 0x94
avrdude: verification error; content mismatch
</code></pre>

<p><strong>Any hints on this side?</strong></p>

<p>Secondly: after deleting the whole flash, when I flash a custom bootloader (from Atmel Studio - fuses are Ext. 0xFD, High: 0xD2, Low: 0xFF), command:</p>

<pre class="lang-none prettyprint-override"><code>/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
</code></pre>

<p>and afterwards read the flash, the bootloader ended up in several blocks within the flash.</p>

<p>From the readout hexfile (data blocks):</p>

<p>Line 1</p>

<pre class="lang-none prettyprint-override"><code>&gt;:20000000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF00
</code></pre>

<p>All the flash is 0xFF until Line 1921</p>

<blockquote>
  <p>:20F0000077C000009BC0000099C0000097C0000095C0000093C0000091C000008FC0000066</p>
</blockquote>

<p>Some more data until Line 1995.</p>

<blockquote>
  <p>:20F940000895F894FFCF65300000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF31</p>
</blockquote>

<p>All the flash is 0xFF until Line 3970.</p>

<blockquote>
  <p>:20F0000077C000009BC0000099C0000097C0000095C0000093C0000091C000008FC0000066</p>
</blockquote>

<p>Some more data until Line 4044.</p>

<blockquote>
  <p>:20F940000895F894FFCF65300000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF31</p>
</blockquote>

<p>And so on... I can find similar data 4 times in the file.</p>

<p><strong>Is this a problem with the flashing or with reading the data from the chip?</strong></p>

<p>Let me know if you need more information to help me here.</p>
 40578: <p>Personally I use <a href="https://github.com/zkemble/AVRDUDESS?files=1" rel="nofollow noreferrer">AVRDUDESS</a> for uploading sketch on atmega328p and attiny85. Try to use it and run detect.
I answer this because AVRDUDESS is very easy to use and it can help you to show more info of your error.
I think you maybe have a bad wiring or a defect cable.</p>
 34529: <p>I'm not certain that it's going to fix your problem, but few years ago I had similar issue. I was trying to upload program to ATTiny13A using cheap e-bay USPasp and got verification errors. One step of my solution was changing programmer id from "<code>-c usbasp</code>" to "<code>-c usbasp-clone</code>"</p>

<p>More here: <a href="https://www.nongnu.org/avrdude/user-manual/avrdude_4.html" rel="nofollow noreferrer">https://www.nongnu.org/avrdude/user-manual/avrdude_4.html</a></p>

<p><a href="https://i.stack.imgur.com/xLP97.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/xLP97.png" alt="USBasp vs USBasp-clone"></a>  </p>
 23644: <p>I am familiar with that issue. I don't have an USBasp but an USBtinyISP but I think the problem is the same.</p>

<p>The USBtinyISP cannot read or write past 64kiB. Since AVR are 8-bit machines with 16-bit addressing they cannot address past 64kiB on their own. A special addressing schema is used on runtime and also during flash. (I think it was larger page sizes during flash.)</p>

<p>I could manage to get around the issue by using an original <a href="https://www.microchip.com/developmenttools/ProductDetails/PartNo/atavrisp2" rel="nofollow noreferrer">Atmel AVRISP mkII</a>.</p>
