Go Down

Topic: Mega 2560 bootloader revised? (Read 6748 times) previous topic - next topic

draythomp

I just posted (again) on the developers list about this item.  I've lost contact with the developer and he may well be extremely busy in his real life, plus, he told me that he had fixes and was just working to get them in the official code.  However, there has been nothing said about this for a couple of months so:

Code: [Select]

Folks,

I've been trying to be a nice guy and not bug the heck out of you about this other than the
few messages I've sent, but what about the two major bugs in the 2560 bootloader?  1. The
watchdog timer doesn't work right and, 2. three exclamation points cause the bootloader to
fail.  There are a number of us 2560 owners out here and many of us are painfully working
around these problems in some fashion.  The exclamation point problem is especially insidious
since it can exhibit itself any time the data organizes itself into that pattern, arrays, data
values, etc.

These have been known about for a year now, and as I understand it, there are fixes in place
for both of them; they just aren't where any of us normal folk can get them.

So, perhaps someone could delay interminable discussions of return values and text formatting
and fix a couple of the problems that are driving your users nuts....


I probably made a few enemies, sorry.
Trying to keep my house under control http://www.desert-home.com/

gerg


I probably made a few enemies, sorry.


If you did, it speaks very poorly about the core arduino (presumably) developer base.

Once again, thanks for representing the best interests of your fellow 2560 users.
http://maniacalbits.blogspot.com

draythomp

OK, progress.  I saw the following on the developer's mail list.  Note, I'm just posting this, I haven't done anything with it yet.  I'll get into that in the next week or so.  I haven't burned a boot loader on a 2560 and want to be sure I can put a (sorta) working one back in place if I install one that doesn't work.  So, I've got a little research to do first.  However, here's the message:

Code: [Select]
Rick Anderson rick.rickanderson at gmail.com
Tue Sep 13 09:32:15 EDT 2011
Previous message: [Developers] Repository for source of ADK on labs?
Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
The latest code from Mark Sproul for the Arduino stk500v2 is in a
github repository.

Arduino stk500v2 bootloader
https://github.com/msproul/Arduino-stk500v2-bootloader

Does need some testing, and many people have talked about issues so
please feel free to file the issues here:
https://github.com/msproul/Arduino-stk500v2-bootloader/issues

Also, it can be forked back to Arduino if it should live there.

-_Rick
--
President
Fair Use Building and Research (FUBAR) Labs
http://fubarlabs.org



So, if there's someone out there that already has the experience to try this out, go for it.
Trying to keep my house under control http://www.desert-home.com/

draythomp

I got the zip file and put it in place using IDE 21 and tried to burn it.  Got an address exception instantly.  Unfortunately, I didn't get it copied down.  I had to burn the old bootloader back on the board and reload my sketch because I only have one 2560 right now.

Someone else care to give this a try?  If not, I'll try it again later, but right now I need the 2560 running.
Trying to keep my house under control http://www.desert-home.com/

draythomp

Got a chance to try it again and this was the message

avrdude: ERROR: address 0x40010 out of range at line 515 of < and the file name followed >

Does anyone know what this means?
Trying to keep my house under control http://www.desert-home.com/

draythomp

Still trying to get these problems resolved.  Here's my latest mail to the
developer's group.

Code: [Select]
It's been a couple of weeks since the last response, has there been any
progress on this long-term problem?

Meanwhile, at least one person has replaced the 2560 bootloader with one
for the 1280 to get around the problems.  Is that what we're going to be
reduced to, crippling the board to make it work?  Especially since the fixes
for both problems have existed for months and months?  I totally understand
the need to organize the code and keep track of it, but give us a hex file to
load and test with while the other stuff is being done.

>Hey Guys,
>
>I talked to Massimo he wants to make sure this is moved into a project
>in Arduino. We'll get this straightened out.

>In the meantime I'll ask Mark about the hex file.
>
>-_Rick
>
>On Wed, Sep 14, 2011 at 10:34 PM, Dave Thompson <draythomp at
>gmail.com> wrote:
>> Thanks for the update and the code.  I can't get the hex file to load
>> though.  This is the error I get:
>>
>>
>>
>> avrdude: ERROR: address 0x40010 out of range at line 515 of < and the
>> file name followed >
>>
>>
>>
>> dave
>>


I know the developers visit this board from time to time because I see their comments.  Why are we being stonewalled on this?
Trying to keep my house under control http://www.desert-home.com/

Big Dutch

Thanks for keeping us posted on your progress!

draythomp

Progress  !!!

Quote
the bootloader is now an "official" Arduino repository.
we recompiled the code because the HEX provided were defective.

We've added a test program to verify that the bootloader can work with files bigger than 128k

you can find it here https://github.com/arduino/Arduino-stk500v2-bootloader

let us know if this solves your issues. we're committed to fix all the issues asap.

thanks

massimo


I'll get to try it soon, but I can't right now.  If someone else out there has a minute, take a shot.  I suspect it will work just fine.
Trying to keep my house under control http://www.desert-home.com/

Graynomad

Quote
Progress  !!!

Careful with those exclamation marks :)

______
Rob
Rob Gray aka the GRAYnomad www.robgray.com

draythomp

Ok, got a chance to test it.  I used a USBtinyISP and loaded the file indicated above.  With the test sketch:

Code: [Select]

void setup(){
 Serial.begin(57600);
 Serial.println("Hello World !!!");
}
void loop(){
}


The new bootloader loaded and executed the file just fine.  However, the sketch:

