I have a very strange problem. Using Arduino 1.6.5
In a fairly big sketch i included the 'tone' function. On one computer it works just fine. On another computer the upload fails with this error:
avrdude: verification error, first mismatch at byte 0x7000
0xff != 0x2f
avrdude: verification error; content mismatch
After compilation, the status is:
Sketch uses 29,414 bytes (91%) of program storage space. Maximum is 32,256 bytes.
Global variables use 1,047 bytes (51%) of dynamic memory, leaving 1,001 bytes for local variables. Maximum is 2,048 bytes.
Just by removing the statement:
tone(A4, 200);
from simple-co2-monitor-fw.ino / line 98 - then the sketch uploads successfully.
I've attached the sketch for reference.
Next thing i am going to do is to analyze in detail the two installations of the Arduino ide. But if someone faced this issue already I would be very thankful for some hints
One possible cause that I've heard of: Someone said that avrdude (the uploader) assumes that memory has been cleared to 0xFF before the sketch is uploaded. If there is a memory page in the sketch that contains nothing but 0xFF then avrdude will not bother to write it. If the memory has NOT been reset (and I don't think the Arduino IDE requests a reset) the unwritten page will cause a verification error if it contains anything other than 0xFF.
After i investigated a bit more, it turned out that the reason for failing upload is that the sketch becomes larger than 0x7000 bytes.
And it fails only on some devices. I have bought the ATMega328p chips from Aliexpress and embedded them in my device - is it possible that some of them are faulty ?
I just modify the sketch by increasing or decreasing the length of a string. If it is less than 0x7000 bytes totally - then it is fine - once it reaches 0x7001 it fails to upload
Seems like uploading sketches larger 0x7000 bytes can result in failure in some bootloaders.
Apparently i have flashed my chips at different times, and some of them have a different bootloader
in fact avrdude, shows the Firmware Version of the failing one as 3.3, and the other as 4.4