mirror of
https://github.com/mariusgreuel/avrdude.git
synced 2025-12-16 10:41:07 +00:00
added verbose level in avrdude_message()
git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@1321 81a1dc3b-b13d-400b-aceb-764788c761c2
This commit is contained in:
72
pickit2.c
72
pickit2.c
@@ -75,13 +75,13 @@
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
#define DEBUG(...) do { avrdude_message(__VA_ARGS__); } while(0)
|
||||
#define DEBUG(...) do { avrdude_message(MSG_INFO, __VA_ARGS__); } while(0)
|
||||
#else
|
||||
#define DEBUG(...) ((void)0)
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
#define DEBUGRECV(...) do { avrdude_message(__VA_ARGS__); } while(0)
|
||||
#define DEBUGRECV(...) do { avrdude_message(MSG_INFO, __VA_ARGS__); } while(0)
|
||||
#else
|
||||
#define DEBUGRECV(...) ((void)0)
|
||||
#endif
|
||||
@@ -168,7 +168,7 @@ static void pickit2_setup(PROGRAMMER * pgm)
|
||||
{
|
||||
if ((pgm->cookie = malloc(sizeof(struct pdata))) == 0)
|
||||
{
|
||||
avrdude_message("%s: pickit2_setup(): Out of memory allocating private data\n",
|
||||
avrdude_message(MSG_INFO, "%s: pickit2_setup(): Out of memory allocating private data\n",
|
||||
progname);
|
||||
exit(1);
|
||||
}
|
||||
@@ -191,7 +191,7 @@ static int pickit2_open(PROGRAMMER * pgm, char * port)
|
||||
if (PDATA(pgm)->usb_handle == INVALID_HANDLE_VALUE)
|
||||
{
|
||||
/* no PICkit2 found */
|
||||
avrdude_message("%s: error: could not find PICkit2 with vid=0x%x pid=0x%x\n",
|
||||
avrdude_message(MSG_INFO, "%s: error: could not find PICkit2 with vid=0x%x pid=0x%x\n",
|
||||
progname, PICKIT2_VID, PICKIT2_PID);
|
||||
return -1;
|
||||
}
|
||||
@@ -212,7 +212,7 @@ static int pickit2_open(PROGRAMMER * pgm, char * port)
|
||||
if (usb_open_device(&(PDATA(pgm)->usb_handle), PICKIT2_VID, PICKIT2_PID) < 0)
|
||||
{
|
||||
/* no PICkit2 found */
|
||||
avrdude_message("%s: error: could not find PICkit2 with vid=0x%x pid=0x%x\n",
|
||||
avrdude_message(MSG_INFO, "%s: error: could not find PICkit2 with vid=0x%x pid=0x%x\n",
|
||||
progname, PICKIT2_VID, PICKIT2_PID);
|
||||
return -1;
|
||||
}
|
||||
@@ -261,10 +261,7 @@ static int pickit2_initialize(PROGRAMMER * pgm, AVRPART * p)
|
||||
memset(report, 0, sizeof(report));
|
||||
if ((errorCode = pickit2_read_report(pgm, report)) >= 4)
|
||||
{
|
||||
if (verbose)
|
||||
{
|
||||
avrdude_message("%s: %s firmware version %d.%d.%d\n", progname, pgm->desc, (int)report[1], (int)report[2], (int)report[3]);
|
||||
}
|
||||
avrdude_message(MSG_NOTICE, "%s: %s firmware version %d.%d.%d\n", progname, pgm->desc, (int)report[1], (int)report[2], (int)report[3]);
|
||||
|
||||
// set the pins, apply reset,
|
||||
// TO DO: apply vtarget (if requested though -x option)
|
||||
@@ -299,19 +296,19 @@ static int pickit2_initialize(PROGRAMMER * pgm, AVRPART * p)
|
||||
|
||||
if (pickit2_write_report(pgm, report) < 0)
|
||||
{
|
||||
avrdude_message("pickit2_read_report failed (ec %d). %s\n", errorCode, usb_strerror());
|
||||
avrdude_message(MSG_INFO, "pickit2_read_report failed (ec %d). %s\n", errorCode, usb_strerror());
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
avrdude_message("pickit2_read_report failed (ec %d). %s\n", errorCode, usb_strerror());
|
||||
avrdude_message(MSG_INFO, "pickit2_read_report failed (ec %d). %s\n", errorCode, usb_strerror());
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
avrdude_message("pickit2_write_report failed (ec %d). %s\n", errorCode, usb_strerror());
|
||||
avrdude_message(MSG_INFO, "pickit2_write_report failed (ec %d). %s\n", errorCode, usb_strerror());
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -424,7 +421,7 @@ static int pickit2_program_enable(struct programmer_t * pgm, AVRPART * p)
|
||||
|
||||
if (p->op[AVR_OP_PGM_ENABLE] == NULL)
|
||||
{
|
||||
avrdude_message("program enable instruction not defined for part \"%s\"\n",
|
||||
avrdude_message(MSG_INFO, "program enable instruction not defined for part \"%s\"\n",
|
||||
p->desc);
|
||||
return -1;
|
||||
}
|
||||
@@ -436,13 +433,13 @@ static int pickit2_program_enable(struct programmer_t * pgm, AVRPART * p)
|
||||
if (verbose)
|
||||
{
|
||||
int i;
|
||||
avrdude_message("program_enable(): sending command. Resp = ");
|
||||
avrdude_message(MSG_NOTICE, "program_enable(): sending command. Resp = ");
|
||||
|
||||
for (i = 0; i < 4; i++)
|
||||
{
|
||||
avrdude_message("%x ", (int)res[i]);
|
||||
avrdude_message(MSG_NOTICE, "%x ", (int)res[i]);
|
||||
}
|
||||
avrdude_message("\n");
|
||||
avrdude_message(MSG_NOTICE, "\n");
|
||||
}
|
||||
|
||||
// check for sync character
|
||||
@@ -459,7 +456,7 @@ static int pickit2_chip_erase(struct programmer_t * pgm, AVRPART * p)
|
||||
|
||||
if (p->op[AVR_OP_CHIP_ERASE] == NULL)
|
||||
{
|
||||
avrdude_message("chip erase instruction not defined for part \"%s\"\n",
|
||||
avrdude_message(MSG_INFO, "chip erase instruction not defined for part \"%s\"\n",
|
||||
p->desc);
|
||||
return -1;
|
||||
}
|
||||
@@ -536,7 +533,7 @@ static int pickit2_paged_load(PROGRAMMER * pgm, AVRPART * p, AVRMEM * mem,
|
||||
}
|
||||
else
|
||||
{
|
||||
avrdude_message("no read command specified\n");
|
||||
avrdude_message(MSG_INFO, "no read command specified\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -548,7 +545,7 @@ static int pickit2_paged_load(PROGRAMMER * pgm, AVRPART * p, AVRMEM * mem,
|
||||
|
||||
if (bytes_read < 0)
|
||||
{
|
||||
avrdude_message("Failed @ pgm->spi()\n");
|
||||
avrdude_message(MSG_INFO, "Failed @ pgm->spi()\n");
|
||||
pgm->err_led(pgm, ON);
|
||||
return -1;
|
||||
}
|
||||
@@ -582,7 +579,7 @@ static int pickit2_commit_page(PROGRAMMER * pgm, AVRPART * p, AVRMEM * mem,
|
||||
wp = mem->op[AVR_OP_WRITEPAGE];
|
||||
if (wp == NULL)
|
||||
{
|
||||
avrdude_message("pickit2_commit_page(): memory \"%s\" not configured for page writes\n",
|
||||
avrdude_message(MSG_INFO, "pickit2_commit_page(): memory \"%s\" not configured for page writes\n",
|
||||
mem->desc);
|
||||
return -1;
|
||||
}
|
||||
@@ -630,7 +627,7 @@ static int pickit2_paged_write(PROGRAMMER * pgm, AVRPART * p, AVRMEM * mem,
|
||||
// only paged write for flash implemented
|
||||
if (strcmp(mem->desc, "flash") != 0 && strcmp(mem->desc, "eeprom") != 0)
|
||||
{
|
||||
avrdude_message("Part does not support %d paged write of %s\n", page_size, mem->desc);
|
||||
avrdude_message(MSG_INFO, "Part does not support %d paged write of %s\n", page_size, mem->desc);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -687,7 +684,7 @@ static int pickit2_paged_write(PROGRAMMER * pgm, AVRPART * p, AVRMEM * mem,
|
||||
writeop = mem->op[AVR_OP_WRITE_LO];
|
||||
caddr = addr; // maybe this should divide by 2 & use the write_high opcode also
|
||||
|
||||
avrdude_message("Error AVR_OP_WRITE_LO defined only (where's the HIGH command?)\n");
|
||||
avrdude_message(MSG_INFO, "Error AVR_OP_WRITE_LO defined only (where's the HIGH command?)\n");
|
||||
return -1;
|
||||
}
|
||||
else
|
||||
@@ -712,7 +709,7 @@ static int pickit2_paged_write(PROGRAMMER * pgm, AVRPART * p, AVRMEM * mem,
|
||||
|
||||
if (bytes_read < 0)
|
||||
{
|
||||
avrdude_message("Failed @ pgm->spi()\n");
|
||||
avrdude_message(MSG_INFO, "Failed @ pgm->spi()\n");
|
||||
pgm->err_led(pgm, ON);
|
||||
return -1;
|
||||
}
|
||||
@@ -1154,27 +1151,24 @@ static int usb_open_device(struct usb_dev_handle **device, int vendor, int produ
|
||||
if (handle == NULL)
|
||||
{
|
||||
errorCode = USB_ERROR_ACCESS;
|
||||
avrdude_message("%s: Warning: cannot open USB device: %s\n", progname, usb_strerror());
|
||||
avrdude_message(MSG_INFO, "%s: Warning: cannot open USB device: %s\n", progname, usb_strerror());
|
||||
continue;
|
||||
}
|
||||
|
||||
// return with opened device handle
|
||||
else
|
||||
{
|
||||
if (verbose)
|
||||
{
|
||||
avrdude_message("Device %p seemed to open OK.\n", handle);
|
||||
}
|
||||
avrdude_message(MSG_NOTICE, "Device %p seemed to open OK.\n", handle);
|
||||
|
||||
if ((errorCode = usb_set_configuration(handle, 1)) < 0)
|
||||
{
|
||||
avrdude_message("Could not set configuration. Error code %d, %s.\n"
|
||||
avrdude_message(MSG_INFO, "Could not set configuration. Error code %d, %s.\n"
|
||||
"You may need to run avrdude as root or set up correct usb port permissions.", errorCode, usb_strerror());
|
||||
}
|
||||
|
||||
if ((errorCode = usb_claim_interface(handle, 0)) < 0)
|
||||
{
|
||||
avrdude_message("Could not claim interface. Error code %d, %s\n"
|
||||
avrdude_message(MSG_INFO, "Could not claim interface. Error code %d, %s\n"
|
||||
"You may need to run avrdude as root or set up correct usb port permissions.", errorCode, usb_strerror());
|
||||
}
|
||||
|
||||
@@ -1217,7 +1211,7 @@ static int pickit2_parseextparams(struct programmer_t * pgm, LISTID extparms)
|
||||
int clock_rate;
|
||||
if (sscanf(extended_param, "clockrate=%i", &clock_rate) != 1 || clock_rate <= 0)
|
||||
{
|
||||
avrdude_message("%s: pickit2_parseextparms(): invalid clockrate '%s'\n",
|
||||
avrdude_message(MSG_INFO, "%s: pickit2_parseextparms(): invalid clockrate '%s'\n",
|
||||
progname, extended_param);
|
||||
rv = -1;
|
||||
continue;
|
||||
@@ -1226,11 +1220,8 @@ static int pickit2_parseextparams(struct programmer_t * pgm, LISTID extparms)
|
||||
int clock_period = MIN(1000000 / clock_rate, 255); // max period is 255
|
||||
clock_rate = (int)(1000000 / (clock_period + 5e-7)); // assume highest speed is 2MHz - should probably check this
|
||||
|
||||
if (verbose >= 2)
|
||||
{
|
||||
avrdude_message("%s: pickit2_parseextparms(): clockrate set to 0x%02x\n",
|
||||
avrdude_message(MSG_NOTICE2, "%s: pickit2_parseextparms(): clockrate set to 0x%02x\n",
|
||||
progname, clock_rate);
|
||||
}
|
||||
PDATA(pgm)->clock_period = clock_period;
|
||||
|
||||
continue;
|
||||
@@ -1241,23 +1232,20 @@ static int pickit2_parseextparams(struct programmer_t * pgm, LISTID extparms)
|
||||
int timeout;
|
||||
if (sscanf(extended_param, "timeout=%i", &timeout) != 1 || timeout <= 0)
|
||||
{
|
||||
avrdude_message("%s: pickit2_parseextparms(): invalid timeout '%s'\n",
|
||||
avrdude_message(MSG_INFO, "%s: pickit2_parseextparms(): invalid timeout '%s'\n",
|
||||
progname, extended_param);
|
||||
rv = -1;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (verbose >= 2)
|
||||
{
|
||||
avrdude_message("%s: pickit2_parseextparms(): usb timeout set to 0x%02x\n",
|
||||
avrdude_message(MSG_NOTICE2, "%s: pickit2_parseextparms(): usb timeout set to 0x%02x\n",
|
||||
progname, timeout);
|
||||
}
|
||||
PDATA(pgm)->transaction_timeout = timeout;
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
avrdude_message("%s: pickit2_parseextparms(): invalid extended parameter '%s'\n",
|
||||
avrdude_message(MSG_INFO, "%s: pickit2_parseextparms(): invalid extended parameter '%s'\n",
|
||||
progname, extended_param);
|
||||
rv = -1;
|
||||
}
|
||||
@@ -1323,7 +1311,7 @@ void pickit2_initpgm (PROGRAMMER * pgm)
|
||||
}
|
||||
#else
|
||||
static int pickit2_nousb_open (struct programmer_t *pgm, char * name) {
|
||||
avrdude_message(
|
||||
avrdude_message(MSG_INFO,
|
||||
#ifdef WIN32NATIVE
|
||||
"%s: error: no usb or hid support. Please compile again with libusb or HID support from Win32 DDK installed.\n",
|
||||
#else
|
||||
|
||||
Reference in New Issue
Block a user