? avrdude.new.1
? fakeadd
? stk500.patched
Index: Makefile.am
===================================================================
RCS file: /sources/avrdude/avrdude/Makefile.am,v
retrieving revision 1.42
diff -u -r1.42 Makefile.am
--- Makefile.am	25 Jul 2008 21:06:55 -0000	1.42
+++ Makefile.am	21 Feb 2009 13:31:00 -0000
@@ -77,6 +77,8 @@
 libavrdude_a_SOURCES = \
 	config_gram.y \
 	lexer.l \
+	arduino.h \
+	arduino.c \
 	avr.c \
 	avr.h \
 	avr910.c \
Index: arduino.c
===================================================================
RCS file: arduino.c
diff -N arduino.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ arduino.c	21 Feb 2009 13:31:00 -0000
@@ -0,0 +1,94 @@
+/*
+ * avrdude - A Downloader/Uploader for AVR device programmers
+ * Copyright (C) 2006 Joerg Wunsch <j@uriah.heep.sax.de>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+/* $Id: stk500generic.c,v 1.3 2007/03/25 22:43:50 c_oflynn Exp $ */
+
+/*
+ * avrdude interface for Arduino programmer
+ *
+ * The Arduino programmer is mostly a STK500v1, just the signature bytes
+ * are read differently.
+ */
+
+#include "ac_cfg.h"
+
+#include <stdio.h>
+#include <string.h>
+
+#include "avrdude.h"
+#include "pgm.h"
+#include "stk500_private.h"
+#include "stk500.h"
+#include "serial.h"
+
+/* read signature bytes - arduino version */
+static int arduino_read_sig_bytes(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m)
+{
+  unsigned char buf[32];
+
+  /* Signature byte reads are always 3 bytes. */
+
+  if (m->size < 3) {
+    fprintf(stderr, "%s: memsize too small for sig byte read", progname);
+    return -1;
+  }
+
+  buf[0] = Cmnd_STK_READ_SIGN;
+  buf[1] = Sync_CRC_EOP;
+     
+  serial_send(&pgm->fd, buf, 2);
+
+  if (serial_recv(&pgm->fd, buf, 5) < 0)
+    return -1;
+  if (buf[0] == Resp_STK_NOSYNC) {
+    fprintf(stderr, "%s: stk500_cmd(): programmer is out of sync\n", 
+			progname);
+	return -1;
+  } else if (buf[0] != Resp_STK_INSYNC) {
+    fprintf(stderr,
+			"\n%s: arduino_read_sig_bytes(): (a) protocol error, "
+			"expect=0x%02x, resp=0x%02x\n", 
+			progname, Resp_STK_INSYNC, buf[0]);
+	return -2;
+  }
+  if (buf[4] != Resp_STK_OK) {
+    fprintf(stderr,
+			"\n%s: arduino_read_sig_bytes(): (a) protocol error, "
+			"expect=0x%02x, resp=0x%02x\n", 
+			progname, Resp_STK_OK, buf[4]);
+    return -3;
+  }
+  
+  m->buf[0] = buf[1];
+  m->buf[1] = buf[2];
+  m->buf[2] = buf[3];
+
+  return 3;
+}
+
+void arduino_initpgm(PROGRAMMER * pgm)
+{
+	/* This is mostly a STK500; just the signature is read
+     differently than on real STK500v1 */
+  stk500_initpgm(pgm);
+
+  strcpy(pgm->type, "Arduino");
+  pgm->read_sig_bytes = arduino_read_sig_bytes;
+
+}
Index: arduino.h
===================================================================
RCS file: arduino.h
diff -N arduino.h
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ arduino.h	21 Feb 2009 13:31:00 -0000
@@ -0,0 +1,29 @@
+/*
+ * avrdude - A Downloader/Uploader for AVR device programmers
+ * Copyright (C) 2006 Joerg Wunsch <j@uriah.heep.sax.de>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+/* $Id: stk500generic.h,v 1.1 2006/09/19 22:27:30 joerg_wunsch Exp $ */
+
+#ifndef arduino_h__
+#define arduino_h__
+
+void arduino_initpgm (PROGRAMMER * pgm);
+
+#endif
+
+
Index: avrdude.conf.in
===================================================================
RCS file: /sources/avrdude/avrdude/avrdude.conf.in,v
retrieving revision 1.137
diff -u -r1.137 avrdude.conf.in
--- avrdude.conf.in	17 Feb 2009 14:17:53 -0000	1.137
+++ avrdude.conf.in	21 Feb 2009 13:31:05 -0000
@@ -311,6 +311,12 @@
 #
 
 programmer
+  id    = "arduino";
+  desc  = "Arduino";
+  type  = arduino;
+;
+
+programmer
   id    = "avrisp";
   desc  = "Atmel AVR ISP";
   type  = stk500;
Index: config_gram.y
===================================================================
RCS file: /sources/avrdude/avrdude/config_gram.y,v
retrieving revision 1.61
diff -u -r1.61 config_gram.y
--- config_gram.y	26 Jul 2008 22:53:39 -0000	1.61
+++ config_gram.y	21 Feb 2009 13:31:05 -0000
@@ -36,7 +36,9 @@
 #include "pindefs.h"
 #include "ppi.h"
 #include "pgm.h"
+#include "arduino.h"
 #include "stk500.h"
+#include "arduino.h"
 #include "stk500v2.h"
 #include "stk500generic.h"
 #include "avr910.h"
@@ -79,6 +81,7 @@
 %token K_PAGE_SIZE
 %token K_PAGED
 
+%token K_ARDUINO
 %token K_BAUDRATE
 %token K_BS2
 %token K_BUFF
@@ -417,6 +420,12 @@
     }
   } |
 
+  K_TYPE TKN_EQUAL K_ARDUINO {
+    { 
+      arduino_initpgm(current_prog);
+    }
+  } |
+
   K_TYPE TKN_EQUAL K_STK600 {
     {
       stk600_initpgm(current_prog);
Index: lexer.l
===================================================================
RCS file: /sources/avrdude/avrdude/lexer.l,v
retrieving revision 1.53
diff -u -r1.53 lexer.l
--- lexer.l	26 Jul 2008 22:53:39 -0000	1.53
+++ lexer.l	21 Feb 2009 13:31:05 -0000
@@ -117,6 +117,7 @@
             exit(1); }
 
 allowfullpagebitstream { yylval=NULL; return K_ALLOWFULLPAGEBITSTREAM; }
+arduino          { yylval=NULL; return K_ARDUINO; }
 avr910           { yylval=NULL; return K_AVR910; }
 avr910_devcode   { yylval=NULL; return K_AVR910_DEVCODE; }
 usbasp           { yylval=NULL; return K_USBASP; }
