From 3a1f58ce189a955478702ed89f2ff308a41cc4f3 Mon Sep 17 00:00:00 2001 From: optixx Date: Wed, 2 Sep 2009 21:50:47 +0200 Subject: [PATCH] fix bootloader enable routine --- avr/bootloader/bootloader.c | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/avr/bootloader/bootloader.c b/avr/bootloader/bootloader.c index 874e184..8a677f4 100644 --- a/avr/bootloader/bootloader.c +++ b/avr/bootloader/bootloader.c @@ -460,6 +460,18 @@ int __attribute__ ((noreturn, OS_main)) main(void) DDRC &= ~(1 << AVR_BTLDR_EN_PIN); PORTC &= ~(1 << AVR_BTLDR_EN_PIN); + /* + * if watchdog reset, disable watchdog and jump to app + */ + if (reset & _BV(WDRF)) { + uart_puts("Found watchdog reset\n\r"); + MCUSR = 0; + wdt_disable(); + uart_puts("Jump to 0x0000\n\r"); + jump_to_app(); + } + + if ((AVR_BTLDR_EN_IN & ( 1 << AVR_BTLDR_EN_PIN)) == 0){ banner(); uart_puts("Bootloader flashing is disabled\n\r"); @@ -467,8 +479,6 @@ int __attribute__ ((noreturn, OS_main)) main(void) leave_bootloader(); } - - /* * if power-on reset, quit bootloader via watchdog reset @@ -479,17 +489,6 @@ int __attribute__ ((noreturn, OS_main)) main(void) MCUSR = 0; leave_bootloader(); } - /* - * if watchdog reset, disable watchdog and jump to app - */ - else if (reset & _BV(WDRF)) { - uart_puts("Found watchdog reset\n\r"); - MCUSR = 0; - wdt_disable(); - uart_puts("Jump to 0x0000\n\r"); - jump_to_app(); - } - banner(); uart_puts("Enter programming mode\n\r"); /*