From ad8b6a45dab14ce0e9d335ff3b0c30f8521f4589 Mon Sep 17 00:00:00 2001 From: joerg_wunsch Date: Fri, 8 Jan 2010 16:01:37 +0000 Subject: [PATCH] bug #28516: Linux/Dragon: Error message on exit * stk500v2.c: Fix the "bad response to GO command: RSP_ILLEGAL_EMULATOR_MODE" message. jtagmkII_close() has been called with the wrong pgm->cookie. Wrap it inside stk500v2_jtagmkII_close(), adjusting the cookie data appropriately. git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@895 81a1dc3b-b13d-400b-aceb-764788c761c2 --- ChangeLog | 9 +++++++++ stk500v2.c | 25 +++++++++++++++++++++---- 2 files changed, 30 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index b11202d9..70b231df 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2010-01-08 Joerg Wunsch + + bug #28516: Linux/Dragon: Error message on exit + * stk500v2.c: Fix the "bad response to GO command: + RSP_ILLEGAL_EMULATOR_MODE" message. jtagmkII_close() + has been called with the wrong pgm->cookie. Wrap it + inside stk500v2_jtagmkII_close(), adjusting the cookie + data appropriately. + 2010-01-08 Joerg Wunsch Submitted by Doug: diff --git a/stk500v2.c b/stk500v2.c index 31bdf8f1..b9211c33 100644 --- a/stk500v2.c +++ b/stk500v2.c @@ -2794,6 +2794,23 @@ static int stk500v2_jtagmkII_open(PROGRAMMER * pgm, char * port) } +/* + * Close an AVR Dragon or JTAG ICE mkII in ISP/HVSP/PP mode. + */ +static void stk500v2_jtagmkII_close(PROGRAMMER * pgm) +{ + void *mycookie; + + if (verbose >= 2) + fprintf(stderr, "%s: stk500v2_jtagmkII_close()\n", progname); + + mycookie = pgm->cookie; + pgm->cookie = PDATA(pgm)->chained_pdata; + jtagmkII_close(pgm); + pgm->cookie = mycookie; +} + + /* * Wrapper functions for the AVR Dragon in ISP mode. This mode * uses the normal JTAG ICE mkII packet stream to communicate with the @@ -3543,7 +3560,7 @@ void stk500v2_jtagmkII_initpgm(PROGRAMMER * pgm) pgm->chip_erase = stk500v2_chip_erase; pgm->cmd = stk500v2_cmd; pgm->open = stk500v2_jtagmkII_open; - pgm->close = jtagmkII_close; + pgm->close = stk500v2_jtagmkII_close; pgm->read_byte = avr_read_byte_default; pgm->write_byte = avr_write_byte_default; @@ -3575,7 +3592,7 @@ void stk500v2_dragon_isp_initpgm(PROGRAMMER * pgm) pgm->chip_erase = stk500v2_chip_erase; pgm->cmd = stk500v2_cmd; pgm->open = stk500v2_dragon_isp_open; - pgm->close = jtagmkII_close; + pgm->close = stk500v2_jtagmkII_close; pgm->read_byte = avr_read_byte_default; pgm->write_byte = avr_write_byte_default; @@ -3605,7 +3622,7 @@ void stk500v2_dragon_pp_initpgm(PROGRAMMER * pgm) pgm->program_enable = stk500pp_program_enable; pgm->chip_erase = stk500pp_chip_erase; pgm->open = stk500v2_dragon_hv_open; - pgm->close = jtagmkII_close; + pgm->close = stk500v2_jtagmkII_close; pgm->read_byte = stk500pp_read_byte; pgm->write_byte = stk500pp_write_byte; @@ -3638,7 +3655,7 @@ void stk500v2_dragon_hvsp_initpgm(PROGRAMMER * pgm) pgm->program_enable = stk500hvsp_program_enable; pgm->chip_erase = stk500hvsp_chip_erase; pgm->open = stk500v2_dragon_hv_open; - pgm->close = jtagmkII_close; + pgm->close = stk500v2_jtagmkII_close; pgm->read_byte = stk500hvsp_read_byte; pgm->write_byte = stk500hvsp_write_byte;