From: Stephan Baerwolf Date: Thu, 12 Sep 2013 17:39:18 +0000 (+0200) Subject: BUGfix: Abort timeout when bootLoaderConditionSimple() X-Git-Tag: testing-head~12 X-Git-Url: http://git.linex4red.de/pub/USBaspLoader.git/commitdiff_plain/3e8387dcfe45fa59d9ceab898a163d5630e247b9?ds=sidebyside BUGfix: Abort timeout when bootLoaderConditionSimple() When CONFIG_HAVE__BOOTLOADER_ABORTTIMEOUTONACT is enabled, then timeout must be aborted when entering the bootloader via bootLoaderConditionSimple(). Signed-off-by: Stephan Baerwolf --- diff --git a/firmware/main.c b/firmware/main.c index 038368c..9558089 100644 --- a/firmware/main.c +++ b/firmware/main.c @@ -124,12 +124,13 @@ static volatile uint8_t timeout_remaining; static volatile uint16_t timeout_remaining; # endif # endif + +# define stayinloader_initialValue 0xfe # if ((HAVE_UNPRECISEWAIT)) /* here we have to assume we need to optimize for every byte */ -#define __REGISTER_stayinloader_initialValue 0xfe volatile register uint8_t stayinloader __asm__("r17"); # else -static volatile uint8_t stayinloader = 0xfe; +static volatile uint8_t stayinloader; # endif #endif @@ -213,18 +214,6 @@ static const uchar signatureBytes[4] = { /* ------------------------------------------------------------------------ */ -#if (__REGISTER_stayinloader_initialValue) -/* need to put it after libc init - otherwise it fucks up the register */ -void __attribute__ ((section(".init8"),naked,used,no_instrument_function)) __REGISTER_stayinloader_initialValue_INITIALIZATION(void); -void __REGISTER_stayinloader_initialValue_INITIALIZATION(void) { - asm volatile ( - "ldi %[silreg] , %[silval]\n\t" - : [silreg] "=a" (stayinloader) - : [silval] "M" (__REGISTER_stayinloader_initialValue) - ); -} -#endif - #if (HAVE_BOOTLOADERENTRY_FROMSOFTWARE) void __attribute__ ((section(".init3"),naked,used,no_instrument_function)) __BOOTLOADERENTRY_FROMSOFTWARE__bootup_investigate_RAMEND(void); void __BOOTLOADERENTRY_FROMSOFTWARE__bootup_investigate_RAMEND(void) { @@ -750,6 +739,31 @@ int __attribute__((__noreturn__)) main(void) GICR = (1 << IVSEL); /* move interrupts to boot flash section */ #endif if(bootLoaderCondition()){ +#if (BOOTLOADER_CAN_EXIT) +# if (USE_EXCESSIVE_ASSEMBLER) +asm volatile ( + "ldi %[sil], %[normval]\n\t" +# if ((defined(CONFIG_HAVE__BOOTLOADER_ABORTTIMEOUTONACT)) && (!(BOOTLOADER_IGNOREPROGBUTTON)) && (BOOTLOADER_LOOPCYCLES_TIMEOUT)) + "sbis %[pin], %[bit]\n\t" + "subi %[sil], 0x02\n\t" +# endif + : [sil] "=d" (stayinloader) + : [normval] "M" (stayinloader_initialValue) +# if (!(BOOTLOADER_IGNOREPROGBUTTON)) + , + [pin] "I" (_SFR_IO_ADDR(PIN_PIN(JUMPER_PORT))), + [bit] "I" (PIN(JUMPER_PORT, JUMPER_BIT)) +# endif +); +# else +# if ((defined(CONFIG_HAVE__BOOTLOADER_ABORTTIMEOUTONACT)) && (!(BOOTLOADER_IGNOREPROGBUTTON)) && (BOOTLOADER_LOOPCYCLES_TIMEOUT)) + if (bootLoaderConditionSimple()) { + stayinloader = stayinloader_initialValue - 0x02; + } else +# endif + stayinloader = stayinloader_initialValue; +# endif +#endif #if NEED_WATCHDOG # if (defined(MCUSR) && defined(WDRF)) /*