Browse Source

Tweaks in Virtual boot partition

* Add fallback to WDT interrupt if no SPM ready is available
* Add possibility to define custom vector using Makefile
majekw 9 years ago
parent
commit
9035de2f1e
2 changed files with 11 additions and 3 deletions
  1. 1 1
      optiboot/bootloaders/optiboot/Makefile
  2. 10 2
      optiboot/bootloaders/optiboot/optiboot.c

+ 1 - 1
optiboot/bootloaders/optiboot/Makefile

@@ -238,7 +238,7 @@ endif
 # Virtual boot block test
 # Virtual boot block test
 virboot8: TARGET = atmega8
 virboot8: TARGET = atmega8
 virboot8: MCU_TARGET = atmega8
 virboot8: MCU_TARGET = atmega8
-virboot8: CFLAGS += $(COMMON_OPTIONS) '-DVIRTUAL_BOOT_PARTITION'
+virboot8: CFLAGS += $(COMMON_OPTIONS) '-DVIRTUAL_BOOT_PARTITION' '-Dsave_vect_num=EE_RDY_vect_num'
 virboot8: AVR_FREQ ?= 16000000L 
 virboot8: AVR_FREQ ?= 16000000L 
 virboot8: LDSECTIONS  = -Wl,--section-start=.text=0x1c00 -Wl,--section-start=.version=0x1ffe
 virboot8: LDSECTIONS  = -Wl,--section-start=.text=0x1c00 -Wl,--section-start=.version=0x1ffe
 virboot8: $(PROGRAM)_virboot8.hex
 virboot8: $(PROGRAM)_virboot8.hex

+ 10 - 2
optiboot/bootloaders/optiboot/optiboot.c

@@ -395,14 +395,22 @@ void appStart(uint8_t rstFlags) __attribute__ ((naked));
 #define rstVect1_sav (*(uint8_t*)(RAMSTART+SPM_PAGESIZE*2+5))
 #define rstVect1_sav (*(uint8_t*)(RAMSTART+SPM_PAGESIZE*2+5))
 #define saveVect0_sav (*(uint8_t*)(RAMSTART+SPM_PAGESIZE*2+6))
 #define saveVect0_sav (*(uint8_t*)(RAMSTART+SPM_PAGESIZE*2+6))
 #define saveVect1_sav (*(uint8_t*)(RAMSTART+SPM_PAGESIZE*2+7))
 #define saveVect1_sav (*(uint8_t*)(RAMSTART+SPM_PAGESIZE*2+7))
-// Vector to save original reset jump - SPM Ready is least probably used
+// Vector to save original reset jump:
+//   SPM Ready is least probably used, so it's default
+//   if not, use old way WDT_vect_num,
+//   or simply set custom save_vect_num in Makefile using vector name
+//   or even raw number.
+#if !defined (save_vect_num)
 #if defined (SPM_RDY_vect_num)
 #if defined (SPM_RDY_vect_num)
 #define save_vect_num (SPM_RDY_vect_num)
 #define save_vect_num (SPM_RDY_vect_num)
 #elif defined (SPM_READY_vect_num)
 #elif defined (SPM_READY_vect_num)
 #define save_vect_num (SPM_READY_vect_num)
 #define save_vect_num (SPM_READY_vect_num)
+#elif defined (WDT_vect_num)
+#define save_vect_num (WDT_vect_num)
 #else
 #else
-#error Cant find SPM interrupt vector for this CPU
+#error Cant find SPM or WDT interrupt vector for this CPU
 #endif
 #endif
+#endif //save_vect_num
 // check if it's on the same page (code assumes that)
 // check if it's on the same page (code assumes that)
 #if (SPM_PAGESIZE <= save_vect_num)
 #if (SPM_PAGESIZE <= save_vect_num)
 #error Save vector not in the same page as reset!
 #error Save vector not in the same page as reset!