Browse Source

Revert "Generalize virtualboot fix"

This reverts commit 714a3f31eaca91a48efa2510b9383f1384955eec.
Spence Konde (aka Dr. Azzy) 6 years ago
parent
commit
1f9d9661c3
2 changed files with 98 additions and 449 deletions
  1. 84 423
      optiboot/bootloaders/optiboot/Makefile.tiny
  2. 14 26
      optiboot/bootloaders/optiboot/optiboot.c

+ 84 - 423
optiboot/bootloaders/optiboot/Makefile.tiny

@@ -22,58 +22,58 @@ endif
 #-----------------------
 attiny1634at12:
 	"$(MAKE)" attiny1634	AVR_FREQ=12000000L
-	mv $(PROGRAM)_attiny1634.hex $(PROGRAM)_attiny1634_12000000L.hex
+	mv $(PROGRAM)_attiny1634.hex $(PROGRAM)_$@.hex
 ifndef PRODUCTION
-	mv $(PROGRAM)_attiny1634.lst $(PROGRAM)_attiny1634_12000000L.lst
+	mv $(PROGRAM)_attiny1634.lst $(PROGRAM)_$@.lst
 endif
 
 attiny1634at16:
 	"$(MAKE)" attiny1634	AVR_FREQ=16000000L
-	mv $(PROGRAM)_attiny1634.hex $(PROGRAM)_attiny1634_16000000L.hex
+	mv $(PROGRAM)_attiny1634.hex $(PROGRAM)_$@.hex
 ifndef PRODUCTION
-	mv $(PROGRAM)_attiny1634.lst $(PROGRAM)_attiny1634_16000000L.lst
+	mv $(PROGRAM)_attiny1634.lst $(PROGRAM)_$@.lst
 endif
 
 attiny1634at8:
 	"$(MAKE)" attiny1634	AVR_FREQ=8000000L BAUD_RATE=57600
-	mv $(PROGRAM)_attiny1634.hex $(PROGRAM)_attiny1634_8000000L.hex
+	mv $(PROGRAM)_attiny1634.hex $(PROGRAM)_$@.hex
 ifndef PRODUCTION
-	mv $(PROGRAM)_attiny1634.lst $(PROGRAM)_attiny1634_8000000L.lst
+	mv $(PROGRAM)_attiny1634.lst $(PROGRAM)_$@.lst
 endif
 
 attiny1634at8_5v:
 	"$(MAKE)" attiny1634	AVR_FREQ=8200000L BAUD_RATE=57600
-	mv $(PROGRAM)_attiny1634.hex $(PROGRAM)_attiny1634_8200000L.hex
+	mv $(PROGRAM)_attiny1634.hex $(PROGRAM)_$@.hex
 ifndef PRODUCTION
-	mv $(PROGRAM)_attiny1634.lst $(PROGRAM)_attiny1634_8200000L.lst
+	mv $(PROGRAM)_attiny1634.lst $(PROGRAM)_$@.lst
 endif
 
 attiny1634at737:
 	"$(MAKE)" attiny1634	AVR_FREQ=7372800L BAUD_RATE=57600
-	mv $(PROGRAM)_attiny1634.hex $(PROGRAM)_attiny1634_7372800L.hex
+	mv $(PROGRAM)_attiny1634.hex $(PROGRAM)_$@.hex
 ifndef PRODUCTION
-	mv $(PROGRAM)_attiny1634.lst $(PROGRAM)_attiny1634_7372800L.lst
+	mv $(PROGRAM)_attiny1634.lst $(PROGRAM)_$@.lst
 endif
 
 attiny1634at921:
 	"$(MAKE)" attiny1634	AVR_FREQ=9216000L  BAUD_RATE=57600
-	mv $(PROGRAM)_attiny1634.hex $(PROGRAM)_attiny1634_9216000L.hex
+	mv $(PROGRAM)_attiny1634.hex $(PROGRAM)_$@.hex
 ifndef PRODUCTION
-	mv $(PROGRAM)_attiny1634.lst $(PROGRAM)_attiny1634_9216000L.lst
+	mv $(PROGRAM)_attiny1634.lst $(PROGRAM)_$@.lst
 endif
 
 attiny1634at110:
 	"$(MAKE)" attiny1634	AVR_FREQ=11059200L
-	mv $(PROGRAM)_attiny1634.hex $(PROGRAM)_attiny1634_11059200L.hex
+	mv $(PROGRAM)_attiny1634.hex $(PROGRAM)_$@.hex
 ifndef PRODUCTION
-	mv $(PROGRAM)_attiny1634.lst $(PROGRAM)_attiny1634_11059200L.lst
+	mv $(PROGRAM)_attiny1634.lst $(PROGRAM)_$@.lst
 endif
 
 attiny1634at147:
 	"$(MAKE)" attiny1634	AVR_FREQ=14745600L
-	mv $(PROGRAM)_attiny1634.hex $(PROGRAM)_attiny1634_14745600L.hex
+	mv $(PROGRAM)_attiny1634.hex $(PROGRAM)_$@.hex
 ifndef PRODUCTION
-	mv $(PROGRAM)_attiny1634.lst $(PROGRAM)_attiny1634_14745600L.lst
+	mv $(PROGRAM)_attiny1634.lst $(PROGRAM)_$@.lst
 endif
 
 
@@ -84,58 +84,58 @@ endif
 
 attiny1634at12ser1:
 	"$(MAKE)" attiny1634	AVR_FREQ=12000000L UART=1
-	mv $(PROGRAM)_attiny1634.hex $(PROGRAM)_attiny1634_12000000L_ser1.hex
+	mv $(PROGRAM)_attiny1634.hex $(PROGRAM)_$@.hex
 ifndef PRODUCTION
-	mv $(PROGRAM)_attiny1634.lst $(PROGRAM)_attiny1634_12000000L_ser1.lst
+	mv $(PROGRAM)_attiny1634.lst $(PROGRAM)_$@.lst
 endif
 
 attiny1634at16ser1:
 	"$(MAKE)" attiny1634	AVR_FREQ=16000000L UART=1
-	mv $(PROGRAM)_attiny1634.hex $(PROGRAM)_attiny1634_16000000L_ser1.hex
+	mv $(PROGRAM)_attiny1634.hex $(PROGRAM)_$@.hex
 ifndef PRODUCTION