Code: [Select]

#include <avr/wdt.h>

void setup(){

 wdt_reset();   // First thing, turn it off
 wdt_disable();
 Serial.begin(57600);
 Serial.println("Hello, in setup");
}

int firstTime = true;

void loop() {
     if (firstTime){
       firstTime = false;
       Serial.println("In loop waiting for Watchdog");
       wdt_enable(WDTO_8S);    // eight seconds from now the device will reboot
     }
     // now just do nothing
}


this one loaded and then hung up in a loop.  I had to power down and reload a new script after holding the reset button until the compile finished to get the board back.
Trying to keep my house under control http://www.desert-home.com/

darryl

looking around I came across these two pages.....

http://code.google.com/p/arduino/issues/detail?id=392
http://code.google.com/p/arduino/issues/detail?id=459

anyway. on the 392 link is a fix for the firmware which stops the !!! bug.

so people you can request the code from the developer, or patch your own local code, compile and burn a new hex file.
--
 Darryl

draythomp

Yes, that will probably work for the "!!!" problem if you want to get into the bootloader code and hope you can figure out where to put the changes.  The link I posted above  https://github.com/arduino/Arduino-stk500v2-bootloader also works for the "!!!" changes and is a hex file that you can just burn to the board.

I have tested this hex file quite a bit, but it may still have problems since, to the best of my knowledge, I'm only one of two people that has.  I'm currently running this file on a 2560 that is in service, doing stuff.

Remember though, this hex file and the links you cited don't do a thing for the watchdog timer problem.  We're still waiting on that.
Trying to keep my house under control http://www.desert-home.com/

draythomp

#27
Oct 29, 2011, 11:38 pm Last Edit: Oct 30, 2011, 01:12 am by draythomp Reason: 1
I've been using the bootloader above extensively and have encountered zero problems loading the 2560 board.  However, this bootloader doesn't fix the watchdog timer problem and the board WILL hang up in a loop until you power cycle it; nope, reset won't do it.  I have been using timer three as a pseudo watchdog, but I hate having to use up one of my timers for this when the watchdog is there.  So, I was reading another thread on this board and came up with a solution.  It's not as elegant as a simple watchdog, but it works and also allows a watchdog timer of virtually any length.  The code is below, and following the example, you can have as short or as long a watchdog timer as you need and not tie up one of the other timers.  This will probably work on the 1260 and lower boards as well (I haven't tested it on other boards).  Now, I don't have to wait for the developers to fix it anymore.

So, use it in good health and have fun.

Code: [Select]
#include <avr/wdt.h>

unsigned long resetTime = 0;
#define TIMEOUTPERIOD 5000             // You can make this time as long as you want,
                                      // it's not limited to 8 seconds like the normal
                                      // watchdog
#define doggieTickle() resetTime = millis();  // This macro will reset the timer
void(* resetFunc) (void) = 0; //declare reset function @ address 0

void watchdogSetup()
{
cli();  // disable all interrupts
wdt_reset(); // reset the WDT timer
MCUSR &= ~(1<<WDRF);  // because the data sheet said to
/*
WDTCSR configuration:
WDIE = 1 :Interrupt Enable
WDE = 1  :Reset Enable - I won't be using this on the 2560
WDP3 = 0 :For 1000ms Time-out
WDP2 = 1 :bit pattern is
WDP1 = 1 :0110  change this for a different
WDP0 = 0 :timeout period.
*/
// Enter Watchdog Configuration mode:
WDTCSR = (1<<WDCE) | (1<<WDE);
// Set Watchdog settings: interrupte enable, 0110 for timer
WDTCSR = (1<<WDIE) | (0<<WDP3) | (1<<WDP2) | (1<<WDP1) | (0<<WDP0);
sei();
Serial.println("finished watchdog setup");  // just here for testing
}


ISR(WDT_vect) // Watchdog timer interrupt.
{
 if(millis() - resetTime > TIMEOUTPERIOD){
   Serial.println("This is where it would have rebooted");  // just here for testing
   doggieTickle();                                          // take these lines out
//  resetFunc();     // This will call location zero and cause a reboot.
 }
 else                                                       // these lines should
   Serial.println("Howdy");                                 // be removed also
}


void setup(){
 watchdogSetup();
 Serial.begin(57600);
 Serial.println("Hello, in setup");
}

int firstTime = true;

void loop() {
 if (firstTime){
   firstTime = false;
   Serial.println("In loop waiting for Watchdog");
 }
 if(millis() - resetTime > 2000){
   //doggieTickle();  // if you uncomment this line, it will keep resetting the timer.
 }
}


edit: Yes, yes I know all about the millisecond timer rolling over.  That is left as an exercise for the student.
Trying to keep my house under control http://www.desert-home.com/

draythomp

This problem is very, very near being resolved.  There is new source and a hex file that works; I tried it.

So, those of you that have been working around this problem will soon have a solution available.  However, the existing boards won't fix themselves, you'll have to burn a new bootloader on the board.  The latest software fixes both the exclamation point problem and the watchdog timer problem.

Hooray !!!  (the exclamation points are intentional)
Trying to keep my house under control http://www.desert-home.com/

gerg

That's certainly good news. Are we waiting for an official announcement and code clean up or is what you have been testing the done deal? What makes it "very near being resolved", versus actually done?

Have any links you can share? Hex files, etc? Will this be as simple as burning a new boot loader or will the IDE environment need to change too?
http://maniacalbits.blogspot.com

Go Up