Hello,

avrdude is a really cool tool. Thank you all for writing it.

Since I have a random mix of atmega48/88/168 sometimes p or pa parts I often see the following error message:

avrdude: Device signature = 0x1e930f
avrdude: Expected signature for ATmega168 is 1E 94 06
         Double check chip, or use -F to override this check.

Attached is a patch (and a log message) which prints the part id after the signature it read from the chip. The first line then looks like this:

avrdude: Device signature = 0x1e930f (probably m88p)

Please accept and commit my patch.
Thank you,
Martin
When printing the part signature also print the part id.

* avrpart.c (locate_part_by_signature): New function.
* avrpart.h (locate_part_by_signature): New function.
* main.c (main): Use the new function to find the part and print its id.

Index: avrpart.c
===================================================================
--- avrpart.c   (revision 1298)
+++ avrpart.c   (working copy)
@@ -544,6 +544,27 @@
   return NULL;
 }
 
+AVRPART * locate_part_by_signature(LISTID parts, unsigned char * sig,
+                                   int sigsize)
+{
+  LNODEID ln1;
+  AVRPART * p = NULL;
+  int i;
+
+  if (sigsize == 3) {
+    for (ln1=lfirst(parts); ln1; ln1=lnext(ln1)) {
+      p = ldata(ln1);
+      for (i=0; i<3; i++)
+        if (p->signature[i] != sig[i])
+          break;
+      if (i == 3)
+        return p;
+    }
+  }
+
+  return NULL;
+}
+
 /*
  * Iterate over the list of avrparts given as "avrparts", and
  * call the callback function cb for each entry found.  cb is being
Index: avrpart.h
===================================================================
--- avrpart.h   (revision 1298)
+++ avrpart.h   (working copy)
@@ -222,6 +222,8 @@
 void      avr_free_part(AVRPART * d);
 AVRPART * locate_part(LISTID parts, char * partdesc);
 AVRPART * locate_part_by_avr910_devcode(LISTID parts, int devcode);
+AVRPART * locate_part_by_signature(LISTID parts, unsigned char * sig,
+                                   int sigsize);
 void avr_display(FILE * f, AVRPART * p, const char * prefix, int verbose);
 
 typedef void (*walk_avrparts_cb)(const char *name, const char *desc,
Index: main.c
===================================================================
--- main.c      (revision 1298)
+++ main.c      (working copy)
@@ -1063,6 +1063,14 @@
         if (sig->buf[i] != 0x00)
           zz = 0;
       }
+      if (quell_progress < 2) {
+        AVRPART * part;
+
+        part = locate_part_by_signature(part_list, sig->buf, sig->size);
+        if (part) {
+          fprintf(stderr, " (probably %s)", part->id);
+        }
+      }
       if (ff || zz) {
         if (++attempt < 3) {
           waittime *= 5;
_______________________________________________
avrdude-dev mailing list
[email protected]
https://lists.nongnu.org/mailman/listinfo/avrdude-dev

Reply via email to