-	mv $(PROGRAM)_attiny1634.lst $(PROGRAM)_attiny1634_16000000L_ser1.lst
+	mv $(PROGRAM)_attiny1634.lst $(PROGRAM)_$@.lst
 endif
 
 attiny1634at8ser1:
 	"$(MAKE)" attiny1634	AVR_FREQ=8000000L BAUD_RATE=57600 UART=1
-	mv $(PROGRAM)_attiny1634.hex $(PROGRAM)_attiny1634_8000000L_ser1.hex
+	mv $(PROGRAM)_attiny1634.hex $(PROGRAM)_$@.hex
 ifndef PRODUCTION
-	mv $(PROGRAM)_attiny1634.lst $(PROGRAM)_attiny1634_8000000L_ser1.lst
+	mv $(PROGRAM)_attiny1634.lst $(PROGRAM)_$@.lst
 endif
 
 attiny1634at8_5vser1:
 	"$(MAKE)" attiny1634	AVR_FREQ=8200000L BAUD_RATE=57600 UART=1
-	mv $(PROGRAM)_attiny1634.hex $(PROGRAM)_attiny1634_8200000L_ser1.hex
+	mv $(PROGRAM)_attiny1634.hex $(PROGRAM)_$@.hex
 ifndef PRODUCTION
-	mv $(PROGRAM)_attiny1634.lst $(PROGRAM)_attiny1634_8200000L_ser1.lst
+	mv $(PROGRAM)_attiny1634.lst $(PROGRAM)_$@.lst
 endif
 
 attiny1634at737ser1:
 	"$(MAKE)" attiny1634	AVR_FREQ=7372800L BAUD_RATE=57600 UART=1
-	mv $(PROGRAM)_attiny1634.hex $(PROGRAM)_attiny1634_7372800L_ser1.hex
+	mv $(PROGRAM)_attiny1634.hex $(PROGRAM)_$@.hex
 ifndef PRODUCTION
-	mv $(PROGRAM)_attiny1634.lst $(PROGRAM)_attiny1634_7372800L_ser1.lst
+	mv $(PROGRAM)_attiny1634.lst $(PROGRAM)_$@.lst
 endif
 
 attiny1634at921ser1:
 	"$(MAKE)" attiny1634	AVR_FREQ=9216000L  BAUD_RATE=57600 UART=1
-	mv $(PROGRAM)_attiny1634.hex $(PROGRAM)_attiny1634_9216000L_ser1.hex
+	mv $(PROGRAM)_attiny1634.hex $(PROGRAM)_$@.hex
 ifndef PRODUCTION
-	mv $(PROGRAM)_attiny1634.lst $(PROGRAM)_attiny1634_9216000L_ser1.lst
+	mv $(PROGRAM)_attiny1634.lst $(PROGRAM)_$@.lst
 endif
 
 attiny1634at110ser1:
 	"$(MAKE)" attiny1634	AVR_FREQ=11059200L UART=1
-	mv $(PROGRAM)_attiny1634.hex $(PROGRAM)_attiny1634_11059200L_ser1.hex
+	mv $(PROGRAM)_attiny1634.hex $(PROGRAM)_$@.hex
 ifndef PRODUCTION
-	mv $(PROGRAM)_attiny1634.lst $(PROGRAM)_attiny1634_11059200L_ser1.lst
+	mv $(PROGRAM)_attiny1634.lst $(PROGRAM)_$@.lst
 endif
 
 attiny1634at147ser1:
 	"$(MAKE)" attiny1634	AVR_FREQ=14745600L UART=1
-	mv $(PROGRAM)_attiny1634.hex $(PROGRAM)_attiny1634_14745600L_ser1.hex
+	mv $(PROGRAM)_attiny1634.hex $(PROGRAM)_$@.hex
 ifndef PRODUCTION
-	mv $(PROGRAM)_attiny1634.lst $(PROGRAM)_attiny1634_14745600L_ser1.lst
+	mv $(PROGRAM)_attiny1634.lst $(PROGRAM)_$@.lst
 endif
 
 
@@ -163,72 +163,72 @@ endif
 #-----------------------
 attiny841at184:
 	$(MAKE) attiny841	 AVR_FREQ=18432000L
-	mv $(PROGRAM)_attiny841.hex $(PROGRAM)_attiny841_18432000L.hex
+	mv $(PROGRAM)_attiny841.hex $(PROGRAM)_$@.hex
 ifndef PRODUCTION
-	mv $(PROGRAM)_attiny841.lst $(PROGRAM)_attiny841_18432000L.lst
+	mv $(PROGRAM)_attiny841.lst $(PROGRAM)_$@.lst
 endif
 
 attiny841at147:
 	$(MAKE) attiny841	 AVR_FREQ=14745600L
-	mv $(PROGRAM)_attiny841.hex $(PROGRAM)_attiny841_14745600L.hex
+	mv $(PROGRAM)_attiny841.hex $(PROGRAM)_$@.hex
 ifndef PRODUCTION
-	mv $(PROGRAM)_attiny841.lst $(PROGRAM)_attiny841_14745600L.lst
+	mv $(PROGRAM)_attiny841.lst $(PROGRAM)_$@.lst
 endif
 
 attiny841at110:
 	$(MAKE) attiny841	 AVR_FREQ=11059200L
-	mv $(PROGRAM)_attiny841.hex $(PROGRAM)_attiny841_11059200L.hex
+	mv $(PROGRAM)_attiny841.hex $(PROGRAM)_$@.hex
 ifndef PRODUCTION
-	mv $(PROGRAM)_attiny841.lst $(PROGRAM)_attiny841_11059200L.lst
+	mv $(PROGRAM)_attiny841.lst $(PROGRAM)_$@.lst
 endif
 
 attiny841at921:
 	$(MAKE) attiny841	 AVR_FREQ=9216000L BAUD_RATE=57600
-	mv $(PROGRAM)_attiny841.hex $(PROGRAM)_attiny841_9216000L.hex
+	mv $(PROGRAM)_attiny841.hex $(PROGRAM)_$@.hex
 ifndef PRODUCTION
