From ad3fa869ee6d2dd746b2fc25ca6117cc9fe334db Mon Sep 17 00:00:00 2001
From: joerg_wunsch <joerg_wunsch@81a1dc3b-b13d-400b-aceb-764788c761c2>
Date: Wed, 20 Sep 2006 21:32:18 +0000
Subject: [PATCH] * avr910.c: As there is a lot of ambiguity about the AVR910
 device codes, allow the user to override the device code verification with
 the -F option. * main.c: Make ovsigck a global variable.

git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@665 81a1dc3b-b13d-400b-aceb-764788c761c2
---
 ChangeLog |  7 +++++++
 avr910.c  | 19 +++++++++++++------
 main.c    |  2 +-
 3 files changed, 21 insertions(+), 7 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index dd721e80..6e5da182 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2006-09-20 Joerg Wunsch <j@uriah.heep.sax.de>
+
+	* avr910.c: As there is a lot of ambiguity about the AVR910
+	device codes, allow the user to override the device code
+	verification with the -F option.
+	* main.c: Make ovsigck a global variable.
+
 2006-09-20 Joerg Wunsch <j@uriah.heep.sax.de>
 
 	Add the "stk500generic" programmer that auto-probes for STK500
diff --git a/avr910.c b/avr910.c
index c61de2b5..6a6421ff 100644
--- a/avr910.c
+++ b/avr910.c
@@ -40,6 +40,7 @@
 
 extern char * progname;
 extern int do_cycles;
+extern int ovsigck;
 
 static char has_auto_incr_addr;
 
@@ -134,7 +135,7 @@ static int avr910_initialize(PROGRAMMER * pgm, AVRPART * p)
   char hw[2];
   char buf[10];
   char type;
-  char c;
+  char c, devtype_1st;
   int dev_supported = 0;
   AVRPART * part;
 
@@ -173,8 +174,11 @@ static int avr910_initialize(PROGRAMMER * pgm, AVRPART * p)
 
   avr910_send(pgm, "t", 1);
   fprintf(stderr, "\nProgrammer supports the following devices:\n");
+  devtype_1st = 0;
   while (1) {
     avr910_recv(pgm, &c, 1);
+    if (devtype_1st == 0)
+      devtype_1st = c;
     if (c == 0)
       break;
     part = locate_part_by_avr910_devcode(part_list, c);
@@ -190,15 +194,18 @@ static int avr910_initialize(PROGRAMMER * pgm, AVRPART * p)
 
   if (!dev_supported) {
     fprintf(stderr,
-            "%s: error: selected device is not supported by programmer: %s\n",
-            progname, p->id);
-    exit(1);
+            "%s: %s: selected device is not supported by programmer: %s\n",
+            progname, ovsigck? "warning": "error", p->id);
+    if (!ovsigck)
+      exit(1);
   }
 
-  /* Tell the programmer which part we selected. */
+  /* Tell the programmer which part we selected.
+     If the user forced the selection, use the first device
+     type that is supported by the programmer. */
 
   buf[0] = 'T';
-  buf[1] = p->avr910_devcode;
+  buf[1] = ovsigck? devtype_1st: p->avr910_devcode;
 
   avr910_send(pgm, buf, 2);
   avr910_vfy_cmd_sent(pgm, "select device");
diff --git a/main.c b/main.c
index 0388d654..6025122a 100644
--- a/main.c
+++ b/main.c
@@ -76,6 +76,7 @@ char * version      = VERSION;
 
 int    verbose;     /* verbose output */
 int    quell_progress; /* un-verebose output */
+int    ovsigck;     /* 1=override sig check, 0=don't */
 char * progname;
 char   progbuf[PATH_MAX]; /* temporary buffer of spaces the same
                              length as progname; used for lining up
@@ -683,7 +684,6 @@ int main(int argc, char * argv [])
   int     erase;       /* 1=erase chip, 0=don't */
   int     auto_erase;  /* 0=never erase unless explicity told to do
                           so, 1=erase if we are going to program flash */
-  int     ovsigck;     /* 1=override sig check, 0=don't */
   char  * port;        /* device port (/dev/xxx) */
   int     terminal;    /* 1=enter terminal mode, 0=don't */
   int     nowrite;     /* don't actually write anything to the chip */