Watchdog in Arduino Library - or at least support by bootloader

After much searching the web I finally found a optiboot version for the mega1280 board. Tested on two different mega1280 boards a seeeduino and a arduino mega1280. First the the new boards.txt entry to support the new bootloader:

##############################################################

megao.name=Arduino Mega1280 Optiboot
megao.upload.protocol=arduino
megao.upload.maximum_size=130048
megao.upload.speed=115200
megao.bootloader.low_fuses=0xff
megao.bootloader.high_fuses=0xdc
megao.bootloader.extended_fuses=0xf5
megao.bootloader.path=optiboot
megao.bootloader.file=optiboot_atmega1280.hex
megao.bootloader.unlock_bits=0x3F
megao.bootloader.lock_bits=0x0F
megao.build.mcu=atmega1280
megao.build.f_cpu=16000000L
megao.build.core=arduino
megao.build.variant=mega

And the optiboot hex file optiboot_atmega1280.hex
I was able to burn this bootloader using the arduinoISP sketch from IDE 1.0.3, but not using my USBtiny hardware programmer, as it does not work with flash sizes >64KB in size.

:020000000404F6
:020000021000EC
:10FC0000112484B714BE81FFF2D085E08093810077
:10FC100082E08093C00088E18093C10086E08093F9
:10FC2000C20080E18093C4008EE0CBD0279A86E0AA
:10FC300020E33CEF91E0309385002093840096BB55
:10FC4000B09BFECF1F9AA8958150A9F7CC24DD2444
:10FC500099249394A5E0BA2EF1E1AF2EA6D0813479
:10FC600061F4A3D0082FB3D0023811F0013811F499
:10FC700084E001C083E091D08DC0823411F484E12E
:10FC800003C0853419F485E0AAD084C08535A1F479
:10FC90008CD0082F10E089D0E82EFF24FE2CEE2413
:10FCA000E02AF12A8F2D881F8827881F8BBFEE0C32
:10FCB000FF1C8DD067016EC0863521F484E08FD0A3
:10FCC00080E0D9CF843609F042C06FD06ED0082FC3
:10FCD0006CD080E0C81680EED80620F483E0F601F0
:10FCE00087BFE895C0E0D2E060D089930C17E1F7B8
:10FCF000F0E0CF16F0EEDF0620F083E0F60187BFDC
:10FD0000E89565D007B600FCFDCFA601A0E0B2E003
:10FD10002C9130E011968C91119790E0982F8827C4
:10FD2000822B932B1296FA010C0197BEE8951124B1
:10FD30004E5F5F4FF3E0A030BF0751F7F601B7BE4B
:10FD4000E89507B600FCFDCFA7BEE89523C0843731
:10FD5000A1F42BD02AD0E82E28D039D0E6010E2DE0
:10FD6000FE0186911AD021960150D1F70894C11C4A
:10FD7000D11CEA94CE0CD11C0DC0853731F427D0AC
:10FD80008EE10BD087E909D075CF813511F488E079
:10FD900018D01DD080E101D061CF982F8091C00094
:10FDA00085FFFCCF9093C60008958091C00087FF27
:10FDB000FCCF8091C00084FD01C0A8958091C60051
:10FDC0000895E0E6F0E098E1908380830895EDDF08
:10FDD000803219F088E0F5DFFFCF84E1DECF1F939A
:10FDE000182FE3DF1150E9F7F2DF1F91089580E04B
:08FDF000E8DFEE27FF2709946C
:040000031000FC00ED
:00000001FF

And finally a sketch from a poster here on this forum (forgot name, sorry whoever) to test the ability to handle a very short 15 millisec WDT interrupt timeout. Works with Uno but
will 'brick' mega boards with 'stock' bootloaders.
WDT_test.ino

// Test sketch to see if WDT interrupts are handled properly by the bootloader

/*
 Warning Warning Warning this is a semi-destructive test in that
 if your bootloader does not reset WDT interrupts upon starting 
 it will be forced into a tight loop of bootloader starts/WDT resets
 chip/bootloader starts again/lather rinse repeat. One can only
 recover to normal operation by reburning the bootloader with
 a ICSP programmer. If this sketch runs properly on a chip with a WDT aware bootloader,
 you will see continuous serial output on the serial monitor.

Note that current arduino mega boards will fail this test and brick

*/

// Code from arduino forum poster (sorry name not remembered) 1/11/13

#include <avr/wdt.h>

void setup(){
  Serial.begin(57600);
  delay(100);
  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);
  }
}

Lefty