-	mv $(PROGRAM)_attiny841.lst $(PROGRAM)_attiny841_9216000L.lst
+	mv $(PROGRAM)_attiny841.lst $(PROGRAM)_$@.lst
 endif
 
 attiny841at737:
 	$(MAKE) attiny841	 AVR_FREQ=7372800L BAUD_RATE=57600
-	mv $(PROGRAM)_attiny841.hex $(PROGRAM)_attiny841_7372800L.hex
+	mv $(PROGRAM)_attiny841.hex $(PROGRAM)_$@.hex
 ifndef PRODUCTION
-	mv $(PROGRAM)_attiny841.lst $(PROGRAM)_attiny841_7372800L.lst
+	mv $(PROGRAM)_attiny841.lst $(PROGRAM)_$@.lst
 endif
 
 attiny841at20:
 	$(MAKE) attiny841	 AVR_FREQ=20000000L
-	mv $(PROGRAM)_attiny841.hex $(PROGRAM)_attiny841_20000000L.hex
+	mv $(PROGRAM)_attiny841.hex $(PROGRAM)_$@.hex
 ifndef PRODUCTION
-	mv $(PROGRAM)_attiny841.lst $(PROGRAM)_attiny841_20000000L.lst
+	mv $(PROGRAM)_attiny841.lst $(PROGRAM)_$@.lst
 endif
 
 attiny841at16:
 	$(MAKE) attiny841	 AVR_FREQ=16000000L
-	mv $(PROGRAM)_attiny841.hex $(PROGRAM)_attiny841_16000000L.hex
+	mv $(PROGRAM)_attiny841.hex $(PROGRAM)_$@.hex
 ifndef PRODUCTION
-	mv $(PROGRAM)_attiny841.lst $(PROGRAM)_attiny841_16000000L.lst
+	mv $(PROGRAM)_attiny841.lst $(PROGRAM)_$@.lst
 endif
 
 attiny841at12:
 	$(MAKE) attiny841	 AVR_FREQ=12000000L
-	mv $(PROGRAM)_attiny841.hex $(PROGRAM)_attiny841_12000000L.hex
+	mv $(PROGRAM)_attiny841.hex $(PROGRAM)_$@.hex
 ifndef PRODUCTION
-	mv $(PROGRAM)_attiny841.lst $(PROGRAM)_attiny841_12000000L.lst
+	mv $(PROGRAM)_attiny841.lst $(PROGRAM)_$@.lst
 endif
 
 attiny841at8:
 	$(MAKE) attiny841	 AVR_FREQ=8000000L BAUD_RATE=57600
-	mv $(PROGRAM)_attiny841.hex $(PROGRAM)_attiny841_8000000L.hex
+	mv $(PROGRAM)_attiny841.hex $(PROGRAM)_$@.hex
 ifndef PRODUCTION
-	mv $(PROGRAM)_attiny841.lst $(PROGRAM)_attiny841_8000000L.lst
+	mv $(PROGRAM)_attiny841.lst $(PROGRAM)_$@.lst
 endif
 
 attiny841at8_5v:
 	$(MAKE) attiny841	 AVR_FREQ=8200000L BAUD_RATE=57600
-	mv $(PROGRAM)_attiny841.hex $(PROGRAM)_attiny841_8200000L.hex
+	mv $(PROGRAM)_attiny841.hex $(PROGRAM)_$@.hex
 ifndef PRODUCTION
-	mv $(PROGRAM)_attiny841.lst $(PROGRAM)_attiny841_8200000L.lst
+	mv $(PROGRAM)_attiny841.lst $(PROGRAM)_$@.lst
 endif
 
 
@@ -238,65 +238,65 @@ endif
 #-----------------------
 attiny841at184ser1:
 	$(MAKE) attiny841	 AVR_FREQ=18432000L UART=1
-	mv $(PROGRAM)_attiny841.hex $(PROGRAM)_attiny841_18432000L_ser1.hex
+	mv $(PROGRAM)_attiny841.hex $(PROGRAM)_$@.hex
 ifndef PRODUCTION
-	mv $(PROGRAM)_attiny841.lst $(PROGRAM)_attiny841_18432000L_ser1.lst
+	mv $(PROGRAM)_attiny841.lst $(PROGRAM)_$@.lst
 endif
 
 attiny841at147ser1:
 	$(MAKE) attiny841	 AVR_FREQ=14745600L UART=1
-	mv $(PROGRAM)_attiny841.hex $(PROGRAM)_attiny841_14745600L_ser1.hex
+	mv $(PROGRAM)_attiny841.hex $(PROGRAM)_$@.hex
 ifndef PRODUCTION
-	mv $(PROGRAM)_attiny841.lst $(PROGRAM)_attiny841_14745600L_ser1.lst
+	mv $(PROGRAM)_attiny841.lst $(PROGRAM)_$@.lst
 endif
 
 attiny841at110ser1:
-	$(MAKE) attiny841	 AVR_FREQ=11059200L UART=1 
-	mv $(PROGRAM)_attiny841.hex $(PROGRAM)_attiny841_11059200L_ser1.hex
+	$(MAKE) attiny841	 AVR_FREQ=11059200L UART=1
+	mv $(PROGRAM)_attiny841.hex $(PROGRAM)_$@.hex
 ifndef PRODUCTION
-	mv $(PROGRAM)_attiny841.lst $(PROGRAM)_attiny841_11059200L_ser1.lst
+	mv $(PROGRAM)_attiny841.lst $(PROGRAM)_$@.lst
 endif
 
 attiny841at921ser1:
 	$(MAKE) attiny841	 AVR_FREQ=9216000L BAUD_RATE=57600 UART=1
-	mv $(PROGRAM)_attiny841.hex $(PROGRAM)_attiny841_9216000L_ser1.hex
+	mv $(PROGRAM)_attiny841.hex $(PROGRAM)_$@.hex
 ifndef PRODUCTION
-	mv $(PROGRAM)_attiny841.lst $(PROGRAM)_attiny841_9216000L_ser1.lst
+	mv $(PROGRAM)_attiny841.lst $(PROGRAM)_$@.lst
 endif
 
 attiny841at737ser1:
 	$(MAKE) attiny841	 AVR_FREQ=7372800L BAUD_RATE=57600 UART=1
