Arduino Forum

Forum 2005-2010 (read only) => Hardware => Troubleshooting => Topic started by: westfw on Jan 20, 2011, 10:45 am

Title: Uno Bootloader Fixer...
Post by: westfw on Jan 20, 2011, 10:45 am
I've written a short sketch that will help you load a fixed bootloader unto you Uno systems, assuming that you have a second arduino of some kind to do the fixing.

This is based on the arduinoISP programming sketch, except it includes an internal copy of a (fixed) optiboot bootloader, so there are no communications issues.  You just connect up an Arduino containing the sketch to an Uno with the iffy bootloader (as per instructions here: http://arduino.cc/en/Tutorial/ArduinoISP ), hit reset, and it will drop in a new bootloader.  (Status is displayed to the Serial port at 19200bps, but you don't really need to watch it.)

This is actually a subset of a more ambitious effort to load optiboot into all sorts of old Arduinos, but that's waiting on more complete documentation.  meanwhile, doing Uno only is pretty simple and is getting increasingly urgent as more optiboot bugs show up.

the fixed optiboot included in the sketch has:
1) PWM timer initialization fixed (this was also fixed in the core.)
2) 30k upload limit fixed.
3) zero register initialization (Sketch amnesia) fixed.

optifix.zip (https://docs.google.com/uc?id=0B6dMB5dovDUZM2ZhMmUxYTItM2ExNy00MWM1LWIzMTgtNWI0ZGUwYTNhZTE2&export=download&hl=en)
Title: Re: Uno Bootloader Fixer...
Post by: pluggy on Jan 20, 2011, 11:21 am
Question, do I give optiboot up as a lost cause (like I had done) or try it one more time ?
Title: Re: Uno Bootloader Fixer...
Post by: pluggy on Jan 20, 2011, 02:43 pm
After previous negative comment, I'm happy to report that after implementing this, it appears to have resolved my issues with optiboot, for the first time I've been able to put it to work running my home monitoring system.  
Title: Re: Uno Bootloader Fixer...
Post by: retrolefty on Jan 20, 2011, 02:46 pm
Well see, that wasn't so bad.  8-)
Title: Re: Uno Bootloader Fixer...
Post by: pluggy on Jan 20, 2011, 02:50 pm
I'd been suffering optiboot since I first came across it about 3 months before they launched the UNO.  This one appears to work.  If it continues to behave I might just put it on my Duemilanoves  :)
Title: Re: Uno Bootloader Fixer...
Post by: retrolefty on Jan 20, 2011, 02:59 pm
I've been using the lady adafruit bootloader for seems like a year now on all my 328 setups. It handles WDT correctly and seems to have a very short bootloader time out, sketches seem to start instantly on power up.

What is the timeout period of optiboot and does it handle WDT interrupts correctly? I'm aware of it's biggest advantages, smaller size and faster baud rate.
Title: Re: Uno Bootloader Fixer...
Post by: pluggy on Jan 20, 2011, 03:08 pm
I do use an interrupt in my sketch but its just a standard attachInterrupt(); job. Never really done anything with the watchdog stuff.  I always had it down as something you used when you put it to sleep to save your precious batteries....  
Title: Re: Uno Bootloader Fixer...
Post by: retrolefty on Jan 20, 2011, 03:49 pm
Quote
I always had it down as something you used when you put it to sleep to save your precious batteries....


That's it's most common use around here I think. It's main purpose in industrial use is as a safety feature to reset the processor in case it locks up in some kind of endless loop due to a programming error or some kind of glitch, and can be used externally to cause fall back to manual control, sound an alarm, etc.

Title: Re: Uno Bootloader Fixer...
Post by: westfw on Jan 20, 2011, 04:51 pm
Quote
What is the timeout period of optiboot and does it handle WDT interrupts correctly?

I believe the optiboot in optifix has a one second timeout.
All versions of optiboot handle WDT correctly (optiboot includes the AdaBoot startup features...)
Title: Re: Uno Bootloader Fixer...
Post by: pluggy on Jan 20, 2011, 05:43 pm
Can your fix be made the standard Optiboot ?   The 'official' optiboot site still has V3 from May last year.

http://code.google.com/p/optiboot/

Which is probably whats going onto the Uno as standard.
Title: Re: Uno Bootloader Fixer...
Post by: westfw on Jan 20, 2011, 06:18 pm
The optiboot source code is now beyond "version 3"; the new source version has the 30k fix (plus support for other CPUs, plus some other stuff.)
The "amnesia" fix has been submitted as an optiboot issue (with patch), and SHOULD get into the official source at some point.  (meanwhile, it got added to the optiboot source that comes with the Arduino environment, but that version doesn't have the 30k fix.)

Sigh.  Keeping the official optiboot in sync with the arduino optiboot, and up-to-date (tested?) with some set of changes becomes essentially a non-technical issue of ... some difficulty.  Not dissimilar to the Arduino issues that turn out to be due to gcc compiler bugs.