]> git.donarmstrong.com Git - tmk_firmware.git/commitdiff
Fix bootloader jump use word address
authortmk <nobody@nowhere>
Wed, 18 Sep 2013 07:03:03 +0000 (16:03 +0900)
committertmk <nobody@nowhere>
Wed, 18 Sep 2013 07:10:53 +0000 (16:10 +0900)
- Call of function pointer is compiled into 'icall' instruction.
It should use word address but it has used byte address :( It seems
jump has worked luckily by chance until now. why it worked?

common/bootloader.c

index 43a7e47ce23fb78213348e0f1cca1db5519b56bf..cda295b1811e92f90baea342084b37a07139bcc1 100644 (file)
@@ -71,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))();
     }
 }
 
@@ -141,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