-	mv $(PROGRAM)_attiny841.hex $(PROGRAM)_attiny841_7372800L_ser1.hex
+	mv $(PROGRAM)_attiny841.hex $(PROGRAM)_$@.hex
 ifndef PRODUCTION
-	mv $(PROGRAM)_attiny841.lst $(PROGRAM)_attiny841_7372800L_ser1.lst
+	mv $(PROGRAM)_attiny841.lst $(PROGRAM)_$@.lst
 endif
 
 attiny841at20ser1:
 	$(MAKE) attiny841	 AVR_FREQ=20000000L UART=1
-	mv $(PROGRAM)_attiny841.hex $(PROGRAM)_attiny841_20000000L_ser1.hex
+	mv $(PROGRAM)_attiny841.hex $(PROGRAM)_$@.hex
 ifndef PRODUCTION
-	mv $(PROGRAM)_attiny841.lst $(PROGRAM)_attiny841_20000000L_ser1.lst
+	mv $(PROGRAM)_attiny841.lst $(PROGRAM)_$@.lst
 endif
 
 attiny841at16ser1:
 	$(MAKE) attiny841	 AVR_FREQ=16000000L UART=1
-	mv $(PROGRAM)_attiny841.hex $(PROGRAM)_attiny841_16000000L_ser1.hex
+	mv $(PROGRAM)_attiny841.hex $(PROGRAM)_$@.hex
 ifndef PRODUCTION
-	mv $(PROGRAM)_attiny841.lst $(PROGRAM)_attiny841_16000000L_ser1.lst
+	mv $(PROGRAM)_attiny841.lst $(PROGRAM)_$@.lst
 endif
 
 attiny841at12ser1:
 	$(MAKE) attiny841	 AVR_FREQ=12000000L UART=1
-	mv $(PROGRAM)_attiny841.hex $(PROGRAM)_attiny841_12000000L_ser1.hex
+	mv $(PROGRAM)_attiny841.hex $(PROGRAM)_$@.hex
 ifndef PRODUCTION
-	mv $(PROGRAM)_attiny841.lst $(PROGRAM)_attiny841_12000000L_ser1.lst
+	mv $(PROGRAM)_attiny841.lst $(PROGRAM)_$@.lst
 endif
 
 attiny841at8ser1:
 	$(MAKE) attiny841	 AVR_FREQ=8000000L BAUD_RATE=57600 UART=1
-	mv $(PROGRAM)_attiny841.hex $(PROGRAM)_attiny841_8000000L_ser1.hex
+	mv $(PROGRAM)_attiny841.hex $(PROGRAM)_$@.hex
 ifndef PRODUCTION
-	mv $(PROGRAM)_attiny841.lst $(PROGRAM)_attiny841_8000000L_ser1.lst
+	mv $(PROGRAM)_attiny841.lst $(PROGRAM)_$@.lst
 endif
 
 #-----------------------
@@ -306,212 +306,26 @@ endif
 #-----------------------
 
 attiny841at20noLED:
-	$(MAKE) attiny841	 AVR_FREQ=20000000L LED_START_FLASHES=0  LDSECTIONS  = -Wl,--section-start=.text=0x1dc0 -Wl,--section-start=.version=0x1ffe
-	mv $(PROGRAM)_attiny841.hex $(PROGRAM)_attiny841_20000000L_noLED.hex
+	$(MAKE) attiny841	 AVR_FREQ=20000000L LED_START_FLASHES=0
+	mv $(PROGRAM)_attiny841.hex $(PROGRAM)_$@.hex
 ifndef PRODUCTION
-	mv $(PROGRAM)_attiny841.lst $(PROGRAM)_attiny841_20000000L_noLED.lst
+	mv $(PROGRAM)_attiny841.lst $(PROGRAM)_$@.lst
 endif
 
 attiny841at16noLED:
-	$(MAKE) attiny841	 AVR_FREQ=16000000L LED_START_FLASHES=0 LDSECTIONS  = -Wl,--section-start=.text=0x1dc0 -Wl,--section-start=.version=0x1ffe
-	mv $(PROGRAM)_attiny841.hex $(PROGRAM)_attiny841_16000000L_noLED.hex
+	$(MAKE) attiny841	 AVR_FREQ=16000000L LED_START_FLASHES=0
+	mv $(PROGRAM)_attiny841.hex $(PROGRAM)_$@.hex
 ifndef PRODUCTION
-	mv $(PROGRAM)_attiny841.lst $(PROGRAM)_attiny841_16000000L_noLED.lst
+	mv $(PROGRAM)_attiny841.lst $(PROGRAM)_$@.lst
 endif
 
 attiny841at8noLED:
-	$(MAKE) attiny841	 AVR_FREQ=8000000L  BAUD_RATE=57600 LED_START_FLASHES=0 LDSECTIONS  = -Wl,--section-start=.text=0x1dc0 -Wl,--section-start=.version=0x1ffe
-	mv $(PROGRAM)_attiny841.hex $(PROGRAM)_attiny841_8000000L_noLED.hex
+	$(MAKE) attiny841	 AVR_FREQ=8000000L  BAUD_RATE=57600 LED_START_FLASHES=0
+	mv $(PROGRAM)_attiny841.hex $(PROGRAM)_$@.hex
 ifndef PRODUCTION
-	mv $(PROGRAM)_attiny841.lst $(PROGRAM)_attiny841_8000000L_noLED.lst
+	mv $(PROGRAM)_attiny841.lst $(PROGRAM)_$@.lst
 endif
 
