make bootloader able to cope with different watchdog settings 2010-07-27-stephan-201208012130
authorStephan Baerwolf <stephan.baerwolf@tu-ilmenau.de>
Wed, 1 Aug 2012 19:16:51 +0000 (21:16 +0200)
committerStephan Baerwolf <stephan.baerwolf@tu-ilmenau.de>
Wed, 1 Aug 2012 19:26:50 +0000 (19:26 +0000)
Signed-off-by: Stephan Baerwolf <stephan.baerwolf@tu-ilmenau.de>
firmware/bootloaderconfig.h
firmware/main.c
firmware/spminterface.h

index e2710c0..97311dd 100644 (file)
@@ -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();
index d651ec3..4a94194 100644 (file)
@@ -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();
index 677b8c9..846ae87 100644 (file)
@@ -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