From 932bd18ec106fc4f1f9d3cba8cc95eac9e0f70f2 Mon Sep 17 00:00:00 2001 From: Joerg Wunsch Date: Mon, 11 Dec 2006 15:15:50 +0000 Subject: [PATCH] In jtagmkI_close(), revert baud rate to the initial value in case we had changed it. Fixes bug #18262: JTAGMKI/JTAG1 Reset Bug git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@699 81a1dc3b-b13d-400b-aceb-764788c761c2 --- ChangeLog | 11 ++++++++--- jtagmkI.c | 23 ++++++++++++++++++++++- 2 files changed, 30 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index a4071ffa..200c9239 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,8 +1,13 @@ +2006-12-11 Joerg Wunsch + + * jtagmkI.c (jtagmkI_close): revert baud rate to the initial + value in case we had changed it. + Fixes bug #18262: JTAGMKI/JTAG1 Reset Bug + 2006-12-11 Colin O'Flynn - * safemode.c: Stop ignoring return values! - Closes bug #18339 - + * safemode.c: Stop ignoring return values! + Closes bug #18339 2006-12-11 Joerg Wunsch diff --git a/jtagmkI.c b/jtagmkI.c index 04aed441..ef8ed02b 100644 --- a/jtagmkI.c +++ b/jtagmkI.c @@ -46,7 +46,7 @@ extern int do_cycles; * XXX There should really be a programmer-specific private data * pointer in struct PROGRAMMER. */ -static long initial_baudrate; +static int initial_baudrate; /* * See jtagmkI_read_byte() for an explanation of the flash and @@ -681,10 +681,31 @@ static int jtagmkI_open(PROGRAMMER * pgm, char * port) static void jtagmkI_close(PROGRAMMER * pgm) { + unsigned char b; if (verbose >= 2) fprintf(stderr, "%s: jtagmkI_close()\n", progname); + /* + * Revert baud rate to what it used to be when we started. This + * appears to make AVR Studio happier when it is about to access the + * ICE later on. + */ + if ((serdev->flags & SERDEV_FL_CANSETSPEED) && initial_baudrate != pgm->baudrate) { + if ((b = jtagmkI_get_baud(initial_baudrate)) == 0) { + fprintf(stderr, "%s: jtagmkI_close(): unsupported baudrate %d\n", + progname, initial_baudrate); + } else { + if (verbose >= 2) + fprintf(stderr, "%s: jtagmkI_close(): " + "trying to set baudrate to %d\n", + progname, initial_baudrate); + if (jtagmkI_setparm(pgm, PARM_BITRATE, b) == 0) { + serial_setspeed(&pgm->fd, pgm->baudrate); + } + } + } + if (pgm->fd.ifd != -1) { serial_close(&pgm->fd); }