From: Stephan Baerwolf Date: Wed, 1 Aug 2012 19:16:51 +0000 (+0200) Subject: make bootloader able to cope with different watchdog settings X-Git-Tag: 2010-07-27-stephan-201208012130^0 X-Git-Url: http://git.linex4red.de/pub/USBaspLoader.git/commitdiff_plain/c99e4b0f4e8dc636060fca152df271298caa8342?ds=inline make bootloader able to cope with different watchdog settings Signed-off-by: Stephan Baerwolf --- diff --git a/firmware/bootloaderconfig.h b/firmware/bootloaderconfig.h index e2710c0..97311dd 100644 --- a/firmware/bootloaderconfig.h +++ b/firmware/bootloaderconfig.h @@ -165,7 +165,8 @@ these macros are defined, the boot loader usees them. static inline void bootLoaderInit(void) { - PORTD |= (1 << JUMPER_BIT); /* activate pull-up */ + DDRD = 0; + PORTD = (1 << JUMPER_BIT); /* activate pull-up */ // deactivated by Stephan - reset after each avrdude op is annoing! // if(!(MCUCSR & (1 << EXTRF))) /* If this was not an external reset, ignore */ // leaveBootloader(); diff --git a/firmware/main.c b/firmware/main.c index d651ec3..4a94194 100644 --- a/firmware/main.c +++ b/firmware/main.c @@ -111,6 +111,8 @@ static uchar currentRequest; static const uchar currentRequest = 0; #endif +static unsigned char wdtstatus; + static const uchar signatureBytes[4] = { #ifdef SIGNATURE_BYTES SIGNATURE_BYTES @@ -143,6 +145,9 @@ static void leaveBootloader() USB_INTR_CFG = 0; /* also reset config bits */ GICR = (1 << IVCE); /* enable change of interrupt vectors */ GICR = (0 << IVSEL); /* move interrupts to application flash section */ + + WDTCR = wdtstatus; + /* We must go through a global function pointer variable instead of writing * ((void (*)(void))0)(); * because the compiler optimizes a constant 0 to "rcall 0" which is not @@ -328,6 +333,7 @@ uchar i = 0; int __attribute__((noreturn)) main(void) { /* initialize */ + wdtstatus = WDTCR; wdt_disable(); /* main app may have enabled watchdog */ bootLoaderInit(); odDebugInit(); diff --git a/firmware/spminterface.h b/firmware/spminterface.h index 677b8c9..846ae87 100644 --- a/firmware/spminterface.h +++ b/firmware/spminterface.h @@ -92,10 +92,9 @@ ret */ #if defined (__AVR_ATmega8__) || defined (__AVR_ATmega8HVA__) //assume SPMCR==0x37, SPMEN==0x00 -const uint16_t bootloader__do_spm[30] PROGMEM = {0x0000, 0x2dec, 0x2dfd, 0xb6c7, 0xfcc0, 0xcffd, 0xbea7, 0x95e8, 0x9508, +const uint16_t bootloader__do_spm[22] PROGMEM = {0x0000, 0x2dec, 0x2dfd, 0xb6c7, 0xfcc0, 0xcffd, 0xbea7, 0x95e8, 0x9508, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, - 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, - 0xFFFF, 0xFFFF, 0xFFFF}; + 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF}; #else #error "bootloader__do_spm has to be adapted, since there is no architecture code, yet" #endif