Help with error "Problem uploading to board. See..."

Hi all,

First, I apologize if I've missed a duplicate post with discussions/solutions. I honestly tried searching, but please direct me to a relevant post if needed.

I'm having a problem uploading my sketch to an Arduino UNO board on Win 7 32-bit. The code can be "verified" successfully, but the error occurs when I actually push the Upload button. The error text (with verbose output enabled) I get is shown below. I intentionally left out a lot of the text with the verbose output option because there was a ton of it. If you want to see it all, just let me know. The three starred (*) lines are the lines I get with verbose output disabled.

Problem uploading to board. See http://www.arduino.cc/en/Guide/Troubleshooting#upload for suggestions.

Binary sketch size: 28908 bytes (of a 32256 byte maximum).
...
* avrdude: stk500_paged_write(): (a) protocol error, expect=0x14, resp=0x64
# | 100% 10.62s

* avrdude: failed to write flash memory, rc=-4
avrdude: Send: Q [51]   [20] 
avrdude: Recv: 
* avrdude: stk500_disable(): protocol error, expect=0x14, resp=0x51

avrdude done.  Thank you.

Now, it is important to note that with a sketch size of 28652 bytes (256 bytes less than the sketch that throws the error), everything works fine. Those 256 bytes come from an unsigned char array in a massive data table I'm using. So essentially I've narrowed down the problem such that when the size of the table pushes the sketch size above 28652 bytes, the above error is thrown. Because I'm not hitting the 32256 byte maximum, my question is why?

Here's another important thing to note » Because of the amount of space I needed to include this table, it is declared in a header file (.h) in the program memory with the following statement:

PROGMEM prog_uchar frames[] = {0,0,540,250,43, ... // LOTS of data

The rest of my code is driving an 8x8 LED matrix over SPI. The massive data table I use is for the look up of the frames I display on the LED matrix. What the code actually does is grab a byte at a time and sends it out the SPI data out port to my hardware. When 4 bytes have been sent, a pulse is sent to my hardware that "latches" the frame in place. This process continually loops through the frames[] array forever and ever. (When it works it looks awesome, I might add :slight_smile: Very pleased thus far)

I've tried looking through the troubleshooting guide the error message mentions, but because my code works fine with sketch sizes below 28652 bytes, I really wasn't able to find anything useful in the guide. Can anyone shed some light into why this problem occurs? I imagine that there is some kind of limit in the amount of program memory I can use or perhaps the size of my frames[] array, but I just don't know what. By the way, I am more than willing to do some leg work on my side, and all I'm looking for is a little nudge in the right direction.

Thanks!
-Rory

Can you state your fuse settings? Something like this should do it:

avrdude -c arduino -p m328p -v

Also does your large array have a lot of 0xFF in it (255)?

PROGMEM prog_uchar frames[] = {0,0,540,250,43, ... // LOTS of data

BTW 540 won't fit into an unsigned char.

One easy thing to try:

Hold down the Reset button on the Arduino.
Unplug the USB cable (either end) for a few seconds.
Plug the USB cable back in.
Click on the Upload button and when the "Binary sketch size" messages appears, release the Reset button.

@johnwasser - unfortunately, this did not work. No change.
@Nick Gammon - thanks for catching my typo XD. I've actually never investigated fuse settings before, so I'm not sure what you mean/how to check them. I don't have a programmer, but I found another post (http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1287169320/0)that looks like a software way to check the fuse settings. If you scroll halfway down to the post by westfw, he posted a sketch that returns what looks to be fuse information. Is this the information you're after?

Concerning the array of data, no there's not much 0xFF data in it. In fact, most of the data is actually 0x00, corresponding to 'off' LEDs. This data can change from time to time depending on the pattern I'll be displaying, but still rarely any 0xFF's are used. Here's the first few lines if you're still curious:

PROGMEM prog_uchar frames[] = {
  /*** 0-0-0 ***/ 0, 72, 0, 127, 
  /*** 0-0-1 ***/ 0, 4, 0, 191, 
  /*** 0-0-2 ***/ 0, 0, 128, 223,
  /*** 0-0-3 ***/ 0, 146, 64, 239,
  /*** 0-0-4 ***/ 0, 90, 0, 247,
  /*** 0-0-5 ***/ 0, 90, 0, 251,
  /*** 0-0-6 ***/ 0, 8, 0, 253,
  /*** 0-0-7 ***/ 0, 72, 6, 254,

so I'm not sure what you mean/how to check them

Just run the command Nick provided from a command window.

You might want to post (or attach) your code. Since you need to keep he frame array, people here may have suggestions as to how you can make other areas of your code shorter.

He doesn't have a programmer, he says. But if you have a second Arduino you can run this:

Run this sketch, it will tell you your fuses:

Fuse self-detect sketch

#include <avr/boot.h>

#define SIGRD 5

void setup ()
{
Serial.begin (115200);
Serial.println ();

Serial.println ("Signature");

byte sig;
  sig = boot_signature_byte_get (0);
  Serial.println (sig, HEX);
  sig = boot_signature_byte_get (2);
  Serial.println (sig, HEX);
  sig = boot_signature_byte_get (4);
  Serial.println (sig, HEX);

Serial.println ("Fuses");
byte fuse;
  
  fuse = boot_lock_fuse_bits_get (GET_LOW_FUSE_BITS);
  Serial.println (fuse, HEX);
  fuse = boot_lock_fuse_bits_get (GET_HIGH_FUSE_BITS);
  Serial.println (fuse, HEX);
  fuse = boot_lock_fuse_bits_get (GET_EXTENDED_FUSE_BITS);
  Serial.println (fuse, HEX);
  fuse = boot_lock_fuse_bits_get (GET_LOCK_BITS);
  Serial.println (fuse, HEX);
}

void loop () {}