Pages: [1]   Go Down
Author Topic: Update MEGA 2560 bootloader  (Read 1360 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 10
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello, I read that there was a bug in the Mega 2560 bootloader that causes it to hang when there are three ! in a row, I have come across this several times.

I found this bootloader, and am guessing this is the new bootloader https://github.com/arduino/Arduino-stk500v2-bootloader/blob/master/goodHexFiles/stk500boot_v2_mega2560.hex

If it is the new one, how do I go about writing it to my mega 2560?
If it is not, where can I find the new one?

Thanks in advance for any help I recieve
Logged

Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 443
Posts: 23834
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

To burn a new bootloader, you need a programmer.
I use Atmel AVR ISP MKii.
If you have another Arduino you can use that:
http://www.gammon.com.au/forum/?id=11635
Logged

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

Offline Offline
Newbie
*
Karma: 0
Posts: 10
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

hmmm... i didnt really want to buy  something extra, i will see if i can get hold of my friends uno
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 10
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I managed to get hold of my friends uno

it was much simpler and more painless than i expected
Logged

Left Coast, CA (USA)
Offline Offline
Brattain Member
*****
Karma: 331
Posts: 16540
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I managed to get hold of my friends uno

it was much simpler and more painless than i expected

Not so painless for many that try on their first attempt, congratulations.

So did this bootloader indeed fix the !!! problem?
I wonder if it also includes the fix to handle WDT resets correctly also?

Lefty
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 10
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset


Not so painless for many that try on their first attempt, congratulations.

So did this bootloader indeed fix the !!! problem?
I wonder if it also includes the fix to handle WDT resets correctly also?

Lefty


Thank you!

i can confirm that it has solved my !!! problem, and how do i check the WDT resets?

EDIT: i tried the sketch from this post
http://arduino.cc/forum/index.php/topic,45381.msg329036.html#msg329036
Code:
#include <avr/wdt.h>

void setup(void)
{
   Serial.begin(57600);    // start serial port
//  wdt_disable();
  wdt_enable(WDTO_8S);   // set the wdt on 8 sec
}

void loop(void)
{
    wdt_reset(); // reset the wdt
Serial.println("delays 5000");
 delay(5000);
 wdt_reset(); // reset the wdt
 Serial.println("delays 7000");
 delay(7000);
  wdt_reset(); // reset the wdt
  Serial.println("delays 10000");
 delay(10000);
   Serial.println("delays 15000");
 delay(15000);
}

and i get...
delays 5000
delays 7000
delays 10000
delays 5000
delays 7000
delays 10000
delays 5000
delays 7000
delays 10000
delays 5000
delays 7000
delays 10000
« Last Edit: December 28, 2012, 04:18:52 pm by Shuttleu » Logged

Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 443
Posts: 23834
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Apparently something is resetting after this
 
Code:
Serial.println("delays 10000");
delay(10000);

As this is not occurring
Code:
   Serial.println("delays 15000");
Logged

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

Offline Offline
Newbie
*
Karma: 0
Posts: 10
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Apparently something is resetting after this
 
Code:
Serial.println("delays 10000");
delay(10000);

As this is not occurring
Code:
   Serial.println("delays 15000");

isnt that what the wdt is supposed to do?

also i have been reading about making sure the fuse sets are correct after i have burned the bootloader

what should i be doing/looking at?
Logged

Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 443
Posts: 23834
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I've not used the WDT, how are you setting the time it needs before it decides a reset is necessary?

If you can download code and it runs as expected, I'd say your fuses were okay.  Nothing more to check.
Logged

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

Offline Offline
Newbie
*
Karma: 0
Posts: 10
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I've not used the WDT, how are you setting the time it needs before it decides a reset is necessary?

If you can download code and it runs as expected, I'd say your fuses were okay.  Nothing more to check.

well im guessing at
Code:
wdt_enable(WDTO_8S);   // set the wdt on 8 sec
it is set to 8 seconds (during the setup)
so when it gets to
Code:
delay(10000);
it waits over 8 seconds then times out and resets
Logged

Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 443
Posts: 23834
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Oh, too easy! I should have looked at posted code a little more  smiley-mr-green
Logged

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

Left Coast, CA (USA)
Offline Offline
Brattain Member
*****
Karma: 331
Posts: 16540
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

However the problem with the WDT and some older bootloaders is if the WDT is using some minimum time out value that when the system is reset the bootloader doesn't complete it's thing quick enough before the WDT triggers another reset and you are stuck in a bootloader/WDT tight loop that won't end. A proper bootloader these days resets the WDT interrupt when the bootloader starts, to prevent the WDT from tripping again.

So testing the WDT with a 8 second value won't test out the bootloader for proper WDT handling.

Lefty
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 10
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

how about 15ms?
Code:
#include <avr/wdt.h>

void setup(){
  Serial.begin(9600);
  Serial.println("Hello world");
  wdt_enable(WDTO_15MS);
}

void loop(){
  Serial.println("I am going to not get stuck..");
  for(int x=0; x<100; x++) {
    wdt_reset();
    x++;
    delay(10);
  }
  wdt_reset();
  Serial.println("I am going to get stuck now..");
  for(int x=0; 1; x++) {
    delay(10);
  }
}

and i get

Hello world
I am going to not get stuck..
I am going to get stuck now..
Hello world
I am going to not get stuck..
I am going to get stuck now..
Hello world
I am going to not get stuck..
I am going to get stuck now..
Hello world
I am going to not get stuck..
I am going to get stuck now..
Hello world
I am going to not get stuck..
I am going to get stuck now..
Logged

Left Coast, CA (USA)
Offline Offline
Brattain Member
*****
Karma: 331
Posts: 16540
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Looking good! No bootloader hang up condition.

Lefty
Logged

Left Coast, CA (USA)
Offline Offline
Brattain Member
*****
Karma: 331
Posts: 16540
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

So LOL me. I loaded the WDT test using the 15msec timeout value onto a Uno board and it worked fine. So I decided to see if my old mega1280 board did indeed suffer from the WDT problem so I loaded it and bang it bricked the board with led13 blinking at a very fast rate. Couldn't load anything else via the IDE. So went to Nick's great bootloader writer and it fixed me right up, highly recommended sketch ( http://www.gammon.com.au/forum/?id=11635 )

 Out of curiosity I tried the WDT test again on the mega board hoping that maybe the bootloader code in Nick's sketch handles that bug, but no luck the test bricked the mega1280 board once again. So back to looking around for a updated mega1280 bootloader that handles WDT interrupts properly.

Lefty
Logged

Pages: [1]   Go Up
Jump to: