]> git.donarmstrong.com Git - tmk_firmware.git/blobdiff - common/bootloader.c
Merge branch 'rhaberkorn-serial-mouse'
[tmk_firmware.git] / common / bootloader.c
index 023220414bb6dedf3890e88b608e1fee8a373164..cda295b1811e92f90baea342084b37a07139bcc1 100644 (file)
 
 
 /* Boot Section Size in *BYTEs*
- * Teensy   halfKay     512
- * Teensy++ halfKay     1024
- * Atmel DFU loader     4096
- * LUFA bootloader      4096
+ *   Teensy   halfKay    512
+ *   Teensy++ halfKay    1024
+ *   Atmel DFU loader    4096
+ *   LUFA bootloader     4096
+ *   USBaspLoader        2048
  */
-#ifndef BOOT_SIZE
-#define BOOT_SIZE 512
+#ifndef BOOTLOADER_SIZE
+#warning To use bootloader_jump() you need to define BOOTLOADER_SIZE in config.h.
+#define BOOTLOADER_SIZE     4096
 #endif
+
 #define FLASH_SIZE          (FLASHEND + 1L)
-#define BOOTLOADER_START    (FLASH_SIZE - BOOT_SIZE)
+#define BOOTLOADER_START    (FLASH_SIZE - BOOTLOADER_SIZE)
 
 
 /* 
@@ -68,7 +71,8 @@ void bootloader_jump_after_watchdog_reset(void)
         MCUSR &= ~(1<<WDRF);
         wdt_disable();
 
-        ((void (*)(void))BOOTLOADER_START)();
+        // This is compled into 'icall', address should be in word unit, not byte.
+        ((void (*)(void))(BOOTLOADER_START/2))();
     }
 }
 
@@ -138,7 +142,7 @@ void bootloader_jump(void) {
     ADCSRA = 0; TWCR = 0; UCSR0B = 0;
 #endif
 
-    // start Bootloader
-    ((void (*)(void))BOOTLOADER_START)();
+    // This is compled into 'icall', address should be in word unit, not byte.
+    ((void (*)(void))(BOOTLOADER_START/2))();
 }
 #endif