While working on my LED Sketch I getting this error......

While working on my LED Sketch I getting this error…
Has anyone seen this before? I’m getting on both my MEGA and UNO

Binary sketch size: 6,524 bytes (of a 32,256 byte maximum)
avrdude: verification error, first mismatch at byte 0x1800
0xff != 0x30
avrdude: verification error; content mismatch

Any help would be great!
Thanks
Greg

Have you by chance tried a different cable?

I can upload a different sketch and that works … The sketch compiles so I don’t the is a issue with the code

Try compiling with the newest version or the nightly build.

Larry, do you mean the Arduino compiler ?

Nothing to do with the compiler. This error is from AVRDude. The program that downloads your compiled and linked program into your device. ACRDude does not get updated very often, so fetching a new version of the compiler probably won’t get you a new version of AVRDude.

It is complaining that at address 0x1800 it tried to write the memory with 0x30, but when it read it back (to make sure it programmed OK), it got 0xFF. 0xFF is the value after the chip is erased, but 0x30 is part of your program/data. If trying a different program, it will need to be bigger than 6144 bytes long so that it tries to write the same memory location. Shorter programs will program fine and thus not a valid test.

Possible issues for this include, from the info given:

  1. Duff USB cable causing data or power issues. Avoid cheap/free cables. Even short ones. Just try another that looks totally different.
  2. Power cycling the target board. I have had timing issues and disconnecting the board for a couple of minutes and re-connecting sometimes fixes.
  3. Also had the computer sending the data out via AVRDude get messed up too with virtual COM ports and had to do a reboot to fix.

This happens to me when I program and program and program over an over again on one of my systems. Never found out why. Rebooted and it works again for days.

The error is when verifying, so AVRDude has completed programming. You could ignore the error and just let your code run and see if the fault was programming the target or verifying the target. If it runs fine, then it is just a fault while verifying. If the program does not run, then it is either a fault programming or your program is at fault. I think you have a programming fault through.

Adam,
I have tried a new usb cable, powering the device from battery, different usb port, rebooting the computer… and still getting the same issue. wound changing to a different burner help ? or any other ideas

Greg,

I presume you are programming your board through the USB anyway as you have not mentioned using the JTAG port at all.

If you have a suitable JTAG programmer you could try getting the Arduino IDE to re-flash the boot loader on your boards. Don’t forget that the UNO and Mega boot loaders are different. There are articles around on using one Arduino to program another if you don’t have a suitable programmer.

I have damaged the boot loader in the past, but they usually no longer work at all, rather being a pain.

If you know AVRDude and have a JTAG programmer, then you could use it to manually program things up or run tests on the memories of your boards. But unless you have been flashing thousands of times, I doubt if you have used up all the programming cycles. It is very difficult for an AWOL program to destroy the program memory, it is so convoluted to write to this memory.

But remember that after testing memory and manual program installs you will probably require the re-install of the boot loader. So unless you know where you are going here, this may not be a good choice.

You will need to compile your code differently if you use JTAG programming methods. Which is probably beyond the scope of this forum to discuss in depth.

It does seem odd. Is it the same memory location on your Mega and Uno, i.e. the 0x1800? Which would be a little odd because the code produced for these processors is different. And the boot loaders are different sizes, so the code would be loaded to different memory start addresses anyhow.

I’m at a loss for ideas. I’m missing a key point that you have not imparted , which is not your fault. This fault should be really obvious.

Try getting the latest AVRDude program from their web site (not Arduino) and replace it in your Arduino install. Should be a simple matter to drop the 2 or 3 files needed into Arduino without affecting anything. Keep copies of what you replace.

I went back to my mega and now it uploads the only change I made was I shorten some arrays that I had in my code. when it compiles its only using Binary sketch size: 8540 bytes (used 3% of a 258048 byte maximum) (5.25 secs) this should not be a size issue could it? is there some magic limit that arrays can be set to?

any help would be great!

Greg,

AVRDude has no understanding of the code it is programming into the target. So I’m not sure what the arrays had to do with it.

The UNO has 32KB of program memory, of which 0.5KB is used for the boot loader, leaving you with 31.5KB for your program.

The Mega 2560 (I presume this is the one you have) has 256KB, of which 8KB is used by the boot loader, leaving you with 248KB for your program.

The write fault occurred at 0x1800, which is location 6144. Nowwhere near the end of program memory on either board. I’m also suspicious of any memory fault that lands of a page boundary (256bytes) which this is.

AVRDude does not program RAM, not much point really. And it fails in programming EEPROM from the Arduino IDE due to a bug in the bootloaders. So neither of those are a concern.

You do have limits on your RAM, but these are normally a problem after programming and you try to run the program. If the arrays are pre-initialised, then they will be stored in program memory and transferred to RAM when their actual initialisation takes place. But again this transfer to RAM occurs after programming. The linker often picks up RAM shortages prior to outputing the HEX file and gives an error.

How big were these arrays and how big are they now?

I have 3 arrays each have 384 bytes in them plus the CRGB array for 60 leds…

