Arduino Mega ADK (ATMEGA2560): execute code before bootloader?

Hi all,

I'm using an Arduino Mega ADK (based on ATMEGA2560). I need to execute code before the bootloader in order to turn off the watchdog timer in order to avoid a reset cycle after the watchdog timer caused a reset. Is it possible to run code before the bootloader?

I tried using

  void wdt_init(void) __attribute__((naked)) __attribute__((section(".init1")));

but apparently, this is not called before the bootloader.

Any ideas apart from modifying the bootloader (I have no idea how to do that and apparently custom hardware is needed to burn it)?

Many thanks, Michael

If you have the bootloader fuses enabled the reset vector is redirected to a specific bootloader start address. No code runs before the bootloader. If you need some extra code to 'tame' the watchdog timer, you need to put it in there yourself = recompile the bootloader.

The extra hardware you speak of is just 20-50 bucks, depending on the amount of luxury you need. And I highly recommend to get an ISP.