+FUSEOPT_640 = -U lfuse:w:0xd7:m -U hfuse:w:0xd0:m -U efuse:w:0xfc:m
+BOOTLOADER_ADDRESS_640 = 0xE000
+DEFINES_640 = #-DEMPTY
+
+
+
+FUSEOPT_1280 = $(FUSEOPT_640)
+BOOTLOADER_ADDRESS_1280 = 0x1E000
+DEFINES_1280 = #-DEMPTY
+
+
+
+FUSEOPT_1281 = $(FUSEOPT_1280)
+BOOTLOADER_ADDRESS_1281 = 0x1E000
+DEFINES_1281 = #-DEMPTY
+
+
+
+FUSEOPT_2560 = $(FUSEOPT_1280)
+BOOTLOADER_ADDRESS_2560 = 0x3E000
+DEFINES_2560 = #-DEMPTY
+
+
+
+FUSEOPT_2561 = $(FUSEOPT_1281)
+BOOTLOADER_ADDRESS_2561 = 0x3E000
+DEFINES_2561 = #-DEMPTY
+
+
+
#tested devices
-
+#http://www.nongnu.org/avr-libc/user-manual/using_tools.html
#autoselect logic
ifeq ($(DEVICE), atmega8)
FUSEOPT = $(FUSEOPT_8)
BOOTLOADER_ADDRESS = $(BOOTLOADER_ADDRESS_328)
MCUARCH = avr5
DEFINES += $(DEFINES_328)
+else ifeq ($(DEVICE), atmega640)
+ FUSEOPT = $(FUSEOPT_640)
+ BOOTLOADER_ADDRESS = $(BOOTLOADER_ADDRESS_640)
+ MCUARCH = avr5
+ DEFINES += $(DEFINES_640)
else ifeq ($(DEVICE), atmega644)
FUSEOPT = $(FUSEOPT_644)
BOOTLOADER_ADDRESS = $(BOOTLOADER_ADDRESS_644)
BOOTLOADER_ADDRESS = $(BOOTLOADER_ADDRESS_128)
MCUARCH = avr51
DEFINES += $(DEFINES_128)
+else ifeq ($(DEVICE), atmega1280)
+ FUSEOPT = $(FUSEOPT_1280)
+ BOOTLOADER_ADDRESS = $(BOOTLOADER_ADDRESS_1280)
+ MCUARCH = avr51
+ DEFINES += $(DEFINES_1280)
+else ifeq ($(DEVICE), atmega1281)
+ FUSEOPT = $(FUSEOPT_1281)
+ BOOTLOADER_ADDRESS = $(BOOTLOADER_ADDRESS_1281)
+ MCUARCH = avr51
+ DEFINES += $(DEFINES_1281)
else ifeq ($(DEVICE), atmega1284)
FUSEOPT = $(FUSEOPT_1284)
BOOTLOADER_ADDRESS = $(BOOTLOADER_ADDRESS_1284)
BOOTLOADER_ADDRESS = $(BOOTLOADER_ADDRESS_1284)
MCUARCH = avr51
DEFINES += $(DEFINES_1284)
+else ifeq ($(DEVICE), atmega2560)
+ FUSEOPT = $(FUSEOPT_2560)
+ BOOTLOADER_ADDRESS = $(BOOTLOADER_ADDRESS_2560)
+ MCUARCH = avr6
+ DEFINES += $(DEFINES_2560)
+else ifeq ($(DEVICE), atmega2561)
+ FUSEOPT = $(FUSEOPT_2561)
+ BOOTLOADER_ADDRESS = $(BOOTLOADER_ADDRESS_2561)
+ MCUARCH = avr6
+ DEFINES += $(DEFINES_2561)
else
FUSEOPT = unknown
endif
0x1e, 0x95, 0x14, 0
#elif defined (__AVR_ATmega328P__)
0x1e, 0x95, 0x0f, 0
+#elif defined (__AVR_ATmega640__)
+ 0x1e, 0x96, 0x08, 0
#elif defined (__AVR_ATmega644__) || defined (__AVR_ATmega644A__)
0x1e, 0x96, 0x09, 0
#elif defined (__AVR_ATmega644P__) || defined (__AVR_ATmega644PA__)
0x1e, 0x96, 0x0a, 0
#elif defined (__AVR_ATmega128__)
0x1e, 0x97, 0x02, 0
+#elif defined (__AVR_ATmega1280__)
+ 0x1e, 0x97, 0x03, 0
+#elif defined (__AVR_ATmega1281__)
+ 0x1e, 0x97, 0x04, 0
#elif defined (__AVR_ATmega1284__)
0x1e, 0x97, 0x06, 0
#elif defined (__AVR_ATmega1284P__)
0x1e, 0x97, 0x05, 0
+#elif defined (__AVR_ATmega2560__)
+ 0x1e, 0x98, 0x01, 0
+#elif defined (__AVR_ATmega2561__)
+ 0x1e, 0x98, 0x02, 0
#else
-# error "Device signature is not known, please edit main.c!"
+# if (defined(SIGNATURE_0) && defined(SIGNATURE_1) && defined(SIGNATURE_2))
+# warning "Device signature is not known - using AVR Libc suggestion..."
+ SIGNATURE_0, SIGNATURE_1, SIGNATURE_2, 0
+# else
+# error "Device signature is not known, please edit main.c!"
+# endif
#endif
};
defined (__AVR_ATmega168__) || defined (__AVR_ATmega168A__) || defined (__AVR_ATmega168P__) || defined (__AVR_ATmega168PA__) || \
defined (__AVR_ATmega324A__) || defined (__AVR_ATmega324P__) || \
defined (__AVR_ATmega328__) || defined (__AVR_ATmega328P__) || \
+defined (__AVR_ATmega640__) || \
defined (__AVR_ATmega644__) || defined (__AVR_ATmega644A__) || defined (__AVR_ATmega644P__) || defined (__AVR_ATmega644PA__) || \
defined (__AVR_ATmega128__) || \
-defined (__AVR_ATmega1284__) || defined (__AVR_ATmega1284P__)
+defined (__AVR_ATmega1280__) || \
+defined (__AVR_ATmega1281__) || \
+defined (__AVR_ATmega1284__) || defined (__AVR_ATmega1284P__) || \
+defined (__AVR_ATmega2560__) || \
+defined (__AVR_ATmega2561__)
}else if(rq->wValue.bytes[0] == 0x58 && rq->wValue.bytes[1] == 0x00){ /* read lock bits */
rval = boot_lock_fuse_bits_get(GET_LOCK_BITS);
}else if(rq->wValue.bytes[0] == 0x50 && rq->wValue.bytes[1] == 0x00){ /* read lfuse bits */
#define funcaddr___bootloader__do_spm 0x707c
#elif defined (__AVR_ATmega328__) || defined (__AVR_ATmega328P__)
#define funcaddr___bootloader__do_spm 0x7068
+ #elif defined (__AVR_ATmega640__)
+ #define funcaddr___bootloader__do_spm 0xe0e4
#elif defined (__AVR_ATmega644__) || defined (__AVR_ATmega644A__) || defined (__AVR_ATmega644P__) || defined (__AVR_ATmega644PA__)
#define funcaddr___bootloader__do_spm 0xe07c
#elif defined (__AVR_ATmega128__)
#define funcaddr___bootloader__do_spm 0x1e08c
+ #elif defined (__AVR_ATmega1280__)
+ #define funcaddr___bootloader__do_spm 0x1e0e4
+ #elif defined (__AVR_ATmega1281__)
+ #define funcaddr___bootloader__do_spm 0x1e0e4
#elif defined (__AVR_ATmega1284__) || defined (__AVR_ATmega1284P__)
#define funcaddr___bootloader__do_spm 0x1e08c
+ #elif defined (__AVR_ATmega2560__)
+ #define funcaddr___bootloader__do_spm 0x3e0e4
+ #elif defined (__AVR_ATmega2561__)
+ #define funcaddr___bootloader__do_spm 0x3e0e4
#else
#error "unknown MCU - where is bootloader__do_spm located?"
#endif
-#elif defined (__AVR_ATmega164A__) || defined (__AVR_ATmega164P__) || defined (__AVR_ATmega164PA__) || defined (__AVR_ATmega324A__) || defined (__AVR_ATmega324P__) || defined (__AVR_ATmega324PA__) || defined (__AVR_ATmega644__) || defined (__AVR_ATmega644A__) || defined (__AVR_ATmega644P__) || defined (__AVR_ATmega644PA__) || defined (__AVR_ATmega1284__) || defined (__AVR_ATmega1284P__)
+#elif defined (__AVR_ATmega164A__) || defined (__AVR_ATmega164P__) || defined (__AVR_ATmega164PA__) || defined (__AVR_ATmega324A__) || defined (__AVR_ATmega324P__) || defined (__AVR_ATmega324PA__) || defined (__AVR_ATmega640__) || defined (__AVR_ATmega644__) || defined (__AVR_ATmega644A__) || defined (__AVR_ATmega644P__) || defined (__AVR_ATmega644PA__) || defined (__AVR_ATmega1280__) || defined (__AVR_ATmega1281__) || defined (__AVR_ATmega1284__) || defined (__AVR_ATmega1284P__) || defined (__AVR_ATmega2560__) || defined (__AVR_ATmega2561__)
#if defined (__AVR_ATmega164A__) || defined (__AVR_ATmega164P__) || defined (__AVR_ATmega164PA__)
#if (BOOTLOADER_ADDRESS != 0x3800)
#if (BOOTLOADER_ADDRESS != 0x7000)
#error BOOTLOADER_ADDRESS!=0x7000, on current MCU "funcaddr___bootloader__do_spm" might be currupted - please edit spminterface.h for nonstandard use
#endif
+#elif defined (__AVR_ATmega640__)
+ #if (BOOTLOADER_ADDRESS != 0xE000)
+ #error BOOTLOADER_ADDRESS!=0xE000, on current MCU "funcaddr___bootloader__do_spm" might be currupted - please edit spminterface.h for nonstandard use
+ #endif
#elif defined (__AVR_ATmega644__) || defined (__AVR_ATmega644A__) || defined (__AVR_ATmega644P__) || defined (__AVR_ATmega644PA__)
#if (BOOTLOADER_ADDRESS != 0xE000)
#error BOOTLOADER_ADDRESS!=0xE000, on current MCU "funcaddr___bootloader__do_spm" might be currupted - please edit spminterface.h for nonstandard use
#endif
+#elif defined (__AVR_ATmega1280__)
+ #if (BOOTLOADER_ADDRESS != 0x1E000)
+ #error BOOTLOADER_ADDRESS!=0x1E000, on current MCU "funcaddr___bootloader__do_spm" might be currupted - please edit spminterface.h for nonstandard use
+ #endif
+#elif defined (__AVR_ATmega1281__)
+ #if (BOOTLOADER_ADDRESS != 0x1E000)
+ #error BOOTLOADER_ADDRESS!=0x1E000, on current MCU "funcaddr___bootloader__do_spm" might be currupted - please edit spminterface.h for nonstandard use
+ #endif
#elif defined (__AVR_ATmega1284__) || defined (__AVR_ATmega1284P__)
#if (BOOTLOADER_ADDRESS != 0x1E000)
#error BOOTLOADER_ADDRESS!=0x1E000, on current MCU "funcaddr___bootloader__do_spm" might be currupted - please edit spminterface.h for nonstandard use
#endif
+#elif defined (__AVR_ATmega2560__)
+ #if (BOOTLOADER_ADDRESS != 0x3E000)
+ #error BOOTLOADER_ADDRESS!=0x3E000, on current MCU "funcaddr___bootloader__do_spm" might be currupted - please edit spminterface.h for nonstandard use
+ #endif
+#elif defined (__AVR_ATmega2561__)
+ #if (BOOTLOADER_ADDRESS != 0x3E000)
+ #error BOOTLOADER_ADDRESS!=0x3E000, on current MCU "funcaddr___bootloader__do_spm" might be currupted - please edit spminterface.h for nonstandard use
+ #endif
#else
#error undefined device selection - this should not happen!
#endif