void loop() {
Serial.println(size);

for(int h1 = size 1 ; h1 > -1; h1-) {
fill_solid(&(String1_leds[0]), (ledsPerStrip), CHSV(hue[h1],saturation[h1],brightness[h1])); //-CLEAR STRIP
LEDS.show();
delay(50);
Serial.print("h1: “);
Serial.print(h1);
Serial.print(’,’);
Serial.print(” hue: “);
Serial.print(hue[h1]);
Serial.print(’,’);
Serial.print(” saturation: “);
Serial.print(saturation[h1]);
Serial.print(’,’);
Serial.print(” value: ");
Serial.println(brightness[h1]);
Serial.println(size);
}
delay(5000);
for(int h1 = 0 ; h1 < size -1; h1++) {
fill_solid(&(String1_leds[0]), (ledsPerStrip), CHSV(hue[h1],saturation[h1],brightness[h1]));
LEDS.show();
delay(50);
}
delay(5000);

This seem like a really simple sketch

Greg

Greg,

Yes, looks simple enough.

Could you PM me the entire sourcecode for the program that reliably fails to program and I’ll try it for myself.

Thanks.

Adam here is the code that fails the arrays are larger
#include <FastLED.h>
// Pin to which the input of the matrix is connected
#define String1_DATA_PIN 6
//—LED SETUP STUFF
const int ledsPerStrip = 60;
byte iCCW;
byte iCW;

//—LED FX VARS
int max_bright = 128; //-SET MAX BRIGHTNESS TO 1/4
CRGB String1_leds[60];
//—CHSV Color Setup
byte hue[] = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,32,33,34,35,36,37,38,39,40
,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81
,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116
,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147
,148,149,150,151,152,153,154,155,156,157,158,159,160,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176
,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207
,208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223,224,225,226,227,228,229,230,231,232,233,234,235,236,237,238
,239,240,241,242,243,242,243,244,245,246,247,248,249,250,251,252,253,254,255,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19
,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60
,61,62,63,64,65,66,67,68,69,70,71,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99
,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130
,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,153,154,155,156,157,158,159
,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,181,182,183,184,185,186,187,188,189,190
,191,192,193,194,195,196,197,198,199,200,201,202,203,204
};
byte saturation[] = {255,252,250,250,247,245,242,240,237,235,232,232,230,227,224,222,219,217,214,212,207,204,201,201,199,196,196
,194,194,191,189,186,186,186,186,184,181,179,176,176,173,171,168,166,163,161,158,156,156,153,150,148,143,140,138,135,133,130
,128,122,120,115,112,107,105,102,99,97,99,99,99,99,99,99,99,102,102,105,105,105,105,105,105,105,107,110,112,117,122,128,130
,133,138,143,145,150,153,156,161,163,166,171,173,176,179,181,186,189,191,194,196,199,201,204,207,209,212,214,212,214,217,219
,222,224,224,227,230,232,235,235,237,222,212,201,191,184,176,168,161,153,148,140,135,130,122,117,112,107,102,97,92,87,82,79,74
,69,64,61,56,54,48,46,41,38,41,38,36,31,28,26,23,18,15,13,10,10,8,5,5,8,10,10,13,13,15,15,18,20,23,23,26,28,28,31,31,33,33,36
,38,38,38,41,41,43,43,46,46,46,48,48,48,51,51,51,54,54,54,56,56,56,56,59,59,59,61,61,61,61,61,64,64,64,64,64,64,66,66,66,66,69
,69,69,69,69,69,69,71,71,71,71,71,71,71,74,74,74,74,74,74,74,74,74,77,77,77,77,77,77,77,79,79,79,79,79,79,79,79,79,79,79,79,82
,82,82,82,82,82,82,82,82,84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,87,87,87,87,87,87,87,87,87,87,87,87,87,87,89,89,89,89
,89,89,89,89,89,89,89,89,89,89,89,89,89,89,89,89,89,89,89,89,89,89,92,92,92,92,92,92,92,92,92,92,92,92,92,92,92,92,92,92,92,92
,92,92,92,92,92,92,92,92,92,92,92,92,92,92,94,94,94,94,94,94,94,94,94,94,94,94,94,94,94,94,94,94,94,94,94,94,94,94,94,94,94,94
,94,97,97,97,97,97,97,97,97,97,97,97,97,97,97,97,97,97,97,97,97,97,97,97,97,97,97,97,97,97,97,97,97,97,97,97,97,97,97,97,97,97
,97,97,97,97,97,97,97,97,97,97,97,97,97,97,97,97,97,97,97,97,97
};
byte brightness[] = {255,252,250,250,247,245,242,242,240,237,235,232,232,230,227,227,224,222,219,217,217,214,212,209,209,207,204
,204,201,199,196,194,194,194,194,191,189,186,186,184,181,181,179,176,173,171,171,168,166,163,163,161,158,158,156,153,150,148
,148,145,143,140,140,138,135,135,133,133,135,138,140,140,143,145,148,148,150,153,156,158,158,161,163,166,166,168,171,173,176
,176,179,181,184,186,186,189,191,194,194,196,199,201,204,204,207,209,212,214,214,217,219,222,222,224,227,230,232,232,232,232
,235,237,240,242,242,245,247,250,250,252,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255
,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255
,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255
,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255
,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255
,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255
,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255
,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255
,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255
,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255
,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255
,255,255,255,255,255,255,255,255,255,255
};

int size = sizeof(hue);

CRGB interpolate(CRGB from, CRGB to, byte nSteps) {
CRGB ret;
ret.r = map(nSteps, 0, 255, from.r, to.r);
ret.g = map(nSteps, 0, 255, from.g, to.g);
ret.b = map(nSteps, 0, 255, from.b, to.b);
return ret;
}

//------------------SETUP------------------
void setup()
{
Serial.begin(9600);
LEDS.addLeds<WS2811, String1_DATA_PIN ,GRB>(String1_leds, ledsPerStrip);
LEDS.setBrightness(max_bright); // SET BRIGHTNESS TO 1/4 POWER
LEDS.clear();
LEDS.show();
delay(2000);
}
//----------------Loop----------------
void loop() {
Serial.println(size);

for(int h1 = size 1 ; h1 > -1; h1-) {
fill_solid(&(String1_leds[0]), (ledsPerStrip), CHSV(hue[h1],saturation[h1],brightness[h1])); //-CLEAR STRIP
LEDS.show();
delay(50);
Serial.print("h1: “);
Serial.print(h1);
Serial.print(‘,’);
Serial.print(” hue: “);
Serial.print(hue[h1]);
Serial.print(‘,’);
Serial.print(” saturation: “);
Serial.print(saturation[h1]);
Serial.print(‘,’);
Serial.print(” value: ");
Serial.println(brightness[h1]);
Serial.println(size);
}
delay(5000);
for(int h1 = 0 ; h1 < size -1; h1++) {
fill_solid(&(String1_leds[0]), (ledsPerStrip), CHSV(hue[h1],saturation[h1],brightness[h1]));
LEDS.show();
delay(50);
}
delay(5000);
}

Greg,

Code compiled with Arduino 1.0.5 perfectly OK.
Downloaded to Mega2560 with AVRDude 5.11 perfectly OK.

I don’t know if AVRDude 5.11 is the standard version that comes with Arduino 1.0.5. I some times update parts of Arduino between its official releases. It is very unlikely that I have changed the version of WinAVR. But AVRDude is very likely.

I normally use AVRStudio for the bulk of my works, making it emulate Arduino. But I use the Arduino IDE for short test bits of code, so I know its pretty stable.

So, from you code. I can find no problem compiling and more importantly no download problems.

I presume it runs, I didn’t have anything connected to the Mega2560, other than an Ethernet Shield.

Having said that, the Bootloader on the Mega2560 is non -standard. I used one that supports USB and TFTP. This maybe an issue.

I’ll re-flash the original Arduino bootloader over the weekend and get back to you.

I re-flashed my boot loader on my uno and now that one works but I can’t get the mega to re-flash at all can any share on how to do that device

Adam,
You were correct it was in the bootloader I found this great link to fix it
http://www.gammon.com.au/forum/?id=11635

Thanks for all your help!
Greg

Greg,

That is good news indeed. Interesting article, I try and read fully at some point.

How to flash will depend on what tools you have to do the flashing? I have and AVR Dragon and a TinyUSB to re-program stuff. The TinyUSB would be my choice for just doing a boot loader.

I tend to write a short script that programs a board (e.g. Mega), with a programmer (e.g.Tiny) with a specific bootloader. I have a directory full of these scripts for the various combinations with a sub-directory full of different bootloaders. Mostly use the latest version of AVRDude to flash stuff as it does almost everything Atmel. Don’t expect the Arduino IDE to do everything you need, its not really supporting such a low level. It programs boot loaders, but only with its released versions (with bugs, like no EEPROM support). You need to get down to the command prompt to do all the useful stuff.

Make sure the bootloader is actually designed AND compiled for the board it is to be used on. You can’t just compile a 328P loader for the 2560, as the method of programming and addressing the memory is different. The 328P and 2560 are very different and the code is NOT interchangeable. If you have a HEX file, then you are at a good point, but with an ELF file it’s easier. The ELF file can tell the programming software much more detail. If you don’t have this, you will have to tell AVRDude this missing bits, like where, and fuse settings and so on. Even with a ELF file, you may still need to define other settings for the processor.

For missing settings, you can get AVRDude to read out the current settings (like fuse bits) and make a note. The fuses for a 328P are not the same as 2560 either.

To compile a boot loader you can either use AVRStudio or WinAVR, depending on what tools the author used.

The 328P is better supported with articles, and I can only give you pointers as there are so many variable here. You appear skilled enough to learn and find out for yourself, which is good. The Optiboot is good and I use it. And it is the corrected version that the Arduino IDE uses.

Happy programming.

Adam.