-#--------------------------------
-# ATtiny 441, base instructions
-#-------------------------------
-
-HELPTEXT += "target attiny441     - atttiny441at<freq>  attiny441at<freq>ser1\n"
-HELPTEXT += "                     - atttiny441at8_5v  attiny441at8_5vser1\n"
-HELPTEXT += "                     - atttiny441at<freq>noLED\n"
-
-attiny441: TARGET = attiny441
-attiny441: MCU_TARGET = attiny441
-attiny441: CFLAGS += $(COMMON_OPTIONS) '-DVIRTUAL_BOOT_PARTITION' '-DFOURPAGEERASE' $(UART_CMD)
-attiny441: AVR_FREQ ?= 8000000L
-attiny441: LDSECTIONS  = -Wl,--section-start=.text=0x0d80 -Wl,--section-start=.version=0x0ffe
-attiny441: $(PROGRAM)_attiny441.hex
-ifndef PRODUCTION
-attiny441: $(PROGRAM)_attiny441.lst
-endif
-
-#-----------------------
-# ATtiny 441, UART 0 
-#-----------------------
-attiny441at184:
-	$(MAKE) attiny441	 AVR_FREQ=18432000L
-	mv $(PROGRAM)_attiny441.hex $(PROGRAM)_attiny441_18432000L.hex
-ifndef PRODUCTION
-	mv $(PROGRAM)_attiny441.lst $(PROGRAM)_attiny441_18432000L.lst
-endif
-
-attiny441at147:
-	$(MAKE) attiny441	 AVR_FREQ=14745600L
-	mv $(PROGRAM)_attiny441.hex $(PROGRAM)_attiny441_14745600L.hex
-ifndef PRODUCTION
-	mv $(PROGRAM)_attiny441.lst $(PROGRAM)_attiny441_14745600L.lst
-endif
-
-attiny441at110:
-	$(MAKE) attiny441	 AVR_FREQ=11059200L
-	mv $(PROGRAM)_attiny441.hex $(PROGRAM)_attiny441_11059200L.hex
-ifndef PRODUCTION
-	mv $(PROGRAM)_attiny441.lst $(PROGRAM)_attiny441_11059200L.lst
-endif
-
-attiny441at921:
-	$(MAKE) attiny441	 AVR_FREQ=9216000L BAUD_RATE=57600
-	mv $(PROGRAM)_attiny441.hex $(PROGRAM)_attiny441_9216000L.hex
-ifndef PRODUCTION
-	mv $(PROGRAM)_attiny441.lst $(PROGRAM)_attiny441_9216000L.lst
-endif
-
-attiny441at737:
-	$(MAKE) attiny441	 AVR_FREQ=7372800L BAUD_RATE=57600
-	mv $(PROGRAM)_attiny441.hex $(PROGRAM)_attiny441_7372800L.hex
-ifndef PRODUCTION
-	mv $(PROGRAM)_attiny441.lst $(PROGRAM)_attiny441_7372800L.lst
-endif
-
-attiny441at20:
-	$(MAKE) attiny441	 AVR_FREQ=20000000L
-	mv $(PROGRAM)_attiny441.hex $(PROGRAM)_attiny441_20000000L.hex
-ifndef PRODUCTION
-	mv $(PROGRAM)_attiny441.lst $(PROGRAM)_attiny441_20000000L.lst
-endif
-
-attiny441at16:
-	$(MAKE) attiny441	 AVR_FREQ=16000000L
-	mv $(PROGRAM)_attiny441.hex $(PROGRAM)_attiny441_16000000L.hex
-ifndef PRODUCTION
-	mv $(PROGRAM)_attiny441.lst $(PROGRAM)_attiny441_16000000L.lst
-endif
-
-attiny441at12:
-	$(MAKE) attiny441	 AVR_FREQ=12000000L
-	mv $(PROGRAM)_attiny441.hex $(PROGRAM)_attiny441_12000000L.hex
-ifndef PRODUCTION
-	mv $(PROGRAM)_attiny441.lst $(PROGRAM)_attiny441_12000000L.lst
-endif
-
-attiny441at8:
-	$(MAKE) attiny441	 AVR_FREQ=8000000L BAUD_RATE=57600
-	mv $(PROGRAM)_attiny441.hex $(PROGRAM)_attiny441_8000000L.hex
-ifndef PRODUCTION
-	mv $(PROGRAM)_attiny441.lst $(PROGRAM)_attiny441_8000000L.lst
-endif
-
-attiny441at8_5v:
-	$(MAKE) attiny441	 AVR_FREQ=8200000L BAUD_RATE=57600
-	mv $(PROGRAM)_attiny441.hex $(PROGRAM)_attiny441_8200000L.hex
-ifndef PRODUCTION
-	mv $(PROGRAM)_attiny441.lst $(PROGRAM)_attiny441_8200000L.lst
-endif
-
-
-
-#-----------------------
-# ATtiny 441, UART 1
-#-----------------------
-attiny441at184ser1:
-	$(MAKE) attiny441	 AVR_FREQ=18432000L UART=1
-	mv $(PROGRAM)_attiny441.hex $(PROGRAM)_attiny441_18432000L_ser1.hex
-ifndef PRODUCTION
-	mv $(PROGRAM)_attiny441.lst $(PROGRAM)_attiny441_18432000L_ser1.lst
-endif
-
-attiny441at147ser1:
-	$(MAKE) attiny441	 AVR_FREQ=14745600L UART=1
-	mv $(PROGRAM)_attiny441.hex $(PROGRAM)_attiny441_14745600L_ser1.hex
-ifndef PRODUCTION
-	mv $(PROGRAM)_attiny441.lst $(PROGRAM)_attiny441_14745600L_ser1.lst
-endif
-
-attiny441at110ser1:
-	$(MAKE) attiny441	 AVR_FREQ=11059200L UART=1
-	mv $(PROGRAM)_attiny441.hex $(PROGRAM)_attiny441_11059200L_ser1.hex
-ifndef PRODUCTION
-	mv $(PROGRAM)_attiny441.lst $(PROGRAM)_attiny441_11059200L_ser1.lst
-endif
-
-attiny441at921ser1:
-	$(MAKE) attiny441	 AVR_FREQ=9216000L BAUD_RATE=57600 UART=1
-	mv $(PROGRAM)_attiny441.hex $(PROGRAM)_attiny441_9216000L_ser1.hex
-ifndef PRODUCTION
-	mv $(PROGRAM)_attiny441.lst $(PROGRAM)_attiny441_9216000L_ser1.lst
-endif
-
-attiny441at737ser1:
-	$(MAKE) attiny441	 AVR_FREQ=7372800L BAUD_RATE=57600 UART=1
-	mv $(PROGRAM)_attiny441.hex $(PROGRAM)_attiny441_7372800L_ser1.hex
-ifndef PRODUCTION
-	mv $(PROGRAM)_attiny441.lst $(PROGRAM)_attiny441_7372800L_ser1.lst
-endif
-
-attiny441at20ser1:
-	$(MAKE) attiny441	 AVR_FREQ=20000000L UART=1
-	mv $(PROGRAM)_attiny441.hex $(PROGRAM)_attiny441_20000000L_ser1.hex
-ifndef PRODUCTION
-	mv $(PROGRAM)_attiny441.lst $(PROGRAM)_attiny441_20000000L_ser1.lst
-endif
-
-attiny441at16ser1:
-	$(MAKE) attiny441	 AVR_FREQ=16000000L UART=1
-	mv $(PROGRAM)_attiny441.hex $(PROGRAM)_attiny441_16000000L_ser1.hex
-ifndef PRODUCTION
-	mv $(PROGRAM)_attiny441.lst $(PROGRAM)_attiny441_16000000L_ser1.lst
-endif
-
-attiny441at12ser1:
-	$(MAKE) attiny441	 AVR_FREQ=12000000L UART=1
-	mv $(PROGRAM)_attiny441.hex $(PROGRAM)_attiny441_12000000L_ser1.hex
-ifndef PRODUCTION
-	mv $(PROGRAM)_attiny441.lst $(PROGRAM)_attiny441_12000000L_ser1.lst
-endif
-
-attiny441at8ser1:
-	$(MAKE) attiny441	 AVR_FREQ=8000000L BAUD_RATE=57600 UART=1
-	mv $(PROGRAM)_attiny441.hex $(PROGRAM)_attiny441_8000000L_ser1.hex
-ifndef PRODUCTION
-	mv $(PROGRAM)_attiny441.lst $(PROGRAM)_attiny441_8000000L_ser1.lst
-endif
-
-
-#-----------------------
-# ATtiny 841, UART 0, no LED
-# There's no noLED definitions for 1634 because the larger page size
-# on the 1634 means that you don't gain any usable flash from it. 
-#-----------------------
-
-attiny441at20noLED:
-	$(MAKE) attiny441	 AVR_FREQ=20000000L LED_START_FLASHES=0  LDSECTIONS  = -Wl,--section-start=.text=0x0dc0 -Wl,--section-start=.version=0x0ffe
-	mv $(PROGRAM)_attiny441.hex $(PROGRAM)_attiny441_20000000L_noLED.hex
-ifndef PRODUCTION
-	mv $(PROGRAM)_attiny441.lst $(PROGRAM)_attiny441_20000000L_noLED.lst
-endif
-
-attiny441at16noLED:
-	$(MAKE) attiny441	 AVR_FREQ=16000000L LED_START_FLASHES=0 LDSECTIONS  = -Wl,--section-start=.text=0x0dc0 -Wl,--section-start=.version=0x0ffe
-	mv $(PROGRAM)_attiny441.hex $(PROGRAM)_attiny441_16000000L_noLED.hex
-ifndef PRODUCTION
-	mv $(PROGRAM)_attiny441.lst $(PROGRAM)_attiny441_16000000L_noLED.lst
-endif
-
-attiny441at8noLED:
-	$(MAKE) attiny441	 AVR_FREQ=8000000L  BAUD_RATE=57600 LED_START_FLASHES=0 LDSECTIONS  = -Wl,--section-start=.text=0x0dc0 -Wl,--section-start=.version=0x0ffe
-	mv $(PROGRAM)_attiny441.hex $(PROGRAM)_attiny441_8000000L_noLED.hex
-ifndef PRODUCTION
-	mv $(PROGRAM)_attiny441.lst $(PROGRAM)_attiny441_8000000L_noLED.lst
-endif
 
 #-------------------
 # ATtiny828 - only one speed since it doesn't support crystal. 
