add support for ATmega8535
authorStephan Baerwolf <stephan.baerwolf@tu-ilmenau.de>
Mon, 10 Jun 2013 09:46:34 +0000 (11:46 +0200)
committerStephan Baerwolf <stephan.baerwolf@tu-ilmenau.de>
Mon, 26 Aug 2013 18:15:38 +0000 (18:15 +0000)
Thanks to Jony Smith reporting this missing MCU.

Reported-by: Jony Smith <jony.nambela@gmail.com>
Signed-off-by: Stephan Baerwolf <stephan.baerwolf@tu-ilmenau.de>
Makefile.inc
firmware/main.c
firmware/spminterface.h

index f5a0a2b..7515129 100644 (file)
@@ -39,6 +39,12 @@ LOCKOPT = -U lock:w:0x3f:m
 #some features may be deactivated to fit into bootloader section
 #ATTANTION: CONFIG_NO... feature deactivation may not be optimal!
 
 #some features may be deactivated to fit into bootloader section
 #ATTANTION: CONFIG_NO... feature deactivation may not be optimal!
 
+FUSEOPT_8535            = -U lfuse:w:0x1f:m -U hfuse:w:0xc0:m
+BOOTLOADER_ADDRESS_8535 = 0x1800
+DEFINES_8535            = -DCONFIG_USE__EXCESSIVE_ASSEMBLER -DCONFIG_NO__NEED_WATCHDOG -DCONFIG_NO__PRECISESLEEP
+
+
+
 FUSEOPT_16              = -U lfuse:w:0x1f:m -U hfuse:w:0xc0:m
 BOOTLOADER_ADDRESS_16   = 0x3800
 DEFINES_16              = -DCONFIG_USE__EXCESSIVE_ASSEMBLER -DCONFIG_NO__NEED_WATCHDOG -DCONFIG_NO__PRECISESLEEP
 FUSEOPT_16              = -U lfuse:w:0x1f:m -U hfuse:w:0xc0:m
 BOOTLOADER_ADDRESS_16   = 0x3800
 DEFINES_16              = -DCONFIG_USE__EXCESSIVE_ASSEMBLER -DCONFIG_NO__NEED_WATCHDOG -DCONFIG_NO__PRECISESLEEP
@@ -149,7 +155,12 @@ DEFINES_2560             = #-DEMPTY
 
 #http://www.nongnu.org/avr-libc/user-manual/using_tools.html
 #autoselect logic
 
 #http://www.nongnu.org/avr-libc/user-manual/using_tools.html
 #autoselect logic
-ifeq ($(DEVICE), atmega8)
+ifeq ($(DEVICE), atmega8535)
+  FUSEOPT            = $(FUSEOPT_8535)
+  BOOTLOADER_ADDRESS = $(BOOTLOADER_ADDRESS_8535) 
+  MCUARCH            = avr4
+  DEFINES           += $(DEFINES_8535)
+else ifeq ($(DEVICE), atmega8)
   FUSEOPT            = $(FUSEOPT_8)
   BOOTLOADER_ADDRESS = $(BOOTLOADER_ADDRESS_8) 
   MCUARCH            = avr4
   FUSEOPT            = $(FUSEOPT_8)
   BOOTLOADER_ADDRESS = $(BOOTLOADER_ADDRESS_8) 
   MCUARCH            = avr4
