Thursday, February 14, 2013

Still Wrapping up the Mega2560 Bootloader

More on the continuing drama of the 2560 bootloader.  Most recent post on this is here.

I just moved a lot of my code up to IDE 1.0.3 and decided to check and see if they had updated the bootloader in this.  Well, they haven't.  I just used it to program a 2560 and the bootloader supplied with the release failed on both the '!!!' and the watchdog timer problems.

But, I went searching to see if there was some schedule and ran across another bootloader that works.  This one is smaller because the author removed the code that samples for the '!!!' to jump into a rom monitor.  So, there is no problem with '!!!' because it doesn't look for it, and the watchdog timer works.  Plus, we get a little code space back (not that it matters on a 2560).  I tested it with several things and successfully loaded code that exceeds 60K (biggest I currently have) to the board.  The hex file is in text form here <link>.  If you want to get it and try it, just copy and paste it into notepad and save it as a .hex file.  I used an AVRISP mk 2 to replace the bootloader, I haven't tried any other device for programming the chip.


Here is the code I used to test the two problems notice the '!!!' in the Serial.print:


Code:
#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
}

It's annoying that they haven't updated the IDE with a version that works.  But, there are a couple of solutions that work now.

7 comments:

  1. Thanks for the info about the 2560 bootloader. I put it on both my Arduino Mega2560 and my Seeeduino Mega2560 and it works like a charm.

    ReplyDelete
  2. Glad I could help. I felt I should make some effort to help other folk that had the same problems I did.

    ReplyDelete
  3. This bootloader is not working with my Seeedunio 2560.

    ReplyDelete
  4. Drop them a note, they're a good company. They can probably steer you to the right place.

    ReplyDelete
  5. Hi,
    How about fuse settings for Atmega2560?

    ReplyDelete
  6. The fuse settings were fine, didn't have to mess with them at all.

    ReplyDelete