From 453761106e52db9db81a6a63b1ed28d23bbcd71d Mon Sep 17 00:00:00 2001 From: joerg_wunsch Date: Sat, 31 Aug 2013 07:32:18 +0000 Subject: [PATCH] Add -vvvv trace output to usbasp_transmit(). git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@1189 81a1dc3b-b13d-400b-aceb-764788c761c2 --- ChangeLog | 4 ++++ usbasp.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 53 insertions(+) diff --git a/ChangeLog b/ChangeLog index a1b26f85..28987125 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2013-08-31 Joerg Wunsch + + * usbasp.c (usbasp_transmit): Add -vvvv trace output. + 2013-08-30 Joerg Wunsch bug #39893: Verification failure with AVRISPmkII and Xmega diff --git a/usbasp.c b/usbasp.c index bf348479..c4d77740 100644 --- a/usbasp.c +++ b/usbasp.c @@ -191,6 +191,31 @@ static void usbasp_teardown(PROGRAMMER * pgm) } /* Internal functions */ + +static const char *usbasp_get_funcname(unsigned char functionid) +{ + switch (functionid) { + case USBASP_FUNC_CONNECT: return "USBASP_FUNC_CONNECT"; break; + case USBASP_FUNC_DISCONNECT: return "USBASP_FUNC_DISCONNECT"; break; + case USBASP_FUNC_TRANSMIT: return "USBASP_FUNC_TRANSMIT"; break; + case USBASP_FUNC_READFLASH: return "USBASP_FUNC_READFLASH"; break; + case USBASP_FUNC_ENABLEPROG: return "USBASP_FUNC_ENABLEPROG"; break; + case USBASP_FUNC_WRITEFLASH: return "USBASP_FUNC_WRITEFLASH"; break; + case USBASP_FUNC_READEEPROM: return "USBASP_FUNC_READEEPROM"; break; + case USBASP_FUNC_WRITEEEPROM: return "USBASP_FUNC_WRITEEEPROM"; break; + case USBASP_FUNC_SETLONGADDRESS: return "USBASP_FUNC_SETLONGADDRESS"; break; + case USBASP_FUNC_SETISPSCK: return "USBASP_FUNC_SETISPSCK"; break; + case USBASP_FUNC_TPI_CONNECT: return "USBASP_FUNC_TPI_CONNECT"; break; + case USBASP_FUNC_TPI_DISCONNECT: return "USBASP_FUNC_TPI_DISCONNECT"; break; + case USBASP_FUNC_TPI_RAWREAD: return "USBASP_FUNC_TPI_RAWREAD"; break; + case USBASP_FUNC_TPI_RAWWRITE: return "USBASP_FUNC_TPI_RAWWRITE"; break; + case USBASP_FUNC_TPI_READBLOCK: return "USBASP_FUNC_TPI_READBLOCK"; break; + case USBASP_FUNC_TPI_WRITEBLOCK: return "USBASP_FUNC_TPI_WRITEBLOCK"; break; + case USBASP_FUNC_GETCAPABILITIES: return "USBASP_FUNC_GETCAPABILITIES"; break; + default: return "Unknown USBASP function"; break; + } +} + /* * wrapper for usb_control_msg call */ @@ -199,6 +224,21 @@ static int usbasp_transmit(PROGRAMMER * pgm, unsigned char send[4], unsigned char * buffer, int buffersize) { int nbytes; + + if (verbose > 3) { + fprintf(stderr, + "%s: usbasp_transmit(\"%s\", 0x%02x, 0x%02x, 0x%02x, 0x%02x)\n", + progname, + usbasp_get_funcname(functionid), send[0], send[1], send[2], send[3]); + if (!receive && buffersize > 0) { + int i; + fprintf(stderr, "%s => ", progbuf); + for (i = 0; i < buffersize; i++) + fprintf(stderr, "[%02x] ", buffer[i]); + fprintf(stderr, "\n"); + } + } + #ifdef USE_LIBUSB_1_0 nbytes = libusb_control_transfer(PDATA(pgm)->usbhandle, (LIBUSB_REQUEST_TYPE_VENDOR | LIBUSB_RECIPIENT_DEVICE | (receive << 7)) & 0xff, @@ -225,6 +265,15 @@ static int usbasp_transmit(PROGRAMMER * pgm, return -1; } #endif + + if (verbose > 3 && receive && nbytes > 0) { + int i; + fprintf(stderr, "%s<= ", progbuf); + for (i = 0; i < nbytes; i++) + fprintf(stderr, "[%02x] ", buffer[i]); + fprintf(stderr, "\n"); + } + return nbytes; }