Skip to content

handle watchdog resets in stk500v2 (Mega 2560) bootloader [imported] #181

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
cmaglie opened this issue Nov 15, 2012 · 1 comment
Closed
Assignees
Labels
Component: Bootloader The bootloader is the program used to load the uploaded program into the microcontroller's memory Component: Firmware Limited to the contents of the firmwares folder in the core packages
Milestone

Comments

@cmaglie
Copy link
Member

cmaglie commented Nov 15, 2012

This is Issue 181 moved from a Google Code project.
Added by 2010-01-10T21:53:46.000Z by [email protected].
Please review that bug for more context and additional comments, but update this bug.

Original labels: Type-Defect, Priority-Medium, Component-stk500v2

Original description

when a watchdog reset occurs, the watchdog timer stays enabled (as
described on p.52 of the atmega 168 datasheet) - and this leads to the
watchdog resetting again and again in the bootloader, requiring a hard
powerdown by the user.

the current ATmegaBOOT_168.c now has the WATCHDOG_MODS part from the
lilypad bootloader - but i think whether or not that is being used
(skipping the bootloader code early on after a watchdog reset), the
watchdog registers should be cleared anyway.

the attached patch is against 0013, but it should still apply with
some offset to the latest (0017) source

kind regards,
gohai

diff -u orig/ATmegaBOOT_168.c new/ATmegaBOOT_168.c
--- orig/ATmegaBOOT_168.c Fri Feb 6 12:56:00 2009
+++ new/ATmegaBOOT_168.c Wed Mar 4 14:08:31 2009
@@ -258,13 +258,12 @@
uint8_t ch,ch2;
uint16_t w;

-#ifdef WATCHDOG_MODS
ch = MCUSR;
MCUSR = 0;

   WDTCSR |= _BV(WDCE) | _BV(WDE);
   WDTCSR = 0;

+#ifdef WATCHDOG_MODS
// Check if the WDT was used to reset, in which case we dont
bootload and skip straight to the code. woot.
if (! (ch & _BV(EXTRF))) // if its a not an external reset...
app_start(); // skip bootloader

@cmaglie
Copy link
Member Author

cmaglie commented Feb 11, 2013

Please look at the pullrequest here #1183

The updated hex bootloader is available here:

https://github.com/cmaglie/Arduino/blob/mega2560-bootloader/hardware/arduino/bootloaders/stk500v2/stk500boot_v2_mega2560.hex

Please check it out and report here #1183 success or failures.
Thank you!

C

@cmaglie cmaglie closed this as completed Mar 11, 2013
tbowmo pushed a commit to tbowmo/Arduino that referenced this issue Jul 14, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: Bootloader The bootloader is the program used to load the uploaded program into the microcontroller's memory Component: Firmware Limited to the contents of the firmwares folder in the core packages
Projects
None yet
Development

No branches or pull requests

1 participant