From eb3660e618107cab43a39be01399fb0aa2511968 Mon Sep 17 00:00:00 2001
From: Joerg Wunsch <j@uriah.heep.sax.de>
Date: Mon, 16 Sep 2013 19:40:15 +0000
Subject: [PATCH] Submitted by Joakim Lubeck: bug #40040: Support for ATtiny20
 and ATtiny40 * avrdude.conf.in: Restructure the reduced-core tiny devices to
 use a common entry .reduced_core_tiny; add ATtiny20 and ATtiny40

git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@1236 81a1dc3b-b13d-400b-aceb-764788c761c2
---
 avrdude/ChangeLog       |   8 +++
 avrdude/NEWS            |   2 +
 avrdude/avrdude.conf.in | 154 +++++++++++++---------------------------
 3 files changed, 61 insertions(+), 103 deletions(-)

diff --git a/avrdude/ChangeLog b/avrdude/ChangeLog
index 92e39e04..e8a78025 100644
--- a/avrdude/ChangeLog
+++ b/avrdude/ChangeLog
@@ -1,3 +1,11 @@
+2013-09-16  Joerg Wunsch <j.gnu@uriah.heep.sax.de>
+
+	Submitted by Joakim Lubeck:
+	bug #40040: Support for ATtiny20 and ATtiny40
+	* avrdude.conf.in: Restructure the reduced-core tiny devices
+	to use a common entry .reduced_core_tiny; add ATtiny20 and
+	ATtiny40
+
 2013-09-15  Joerg Wunsch <j.gnu@uriah.heep.sax.de>
 
 	Submitted by Joakim Lubeck:
diff --git a/avrdude/NEWS b/avrdude/NEWS
index 1488e740..c450ba70 100644
--- a/avrdude/NEWS
+++ b/avrdude/NEWS
@@ -103,6 +103,7 @@ Current:
     - ATtiny43U
     - ATmega406
     - ATxmega8E5, ATxmega16E5, ATxmega32E5
+    - ATtiny20, ATtiny40
 
 
   * New programmers supported:
@@ -193,6 +194,7 @@ Current:
       - bug #35474: Feature request: print fuse values in safemode output.
       - patch #7710: usb_libusb: Check VID/PID before opening device
       - [no-id]: Fix SCK period adjustment for STK500v2
+      - bug #40040: Support for ATtiny20 and ATtiny40
 
   * Internals:
 
diff --git a/avrdude/avrdude.conf.in b/avrdude/avrdude.conf.in
index 4b5986b4..3bc35cab 100644
--- a/avrdude/avrdude.conf.in
+++ b/avrdude/avrdude.conf.in
@@ -14162,22 +14162,14 @@ part
 ;
 
 #------------------------------------------------------------
-# ATtiny4
+# Common values for reduced core tinys (4/5/9/10/20/40)
 #------------------------------------------------------------
 
 part
-    id		= "t4";
-    desc	= "ATtiny4";
-    signature	= 0x1e 0x8f 0x0a;
+    id		= ".reduced_core_tiny";
+    desc	= "Common values for reduced core tinys";
     has_tpi	= yes;
 
-    memory "flash"
-        size		= 512;
-        offset		= 0x4000;
-        page_size	= 16;
-        blocksize	= 128;
-    ;
-
     memory "signature"
         size		= 3;
         offset		= 0x3fc0;
@@ -14204,60 +14196,41 @@ part
     ;
 ;
 
+#------------------------------------------------------------
+# ATtiny4
+#------------------------------------------------------------
+
+part parent ".reduced_core_tiny"
+    id		= "t4";
+    desc	= "ATtiny4";
+    signature	= 0x1e 0x8f 0x0a;
+
+    memory "flash"
+        size		= 512;
+        offset		= 0x4000;
+        page_size	= 16;
+        blocksize	= 128;
+    ;
+;
 
 #------------------------------------------------------------
 # ATtiny5
 #------------------------------------------------------------
 
-part
+part parent "t4"
     id		= "t5";
     desc	= "ATtiny5";
     signature	= 0x1e 0x8f 0x09;
-    has_tpi	= yes;
-
-    memory "flash"
-        size		= 512;
-        offset		= 0x4000;
-        page_size	= 16;
-        blocksize	= 128;
-    ;
-
-    memory "signature"
-        size		= 3;
-        offset		= 0x3fc0;
-        page_size	= 16;
-    ;
-
-    memory "fuse"
-        size		= 1;
-        offset		= 0x3f40;
-        page_size	= 16;
-	blocksize	= 4;
-    ;
-
-    memory "calibration"
-        size		= 1;
-        offset		= 0x3f80;
-        page_size	= 16;
-    ;
-
-    memory "lockbits"
-        size		= 1;
-        offset		= 0x3f00;
-        page_size	= 16;
-    ;
 ;
 
-
 #------------------------------------------------------------
 # ATtiny9
 #------------------------------------------------------------
 
-part
+part parent ".reduced_core_tiny"
     id		= "t9";
     desc	= "ATtiny9";
     signature	= 0x1e 0x90 0x08;
-    has_tpi	= yes;
 
     memory "flash"
         size		= 1024;
@@ -14265,75 +14238,50 @@ part
         page_size	= 16;
         blocksize	= 128;
     ;
-
-    memory "signature"
-        size		= 3;
-        offset		= 0x3fc0;
-        page_size	= 16;
-    ;
-
-    memory "fuse"
-        size		= 1;
-        offset		= 0x3f40;
-        page_size	= 16;
-	blocksize	= 4;
-    ;
-
-    memory "calibration"
-        size		= 1;
-        offset		= 0x3f80;
-        page_size	= 16;
-    ;
-
-    memory "lockbits"
-        size		= 1;
-        offset		= 0x3f00;
-        page_size	= 16;
-    ;
 ;
 
-
 #------------------------------------------------------------
 # ATtiny10
 #------------------------------------------------------------
 
-part
+part parent "t9"
     id		= "t10";
     desc	= "ATtiny10";
     signature	= 0x1e 0x90 0x03;
-    has_tpi	= yes;
+;
+
+#------------------------------------------------------------
+# ATtiny20
+#------------------------------------------------------------
+
+part parent ".reduced_core_tiny"
+    id          = "t20";
+    desc        = "ATtiny20";
+    signature   = 0x1e 0x91 0x0F;
 
     memory "flash"
-        size		= 1024;
+        size            = 2048;
+        offset          = 0x4000;
+        page_size       = 16;
+        blocksize       = 128;
+    ;
+;
+
+#------------------------------------------------------------
+# ATtiny40
+#------------------------------------------------------------
+
+part parent ".reduced_core_tiny"
+    id		= "t40";
+    desc	= "ATtiny40";
+    signature	= 0x1e 0x92 0x0E;
+
+    memory "flash"
+        size		= 4096;
         offset		= 0x4000;
-        page_size	= 16;
+        page_size	= 64;
         blocksize	= 128;
     ;
-
-    memory "signature"
-        size		= 3;
-        offset		= 0x3fc0;
-        page_size	= 16;
-    ;
-
-    memory "fuse"
-        size		= 1;
-        offset		= 0x3f40;
-        page_size	= 16;
-	blocksize	= 4;
-    ;
-
-    memory "calibration"
-        size		= 1;
-        offset		= 0x3f80;
-        page_size	= 16;
-    ;
-
-    memory "lockbits"
-        size		= 1;
-        offset		= 0x3f00;
-        page_size	= 16;
-    ;
 ;
 
 #------------------------------------------------------------