avrdude: verification error, first mismatch at byte 0x7800

Hi,

i’ve been trying to upload a sketch to my arduino Uno R3 and avrdude give me this error every time:

avrdude: verification error, first mismatch at byte 0x7800
0xff != 0xb1
avrdude: verification error; content mismatch

when I upload my sketch to a mega board, there is no problem at all. Or when i upload some other sketch to my uno, it is always working well. The sketch itself is pretty big:

Sketch uses 32 008 bytes (99%) of program storage space. Maximum is 32 256 bytes.
Global variables use 1 483 bytes (72%) of dynamic memory, leaving 565 bytes for local variables. Maximum is 2 048 bytes.

But I think it should not cause this problem. I attached 2 pictures of my board, if it counts something… So what can I do? It is urgent, thank you in advance!

I don't know if it has to do with your errors, but the board looks like a counterfeit board. Almost textbook per this link:

http://www.arduino.cc/en/Products/Counterfeit

It sounds like you’re trying to write a sketch that’s so big it’s trying to overwrite your bootloader. You do not get the full 32kB of Flash for your sketch. The Arduino has a small piece of code that it keeps at the end of Flash so that it can download new sketches into the rest of memory.

I’d need to go check the size/location of the bootloader to be sure and a 2kB bootloader would be pretty big, but it definitely sounds like you’re trying to write a sketch that is starting to infringe on the bootloader space.

Edited to add:

These are the bootloader space options in the Uno:
bootsz_fuse_options.png

It seems your Arduino is using the default option, which is a 2kB bootloader. I’ve actually never owned a genuine Arduino so I don’t know if that’s normal or not.

I do know that I use Optiboot in my Uno clones, and it uses the 512B bootloader space. Instructions for burning Optiboot in your Uno are here → https://github.com/Optiboot/optiboot

Keep in mind, however, this just gets you 32kB - 512B = 32256 bytes! That’s more than the 32008 bytes your sketch needs, but not by much! It’s likely worth finding ways to make your code smaller.