Skip to content

Commit

Permalink
Fix bootloader jump use word address
Browse files Browse the repository at this point in the history
- 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?
  • Loading branch information
yashikno committed Sep 18, 2013
1 parent c7faa51 commit 0ca4150
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions common/bootloader.c
Original file line number Diff line number Diff line change
Expand Up @@ -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))();
}
}

Expand Down Expand Up @@ -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

0 comments on commit 0ca4150

Please sign in to comment.