Go Down

Topic: weird sketch size issues with Optiboot in Arduino 0022/0023 and Atmega328 (Read 1 time) previous topic - next topic

bigfun

This is just a word of warning to people who compile large Atmega328 sketches using the Optiboot bootloader on Arduino0022 and 0023 (I haven't tried it on other versions of the IDE).  When the sketch exceeds 28725 bytes in size (and possibly smaller, though no smaller than 27734 bytes), the upload will fail if you are using the Optiboot bootloader.  It will initially seem to be working (lights will blink, etc.) but the the upload will hang.  This isn't a problem with the Adaboot bootloader (and perhaps others that allow so much usable flash space).  It was good to finally figure out that the size of the sketch was the issue and not something else. (It took me hours to figure out what was wrong -- it was only obvious when I tried uploading a different sketch.)

The error you will get when the upload fails is:

avrdude: stk500_getsync(): not in sync: resp=0x00
avrdude: stk500_disable(): protocol error, expect=0x14, resp=0x51

westfw

How old is your Arduino?  Or did you load optiboot into a 328 yourself?
This was a well-known bug in the initially released version of optiboot, but it was fixed in the 1.0 timeframe (About two years ago.)
http://arduino.cc/forum/index.php/topic,28074.0.html
https://github.com/arduino/Arduino/pull/30

bigfun

I loaded the bootloader myself, using (in at least one case) the optiboot bootloader provided with the Arduino022 download (I've found it more or less impossible to migrate my code to Arduino 1.0X, but then again there isn't much motivation). The thing about "well known bugs" is that they're only really well-known to people who know.  My Google searches turned up nothing when I searched for all the symptoms I was seeing. It's good to hear this bug has been fixed; Optiboot is so much better than any other bootloader I've tried.  I really don't have the time to wait around for the stock bootloader. Also:  for an Arduino to be usable in real equipment, there needs to be a watchdog (supported by Optiboot and Adaboot). Otherwise your solar pump will hang at some point while you're on a beach in the Dominican Republic and all your antifreeze will boil out into the snow.

DirtBiker


Otherwise your solar pump will hang at some point while you're on a beach in the Dominican Republic and all your antifreeze will boil out into the snow.


Sounds like the voice of experience. :smiley-eek:
Dirt Biker

bigfun

i narrowed down the range of sketch sizes where the optiboot bootloader would fail to between 28660 and 28676 and then did google searches on each of the values with optiboot:

optiboot 28660
optiboot 28661
etc.

and got hits for 28666 and 28668 -- that latter one (and 28672) gave me this page:
http://code.google.com/p/optiboot/issues/detail?id=23

westfw

Quote
i narrowed down the range of sketch sizes

Ah.  I was wondering what you had searched for that hadn't turned up anything useful.  AFAIK, few of the early reports of this problem went to the effort to determine the exact sketch size that caused problems.  If you had googled "Uno sketch size hang", you would have had better luck...

bigfun

I'm using an old Arduino BT for testing at my workstation and, for the actual application, an Atmega328 in an Olimex 28 pin development board (reachable only via RS-232) -- so I wouldn't have thought to call it a UNO.

Go Up