index 9c8bab3..19c7756 100644 (file)
@@ -128,6 +128,8 @@ static const uchar          currentRequest = 0;
 static const uchar  signatureBytes[4] = {
 #ifdef SIGNATURE_BYTES
     SIGNATURE_BYTES
 static const uchar  signatureBytes[4] = {
 #ifdef SIGNATURE_BYTES
     SIGNATURE_BYTES
+#elif defined (__AVR_ATmega8535__)
+    0x1e, 0x93, 0x08, 0
 #elif defined (__AVR_ATmega8__) || defined (__AVR_ATmega8A__) || defined (__AVR_ATmega8HVA__)
     0x1e, 0x93, 0x07, 0
 #elif defined (__AVR_ATmega16__)
 #elif defined (__AVR_ATmega8__) || defined (__AVR_ATmega8A__) || defined (__AVR_ATmega8HVA__)
     0x1e, 0x93, 0x07, 0
 #elif defined (__AVR_ATmega16__)
@@ -291,7 +293,9 @@ uchar usbFunctionSetup_USBASP_FUNC_TRANSMIT(usbRequest_t *rq) {
     rval = rq->wIndex.bytes[0] & 3;
     rval = signatureBytes[rval];
 #if HAVE_READ_LOCK_FUSE
     rval = rq->wIndex.bytes[0] & 3;
     rval = signatureBytes[rval];
 #if HAVE_READ_LOCK_FUSE
-#if defined (__AVR_ATmega8__) || defined (__AVR_ATmega8A__) || defined (__AVR_ATmega16__) || defined (__AVR_ATmega32__)
+#if defined (__AVR_ATmega8535__) ||                                    \
+    defined (__AVR_ATmega8__) || defined (__AVR_ATmega8A__) ||                 \
+    defined (__AVR_ATmega16__) || defined (__AVR_ATmega32__)
   }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 */
   }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 */
index f750b0e..c71cbdf 100644 (file)
@@ -110,7 +110,9 @@ ret
       #define  funcaddr___bootloader__do_spm (&bootloader__do_spm)
     #endif  
   #else
       #define  funcaddr___bootloader__do_spm (&bootloader__do_spm)
     #endif  
   #else
-    #if defined (__AVR_ATmega8__) || defined (__AVR_ATmega8A__) || defined (__AVR_ATmega8HVA__)
+    #if defined (__AVR_ATmega8535__)
+      #define  funcaddr___bootloader__do_spm 0x182a
+    #elif defined (__AVR_ATmega8__) || defined (__AVR_ATmega8A__) || defined (__AVR_ATmega8HVA__)
       #define  funcaddr___bootloader__do_spm 0x1826
     #elif defined (__AVR_ATmega16__)
       #define  funcaddr___bootloader__do_spm 0x3854
       #define  funcaddr___bootloader__do_spm 0x1826
     #elif defined (__AVR_ATmega16__)
       #define  funcaddr___bootloader__do_spm 0x3854
@@ -433,9 +435,9 @@ void do_spm(const uint32_t flash_byteaddress, const uint8_t spmcrval, const uint
  * try to make this array as big as possible
  * (so bootloader always uses 2kbytes flash)
  */
  * try to make this array as big as possible
  * (so bootloader always uses 2kbytes flash)
  */
-#if defined (__AVR_ATmega8__) || defined (__AVR_ATmega8A__) || defined (__AVR_ATmega8HVA__) || defined (__AVR_ATmega16__) || defined (__AVR_ATmega32__)
+#if defined (__AVR_ATmega8535__) || defined (__AVR_ATmega8__) || defined (__AVR_ATmega8A__) || defined (__AVR_ATmega8HVA__) || defined (__AVR_ATmega16__) || defined (__AVR_ATmega32__)
 
 
-#if defined (__AVR_ATmega8__) || defined (__AVR_ATmega8A__) || defined (__AVR_ATmega8HVA__)
+#if defined (__AVR_ATmega8535__) || defined (__AVR_ATmega8__) || defined (__AVR_ATmega8A__) || defined (__AVR_ATmega8HVA__)
   #if (BOOTLOADER_ADDRESS != 0x1800)
     #error BOOTLOADER_ADDRESS!=0x1800, on current MCU "funcaddr___bootloader__do_spm" might be currupted - please edit spminterface.h for nonstandard use
   #endif
   #if (BOOTLOADER_ADDRESS != 0x1800)
     #error BOOTLOADER_ADDRESS!=0x1800, on current MCU "funcaddr___bootloader__do_spm" might be currupted - please edit spminterface.h for nonstandard use
   #endif