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)?