]> git.donarmstrong.com Git - qmk_firmware.git/commitdiff
Fix watchdog in bootloader jump
authortmk <nobody@nowhere>
Sun, 10 Mar 2013 06:05:28 +0000 (15:05 +0900)
committertmk <nobody@nowhere>
Sun, 10 Mar 2013 06:06:33 +0000 (15:06 +0900)
- disable watchdog after watchdog reset
- clear WDRF after watchdog reset

common/bootloader.c
keyboard/hhkb/Makefile.iwrap
keyboard/hhkb/Makefile.lufa

index 77fa1b30a721f26d54281267a928cd35e2bf17a5..023220414bb6dedf3890e88b608e1fee8a373164 100644 (file)
 #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
index f87df0d2bbaea56e3bb67dfd0cb82359d1009682..3ec1a31645ca9fa863d13b0fc901a0720faf90bc 100644 (file)
@@ -49,6 +49,15 @@ EXTRAKEY_ENABLE = yes        # Audio control and System control
 #NKRO_ENABLE = yes     # USB Nkey Rollover
 
 
+# Boot Section Size in *BYTEs*
+#   Teensy   halfKay    512
+#   Teensy++ halfKay    1024
+#   Atmel DFU loader    4096
+#   LUFA bootloader     4096
+#   USBaspLoader        2048
+OPT_DEFS += -DBOOT_SIZE=2048
+
+
 
 #---------------- Programming Options --------------------------
 AVRDUDE = avrdude
index afd413d019561b63a69693a8a67e36d1eeb579a0..75c0310d6ecdec668413d07df49dbdf8f3e570ad 100644 (file)
@@ -107,11 +107,12 @@ CONSOLE_ENABLE = yes      # Console for debug
 #PS2_MOUSE_ENABLE = yes        # PS/2 mouse(TrackPoint) support
 
 
-# Boot Section Size in bytes
-#   Teensy halfKay   512
-#   Atmel DFU loader 4096
-#   LUFA bootloader  4096
-#OPT_DEFS += -DBOOT_SIZE=4096
+# Boot Section Size in *BYTEs*
+#   Teensy   halfKay    512
+#   Teensy++ halfKay    1024
+#   Atmel DFU loader    4096
+#   LUFA bootloader     4096
+OPT_DEFS += -DBOOT_SIZE=1024
 
 
 # Search Path