@@ -533,16 +347,16 @@ endif
 
 attiny828at8: 
 	$(MAKE) attiny828at8 AVR_FREQ=8000000L BAUD_RATE=57600
-	mv $(PROGRAM)_attiny828.hex $(PROGRAM)_attiny828_8000000L.hex
+	mv $(PROGRAM)_attiny828.hex $(PROGRAM)_$@.hex
 ifndef PRODUCTION
-	mv $(PROGRAM)_attiny828.lst $(PROGRAM)_attiny828_8000000L.lst
+	mv $(PROGRAM)_attiny828.lst $(PROGRAM)_$@.lst
 endif
 
 attiny828at8_5v: 
 	$(MAKE) attiny828at8 AVR_FREQ=8200000L BAUD_RATE=57600
-	mv $(PROGRAM)_attiny828.hex $(PROGRAM)_attiny828_8000000L.hex
+	mv $(PROGRAM)_attiny828.hex $(PROGRAM)_$@.hex
 ifndef PRODUCTION
-	mv $(PROGRAM)_attiny828.lst $(PROGRAM)_attiny828_8000000L.lst
+	mv $(PROGRAM)_attiny828.lst $(PROGRAM)_$@.lst
 endif
 
 
@@ -573,156 +387,3 @@ attiny87: $(PROGRAM)_attiny87.hex
 ifndef PRODUCTION
 attiny87: $(PROGRAM)_attiny87.lst
 endif
