Browse Source

Fix watchdog in bootloader jump

- disable watchdog after watchdog reset
- clear WDRF after watchdog reset
tags/v1.9
tmk 11 years ago
parent
commit
f55c677ba4
3 changed files with 28 additions and 15 deletions
  1. 13
    10
      common/bootloader.c
  2. 9
    0
      keyboard/hhkb/Makefile.iwrap
  3. 6
    5
      keyboard/hhkb/Makefile.lufa

+ 13
- 10
common/bootloader.c View File

#endif #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 #ifndef BOOT_SIZE
#define BOOT_SIZE 512 #define BOOT_SIZE 512
#endif #endif
#define FLASH_SIZE (FLASHEND + 1)
#define FLASH_SIZE (FLASHEND + 1L)
#define BOOTLOADER_START (FLASH_SIZE - BOOT_SIZE) #define BOOTLOADER_START (FLASH_SIZE - BOOT_SIZE)




void bootloader_jump_after_watchdog_reset(void) void bootloader_jump_after_watchdog_reset(void)
{ {
if ((MCUSR & (1<<WDRF)) && reset_key == BOOTLOADER_RESET_KEY) { 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; 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)(); ((void (*)(void))BOOTLOADER_START)();
} }
} }
// start Bootloader // start Bootloader
((void (*)(void))BOOTLOADER_START)(); ((void (*)(void))BOOTLOADER_START)();
} }
#endif
#endif

+ 9
- 0
keyboard/hhkb/Makefile.iwrap View File

#NKRO_ENABLE = yes # USB Nkey Rollover #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 -------------------------- #---------------- Programming Options --------------------------
AVRDUDE = avrdude AVRDUDE = avrdude

+ 6
- 5
keyboard/hhkb/Makefile.lufa View File

#PS2_MOUSE_ENABLE = yes # PS/2 mouse(TrackPoint) support #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 # Search Path

Loading…
Cancel
Save