Go Down

Topic: Arduino Mega ADK (ATMEGA2560): execute code before bootloader? (Read 608 times) previous topic - next topic

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
Code: [Select]
  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

madworm

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.
• Upload doesn't work? Do a loop-back test.
• There's absolutely NO excuse for not having an ISP!
• Your AVR needs a brain surgery? Use the online FUSE calculator.
My projects: RGB LED matrix, RGB LED ring, various ATtiny gadgets...
• Microsoft is not the answer. It is the question, and the answer is NO!

Go Up