diff options
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 @@ | |||
| 11 | #endif | 11 | #endif |
| 12 | 12 | ||
| 13 | 13 | ||
| 14 | /* Boot Section Size in bytes | 14 | /* Boot Section Size in *BYTEs* |
| 15 | * Teensy halfKay 512 | 15 | * Teensy halfKay 512 |
| 16 | * Atmel DFU loader 4096 | 16 | * Teensy++ halfKay 1024 |
| 17 | * LUFA bootloader 4096 | 17 | * Atmel DFU loader 4096 |
| 18 | * LUFA bootloader 4096 | ||
| 18 | */ | 19 | */ |
| 19 | #ifndef BOOT_SIZE | 20 | #ifndef BOOT_SIZE |
| 20 | #define BOOT_SIZE 512 | 21 | #define BOOT_SIZE 512 |
| 21 | #endif | 22 | #endif |
| 22 | #define FLASH_SIZE (FLASHEND + 1) | 23 | #define FLASH_SIZE (FLASHEND + 1L) |
| 23 | #define BOOTLOADER_START (FLASH_SIZE - BOOT_SIZE) | 24 | #define BOOTLOADER_START (FLASH_SIZE - BOOT_SIZE) |
| 24 | 25 | ||
| 25 | 26 | ||
| @@ -58,13 +59,15 @@ void bootloader_jump_after_watchdog_reset(void) __attribute__ ((used, naked, sec | |||
| 58 | void bootloader_jump_after_watchdog_reset(void) | 59 | void bootloader_jump_after_watchdog_reset(void) |
| 59 | { | 60 | { |
| 60 | if ((MCUSR & (1<<WDRF)) && reset_key == BOOTLOADER_RESET_KEY) { | 61 | if ((MCUSR & (1<<WDRF)) && reset_key == BOOTLOADER_RESET_KEY) { |
| 62 | reset_key = 0; | ||
| 61 | 63 | ||
| 62 | #if defined(__AVR_ATmega168__) || defined(__AVR_ATmega168P__) || defined(__AVR_ATmega328P__) | 64 | // My custom USBasploader requires this to come up. |
| 63 | // This makes custom USBasploader come up. | ||
| 64 | MCUSR = 0; | 65 | MCUSR = 0; |
| 65 | #endif | ||
| 66 | 66 | ||
| 67 | reset_key = 0; | 67 | // Seems like Teensy halfkay loader requires clearing WDRF and disabling watchdog. |
| 68 | MCUSR &= ~(1<<WDRF); | ||
| 69 | wdt_disable(); | ||
| 70 | |||
| 68 | ((void (*)(void))BOOTLOADER_START)(); | 71 | ((void (*)(void))BOOTLOADER_START)(); |
| 69 | } | 72 | } |
| 70 | } | 73 | } |
| @@ -138,4 +141,4 @@ void bootloader_jump(void) { | |||
| 138 | // start Bootloader | 141 | // start Bootloader |
| 139 | ((void (*)(void))BOOTLOADER_START)(); | 142 | ((void (*)(void))BOOTLOADER_START)(); |
| 140 | } | 143 | } |
| 141 | #endif | 144 | #endif |
