From 2343e419d3caa94c77d9bb2afa2906eaeae6464d Mon Sep 17 00:00:00 2001 From: Joerg Wunsch Date: Fri, 20 Apr 2012 12:33:15 +0000 Subject: [PATCH] bug #30756: When setting SUT to 64ms on XMEGA, avrdude doesn't read device signature * main.c: When reading the signature yields 0x000000 or 0xffffff, retry (up to twice) after some progressive delay. git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@1084 81a1dc3b-b13d-400b-aceb-764788c761c2 --- ChangeLog | 7 +++++++ NEWS | 2 ++ main.c | 55 +++++++++++++++++++++++++++++++++++-------------------- 3 files changed, 44 insertions(+), 20 deletions(-) diff --git a/ChangeLog b/ChangeLog index 75f394d3..8a1819d7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2012-04-20 Joerg Wunsch + + bug #30756: When setting SUT to 64ms on XMEGA, avrdude doesn't + read device signature + * main.c: When reading the signature yields 0x000000 or 0xffffff, + retry (up to twice) after some progressive delay. + 2012-04-20 Joerg Wunsch * avrdude.conf.in (ATxmega16D4, ATxmega32D4, ATxmega64D4, diff --git a/NEWS b/NEWS index 87efa54b..90380316 100644 --- a/NEWS +++ b/NEWS @@ -60,6 +60,8 @@ Current: supported error - bug #28744: Can't load bootloader to xmega128a1 - bug #29019: pagel/bs2 warning when uploading using stk500 to xmega + - bug #30756: When setting SUT to 64ms on XMEGA, avrdude doesn't + read device signature * Keep track of input file contents diff --git a/main.c b/main.c index 78566edc..c2758e27 100644 --- a/main.c +++ b/main.c @@ -989,6 +989,11 @@ int main(int argc, char * argv []) * are valid. */ if(!(p->flags & AVRPART_AVR32)) { + int attempt = 0; + int waittime = 10000; /* 10 ms */ + + sig_again: + usleep(waittime); if (init_ok) { rc = avr_signature(pgm, p); if (rc != 0) { @@ -1022,11 +1027,17 @@ int main(int argc, char * argv []) if (sig->buf[i] != 0x00) zz = 0; } - if (quell_progress < 2) { - fprintf(stderr, "\n"); - } - if (ff || zz) { + if (++attempt < 3) { + waittime *= 5; + if (quell_progress < 2) { + fprintf(stderr, " (retrying)\n"); + } + goto sig_again; + } + if (quell_progress < 2) { + fprintf(stderr, "\n"); + } fprintf(stderr, "%s: Yikes! Invalid device signature.\n", progname); if (!ovsigck) { @@ -1037,23 +1048,27 @@ int main(int argc, char * argv []) exitrc = 1; goto main_exit; } + } else { + if (quell_progress < 2) { + fprintf(stderr, "\n"); + } } - } - - if (sig->size != 3 || - sig->buf[0] != p->signature[0] || - sig->buf[1] != p->signature[1] || - sig->buf[2] != p->signature[2]) { - fprintf(stderr, - "%s: Expected signature for %s is %02X %02X %02X\n", - progname, p->desc, - p->signature[0], p->signature[1], p->signature[2]); - if (!ovsigck) { - fprintf(stderr, "%sDouble check chip, " - "or use -F to override this check.\n", - progbuf); - exitrc = 1; - goto main_exit; + + if (sig->size != 3 || + sig->buf[0] != p->signature[0] || + sig->buf[1] != p->signature[1] || + sig->buf[2] != p->signature[2]) { + fprintf(stderr, + "%s: Expected signature for %s is %02X %02X %02X\n", + progname, p->desc, + p->signature[0], p->signature[1], p->signature[2]); + if (!ovsigck) { + fprintf(stderr, "%sDouble check chip, " + "or use -F to override this check.\n", + progbuf); + exitrc = 1; + goto main_exit; + } } } }