From 86f70682e25348b8402d652c2d037467256cad9f Mon Sep 17 00:00:00 2001 From: Joerg Wunsch Date: Fri, 1 Sep 2006 21:00:36 +0000 Subject: [PATCH] Contributed by as patch #4372: Better synchronization for stk500 Sync three times, and drop any noise inbetween. git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@641 81a1dc3b-b13d-400b-aceb-764788c761c2 --- ChangeLog | 6 ++++++ stk500.c | 10 ++++++++++ 2 files changed, 16 insertions(+) diff --git a/ChangeLog b/ChangeLog index fb66db70..e9730e98 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2006-09-01 Joerg Wunsch + + Contributed by as + patch #4372: Better synchronization for stk500 + * stk500.c: Sync three times, and drop any noise inbetween. + 2006-09-01 Joerg Wunsch * avrdude.conf.in (ATtiny261, ATtiny461, ATtiny861): new diff --git a/stk500.c b/stk500.c index b131a720..170962dd 100644 --- a/stk500.c +++ b/stk500.c @@ -90,6 +90,16 @@ static int stk500_getsync(PROGRAMMER * pgm) * get in sync */ buf[0] = Cmnd_STK_GET_SYNC; buf[1] = Sync_CRC_EOP; + + /* + * First send and drain a few times to get rid of line noise + */ + + stk500_send(pgm, buf, 2); + stk500_drain(pgm, 0); + stk500_send(pgm, buf, 2); + stk500_drain(pgm, 0); + stk500_send(pgm, buf, 2); stk500_recv(pgm, resp, 1); if (resp[0] != Resp_STK_INSYNC) {