-
-attiny167at184:
-	$(MAKE) attiny167	 AVR_FREQ=18432000L
-	mv $(PROGRAM)_attiny167.hex $(PROGRAM)_attiny167_18432000L.hex
-ifndef PRODUCTION
-	mv $(PROGRAM)_attiny167.lst $(PROGRAM)_attiny167_18432000L.lst
-endif
-
-attiny167at147:
-	$(MAKE) attiny167	 AVR_FREQ=14745600L
-	mv $(PROGRAM)_attiny167.hex $(PROGRAM)_attiny167_14745600L.hex
-ifndef PRODUCTION
-	mv $(PROGRAM)_attiny167.lst $(PROGRAM)_attiny167_14745600L.lst
-endif
-
-attiny167at110:
-	$(MAKE) attiny167	 AVR_FREQ=11059200L
-	mv $(PROGRAM)_attiny167.hex $(PROGRAM)_attiny167_11059200L.hex
-ifndef PRODUCTION
-	mv $(PROGRAM)_attiny167.lst $(PROGRAM)_attiny167_11059200L.lst
-endif
-
-attiny167at921:
-	$(MAKE) attiny167	 AVR_FREQ=9216000L BAUD_RATE=57600
-	mv $(PROGRAM)_attiny167.hex $(PROGRAM)_attiny167_9216000L.hex
-ifndef PRODUCTION
-	mv $(PROGRAM)_attiny167.lst $(PROGRAM)_attiny167_9216000L.lst
-endif
-
-attiny167at737:
-	$(MAKE) attiny167	 AVR_FREQ=7372800L BAUD_RATE=57600
-	mv $(PROGRAM)_attiny167.hex $(PROGRAM)_attiny167_7372800L.hex
-ifndef PRODUCTION
-	mv $(PROGRAM)_attiny167.lst $(PROGRAM)_attiny167_7372800L.lst
-endif
-
-attiny167at20:
-	$(MAKE) attiny167	 AVR_FREQ=20000000L
-	mv $(PROGRAM)_attiny167.hex $(PROGRAM)_attiny167_20000000L.hex
-ifndef PRODUCTION
-	mv $(PROGRAM)_attiny167.lst $(PROGRAM)_attiny167_20000000L.lst
-endif
-
-attiny167at16:
-	$(MAKE) attiny167	 AVR_FREQ=16000000L
-	mv $(PROGRAM)_attiny167.hex $(PROGRAM)_attiny167_16000000L.hex
-ifndef PRODUCTION
-	mv $(PROGRAM)_attiny167.lst $(PROGRAM)_attiny167_16000000L.lst
-endif
-
-attiny167at12:
-	$(MAKE) attiny167	 AVR_FREQ=12000000L
-	mv $(PROGRAM)_attiny167.hex $(PROGRAM)_attiny167_12000000L.hex
-ifndef PRODUCTION
-	mv $(PROGRAM)_attiny167.lst $(PROGRAM)_attiny167_12000000L.lst
-endif
-
-attiny167at8:
-	$(MAKE) attiny167	 AVR_FREQ=8000000L BAUD_RATE=57600
-	mv $(PROGRAM)_attiny167.hex $(PROGRAM)_attiny167_8000000L.hex
-ifndef PRODUCTION
-	mv $(PROGRAM)_attiny167.lst $(PROGRAM)_attiny167_8000000L.lst
-endif
-
-attiny87at184:
-	$(MAKE) attiny87	 AVR_FREQ=18432000L
-	mv $(PROGRAM)_attiny87.hex $(PROGRAM)_attiny87_18432000L.hex
-ifndef PRODUCTION
-	mv $(PROGRAM)_attiny87.lst $(PROGRAM)_attiny87_18432000L.lst
-endif
-
-attiny87at147:
-	$(MAKE) attiny87	 AVR_FREQ=14745600L
-	mv $(PROGRAM)_attiny87.hex $(PROGRAM)_attiny87_14745600L.hex
-ifndef PRODUCTION
-	mv $(PROGRAM)_attiny87.lst $(PROGRAM)_attiny87_14745600L.lst
-endif
-
-attiny87at110:
-	$(MAKE) attiny87	 AVR_FREQ=11059200L
-	mv $(PROGRAM)_attiny87.hex $(PROGRAM)_attiny87_11059200L.hex
-ifndef PRODUCTION
-	mv $(PROGRAM)_attiny87.lst $(PROGRAM)_attiny87_11059200L.lst
-endif
-
-attiny87at921:
-	$(MAKE) attiny87	 AVR_FREQ=9216000L BAUD_RATE=57600
-	mv $(PROGRAM)_attiny87.hex $(PROGRAM)_attiny87_9216000L.hex
-ifndef PRODUCTION
-	mv $(PROGRAM)_attiny87.lst $(PROGRAM)_attiny87_9216000L.lst
-endif
-
-attiny87at737:
-	$(MAKE) attiny87	 AVR_FREQ=7372800L BAUD_RATE=57600
-	mv $(PROGRAM)_attiny87.hex $(PROGRAM)_attiny87_7372800L.hex
-ifndef PRODUCTION
-	mv $(PROGRAM)_attiny87.lst $(PROGRAM)_attiny87_7372800L.lst
-endif
-
-attiny87at20:
-	$(MAKE) attiny87	 AVR_FREQ=20000000L
-	mv $(PROGRAM)_attiny87.hex $(PROGRAM)_attiny87_20000000L.hex
-ifndef PRODUCTION
-	mv $(PROGRAM)_attiny87.lst $(PROGRAM)_attiny87_20000000L.lst
-endif
-
-attiny87at16:
-	$(MAKE) attiny87	 AVR_FREQ=16000000L
-	mv $(PROGRAM)_attiny87.hex $(PROGRAM)_attiny87_16000000L.hex
-ifndef PRODUCTION
-	mv $(PROGRAM)_attiny87.lst $(PROGRAM)_attiny87_16000000L.lst
-endif
-
-attiny87at12:
-	$(MAKE) attiny87	 AVR_FREQ=12000000L
-	mv $(PROGRAM)_attiny87.hex $(PROGRAM)_attiny87_12000000L.hex
-ifndef PRODUCTION
-	mv $(PROGRAM)_attiny87.lst $(PROGRAM)_attiny87_12000000L.lst
-endif
-
-attiny87at8:
-	$(MAKE) attiny87	 AVR_FREQ=8000000L BAUD_RATE=57600
-	mv $(PROGRAM)_attiny87.hex $(PROGRAM)_attiny87_8000000L.hex
-ifndef PRODUCTION
-	mv $(PROGRAM)_attiny87.lst $(PROGRAM)_attiny87_8000000L.lst
-endif
-
-
-
-#--------------------------------
-# ATtiny 84, base instructions
-#-------------------------------
-
-HELPTEXT += "target attiny84     - atttiny841at<freq>  attiny841at<freq>ser1\n"
-HELPTEXT += "                     - atttiny841at8_5v  attiny841at8_5vser1\n"
-HELPTEXT += "                     - atttiny841at<freq>noLED\n"
-
-attiny84: TARGET = attiny84
-attiny84: MCU_TARGET = attiny84
-attiny84: CFLAGS += $(COMMON_OPTIONS) '-DVIRTUAL_BOOT_PARTITION' '-DSOFT_UART' 
-attiny84: AVR_FREQ ?= 8000000L
-attiny84: LDSECTIONS  = -Wl,--section-start=.text=0x1d80 -Wl,--section-start=.version=0x1ffe
-attiny84: $(PROGRAM)_attiny84.hex
-ifndef PRODUCTION
-attiny84: $(PROGRAM)_attiny84.lst
-endif
-
-attiny84at8:
-	$(MAKE) attiny84	 AVR_FREQ=8000000L BAUD_RATE=19200
-	mv $(PROGRAM)_attiny84.hex $(PROGRAM)_$@.hex
-ifndef PRODUCTION
-	mv $(PROGRAM)_attiny84.lst $(PROGRAM)_$@.lst
-endif

