diff options
author | tmk <nobody@nowhere> | 2013-03-10 15:05:28 +0900 |
---|---|---|
committer | tmk <nobody@nowhere> | 2013-03-10 15:06:33 +0900 |
commit | f55c677ba46a8243f077195ef4f39cde1babf560 (patch) | |
tree | eb1803049580c109674ed78911f0e9b40549a4dc /common | |
parent | 1385058fc21f80347c7afd2b818e38795ce9d55a (diff) | |
download | firmware-f55c677ba46a8243f077195ef4f39cde1babf560.tar.gz firmware-f55c677ba46a8243f077195ef4f39cde1babf560.tar.bz2 firmware-f55c677ba46a8243f077195ef4f39cde1babf560.zip |
Fix watchdog in bootloader jump
- disable watchdog after watchdog reset
- clear WDRF after watchdog reset
Diffstat (limited to 'common')
-rw-r--r-- | common/bootloader.c | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/common/bootloader.c b/common/bootloader.c index 77fa1b30a..023220414 100644 --- a/common/bootloader.c +++ b/common/bootloader.c @@ -11,15 +11,16 @@ #endif -/* Boot Section Size in bytes - * Teensy halfKay 512 - * Atmel DFU loader 4096 - * LUFA bootloader 4096 +/* Boot Section Size in *BYTEs* + * Teensy halfKay 512 + * Teensy++ halfKay 1024 + * Atmel DFU loader 4096 + * LUFA bootloader 4096 */ #ifndef BOOT_SIZE #define BOOT_SIZE 512 #endif -#define FLASH_SIZE (FLASHEND + 1) +#define FLASH_SIZE (FLASHEND + 1L) #define BOOTLOADER_START (FLASH_SIZE - BOOT_SIZE) @@ -58,13 +59,15 @@ void bootloader_jump_after_watchdog_reset(void) __attribute__ ((used, naked, sec void bootloader_jump_after_watchdog_reset(void) { if ((MCUSR & (1<<WDRF)) && reset_key == BOOTLOADER_RESET_KEY) { + reset_key = 0; - #if defined(__AVR_ATmega168__) || defined(__AVR_ATmega168P__) || defined(__AVR_ATmega328P__) - // This makes custom USBasploader come up. + // My custom USBasploader requires this to come up. MCUSR = 0; - #endif - reset_key = 0; + // Seems like Teensy halfkay loader requires clearing WDRF and disabling watchdog. + MCUSR &= ~(1<<WDRF); + wdt_disable(); + ((void (*)(void))BOOTLOADER_START)(); } } @@ -138,4 +141,4 @@ void bootloader_jump(void) { // start Bootloader ((void (*)(void))BOOTLOADER_START)(); } -#endif +#endif |