+ 14 - 26
optiboot/bootloaders/optiboot/optiboot.c

@@ -474,7 +474,9 @@ static addr16_t buff = {(uint8_t *)(RAMSTART)};
 #endif
 #endif //save_vect_num
 // check if it's on the same page (code assumes that)
-
+#if (SPM_PAGESIZE <= save_vect_num)
+#error Save vector not in the same page as reset!
+#endif
 #if FLASHEND > 8192
 // AVRs with more than 8k of flash have 4-byte vectors, and use jmp.
 //  We save only 16 bits of address, so devices with more than 128KB
@@ -486,7 +488,6 @@ static addr16_t buff = {(uint8_t *)(RAMSTART)};
 #define appstart_vec (save_vect_num*2)
 #else
 // AVRs with up to 8k of flash have 2-byte vectors, and use rjmp.
-
 #define rstVect0 0
 #define rstVect1 1
 #define saveVect0 (save_vect_num*2)
@@ -786,30 +787,18 @@ int main(void) {
 	// Save jmp targets (for "Verify")
 	rstVect0_sav = buff.bptr[rstVect0];
 	rstVect1_sav = buff.bptr[rstVect1];
+	saveVect0_sav = buff.bptr[saveVect0];
+	saveVect1_sav = buff.bptr[saveVect1];
 
+        // Move RESET jmp target to 'save' vector
+        buff.bptr[saveVect0] = rstVect0_sav;
+        buff.bptr[saveVect1] = rstVect1_sav;
 
         // Add jump to bootloader at RESET vector
         // WARNING: this works as long as 'main' is in first section
         buff.bptr[rstVect0] = ((uint16_t)main) & 0xFF;
         buff.bptr[rstVect1] = ((uint16_t)main) >> 8;
-#if (save_vect_num>SPM_PAGESIZE/4)
-	} else if (address.word == (SPM_PAGESIZE*(save_vect_num/(SPM_PAGESIZE/4)))) { //allow for any vector
-		saveVect0_sav = buff.bptr[saveVect0-(SPM_PAGESIZE*(save_vect_num/(SPM_PAGESIZE/4)))];
-		saveVect1_sav = buff.bptr[saveVect1-(SPM_PAGESIZE*(save_vect_num/(SPM_PAGESIZE/4)))];
-
-        // Move RESET jmp target to 'save' vector
-        buff.bptr[saveVect0-(SPM_PAGESIZE*(save_vect_num/(SPM_PAGESIZE/4)))] = rstVect0_sav;
-        buff.bptr[saveVect1-(SPM_PAGESIZE*(save_vect_num/(SPM_PAGESIZE/4)))] = rstVect1_sav;
-    }
-#else 
-        saveVect0_sav = buff.bptr[saveVect0];
-		saveVect1_sav = buff.bptr[saveVect1];
-
-        // Move RESET jmp target to 'save' vector
-        buff.bptr[saveVect0] = rstVect0_sav;
-        buff.bptr[saveVect1] = rstVect1_sav;
-	}
-#endif
+      }
 
 #else
 /*
@@ -828,19 +817,19 @@ int main(void) {
     buff.bptr[0] = vect.bytes[0]; // rjmp to start of bootloader
 	buff.bptr[1] = vect.bytes[1] | 0xC0;  // make an "rjmp"
 #if (save_vect_num > SPM_PAGESIZE/2)
-} else if (address.word == (SPM_PAGESIZE*(save_vect_num/(SPM_PAGESIZE/2)))) { //allow for any vector
+} else if (address.word == SPM_PAGESIZE) { //allow for vectors 8~15
 	// Instruction is a relative jump (rjmp), so recalculate.
 	// an RJMP instruction is 0b1100xxxx xxxxxxxx, so we should be able to
 	// do math on the offsets without masking it off first.
 	addr16_t vect;
 	vect.bytes[0] = rstVect0_sav;
 	vect.bytes[1] = rstVect1_sav;
-	saveVect0_sav = buff.bptr[saveVect0-(SPM_PAGESIZE*(save_vect_num/(SPM_PAGESIZE/2)))];
-	saveVect1_sav = buff.bptr[saveVect1-(SPM_PAGESIZE*(save_vect_num/(SPM_PAGESIZE/2)))];
+	saveVect0_sav = buff.bptr[saveVect0-SPM_PAGESIZE];
+	saveVect1_sav = buff.bptr[saveVect1-SPM_PAGESIZE];
 	vect.word = (vect.word-save_vect_num); //substract 'save' interrupt position
         // Move RESET jmp target to 'save' vector
-        buff.bptr[saveVect0-(SPM_PAGESIZE*(save_vect_num/(SPM_PAGESIZE/2)))] = vect.bytes[0];
-        buff.bptr[saveVect1-(SPM_PAGESIZE*(save_vect_num/(SPM_PAGESIZE/2)))] = (vect.bytes[1] & 0x0F)| 0xC0;  // make an "rjmp"
+        buff.bptr[saveVect0-SPM_PAGESIZE] = vect.bytes[0];
+        buff.bptr[saveVect1-SPM_PAGESIZE] = (vect.bytes[1] & 0x0F)| 0xC0;  // make an "rjmp"
       }
 		
 #else
@@ -1019,7 +1008,6 @@ uint8_t getch(void) {
 #if UART_B_VALUE > 255
 #error Baud rate too slow for soft UART
 #endif
-
 #if UART_B_VALUE < 6
 // (this value is a "guess" at when loop/call overhead might become too
 //  significant for the soft uart to work.  It tests OK with the popular