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:
awachtler 2014-06-13 20:07:40 +00:00
parent 81a6464d53
commit bb48be1ac0
45 changed files with 1854 additions and 2128 deletions

View File

@ -1,3 +1,51 @@
2014-06-13 Axel Wachtler <axel@uracoli.de>
start removing global "verbose" variable, for avrdude library.
* arduino.c: added verbose level in avrdude_message()
* avr910.c: (Dito.)
* avr.c: (Dito.)
* avrdude.h: (Dito.)
* avrftdi.c: (Dito.)
* avrpart.c: (Dito.)
* bitbang.c: (Dito.)
* buspirate.c: (Dito.)
* butterfly.c: (Dito.)
* config.c: (Dito.)
* config_gram.y: (Dito.)
* dfu.c: (Dito.)
* fileio.c: (Dito.)
* flip1.c: (Dito.)
* flip2.c: (Dito.)
* ft245r.c: (Dito.)
* jtag3.c: (Dito.)
* jtagmkI.c: (Dito.)
* jtagmkII.c: (Dito.)
* lexer.l: (Dito.)
* libavrdude.h: (Dito.)
* linuxgpio.c: (Dito.)
* main.c: (Dito.)
* par.c: (Dito.)
* pgm.c: (Dito.)
* pickit2.c: (Dito.)
* pindefs.c: (Dito.)
* ppi.c: (Dito.)
* ppiwin.c: (Dito.)
* safemode.c: (Dito.)
* ser_avrdoper.c: (Dito.)
* serbb_posix.c: (Dito.)
* serbb_win32.c: (Dito.)
* ser_posix.c: (Dito.)
* ser_win32.c: (Dito.)
* stk500.c: (Dito.)
* stk500generic.c: (Dito.)
* stk500v2.c: (Dito.)
* term.c: (Dito.)
* update.c: (Dito.)
* usbasp.c: (Dito.)
* usb_libusb.c: (Dito.)
* usbtiny.c: (Dito.)
* wiring.c: (Dito.)
2014-06-11 Rene Liebscher <R.Liebscher@gmx.de>
bug #42516 spelling-error-in-binary

View File

@ -45,7 +45,7 @@ static int arduino_read_sig_bytes(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m)
/* Signature byte reads are always 3 bytes. */
if (m->size < 3) {
avrdude_message("%s: memsize too small for sig byte read", progname);
avrdude_message(MSG_INFO, "%s: memsize too small for sig byte read", progname);
return -1;
}
@ -57,17 +57,17 @@ static int arduino_read_sig_bytes(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m)
if (serial_recv(&pgm->fd, buf, 5) < 0)
return -1;
if (buf[0] == Resp_STK_NOSYNC) {
avrdude_message("%s: stk500_cmd(): programmer is out of sync\n",
avrdude_message(MSG_INFO, "%s: stk500_cmd(): programmer is out of sync\n",
progname);
return -1;
} else if (buf[0] != Resp_STK_INSYNC) {
avrdude_message("\n%s: arduino_read_sig_bytes(): (a) protocol error, "
avrdude_message(MSG_INFO, "\n%s: arduino_read_sig_bytes(): (a) protocol error, "
"expect=0x%02x, resp=0x%02x\n",
progname, Resp_STK_INSYNC, buf[0]);
return -2;
}
if (buf[4] != Resp_STK_OK) {
avrdude_message("\n%s: arduino_read_sig_bytes(): (a) protocol error, "
avrdude_message(MSG_INFO, "\n%s: arduino_read_sig_bytes(): (a) protocol error, "
"expect=0x%02x, resp=0x%02x\n",
progname, Resp_STK_OK, buf[4]);
return -3;

86
avr.c
View File

@ -60,7 +60,7 @@ int avr_tpi_chip_erase(PROGRAMMER * pgm, AVRPART * p)
/* Set Pointer Register */
mem = avr_locate_mem(p, "flash");
if (mem == NULL) {
avrdude_message("No flash memory to erase for part %s\n",
avrdude_message(MSG_INFO, "No flash memory to erase for part %s\n",
p->desc);
return -1;
}
@ -92,7 +92,7 @@ int avr_tpi_chip_erase(PROGRAMMER * pgm, AVRPART * p)
return 0;
} else {
avrdude_message("%s called for a part that has no TPI\n", __func__);
avrdude_message(MSG_INFO, "%s called for a part that has no TPI\n", __func__);
return -1;
}
}
@ -117,7 +117,7 @@ int avr_tpi_program_enable(PROGRAMMER * pgm, AVRPART * p, unsigned char guard_ti
cmd[0] = (TPI_CMD_SLDCS | TPI_REG_TPIIR);
err = pgm->cmd_tpi(pgm, cmd, 1, &response, sizeof(response));
if (err || response != TPI_IDENT_CODE) {
avrdude_message("TPIIR not correct\n");
avrdude_message(MSG_INFO, "TPIIR not correct\n");
return -1;
}
@ -137,12 +137,12 @@ int avr_tpi_program_enable(PROGRAMMER * pgm, AVRPART * p, unsigned char guard_ti
return 0;
}
avrdude_message("Error enabling TPI external programming mode:");
avrdude_message("Target does not reply\n");
avrdude_message(MSG_INFO, "Error enabling TPI external programming mode:");
avrdude_message(MSG_INFO, "Target does not reply\n");
return -1;
} else {
avrdude_message("%s called for a part that has no TPI\n", __func__);
avrdude_message(MSG_INFO, "%s called for a part that has no TPI\n", __func__);
return -1;
}
}
@ -187,7 +187,7 @@ int avr_read_byte_default(PROGRAMMER * pgm, AVRPART * p, AVRMEM * mem,
OPCODE * readop, * lext;
if (pgm->cmd == NULL) {
avrdude_message("%s: Error: %s programmer uses avr_read_byte_default() but does not\n"
avrdude_message(MSG_INFO, "%s: Error: %s programmer uses avr_read_byte_default() but does not\n"
"provide a cmd() method.\n",
progname, pgm->type);
return -1;
@ -198,7 +198,7 @@ int avr_read_byte_default(PROGRAMMER * pgm, AVRPART * p, AVRMEM * mem,
if (p->flags & AVRPART_HAS_TPI) {
if (pgm->cmd_tpi == NULL) {
avrdude_message("%s: Error: %s programmer does not support TPI\n",
avrdude_message(MSG_INFO, "%s: Error: %s programmer does not support TPI\n",
progname, pgm->type);
return -1;
}
@ -233,7 +233,7 @@ int avr_read_byte_default(PROGRAMMER * pgm, AVRPART * p, AVRMEM * mem,
if (readop == NULL) {
#if DEBUG
avrdude_message("avr_read_byte(): operation not supported on memory type \"%s\"\n",
avrdude_message(MSG_INFO, "avr_read_byte(): operation not supported on memory type \"%s\"\n",
mem->desc);
#endif
return -1;
@ -318,7 +318,7 @@ int avr_read(PROGRAMMER * pgm, AVRPART * p, char * memtype,
if (v != NULL)
vmem = avr_locate_mem(v, memtype);
if (mem == NULL) {
avrdude_message("No \"%s\" memory for part %s\n",
avrdude_message(MSG_INFO, "No \"%s\" memory for part %s\n",
memtype, p->desc);
return -1;
}
@ -351,7 +351,7 @@ int avr_read(PROGRAMMER * pgm, AVRPART * p, char * memtype,
rc = pgm->cmd_tpi(pgm, cmd, 1, mem->buf + i, 1);
lastaddr++;
if (rc == -1) {
avrdude_message("avr_read(): error reading address 0x%04lx\n", i);
avrdude_message(MSG_INFO, "avr_read(): error reading address 0x%04lx\n", i);
return -1;
}
}
@ -407,8 +407,8 @@ int avr_read(PROGRAMMER * pgm, AVRPART * p, char * memtype,
if (rc < 0)
/* paged load failed, fall back to byte-at-a-time read below */
failure = 1;
} else if (verbose >= 3) {
avrdude_message("%s: avr_read(): skipping page %u: no interesting data\n",
} else {
avrdude_message(MSG_DEBUG, "%s: avr_read(): skipping page %u: no interesting data\n",
progname, pageaddr / mem->page_size);
}
nread++;
@ -438,9 +438,9 @@ int avr_read(PROGRAMMER * pgm, AVRPART * p, char * memtype,
{
rc = pgm->read_byte(pgm, p, mem, i, mem->buf + i);
if (rc != 0) {
avrdude_message("avr_read(): error reading address 0x%04lx\n", i);
avrdude_message(MSG_INFO, "avr_read(): error reading address 0x%04lx\n", i);
if (rc == -1)
avrdude_message(" read operation not supported for memory \"%s\"\n",
avrdude_message(MSG_INFO, " read operation not supported for memory \"%s\"\n",
memtype);
return -2;
}
@ -469,7 +469,7 @@ int avr_write_page(PROGRAMMER * pgm, AVRPART * p, AVRMEM * mem,
OPCODE * wp, * lext;
if (pgm->cmd == NULL) {
avrdude_message("%s: Error: %s programmer uses avr_write_page() but does not\n"
avrdude_message(MSG_INFO, "%s: Error: %s programmer uses avr_write_page() but does not\n"
"provide a cmd() method.\n",
progname, pgm->type);
return -1;
@ -477,7 +477,7 @@ int avr_write_page(PROGRAMMER * pgm, AVRPART * p, AVRMEM * mem,
wp = mem->op[AVR_OP_WRITEPAGE];
if (wp == NULL) {
avrdude_message("avr_write_page(): memory \"%s\" not configured for page writes\n",
avrdude_message(MSG_INFO, "avr_write_page(): memory \"%s\" not configured for page writes\n",
mem->desc);
return -1;
}
@ -539,7 +539,7 @@ int avr_write_byte_default(PROGRAMMER * pgm, AVRPART * p, AVRMEM * mem,
struct timeval tv;
if (pgm->cmd == NULL) {
avrdude_message("%s: Error: %s programmer uses avr_write_byte_default() but does not\n"
avrdude_message(MSG_INFO, "%s: Error: %s programmer uses avr_write_byte_default() but does not\n"
"provide a cmd() method.\n",
progname, pgm->type);
return -1;
@ -547,16 +547,16 @@ int avr_write_byte_default(PROGRAMMER * pgm, AVRPART * p, AVRMEM * mem,
if (p->flags & AVRPART_HAS_TPI) {
if (pgm->cmd_tpi == NULL) {
avrdude_message("%s: Error: %s programmer does not support TPI\n",
avrdude_message(MSG_INFO, "%s: Error: %s programmer does not support TPI\n",
progname, pgm->type);
return -1;
}
if (strcmp(mem->desc, "flash") == 0) {
avrdude_message("Writing a byte to flash is not supported for %s\n", p->desc);
avrdude_message(MSG_INFO, "Writing a byte to flash is not supported for %s\n", p->desc);
return -1;
} else if ((mem->offset + addr) & 1) {
avrdude_message("Writing a byte to an odd location is not supported for %s\n", p->desc);
avrdude_message(MSG_INFO, "Writing a byte to an odd location is not supported for %s\n", p->desc);
return -1;
}
@ -644,7 +644,7 @@ int avr_write_byte_default(PROGRAMMER * pgm, AVRPART * p, AVRMEM * mem,
if (writeop == NULL) {
#if DEBUG
avrdude_message("avr_write_byte(): write not supported for memory type \"%s\"\n",
avrdude_message(MSG_INFO, "avr_write_byte(): write not supported for memory type \"%s\"\n",
mem->desc);
#endif
return -1;
@ -737,24 +737,24 @@ int avr_write_byte_default(PROGRAMMER * pgm, AVRPART * p, AVRMEM * mem,
* device if the data read back does not match what we wrote.
*/
pgm->pgm_led(pgm, OFF);
avrdude_message("%s: this device must be powered off and back on to continue\n",
avrdude_message(MSG_INFO, "%s: this device must be powered off and back on to continue\n",
progname);
if (pgm->pinno[PPI_AVR_VCC]) {
avrdude_message("%s: attempting to do this now ...\n", progname);
avrdude_message(MSG_INFO, "%s: attempting to do this now ...\n", progname);
pgm->powerdown(pgm);
usleep(250000);
rc = pgm->initialize(pgm, p);
if (rc < 0) {
avrdude_message("%s: initialization failed, rc=%d\n", progname, rc);
avrdude_message("%s: can't re-initialize device after programming the "
avrdude_message(MSG_INFO, "%s: initialization failed, rc=%d\n", progname, rc);
avrdude_message(MSG_INFO, "%s: can't re-initialize device after programming the "
"%s bits\n", progname, mem->desc);
avrdude_message("%s: you must manually power-down the device and restart\n"
avrdude_message(MSG_INFO, "%s: you must manually power-down the device and restart\n"
"%s: %s to continue.\n",
progname, progname, progname);
return -3;
}
avrdude_message("%s: device was successfully re-initialized\n",
avrdude_message(MSG_INFO, "%s: device was successfully re-initialized\n",
progname);
return 0;
}
@ -836,7 +836,7 @@ int avr_write(PROGRAMMER * pgm, AVRPART * p, char * memtype, int size,
m = avr_locate_mem(p, memtype);
if (m == NULL) {
avrdude_message("No \"%s\" memory for part %s\n",
avrdude_message(MSG_INFO, "No \"%s\" memory for part %s\n",
memtype, p->desc);
return -1;
}
@ -850,7 +850,7 @@ int avr_write(PROGRAMMER * pgm, AVRPART * p, char * memtype, int size,
wsize = size;
}
else if (size > wsize) {
avrdude_message("%s: WARNING: %d bytes requested, but memory region is only %d"
avrdude_message(MSG_INFO, "%s: WARNING: %d bytes requested, but memory region is only %d"
"bytes\n"
"%sOnly %d bytes will actually be written\n",
progname, size, wsize,
@ -940,8 +940,8 @@ int avr_write(PROGRAMMER * pgm, AVRPART * p, char * memtype, int size,
if (rc < 0)
/* paged write failed, fall back to byte-at-a-time write below */
failure = 1;
} else if (verbose >= 3) {
avrdude_message("%s: avr_write(): skipping page %u: no interesting data\n",
} else {
avrdude_message(MSG_DEBUG, "%s: avr_write(): skipping page %u: no interesting data\n",
progname, pageaddr / m->page_size);
}
nwritten++;
@ -1001,8 +1001,8 @@ int avr_write(PROGRAMMER * pgm, AVRPART * p, char * memtype, int size,
if (do_write) {
rc = avr_write_byte(pgm, p, m, i, data);
if (rc) {
avrdude_message(" ***failed; ");
avrdude_message("\n");
avrdude_message(MSG_INFO, " ***failed; ");
avrdude_message(MSG_INFO, "\n");
pgm->err_led(pgm, ON);
werror = 1;
}
@ -1015,11 +1015,11 @@ int avr_write(PROGRAMMER * pgm, AVRPART * p, char * memtype, int size,
if (flush_page) {
rc = avr_write_page(pgm, p, m, i);
if (rc) {
avrdude_message(" *** page %d (addresses 0x%04x - 0x%04x) failed "
avrdude_message(MSG_INFO, " *** page %d (addresses 0x%04x - 0x%04x) failed "
"to write\n",
i % m->page_size,
i - m->page_size + 1, i);
avrdude_message("\n");
avrdude_message(MSG_INFO, "\n");
pgm->err_led(pgm, ON);
werror = 1;
}
@ -1049,7 +1049,7 @@ int avr_signature(PROGRAMMER * pgm, AVRPART * p)
report_progress (0,1,"Reading");
rc = avr_read(pgm, p, "signature", 0);
if (rc < 0) {
avrdude_message("%s: error reading signature data for part \"%s\", rc=%d\n",
avrdude_message(MSG_INFO, "%s: error reading signature data for part \"%s\", rc=%d\n",
progname, p->desc, rc);
return -1;
}
@ -1075,14 +1075,14 @@ int avr_verify(AVRPART * p, AVRPART * v, char * memtype, int size)
a = avr_locate_mem(p, memtype);
if (a == NULL) {
avrdude_message("avr_verify(): memory type \"%s\" not defined for part %s\n",
avrdude_message(MSG_INFO, "avr_verify(): memory type \"%s\" not defined for part %s\n",
memtype, p->desc);
return -1;
}
b = avr_locate_mem(v, memtype);
if (b == NULL) {
avrdude_message("avr_verify(): memory type \"%s\" not defined for part %s\n",
avrdude_message(MSG_INFO, "avr_verify(): memory type \"%s\" not defined for part %s\n",
memtype, v->desc);
return -1;
}
@ -1092,7 +1092,7 @@ int avr_verify(AVRPART * p, AVRPART * v, char * memtype, int size)
vsize = a->size;
if (vsize < size) {
avrdude_message("%s: WARNING: requested verification for %d bytes\n"
avrdude_message(MSG_INFO, "%s: WARNING: requested verification for %d bytes\n"
"%s%s memory region only contains %d bytes\n"
"%sOnly %d bytes will be verified.\n",
progname, size,
@ -1104,7 +1104,7 @@ int avr_verify(AVRPART * p, AVRPART * v, char * memtype, int size)
for (i=0; i<size; i++) {
if ((b->tags[i] & TAG_ALLOCATED) != 0 &&
buf1[i] != buf2[i]) {
avrdude_message("%s: verification error, first mismatch at byte 0x%04x\n"
avrdude_message(MSG_INFO, "%s: verification error, first mismatch at byte 0x%04x\n"
"%s0x%02x != 0x%02x\n",
progname, i,
progbuf, buf1[i], buf2[i]);
@ -1132,7 +1132,7 @@ int avr_get_cycle_count(PROGRAMMER * pgm, AVRPART * p, int * cycles)
for (i=4; i>0; i--) {
rc = pgm->read_byte(pgm, p, a, a->size-i, &v1);
if (rc < 0) {
avrdude_message("%s: WARNING: can't read memory for cycle count, rc=%d\n",
avrdude_message(MSG_INFO, "%s: WARNING: can't read memory for cycle count, rc=%d\n",
progname, rc);
return -1;
}
@ -1173,7 +1173,7 @@ int avr_put_cycle_count(PROGRAMMER * pgm, AVRPART * p, int cycles)
rc = avr_write_byte(pgm, p, a, a->size-i, v1);
if (rc < 0) {
avrdude_message("%s: WARNING: can't write memory for cycle count, rc=%d\n",
avrdude_message(MSG_INFO, "%s: WARNING: can't write memory for cycle count, rc=%d\n",
progname, rc);
return -1;
}

View File

@ -57,7 +57,7 @@ struct pdata
static void avr910_setup(PROGRAMMER * pgm)
{
if ((pgm->cookie = malloc(sizeof(struct pdata))) == 0) {
avrdude_message("%s: avr910_setup(): Out of memory allocating private data\n",
avrdude_message(MSG_INFO, "%s: avr910_setup(): Out of memory allocating private data\n",
progname);
exit(1);
}
@ -83,7 +83,7 @@ static int avr910_recv(PROGRAMMER * pgm, char * buf, size_t len)
rv = serial_recv(&pgm->fd, (unsigned char *)buf, len);
if (rv < 0) {
avrdude_message("%s: avr910_recv(): programmer is not responding\n",
avrdude_message(MSG_INFO, "%s: avr910_recv(): programmer is not responding\n",
progname);
return 1;
}
@ -103,7 +103,7 @@ static int avr910_vfy_cmd_sent(PROGRAMMER * pgm, char * errmsg)
avr910_recv(pgm, &c, 1);
if (c != '\r') {
avrdude_message("%s: error: programmer did not respond to command: %s\n",
avrdude_message(MSG_INFO, "%s: error: programmer did not respond to command: %s\n",
progname, errmsg);
return 1;
}
@ -185,16 +185,16 @@ static int avr910_initialize(PROGRAMMER * pgm, AVRPART * p)
avr910_send(pgm, "p", 1);
avr910_recv(pgm, &type, 1);
avrdude_message("Found programmer: Id = \"%s\"; type = %c\n", id, type);
avrdude_message(" Software Version = %c.%c; ", sw[0], sw[1]);
avrdude_message("Hardware Version = %c.%c\n", hw[0], hw[1]);
avrdude_message(MSG_INFO, "Found programmer: Id = \"%s\"; type = %c\n", id, type);
avrdude_message(MSG_INFO, " Software Version = %c.%c; ", sw[0], sw[1]);
avrdude_message(MSG_INFO, "Hardware Version = %c.%c\n", hw[0], hw[1]);
/* See if programmer supports autoincrement of address. */
avr910_send(pgm, "a", 1);
avr910_recv(pgm, &PDATA(pgm)->has_auto_incr_addr, 1);
if (PDATA(pgm)->has_auto_incr_addr == 'Y')
avrdude_message("Programmer supports auto addr increment.\n");
avrdude_message(MSG_INFO, "Programmer supports auto addr increment.\n");
/* Check support for buffered memory access, ignore if not available */
@ -206,7 +206,7 @@ static int avr910_initialize(PROGRAMMER * pgm, AVRPART * p)
PDATA(pgm)->buffersize = (unsigned int)(unsigned char)c<<8;
avr910_recv(pgm, &c, 1);
PDATA(pgm)->buffersize += (unsigned int)(unsigned char)c;
avrdude_message("Programmer supports buffered memory access with "
avrdude_message(MSG_INFO, "Programmer supports buffered memory access with "
"buffersize = %u bytes.\n",
PDATA(pgm)->buffersize);
PDATA(pgm)->use_blockmode = 1;
@ -224,7 +224,7 @@ static int avr910_initialize(PROGRAMMER * pgm, AVRPART * p)
/* Get list of devices that the programmer supports. */
avr910_send(pgm, "t", 1);
avrdude_message("\nProgrammer supports the following devices:\n");
avrdude_message(MSG_INFO, "\nProgrammer supports the following devices:\n");
devtype_1st = 0;
while (1) {
avr910_recv(pgm, &c, 1);
@ -234,17 +234,17 @@ static int avr910_initialize(PROGRAMMER * pgm, AVRPART * p)
break;
part = locate_part_by_avr910_devcode(part_list, c);
avrdude_message(" Device code: 0x%02x = %s\n", c, part ? part->desc : "(unknown)");
avrdude_message(MSG_INFO, " Device code: 0x%02x = %s\n", c, part ? part->desc : "(unknown)");
/* FIXME: Need to lookup devcode and report the device. */
if (p->avr910_devcode == c)
dev_supported = 1;
};
avrdude_message("\n");
avrdude_message(MSG_INFO, "\n");
if (!dev_supported) {
avrdude_message("%s: %s: selected device is not supported by programmer: %s\n",
avrdude_message(MSG_INFO, "%s: %s: selected device is not supported by programmer: %s\n",
progname, ovsigck? "warning": "error", p->id);
if (!ovsigck)
return -1;
@ -264,9 +264,8 @@ static int avr910_initialize(PROGRAMMER * pgm, AVRPART * p)
avr910_send(pgm, buf, 2);
avr910_vfy_cmd_sent(pgm, "select device");
if (verbose)
avrdude_message("%s: avr910_devcode selected: 0x%02x\n",
progname, (unsigned)buf[1]);
avrdude_message(MSG_NOTICE, "%s: avr910_devcode selected: 0x%02x\n",
progname, (unsigned)buf[1]);
avr910_enter_prog_mode(pgm);
@ -332,30 +331,26 @@ static int avr910_parseextparms(PROGRAMMER * pgm, LISTID extparms)
int devcode;
if (sscanf(extended_param, "devcode=%i", &devcode) != 1 ||
devcode <= 0 || devcode > 255) {
avrdude_message("%s: avr910_parseextparms(): invalid devcode '%s'\n",
avrdude_message(MSG_INFO, "%s: avr910_parseextparms(): invalid devcode '%s'\n",
progname, extended_param);
rv = -1;
continue;
}
if (verbose >= 2) {
avrdude_message("%s: avr910_parseextparms(): devcode overwritten as 0x%02x\n",
progname, devcode);
}
avrdude_message(MSG_NOTICE2, "%s: avr910_parseextparms(): devcode overwritten as 0x%02x\n",
progname, devcode);
PDATA(pgm)->devcode = devcode;
continue;
}
if (strncmp(extended_param, "no_blockmode", strlen("no_blockmode")) == 0) {
if (verbose >= 2) {
avrdude_message("%s: avr910_parseextparms(-x): no testing for Blockmode\n",
progname);
}
avrdude_message(MSG_NOTICE2, "%s: avr910_parseextparms(-x): no testing for Blockmode\n",
progname);
PDATA(pgm)->test_blockmode = 0;
continue;
}
avrdude_message("%s: avr910_parseextparms(): invalid extended parameter '%s'\n",
avrdude_message(MSG_INFO, "%s: avr910_parseextparms(): invalid extended parameter '%s'\n",
progname, extended_param);
rv = -1;
}
@ -728,7 +723,7 @@ static int avr910_read_sig_bytes(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m)
unsigned char tmp;
if (m->size < 3) {
avrdude_message("%s: memsize too small for sig byte read", progname);
avrdude_message(MSG_INFO, "%s: memsize too small for sig byte read", progname);
return -1;
}

View File

@ -28,7 +28,14 @@ extern int ovsigck; /* override signature check (-F) */
extern int verbose; /* verbosity level (-v, -vv, ...) */
extern int quell_progress; /* quiteness level (-q, -qq) */
int avrdude_message(const char *format, ...);
int avrdude_message(const int msglvl, const char *format, ...);
#define MSG_INFO (0) /* no -v option, can be supressed with -qq */
#define MSG_NOTICE (1) /* displayed with -v */
#define MSG_NOTICE2 (2) /* displayed with -vv, used rarely */
#define MSG_DEBUG (3) /* displayed with -vvv */
#define MSG_TRACE (4) /* displayed with -vvvv, show trace commuication */
#define MSG_TRACE2 (5) /* displayed with -vvvvv */
#if defined(WIN32NATIVE)

View File

@ -52,7 +52,7 @@
static int avrftdi_noftdi_open (struct programmer_t *pgm, char * name)
{
avrdude_message("%s: Error: no libftdi or libusb support. Install libftdi1/libusb-1.0 or libftdi/libusb and run configure/make again.\n",
avrdude_message(MSG_INFO, "%s: Error: no libftdi or libusb support. Install libftdi1/libusb-1.0 or libftdi/libusb and run configure/make again.\n",
progname);
return -1;
@ -142,17 +142,17 @@ void avrftdi_log(int level, const char * func, int line,
if(!skip_prefix)
{
switch(level) {
case ERR: avrdude_message("E "); break;
case WARN: avrdude_message("W "); break;
case INFO: avrdude_message("I "); break;
case DEBUG: avrdude_message("D "); break;
case TRACE: avrdude_message("T "); break;
default: avrdude_message(" ");
case ERR: avrdude_message(MSG_INFO, "E "); break;
case WARN: avrdude_message(MSG_INFO, "W "); break;
case INFO: avrdude_message(MSG_INFO, "I "); break;
case DEBUG: avrdude_message(MSG_INFO, "D "); break;
case TRACE: avrdude_message(MSG_INFO, "T "); break;
default: avrdude_message(MSG_INFO, " ");
}
avrdude_message("%s(%d): ", func, line);
avrdude_message(MSG_INFO, "%s(%d): ", func, line);
}
va_start(ap, fmt);
avrdude_message(fmt, ap);
avrdude_message(MSG_INFO, fmt, ap);
va_end(ap);
}
@ -172,16 +172,16 @@ static void buf_dump(const unsigned char *buf, int len, char *desc,
int offset, int width)
{
int i;
avrdude_message("%s begin:\n", desc);
avrdude_message(MSG_INFO, "%s begin:\n", desc);
for (i = 0; i < offset; i++)
avrdude_message("%02x ", buf[i]);
avrdude_message("\n");
avrdude_message(MSG_INFO, "%02x ", buf[i]);
avrdude_message(MSG_INFO, "\n");
for (i++; i <= len; i++) {
avrdude_message("%02x ", buf[i-1]);
avrdude_message(MSG_INFO, "%02x ", buf[i-1]);
if((i-offset) != 0 && (i-offset)%width == 0)
avrdude_message("\n");
avrdude_message(MSG_INFO, "\n");
}
avrdude_message("%s end\n", desc);
avrdude_message(MSG_INFO, "%s end\n", desc);
}
/*
@ -354,7 +354,7 @@ static int avrftdi_transmit_bb(PROGRAMMER * pgm, unsigned char mode, const unsig
size_t max_size = MIN(pdata->ftdic->max_packet_size,pdata->tx_buffer_size);
// select block size so that resulting commands does not exceed max_size if possible
blocksize = MAX(1,(max_size-7)/((8*2*6)+(8*1*2)));
//avrdude_message("blocksize %d \n",blocksize);
//avrdude_message(MSG_INFO, "blocksize %d \n",blocksize);
while(remaining)
{
@ -670,7 +670,7 @@ static int avrftdi_open(PROGRAMMER * pgm, char *port)
if (usbpid) {
pid = *(int *)(ldata(usbpid));
if (lnext(usbpid))
avrdude_message("%s: Warning: using PID 0x%04x, ignoring remaining PIDs in list\n",
avrdude_message(MSG_INFO, "%s: Warning: using PID 0x%04x, ignoring remaining PIDs in list\n",
progname, pid);
} else
pid = USB_DEVICE_FT2232;

View File

@ -36,7 +36,7 @@ OPCODE * avr_new_opcode(void)
m = (OPCODE *)malloc(sizeof(*m));
if (m == NULL) {
avrdude_message("avr_new_opcode(): out of memory\n");
avrdude_message(MSG_INFO, "avr_new_opcode(): out of memory\n");
exit(1);
}
@ -56,7 +56,7 @@ static OPCODE * avr_dup_opcode(OPCODE * op)
m = (OPCODE *)malloc(sizeof(*m));
if (m == NULL) {
avrdude_message("avr_dup_opcode(): out of memory\n");
avrdude_message(MSG_INFO, "avr_dup_opcode(): out of memory\n");
exit(1);
}
@ -249,7 +249,7 @@ AVRMEM * avr_new_memtype(void)
m = (AVRMEM *)malloc(sizeof(*m));
if (m == NULL) {
avrdude_message("avr_new_memtype(): out of memory\n");
avrdude_message(MSG_INFO, "avr_new_memtype(): out of memory\n");
exit(1);
}
@ -272,13 +272,13 @@ int avr_initmem(AVRPART * p)
m = ldata(ln);
m->buf = (unsigned char *) malloc(m->size);
if (m->buf == NULL) {
avrdude_message("%s: can't alloc buffer for %s size of %d bytes\n",
avrdude_message(MSG_INFO, "%s: can't alloc buffer for %s size of %d bytes\n",
progname, m->desc, m->size);
return -1;
}
m->tags = (unsigned char *) malloc(m->size);
if (m->tags == NULL) {
avrdude_message("%s: can't alloc buffer for %s size of %d bytes\n",
avrdude_message(MSG_INFO, "%s: can't alloc buffer for %s size of %d bytes\n",
progname, m->desc, m->size);
return -1;
}
@ -300,7 +300,7 @@ AVRMEM * avr_dup_mem(AVRMEM * m)
if (m->buf != NULL) {
n->buf = (unsigned char *)malloc(n->size);
if (n->buf == NULL) {
avrdude_message("avr_dup_mem(): out of memory (memsize=%d)\n",
avrdude_message(MSG_INFO, "avr_dup_mem(): out of memory (memsize=%d)\n",
n->size);
exit(1);
}
@ -310,7 +310,7 @@ AVRMEM * avr_dup_mem(AVRMEM * m)
if (m->tags != NULL) {
n->tags = (unsigned char *)malloc(n->size);
if (n->tags == NULL) {
avrdude_message("avr_dup_mem(): out of memory (memsize=%d)\n",
avrdude_message(MSG_INFO, "avr_dup_mem(): out of memory (memsize=%d)\n",
n->size);
exit(1);
}
@ -404,7 +404,7 @@ void avr_mem_display(const char * prefix, FILE * f, AVRMEM * m, int type,
m->readback[0],
m->readback[1]);
if (verbose > 4) {
avrdude_message("%s Memory Ops:\n"
avrdude_message(MSG_TRACE2, "%s Memory Ops:\n"
"%s Oeration Inst Bit Bit Type Bitno Value\n"
"%s ----------- -------- -------- ----- -----\n",
prefix, prefix, prefix);
@ -441,7 +441,7 @@ AVRPART * avr_new_part(void)
p = (AVRPART *)malloc(sizeof(AVRPART));
if (p == NULL) {
avrdude_message("new_part(): out of memory\n");
avrdude_message(MSG_INFO, "new_part(): out of memory\n");
exit(1);
}

View File

@ -73,9 +73,8 @@ static void bitbang_calibrate_delay(void)
if (QueryPerformanceFrequency(&freq))
{
has_perfcount = 1;
if (verbose >= 2)
avrdude_message("%s: Using performance counter for bitbang delays\n",
progname);
avrdude_message(MSG_NOTICE2, "%s: Using performance counter for bitbang delays\n",
progname);
}
else
{
@ -88,18 +87,16 @@ static void bitbang_calibrate_delay(void)
* auto-calibration figures seen on various Unix systems on
* comparable hardware.
*/
if (verbose >= 2)
avrdude_message("%s: Using guessed per-microsecond delay count for bitbang delays\n",
progname);
avrdude_message(MSG_NOTICE2, "%s: Using guessed per-microsecond delay count for bitbang delays\n",
progname);
delay_decrement = 100;
}
#else /* !WIN32NATIVE */
struct itimerval itv;
volatile int i;
if (verbose >= 2)
avrdude_message("%s: Calibrating delay loop...",
progname);
avrdude_message(MSG_NOTICE2, "%s: Calibrating delay loop...",
progname);
i = 0;
done = 0;
saved_alarmhandler = signal(SIGALRM, alarmhandler);
@ -125,9 +122,8 @@ static void bitbang_calibrate_delay(void)
* Calculate back from 100 ms to 1 us.
*/
delay_decrement = -i / 100000;
if (verbose >= 2)
avrdude_message(" calibrated to %d cycles per us\n",
delay_decrement);
avrdude_message(MSG_NOTICE2, " calibrated to %d cycles per us\n",
delay_decrement);
#endif /* WIN32NATIVE */
}
@ -266,7 +262,7 @@ int bitbang_tpi_rx(PROGRAMMER * pgm)
break;
}
if (b != 0) {
avrdude_message("bitbang_tpi_rx: start bit not received correctly\n");
avrdude_message(MSG_INFO, "bitbang_tpi_rx: start bit not received correctly\n");
return -1;
}
@ -281,7 +277,7 @@ int bitbang_tpi_rx(PROGRAMMER * pgm)
/* parity bit */
if (bitbang_tpi_clk(pgm) != parity) {
avrdude_message("bitbang_tpi_rx: parity bit is wrong\n");
avrdude_message(MSG_INFO, "bitbang_tpi_rx: parity bit is wrong\n");
return -1;
}
@ -290,7 +286,7 @@ int bitbang_tpi_rx(PROGRAMMER * pgm)
b &= bitbang_tpi_clk(pgm);
b &= bitbang_tpi_clk(pgm);
if (b != 1) {
avrdude_message("bitbang_tpi_rx: stop bits not received correctly\n");
avrdude_message(MSG_INFO, "bitbang_tpi_rx: stop bits not received correctly\n");
return -1;
}
@ -337,15 +333,15 @@ int bitbang_cmd(PROGRAMMER * pgm, const unsigned char *cmd,
if(verbose >= 2)
{
avrdude_message("bitbang_cmd(): [ ");
avrdude_message(MSG_NOTICE2, "bitbang_cmd(): [ ");
for(i = 0; i < 4; i++)
avrdude_message("%02X ", cmd[i]);
avrdude_message("] [ ");
avrdude_message(MSG_NOTICE2, "%02X ", cmd[i]);
avrdude_message(MSG_NOTICE2, "] [ ");
for(i = 0; i < 4; i++)
{
avrdude_message("%02X ", res[i]);
avrdude_message(MSG_NOTICE2, "%02X ", res[i]);
}
avrdude_message("]\n");
avrdude_message(MSG_NOTICE2, "]\n");
}
return 0;
@ -372,15 +368,15 @@ int bitbang_cmd_tpi(PROGRAMMER * pgm, const unsigned char *cmd,
if(verbose >= 2)
{
avrdude_message("bitbang_cmd_tpi(): [ ");
avrdude_message(MSG_NOTICE2, "bitbang_cmd_tpi(): [ ");
for(i = 0; i < cmd_len; i++)
avrdude_message("%02X ", cmd[i]);
avrdude_message("] [ ");
avrdude_message(MSG_NOTICE2, "%02X ", cmd[i]);
avrdude_message(MSG_NOTICE2, "] [ ");
for(i = 0; i < res_len; i++)
{
avrdude_message("%02X ", res[i]);
avrdude_message(MSG_NOTICE2, "%02X ", res[i]);
}
avrdude_message("]\n");
avrdude_message(MSG_NOTICE2, "]\n");
}
pgm->pgm_led(pgm, OFF);
@ -408,15 +404,15 @@ int bitbang_spi(PROGRAMMER * pgm, const unsigned char *cmd,
if(verbose >= 2)
{
avrdude_message("bitbang_cmd(): [ ");
avrdude_message(MSG_NOTICE2, "bitbang_cmd(): [ ");
for(i = 0; i < count; i++)
avrdude_message("%02X ", cmd[i]);
avrdude_message("] [ ");
avrdude_message(MSG_NOTICE2, "%02X ", cmd[i]);
avrdude_message(MSG_NOTICE2, "] [ ");
for(i = 0; i < count; i++)
{
avrdude_message("%02X ", res[i]);
avrdude_message(MSG_NOTICE2, "%02X ", res[i]);
}
avrdude_message("]\n");
avrdude_message(MSG_NOTICE2, "]\n");
}
return 0;
@ -444,7 +440,7 @@ int bitbang_chip_erase(PROGRAMMER * pgm, AVRPART * p)
/* Set Pointer Register */
mem = avr_locate_mem(p, "flash");
if (mem == NULL) {
avrdude_message("No flash memory to erase for part %s\n",
avrdude_message(MSG_INFO, "No flash memory to erase for part %s\n",
p->desc);
return -1;
}
@ -465,7 +461,7 @@ int bitbang_chip_erase(PROGRAMMER * 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;
}
@ -506,7 +502,7 @@ int bitbang_program_enable(PROGRAMMER * 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;
}
@ -539,7 +535,7 @@ int bitbang_initialize(PROGRAMMER * pgm, AVRPART * p)
if (p->flags & AVRPART_HAS_TPI) {
/* make sure cmd_tpi() is defined */
if (pgm->cmd_tpi == NULL) {
avrdude_message("%s: Error: %s programmer does not support TPI\n",
avrdude_message(MSG_INFO, "%s: Error: %s programmer does not support TPI\n",
progname, pgm->type);
return -1;
}
@ -548,22 +544,20 @@ int bitbang_initialize(PROGRAMMER * pgm, AVRPART * p)
pgm->setpin(pgm, PIN_AVR_RESET, 1);
usleep(1000);
if (verbose >= 2)
avrdude_message("doing MOSI-MISO link check\n");
avrdude_message(MSG_NOTICE2, "doing MOSI-MISO link check\n");
pgm->setpin(pgm, PIN_AVR_MOSI, 0);
if (pgm->getpin(pgm, PIN_AVR_MISO) != 0) {
avrdude_message("MOSI->MISO 0 failed\n");
avrdude_message(MSG_INFO, "MOSI->MISO 0 failed\n");
return -1;
}
pgm->setpin(pgm, PIN_AVR_MOSI, 1);
if (pgm->getpin(pgm, PIN_AVR_MISO) != 1) {
avrdude_message("MOSI->MISO 1 failed\n");
avrdude_message(MSG_INFO, "MOSI->MISO 1 failed\n");
return -1;
}
if (verbose >= 2)
avrdude_message("MOSI-MISO link present\n");
avrdude_message(MSG_NOTICE2, "MOSI-MISO link present\n");
}
pgm->setpin(pgm, PIN_AVR_SCK, 0);
@ -584,7 +578,7 @@ int bitbang_initialize(PROGRAMMER * pgm, AVRPART * p)
bitbang_tpi_tx(pgm, TPI_CMD_SLDCS | TPI_REG_TPIIR);
rc = bitbang_tpi_rx(pgm);
if (rc != 0x80) {
avrdude_message("TPIIR not correct\n");
avrdude_message(MSG_INFO, "TPIIR not correct\n");
return -1;
}
} else {
@ -618,7 +612,7 @@ int bitbang_initialize(PROGRAMMER * pgm, AVRPART * p)
* can't sync with the device, maybe it's not attached?
*/
if (rc) {
avrdude_message("%s: AVR device not responding\n", progname);
avrdude_message(MSG_INFO, "%s: AVR device not responding\n", progname);
return -1;
}
}
@ -629,7 +623,7 @@ int bitbang_initialize(PROGRAMMER * pgm, AVRPART * p)
static int verify_pin_assigned(PROGRAMMER * pgm, int pin, char * desc)
{
if (pgm->pinno[pin] == 0) {
avrdude_message("%s: error: no pin has been assigned for %s\n",
avrdude_message(MSG_INFO, "%s: error: no pin has been assigned for %s\n",
progname, desc);
return -1;
}
@ -653,7 +647,7 @@ int bitbang_check_prerequisites(PROGRAMMER *pgm)
return -1;
if (pgm->cmd == NULL) {
avrdude_message("%s: error: no cmd() method defined for bitbang programmer\n",
avrdude_message(MSG_INFO, "%s: error: no cmd() method defined for bitbang programmer\n",
progname);
return -1;
}

View File

@ -97,15 +97,15 @@ static void dump_mem(char *buf, size_t len)
for (i = 0; i<len; i++) {
if (i % 8 == 0)
avrdude_message("\t");
avrdude_message("0x%02x ", (unsigned)buf[i] & 0xFF);
avrdude_message(MSG_INFO, "\t");
avrdude_message(MSG_INFO, "0x%02x ", (unsigned)buf[i] & 0xFF);
if (i % 8 == 3)
avrdude_message(" ");
avrdude_message(MSG_INFO, " ");
else if (i % 8 == 7)
avrdude_message("\n");
avrdude_message(MSG_INFO, "\n");
}
if (i % 8 != 7)
avrdude_message("\n");
avrdude_message(MSG_INFO, "\n");
}
static int buspirate_send_bin(struct programmer_t *pgm, char *data, size_t len)
@ -113,7 +113,7 @@ static int buspirate_send_bin(struct programmer_t *pgm, char *data, size_t len)
int rc;
if (verbose > 1) {
avrdude_message("%s: buspirate_send_bin():\n", progname);
avrdude_message(MSG_INFO, "%s: buspirate_send_bin():\n", progname);
dump_mem(data, len);
}
@ -130,7 +130,7 @@ static int buspirate_recv_bin(struct programmer_t *pgm, char *buf, size_t len)
if (rc < 0)
return EOF;
if (verbose > 1) {
avrdude_message("%s: buspirate_recv_bin():\n", progname);
avrdude_message(MSG_INFO, "%s: buspirate_recv_bin():\n", progname);
dump_mem(buf, len);
}
@ -143,7 +143,7 @@ static int buspirate_expect_bin(struct programmer_t *pgm,
{
char *recv_buf = alloca(expect_len);
if (!pgm->flag & BP_FLAG_IN_BINMODE) {
avrdude_message("BusPirate: Internal error: buspirate_send_bin() called from ascii mode");
avrdude_message(MSG_INFO, "BusPirate: Internal error: buspirate_send_bin() called from ascii mode");
return -1;
}
@ -168,7 +168,7 @@ static int buspirate_getc(struct programmer_t *pgm)
unsigned char ch = 0;
if (pgm->flag & BP_FLAG_IN_BINMODE) {
avrdude_message("BusPirate: Internal error: buspirate_getc() called from binmode");
avrdude_message(MSG_INFO, "BusPirate: Internal error: buspirate_getc() called from binmode");
return EOF;
}
@ -206,10 +206,9 @@ static char *buspirate_readline_noexit(struct programmer_t *pgm, char *buf, size
serial_recv_timeout = PDATA(pgm)->serial_recv_timeout;
}
serial_recv_timeout = orig_serial_recv_timeout;
if (verbose)
avrdude_message("%s: buspirate_readline(): %s%s",
progname, buf,
buf[strlen(buf) - 1] == '\n' ? "" : "\n");
avrdude_message(MSG_NOTICE, "%s: buspirate_readline(): %s%s",
progname, buf,
buf[strlen(buf) - 1] == '\n' ? "" : "\n");
if (! buf[0])
return NULL;
@ -222,7 +221,7 @@ static char *buspirate_readline(struct programmer_t *pgm, char *buf, size_t len)
ret = buspirate_readline_noexit(pgm, buf, len);
if (! ret) {
avrdude_message("%s: buspirate_readline(): programmer is not responding\n",
avrdude_message(MSG_INFO, "%s: buspirate_readline(): programmer is not responding\n",
progname);
return NULL;
}
@ -232,11 +231,10 @@ static int buspirate_send(struct programmer_t *pgm, char *str)
{
int rc;
if (verbose)
avrdude_message("%s: buspirate_send(): %s", progname, str);
avrdude_message(MSG_NOTICE, "%s: buspirate_send(): %s", progname, str);
if (pgm->flag & BP_FLAG_IN_BINMODE) {
avrdude_message("BusPirate: Internal error: buspirate_send() called from binmode");
avrdude_message(MSG_INFO, "BusPirate: Internal error: buspirate_send() called from binmode");
return -1;
}
@ -309,8 +307,8 @@ buspirate_parseextparms(struct programmer_t *pgm, LISTID extparms)
}
if (sscanf(extended_param, "spifreq=%d", &spifreq) == 1) {
if (spifreq & (~0x07)) {
avrdude_message("BusPirate: spifreq must be between 0 and 7.\n");
avrdude_message("BusPirate: see BusPirate manual for details.\n");
avrdude_message(MSG_INFO, "BusPirate: spifreq must be between 0 and 7.\n");
avrdude_message(MSG_INFO, "BusPirate: see BusPirate manual for details.\n");
return -1;
}
pgm->flag = (pgm->flag & ~BP_FLAG_XPARM_RAWFREQ) |
@ -322,7 +320,7 @@ buspirate_parseextparms(struct programmer_t *pgm, LISTID extparms)
unsigned rawfreq;
if (sscanf(extended_param, "rawfreq=%u", &rawfreq) == 1) {
if (rawfreq >= 4) {
avrdude_message("BusPirate: rawfreq must be "
avrdude_message(MSG_INFO, "BusPirate: rawfreq must be "
"between 0 and 3.\n");
return -1;
}
@ -335,8 +333,8 @@ buspirate_parseextparms(struct programmer_t *pgm, LISTID extparms)
if (sscanf(extended_param, "cpufreq=%d", &cpufreq) == 1) {
/* lower limit comes from 'cpufreq > 4 * spifreq', spifreq in ascii mode is 30kHz. */
if (cpufreq < 125 || cpufreq > 4000) {
avrdude_message("BusPirate: cpufreq must be between 125 and 4000 kHz.\n");
avrdude_message("BusPirate: see BusPirate manual for details.\n");
avrdude_message(MSG_INFO, "BusPirate: cpufreq must be between 125 and 4000 kHz.\n");
avrdude_message(MSG_INFO, "BusPirate: see BusPirate manual for details.\n");
return -1;
}
PDATA(pgm)->cpufreq = cpufreq;
@ -355,7 +353,7 @@ buspirate_parseextparms(struct programmer_t *pgm, LISTID extparms)
else if (strcasecmp(resetpin, "aux2") == 0)
PDATA(pgm)->reset |= BP_RESET_AUX2;
else {
avrdude_message("BusPirate: reset must be either CS or AUX.\n");
avrdude_message(MSG_INFO, "BusPirate: reset must be either CS or AUX.\n");
return -1;
}
}
@ -374,7 +372,7 @@ buspirate_parseextparms(struct programmer_t *pgm, LISTID extparms)
}
if (sscanf(extended_param, "serial_recv_timeout=%d", &serial_recv_timeout) == 1) {
if (serial_recv_timeout < 1) {
avrdude_message("BusPirate: serial_recv_timeout must be greater 0.\n");
avrdude_message(MSG_INFO, "BusPirate: serial_recv_timeout must be greater 0.\n");
return -1;
}
PDATA(pgm)->serial_recv_timeout = serial_recv_timeout;
@ -393,18 +391,18 @@ buspirate_verifyconfig(struct programmer_t *pgm)
PDATA(pgm)->reset |= BP_RESET_CS;
if ((PDATA(pgm)->reset != BP_RESET_CS) && buspirate_uses_ascii(pgm)) {
avrdude_message("BusPirate: RESET pin other than CS is not supported in ASCII mode\n");
avrdude_message(MSG_INFO, "BusPirate: RESET pin other than CS is not supported in ASCII mode\n");
return -1;
}
if (( (pgm->flag & BP_FLAG_XPARM_SPIFREQ) ||
(pgm->flag & BP_FLAG_XPARM_RAWFREQ) ) && buspirate_uses_ascii(pgm)) {
avrdude_message("BusPirate: SPI speed selection is not supported in ASCII mode\n");
avrdude_message(MSG_INFO, "BusPirate: SPI speed selection is not supported in ASCII mode\n");
return -1;
}
if ((pgm->flag & BP_FLAG_XPARM_CPUFREQ) && !buspirate_uses_ascii(pgm)) {
avrdude_message("BusPirate: Setting cpufreq is only supported in ASCII mode\n");
avrdude_message(MSG_INFO, "BusPirate: Setting cpufreq is only supported in ASCII mode\n");
return -1;
}
@ -463,12 +461,11 @@ static void buspirate_reset_from_binmode(struct programmer_t *pgm)
}
if (pgm->flag & BP_FLAG_IN_BINMODE) {
avrdude_message("BusPirate reset failed. You may need to powercycle it.\n");
avrdude_message(MSG_INFO, "BusPirate reset failed. You may need to powercycle it.\n");
return;
}
if (verbose)
avrdude_message("BusPirate is back in the text mode\n");
avrdude_message(MSG_NOTICE, "BusPirate is back in the text mode\n");
}
static int buspirate_start_mode_bin(struct programmer_t *pgm)
@ -513,13 +510,12 @@ static int buspirate_start_mode_bin(struct programmer_t *pgm)
memset(buf, 0, sizeof(buf));
buspirate_recv_bin(pgm, buf, 5);
if (sscanf(buf, "BBIO%d", &PDATA(pgm)->binmode_version) != 1) {
avrdude_message("Binary mode not confirmed: '%s'\n", buf);
avrdude_message(MSG_INFO, "Binary mode not confirmed: '%s'\n", buf);
buspirate_reset_from_binmode(pgm);
return -1;
}
if (verbose)
avrdude_message("BusPirate binmode version: %d\n",
PDATA(pgm)->binmode_version);
avrdude_message(MSG_NOTICE, "BusPirate binmode version: %d\n",
PDATA(pgm)->binmode_version);
pgm->flag |= BP_FLAG_IN_BINMODE;
@ -530,18 +526,16 @@ static int buspirate_start_mode_bin(struct programmer_t *pgm)
buspirate_recv_bin(pgm, buf, 4);
if (sscanf(buf, submode->entered_format,
&PDATA(pgm)->submode_version) != 1) {
avrdude_message("%s mode not confirmed: '%s'\n",
avrdude_message(MSG_INFO, "%s mode not confirmed: '%s'\n",
submode->name, buf);
buspirate_reset_from_binmode(pgm);
return -1;
}
if (verbose)
avrdude_message("BusPirate %s version: %d\n",
submode->name, PDATA(pgm)->submode_version);
avrdude_message(MSG_NOTICE, "BusPirate %s version: %d\n",
submode->name, PDATA(pgm)->submode_version);
if (pgm->flag & BP_FLAG_NOPAGEDWRITE) {
if (verbose)
avrdude_message("%s: Paged flash write disabled.\n", progname);
avrdude_message(MSG_NOTICE, "%s: Paged flash write disabled.\n", progname);
pgm->paged_write = NULL;
} else {
/* Check for write-then-read without !CS/CS and disable paged_write if absent: */
@ -558,14 +552,12 @@ static int buspirate_start_mode_bin(struct programmer_t *pgm)
buf[0] = 0x1;
buspirate_send_bin(pgm, buf, 1);
if (verbose)
avrdude_message("%s: Disabling paged flash write. (Need BusPirate firmware >=v5.10.)\n", progname);
avrdude_message(MSG_NOTICE, "%s: Disabling paged flash write. (Need BusPirate firmware >=v5.10.)\n", progname);
/* Flush serial buffer: */
serial_drain(&pgm->fd, 0);
} else {
if (verbose)
avrdude_message("%s: Paged flash write enabled.\n", progname);
avrdude_message(MSG_INFO, "%s: Paged flash write enabled.\n", progname);
}
}
@ -586,8 +578,7 @@ static int buspirate_start_mode_bin(struct programmer_t *pgm)
/* AVR Extended Commands - test for existence */
if (pgm->flag & BP_FLAG_NOPAGEDREAD) {
if (verbose)
avrdude_message("%s: Paged flash read disabled.\n", progname);
avrdude_message(MSG_NOTICE, "%s: Paged flash read disabled.\n", progname);
pgm->paged_load = NULL;
} else {
int rv = buspirate_expect_bin_byte(pgm, 0x06, 0x01);
@ -598,9 +589,9 @@ static int buspirate_start_mode_bin(struct programmer_t *pgm)
buspirate_send_bin(pgm, buf, 1);
buspirate_recv_bin(pgm, buf, 3);
ver = buf[1] << 8 | buf[2];
if (verbose) avrdude_message("AVR Extended Commands version %d\n", ver);
avrdude_message(MSG_NOTICE, "AVR Extended Commands version %d\n", ver);
} else {
if (verbose) avrdude_message("AVR Extended Commands not found.\n");
avrdude_message(MSG_NOTICE, "AVR Extended Commands not found.\n");
pgm->flag |= BP_FLAG_NOPAGEDREAD;
pgm->paged_load = NULL;
}
@ -626,9 +617,9 @@ static int buspirate_start_spi_mode_ascii(struct programmer_t *pgm)
break;
}
if (spi_cmd == -1) {
avrdude_message("%s: SPI mode number not found. Does your BusPirate support SPI?\n",
avrdude_message(MSG_INFO, "%s: SPI mode number not found. Does your BusPirate support SPI?\n",
progname);
avrdude_message("%s: Try powercycling your BusPirate and try again.\n",
avrdude_message(MSG_INFO, "%s: Try powercycling your BusPirate and try again.\n",
progname);
return -1;
}
@ -646,7 +637,7 @@ static int buspirate_start_spi_mode_ascii(struct programmer_t *pgm)
}
if (buspirate_is_prompt(rcvd)) {
if (strncmp(rcvd, "SPI>", 4) == 0) {
if (verbose) avrdude_message("BusPirate is now configured for SPI\n");
if (verbose) avrdude_message(MSG_INFO, "BusPirate is now configured for SPI\n");
break;
}
/* Not yet 'SPI>' prompt */
@ -673,7 +664,7 @@ static void buspirate_enable(struct programmer_t *pgm)
/* Attempt to start binary SPI mode unless explicitly told otherwise: */
if (!buspirate_uses_ascii(pgm)) {
avrdude_message("Attempting to initiate BusPirate binary mode...\n");
avrdude_message(MSG_INFO, "Attempting to initiate BusPirate binary mode...\n");
/* Send two CRs to ensure we're not in a sub-menu of the UI if we're in ASCII mode: */
buspirate_send_bin(pgm, "\n\n", 2);
@ -685,23 +676,23 @@ static void buspirate_enable(struct programmer_t *pgm)
if (buspirate_start_mode_bin(pgm) >= 0)
return;
else
avrdude_message("%s: Failed to start binary mode, falling back to ASCII...\n", progname);
avrdude_message(MSG_INFO, "%s: Failed to start binary mode, falling back to ASCII...\n", progname);
}
avrdude_message("Attempting to initiate BusPirate ASCII mode...\n");
avrdude_message(MSG_INFO, "Attempting to initiate BusPirate ASCII mode...\n");
/* Call buspirate_send_bin() instead of buspirate_send()
* because we don't know if BP is in text or bin mode */
rc = buspirate_send_bin(pgm, reset_str, strlen(reset_str));
if (rc) {
avrdude_message("BusPirate is not responding. Serial port error: %d\n", rc);
avrdude_message(MSG_INFO, "BusPirate is not responding. Serial port error: %d\n", rc);
return;
}
while(1) {
rcvd = buspirate_readline_noexit(pgm, NULL, 0);
if (! rcvd) {
avrdude_message("%s: Fatal: Programmer is not responding.\n", progname);
avrdude_message(MSG_INFO, "%s: Fatal: Programmer is not responding.\n", progname);
return;
}
if (strncmp(rcvd, "Are you sure?", 13) == 0) {
@ -716,13 +707,13 @@ static void buspirate_enable(struct programmer_t *pgm)
break;
}
if (print_banner)
avrdude_message("** %s", rcvd);
avrdude_message(MSG_INFO, "** %s", rcvd);
}
if (!(pgm->flag & BP_FLAG_IN_BINMODE)) {
avrdude_message("BusPirate: using ASCII mode\n");
avrdude_message(MSG_INFO, "BusPirate: using ASCII mode\n");
if (buspirate_start_spi_mode_ascii(pgm) < 0) {
avrdude_message("%s: Failed to start ascii SPI mode\n", progname);
avrdude_message(MSG_INFO, "%s: Failed to start ascii SPI mode\n", progname);
return;
}
}
@ -763,15 +754,15 @@ static void buspirate_powerup(struct programmer_t *pgm)
}
}
if(!ok) {
avrdude_message("%s: warning: did not get a response to start PWM command.\n", progname);
avrdude_message(MSG_INFO, "%s: warning: did not get a response to start PWM command.\n", progname);
}
}
return;
}
}
avrdude_message("%s: warning: did not get a response to PowerUp command.\n", progname);
avrdude_message("%s: warning: Trying to continue anyway...\n", progname);
avrdude_message(MSG_INFO, "%s: warning: did not get a response to PowerUp command.\n", progname);
avrdude_message(MSG_INFO, "%s: warning: Trying to continue anyway...\n", progname);
}
static void buspirate_powerdown(struct programmer_t *pgm)
@ -784,14 +775,14 @@ static void buspirate_powerdown(struct programmer_t *pgm)
} else {
if (pgm->flag & BP_FLAG_XPARM_CPUFREQ) {
if (!buspirate_expect(pgm, "g\n", "PWM disabled", 1)) {
avrdude_message("%s: warning: did not get a response to stop PWM command.\n", progname);
avrdude_message(MSG_INFO, "%s: warning: did not get a response to stop PWM command.\n", progname);
}
}
if (buspirate_expect(pgm, "w\n", "Power supplies OFF", 1))
return;
}
avrdude_message("%s: warning: did not get a response to PowerDown command.\n", progname);
avrdude_message(MSG_INFO, "%s: warning: did not get a response to PowerDown command.\n", progname);
}
static int buspirate_cmd_bin(struct programmer_t *pgm,
@ -834,7 +825,7 @@ static int buspirate_cmd_ascii(struct programmer_t *pgm,
}
if (i != 4) {
avrdude_message("%s: error: SPI has not read 4 bytes back\n", progname);
avrdude_message(MSG_INFO, "%s: error: SPI has not read 4 bytes back\n", progname);
return -1;
}
@ -868,11 +859,11 @@ static int buspirate_paged_load(
unsigned char buf[275];
unsigned int addr = 0;
if (verbose > 1) avrdude_message("BusPirate: buspirate_paged_load(..,%s,%d,%d,%d)\n",m->desc,m->page_size,address,n_bytes);
avrdude_message(MSG_NOTICE, "BusPirate: buspirate_paged_load(..,%s,%d,%d,%d)\n",m->desc,m->page_size,address,n_bytes);
// This should never happen, but still...
if (pgm->flag & BP_FLAG_NOPAGEDREAD) {
avrdude_message("BusPirate: buspirate_paged_load() called while in nopagedread mode!\n");
avrdude_message(MSG_INFO, "BusPirate: buspirate_paged_load() called while in nopagedread mode!\n");
return -1;
}
@ -901,7 +892,7 @@ static int buspirate_paged_load(
buspirate_recv_bin(pgm, buf, 1);
if (buf[0] != 0x01) {
avrdude_message("BusPirate: Paged Read command returned zero.\n");
avrdude_message(MSG_INFO, "BusPirate: Paged Read command returned zero.\n");
return -1;
}
@ -948,12 +939,12 @@ static int buspirate_paged_write(struct programmer_t *pgm,
/* pre-check opcodes */
if (m->op[AVR_OP_LOADPAGE_LO] == NULL) {
avrdude_message("%s failure: %s command not defined for %s\n",
avrdude_message(MSG_INFO, "%s failure: %s command not defined for %s\n",
progname, "AVR_OP_LOADPAGE_LO", p->desc);
return -1;
}
if (m->op[AVR_OP_LOADPAGE_HI] == NULL) {
avrdude_message("%s failure: %s command not defined for %s\n",
avrdude_message(MSG_INFO, "%s failure: %s command not defined for %s\n",
progname, "AVR_OP_LOADPAGE_HI", p->desc);
return -1;
}
@ -1014,7 +1005,7 @@ static int buspirate_paged_write(struct programmer_t *pgm,
/* Check for write failure: */
if ((buspirate_recv_bin(pgm, &recv_byte, 1) == EOF) || (recv_byte != 0x01)) {
avrdude_message("BusPirate: Fatal error: Write Then Read did not succeed.\n");
avrdude_message(MSG_INFO, "BusPirate: Fatal error: Write Then Read did not succeed.\n");
pgm->pgm_led(pgm, OFF);
pgm->err_led(pgm, ON);
return -1;
@ -1045,7 +1036,7 @@ static int buspirate_program_enable(struct programmer_t *pgm, AVRPART * p)
buspirate_expect(pgm, "{\n", "CS ENABLED", 1);
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;
}
@ -1066,7 +1057,7 @@ static int buspirate_chip_erase(struct programmer_t *pgm, AVRPART * p)
unsigned char res[4];
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;
}
@ -1090,7 +1081,7 @@ static void buspirate_setup(struct programmer_t *pgm)
{
/* Allocate private data */
if ((pgm->cookie = calloc(1, sizeof(struct pdata))) == 0) {
avrdude_message("%s: buspirate_initpgm(): Out of memory allocating private data\n",
avrdude_message(MSG_INFO, "%s: buspirate_initpgm(): Out of memory allocating private data\n",
progname);
exit(1);
}
@ -1144,7 +1135,7 @@ static void buspirate_bb_enable(struct programmer_t *pgm)
if (bitbang_check_prerequisites(pgm) < 0)
return; /* XXX should treat as error */
avrdude_message("Attempting to initiate BusPirate bitbang binary mode...\n");
avrdude_message(MSG_INFO, "Attempting to initiate BusPirate bitbang binary mode...\n");
/* Send two CRs to ensure we're not in a sub-menu of the UI if we're in ASCII mode: */
buspirate_send_bin(pgm, "\n\n", 2);
@ -1159,11 +1150,11 @@ static void buspirate_bb_enable(struct programmer_t *pgm)
memset(buf, 0, sizeof(buf));
buspirate_recv_bin(pgm, buf, 5);
if (sscanf(buf, "BBIO%d", &PDATA(pgm)->binmode_version) != 1) {
avrdude_message("Binary mode not confirmed: '%s'\n", buf);
avrdude_message(MSG_INFO, "Binary mode not confirmed: '%s'\n", buf);
buspirate_reset_from_binmode(pgm);
return;
}
avrdude_message("BusPirate binmode version: %d\n",
avrdude_message(MSG_INFO, "BusPirate binmode version: %d\n",
PDATA(pgm)->binmode_version);
pgm->flag |= BP_FLAG_IN_BINMODE;

View File

@ -63,7 +63,7 @@ struct pdata
static void butterfly_setup(PROGRAMMER * pgm)
{
if ((pgm->cookie = malloc(sizeof(struct pdata))) == 0) {
avrdude_message("%s: butterfly_setup(): Out of memory allocating private data\n",
avrdude_message(MSG_INFO, "%s: butterfly_setup(): Out of memory allocating private data\n",
progname);
exit(1);
}
@ -87,7 +87,7 @@ static int butterfly_recv(PROGRAMMER * pgm, char * buf, size_t len)
rv = serial_recv(&pgm->fd, (unsigned char *)buf, len);
if (rv < 0) {
avrdude_message("%s: butterfly_recv(): programmer is not responding\n",
avrdude_message(MSG_INFO, "%s: butterfly_recv(): programmer is not responding\n",
progname);
return -1;
}
@ -107,7 +107,7 @@ static int butterfly_vfy_cmd_sent(PROGRAMMER * pgm, char * errmsg)
butterfly_recv(pgm, &c, 1);
if (c != '\r') {
avrdude_message("%s: error: programmer did not respond to command: %s\n",
avrdude_message(MSG_INFO, "%s: error: programmer did not respond to command: %s\n",
progname, errmsg);
return -1;
}
@ -222,7 +222,7 @@ static int butterfly_initialize(PROGRAMMER * pgm, AVRPART * p)
* Send some ESC to activate butterfly bootloader. This is not needed
* for plain avr109 bootloaders but does not harm there either.
*/
avrdude_message("Connecting to programmer: ");
avrdude_message(MSG_INFO, "Connecting to programmer: ");
if (pgm->flag & IS_BUTTERFLY_MK)
{
char mk_reset_cmd[6] = {"#aR@S\r"};
@ -246,7 +246,7 @@ static int butterfly_initialize(PROGRAMMER * pgm, AVRPART * p)
butterfly_recv(pgm, &c, 1);
if ( c != 'M' && c != '?')
{
avrdude_message("\nConnection FAILED.");
avrdude_message(MSG_INFO, "\nConnection FAILED.");
return -1;
}
else
@ -293,12 +293,12 @@ static int butterfly_initialize(PROGRAMMER * pgm, AVRPART * p)
butterfly_send(pgm, "p", 1);
butterfly_recv(pgm, &type, 1);
avrdude_message("Found programmer: Id = \"%s\"; type = %c\n", id, type);
avrdude_message(" Software Version = %c.%c; ", sw[0], sw[1]);
avrdude_message(MSG_INFO, "Found programmer: Id = \"%s\"; type = %c\n", id, type);
avrdude_message(MSG_INFO, " Software Version = %c.%c; ", sw[0], sw[1]);
if (hw[0]=='?') {
avrdude_message("No Hardware Version given.\n");
avrdude_message(MSG_INFO, "No Hardware Version given.\n");
} else {
avrdude_message("Hardware Version = %c.%c\n", hw[0], hw[1]);
avrdude_message(MSG_INFO, "Hardware Version = %c.%c\n", hw[0], hw[1]);
};
/* See if programmer supports autoincrement of address. */
@ -306,14 +306,14 @@ static int butterfly_initialize(PROGRAMMER * pgm, AVRPART * p)
butterfly_send(pgm, "a", 1);
butterfly_recv(pgm, &PDATA(pgm)->has_auto_incr_addr, 1);
if (PDATA(pgm)->has_auto_incr_addr == 'Y')
avrdude_message("Programmer supports auto addr increment.\n");
avrdude_message(MSG_INFO, "Programmer supports auto addr increment.\n");
/* Check support for buffered memory access, abort if not available */
butterfly_send(pgm, "b", 1);
butterfly_recv(pgm, &c, 1);
if (c != 'Y') {
avrdude_message("%s: error: buffered memory access not supported. Maybe it isn't\n"\
avrdude_message(MSG_INFO, "%s: error: buffered memory access not supported. Maybe it isn't\n"\
"a butterfly/AVR109 but a AVR910 device?\n", progname);
return -1;
};
@ -321,13 +321,13 @@ static int butterfly_initialize(PROGRAMMER * pgm, AVRPART * p)
PDATA(pgm)->buffersize = (unsigned int)(unsigned char)c<<8;
butterfly_recv(pgm, &c, 1);
PDATA(pgm)->buffersize += (unsigned int)(unsigned char)c;
avrdude_message("Programmer supports buffered memory access with buffersize=%i bytes.\n",
avrdude_message(MSG_INFO, "Programmer supports buffered memory access with buffersize=%i bytes.\n",
PDATA(pgm)->buffersize);
/* Get list of devices that the programmer supports. */
butterfly_send(pgm, "t", 1);
avrdude_message("\nProgrammer supports the following devices:\n");
avrdude_message(MSG_INFO, "\nProgrammer supports the following devices:\n");
devtype_1st = 0;
while (1) {
butterfly_recv(pgm, &c, 1);
@ -336,9 +336,9 @@ static int butterfly_initialize(PROGRAMMER * pgm, AVRPART * p)
if (c == 0)
break;
avrdude_message(" Device code: 0x%02x\n", (unsigned int)(unsigned char)c);
avrdude_message(MSG_INFO, " Device code: 0x%02x\n", (unsigned int)(unsigned char)c);
};
avrdude_message("\n");
avrdude_message(MSG_INFO, "\n");
/* Tell the programmer which part we selected.
According to the AVR109 code, this is ignored by the bootloader. As
@ -356,7 +356,7 @@ static int butterfly_initialize(PROGRAMMER * pgm, AVRPART * p)
return -1;
if (verbose)
avrdude_message("%s: devcode selected: 0x%02x\n",
avrdude_message(MSG_INFO, "%s: devcode selected: 0x%02x\n",
progname, (unsigned)buf[1]);
butterfly_enter_prog_mode(pgm);
@ -550,7 +550,7 @@ static int butterfly_page_erase(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m, unsig
return -1; /* not supported */
if (strcmp(m->desc, "eeprom") == 0)
return 0; /* nothing to do */
avrdude_message("%s: butterfly_page_erase() called on memory type \"%s\"\n",
avrdude_message(MSG_INFO, "%s: butterfly_page_erase() called on memory type \"%s\"\n",
progname, m->desc);
return -1;
}
@ -697,7 +697,7 @@ static int butterfly_read_sig_bytes(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m)
unsigned char tmp;
if (m->size < 3) {
avrdude_message("%s: memsize too small for sig byte read", progname);
avrdude_message(MSG_INFO, "%s: memsize too small for sig byte read", progname);
return -1;
}

View File

@ -93,7 +93,7 @@ TOKEN * new_token(int primary)
tkn = (TOKEN *)malloc(sizeof(TOKEN));
if (tkn == NULL) {
avrdude_message("new_token(): out of memory\n");
avrdude_message(MSG_INFO, "new_token(): out of memory\n");
exit(1);
}
@ -145,7 +145,7 @@ TOKEN * number(char * text)
tkn->value.number = atoi(text);
#if DEBUG
avrdude_message("NUMBER(%d)\n", tkn->value.number);
avrdude_message(MSG_INFO, "NUMBER(%d)\n", tkn->value.number);
#endif
return tkn;
@ -160,7 +160,7 @@ TOKEN * number_real(char * text)
tkn->value.number_real = atof(text);
#if DEBUG
avrdude_message("NUMBER(%g)\n", tkn->value.number_real);
avrdude_message(MSG_INFO, "NUMBER(%g)\n", tkn->value.number_real);
#endif
return tkn;
@ -175,12 +175,12 @@ TOKEN * hexnumber(char * text)
tkn->value.type = V_NUM;
tkn->value.number = strtoul(text, &e, 16);
if ((e == text) || (*e != 0)) {
avrdude_message("error at %s:%d: can't scan hex number \"%s\"\n",
avrdude_message(MSG_INFO, "error at %s:%d: can't scan hex number \"%s\"\n",
infile, lineno, text);
}
#if DEBUG
avrdude_message("HEXNUMBER(%g)\n", tkn->value.number);
avrdude_message(MSG_INFO, "HEXNUMBER(%g)\n", tkn->value.number);
#endif
return tkn;
@ -199,13 +199,13 @@ TOKEN * string(char * text)
tkn->value.type = V_STR;
tkn->value.string = (char *) malloc(len+1);
if (tkn->value.string == NULL) {
avrdude_message("id(): out of memory\n");
avrdude_message(MSG_INFO, "id(): out of memory\n");
exit(1);
}
strcpy(tkn->value.string, text);
#if DEBUG
avrdude_message("STRING(%s)\n", tkn->value.string);
avrdude_message(MSG_INFO, "STRING(%s)\n", tkn->value.string);
#endif
return tkn;
@ -227,33 +227,33 @@ void print_token(TOKEN * tkn)
if (!tkn)
return;
avrdude_message("token = %d = ", tkn->primary);
avrdude_message(MSG_INFO, "token = %d = ", tkn->primary);
switch (tkn->value.type) {
case V_NUM:
avrdude_message("NUMBER, value=%d", tkn->value.number);
avrdude_message(MSG_INFO, "NUMBER, value=%d", tkn->value.number);
break;
case V_NUM_REAL:
avrdude_message("NUMBER, value=%g", tkn->value.number_real);
avrdude_message(MSG_INFO, "NUMBER, value=%g", tkn->value.number_real);
break;
case V_STR:
avrdude_message("STRING, value=%s", tkn->value.string);
avrdude_message(MSG_INFO, "STRING, value=%s", tkn->value.string);
break;
default:
avrdude_message("<other>");
avrdude_message(MSG_INFO, "<other>");
break;
}
avrdude_message("\n");
avrdude_message(MSG_INFO, "\n");
}
void pyytext(void)
{
#if DEBUG
avrdude_message("TOKEN: \"%s\"\n", yytext);
avrdude_message(MSG_INFO, "TOKEN: \"%s\"\n", yytext);
#endif
}
@ -264,7 +264,7 @@ char * dup_string(const char * str)
s = strdup(str);
if (s == NULL) {
avrdude_message("dup_string(): out of memory\n");
avrdude_message(MSG_INFO, "dup_string(): out of memory\n");
exit(1);
}
@ -282,7 +282,7 @@ int read_config(const char * file)
f = fopen(file, "r");
if (f == NULL) {
avrdude_message("%s: can't open config file \"%s\": %s\n",
avrdude_message(MSG_INFO, "%s: can't open config file \"%s\": %s\n",
progname, file, strerror(errno));
return -1;
}

View File

@ -271,19 +271,19 @@ prog_def :
PROGRAMMER * existing_prog;
char * id;
if (lsize(current_prog->id) == 0) {
avrdude_message("%s: error at %s:%d: required parameter id not specified\n",
avrdude_message(MSG_INFO, "%s: error at %s:%d: required parameter id not specified\n",
progname, infile, lineno);
exit(1);
}
if (current_prog->initpgm == NULL) {
avrdude_message("%s: error at %s:%d: programmer type not specified\n",
avrdude_message(MSG_INFO, "%s: error at %s:%d: programmer type not specified\n",
progname, infile, lineno);
exit(1);
}
id = ldata(lfirst(current_prog->id));
existing_prog = locate_programmer(programmers, id);
if (existing_prog) {
avrdude_message("%s: warning at %s:%d: programmer %s overwrites "
avrdude_message(MSG_INFO, "%s: warning at %s:%d: programmer %s overwrites "
"previous definition %s:%d.\n",
progname, infile, current_prog->lineno,
id, existing_prog->config_file, existing_prog->lineno);
@ -309,7 +309,7 @@ prog_decl :
{
struct programmer_t * pgm = locate_programmer(programmers, $3->value.string);
if (pgm == NULL) {
avrdude_message("%s: error at %s:%d: parent programmer %s not found\n",
avrdude_message(MSG_INFO, "%s: error at %s:%d: parent programmer %s not found\n",
progname, infile, lineno, $3->value.string);
exit(1);
}
@ -329,7 +329,7 @@ part_def :
AVRPART * existing_part;
if (current_part->id[0] == 0) {
avrdude_message("%s: error at %s:%d: required parameter id not specified\n",
avrdude_message(MSG_INFO, "%s: error at %s:%d: required parameter id not specified\n",
progname, infile, lineno);
exit(1);
}
@ -343,19 +343,19 @@ part_def :
m = ldata(ln);
if (m->paged) {
if (m->page_size == 0) {
avrdude_message("%s: error at %s:%d: must specify page_size for paged "
avrdude_message(MSG_INFO, "%s: error at %s:%d: must specify page_size for paged "
"memory\n",
progname, infile, lineno);
exit(1);
}
if (m->num_pages == 0) {
avrdude_message("%s: error at %s:%d: must specify num_pages for paged "
avrdude_message(MSG_INFO, "%s: error at %s:%d: must specify num_pages for paged "
"memory\n",
progname, infile, lineno);
exit(1);
}
if (m->size != m->page_size * m->num_pages) {
avrdude_message("%s: error at %s:%d: page size (%u) * num_pages (%u) = "
avrdude_message(MSG_INFO, "%s: error at %s:%d: page size (%u) * num_pages (%u) = "
"%u does not match memory size (%u)\n",
progname, infile, lineno,
m->page_size,
@ -370,7 +370,7 @@ part_def :
existing_part = locate_part(part_list, current_part->id);
if (existing_part) {
avrdude_message("%s: warning at %s:%d: part %s overwrites "
avrdude_message(MSG_INFO, "%s: warning at %s:%d: part %s overwrites "
"previous definition %s:%d.\n",
progname, infile, current_part->lineno, current_part->id,
existing_part->config_file, existing_part->lineno);
@ -393,7 +393,7 @@ part_decl :
{
AVRPART * parent_part = locate_part(part_list, $3->value.string);
if (parent_part == NULL) {
avrdude_message("%s: error at %s:%d: can't find parent part",
avrdude_message(MSG_INFO, "%s: error at %s:%d: can't find parent part",
progname, infile, lineno);
exit(1);
}
@ -462,7 +462,7 @@ prog_parm_type_id:
TKN_STRING {
const struct programmer_type_t * pgm_type = locate_programmer_type($1->value.string);
if (pgm_type == NULL) {
avrdude_message("%s: error at %s:%d: programmer type %s not found\n",
avrdude_message(MSG_INFO, "%s: error at %s:%d: programmer type %s not found\n",
progname, infile, lineno, $1->value.string);
exit(1);
}
@ -471,7 +471,7 @@ prog_parm_type_id:
}
| error
{
avrdude_message("%s: error at %s:%d: programmer type must be written as \"id_type\"\n",
avrdude_message(MSG_INFO, "%s: error at %s:%d: programmer type must be written as \"id_type\"\n",
progname, infile, lineno);
exit(1);
}
@ -643,7 +643,7 @@ part_parm :
K_DEVICECODE TKN_EQUAL TKN_NUMBER {
{
avrdude_message("%s: error at %s:%d: devicecode is deprecated, use "
avrdude_message(MSG_INFO, "%s: error at %s:%d: devicecode is deprecated, use "
"stk500_devcode instead\n",
progname, infile, lineno);
exit(1);
@ -708,7 +708,7 @@ part_parm :
}
if (!ok)
{
avrdude_message("%s: Warning: line %d of %s: "
avrdude_message(MSG_INFO, "%s: Warning: line %d of %s: "
"too many bytes in control stack\n",
progname, lineno, infile);
}
@ -741,7 +741,7 @@ part_parm :
}
if (!ok)
{
avrdude_message("%s: Warning: line %d of %s: "
avrdude_message(MSG_INFO, "%s: Warning: line %d of %s: "
"too many bytes in control stack\n",
progname, lineno, infile);
}
@ -773,7 +773,7 @@ part_parm :
}
if (!ok)
{
avrdude_message("%s: Warning: line %d of %s: "
avrdude_message(MSG_INFO, "%s: Warning: line %d of %s: "
"too many bytes in flash instructions\n",
progname, lineno, infile);
}
@ -805,7 +805,7 @@ part_parm :
}
if (!ok)
{
avrdude_message("%s: Warning: line %d of %s: "
avrdude_message(MSG_INFO, "%s: Warning: line %d of %s: "
"too many bytes in EEPROM instructions\n",
progname, lineno, infile);
}
@ -1211,7 +1211,7 @@ part_parm :
op = avr_new_opcode();
parse_cmdbits(op);
if (current_part->op[opnum] != NULL) {
/*avrdude_message("%s: warning at %s:%d: operation redefined\n",
/*avrdude_message(MSG_INFO, "%s: warning at %s:%d: operation redefined\n",
progname, infile, lineno);*/
avr_free_opcode(current_part->op[opnum]);
}
@ -1337,7 +1337,7 @@ mem_spec :
op = avr_new_opcode();
parse_cmdbits(op);
if (current_mem->op[opnum] != NULL) {
/*avrdude_message("%s: warning at %s:%d: operation redefined\n",
/*avrdude_message(MSG_INFO, "%s: warning at %s:%d: operation redefined\n",
progname, infile, lineno);*/
avr_free_opcode(current_mem->op[opnum]);
}
@ -1373,7 +1373,7 @@ static int assign_pin(int pinno, TOKEN * v, int invert)
free_token(v);
if ((value < PIN_MIN) || (value > PIN_MAX)) {
avrdude_message("%s: error at line %d of %s: pin must be in the "
avrdude_message(MSG_INFO, "%s: error at line %d of %s: pin must be in the "
"range %d-%d\n",
progname, lineno, infile, PIN_MIN, PIN_MAX);
exit(1);
@ -1394,7 +1394,7 @@ static int assign_pin_list(int invert)
t = lrmv_n(number_list, 1);
pin = t->value.number;
if ((pin < PIN_MIN) || (pin > PIN_MAX)) {
avrdude_message("%s: error at line %d of %s: pin must be in the "
avrdude_message(MSG_INFO, "%s: error at line %d of %s: pin must be in the "
"range %d-%d\n",
progname, lineno, infile, PIN_MIN, PIN_MAX);
exit(1);
@ -1423,7 +1423,7 @@ static int which_opcode(TOKEN * opcode)
case K_CHIP_ERASE : return AVR_OP_CHIP_ERASE; break;
case K_PGM_ENABLE : return AVR_OP_PGM_ENABLE; break;
default :
avrdude_message("%s: error at %s:%d: invalid opcode\n",
avrdude_message(MSG_INFO, "%s: error at %s:%d: invalid opcode\n",
progname, infile, lineno);
exit(1);
break;
@ -1451,7 +1451,7 @@ static int parse_cmdbits(OPCODE * op)
bitno--;
if (bitno < 0) {
avrdude_message("%s: error at %s:%d: too many opcode bits for instruction\n",
avrdude_message(MSG_INFO, "%s: error at %s:%d: too many opcode bits for instruction\n",
progname, infile, lineno);
exit(1);
}
@ -1459,7 +1459,7 @@ static int parse_cmdbits(OPCODE * op)
len = strlen(s);
if (len == 0) {
avrdude_message("%s: error at %s:%d: invalid bit specifier \"\"\n",
avrdude_message(MSG_INFO, "%s: error at %s:%d: invalid bit specifier \"\"\n",
progname, infile, lineno);
exit(1);
}
@ -1499,7 +1499,7 @@ static int parse_cmdbits(OPCODE * op)
op->bit[bitno].bitno = bitno % 8;
break;
default :
avrdude_message("%s: error at %s:%d: invalid bit specifier '%c'\n",
avrdude_message(MSG_INFO, "%s: error at %s:%d: invalid bit specifier '%c'\n",
progname, infile, lineno, ch);
exit(1);
break;
@ -1510,7 +1510,7 @@ static int parse_cmdbits(OPCODE * op)
q = &s[1];
op->bit[bitno].bitno = strtol(q, &e, 0);
if ((e == q)||(*e != 0)) {
avrdude_message("%s: error at %s:%d: can't parse bit number from \"%s\"\n",
avrdude_message(MSG_INFO, "%s: error at %s:%d: can't parse bit number from \"%s\"\n",
progname, infile, lineno, q);
exit(1);
}
@ -1518,7 +1518,7 @@ static int parse_cmdbits(OPCODE * op)
op->bit[bitno].value = 0;
}
else {
avrdude_message("%s: error at %s:%d: invalid bit specifier \"%s\"\n",
avrdude_message(MSG_INFO, "%s: error at %s:%d: invalid bit specifier \"%s\"\n",
progname, infile, lineno, s);
exit(1);
}

90
dfu.c
View File

@ -39,7 +39,7 @@
#ifndef HAVE_LIBUSB
struct dfu_dev *dfu_open(char *port_name) {
avrdude_message("%s: Error: No USB support in this compile of avrdude\n",
avrdude_message(MSG_INFO, "%s: Error: No USB support in this compile of avrdude\n",
progname);
return NULL;
}
@ -112,7 +112,7 @@ struct dfu_dev * dfu_open(char *port_spec)
*/
if (strncmp(port_spec, "usb", 3) != 0) {
avrdude_message("%s: Error: "
avrdude_message(MSG_INFO, "%s: Error: "
"Invalid port specification \"%s\" for USB device\n",
progname, port_spec);
return NULL;
@ -121,7 +121,7 @@ struct dfu_dev * dfu_open(char *port_spec)
if(':' == port_spec[3]) {
bus_name = strdup(port_spec + 3 + 1);
if (bus_name == NULL) {
avrdude_message("%s: Out of memory in strdup\n", progname);
avrdude_message(MSG_INFO, "%s: Out of memory in strdup\n", progname);
return NULL;
}
@ -138,7 +138,7 @@ struct dfu_dev * dfu_open(char *port_spec)
if (dfu == NULL)
{
avrdude_message("%s: out of memory\n", progname);
avrdude_message(MSG_INFO, "%s: out of memory\n", progname);
return 0;
}
@ -171,7 +171,7 @@ int dfu_init(struct dfu_dev *dfu, unsigned short vid, unsigned short pid)
*/
if (pid == 0 && dfu->dev_name == NULL) {
avrdude_message("%s: Error: No DFU support for part; "
avrdude_message(MSG_INFO, "%s: Error: No DFU support for part; "
"specify PID in config or USB address (via -P) to override.\n",
progname);
return -1;
@ -208,19 +208,19 @@ int dfu_init(struct dfu_dev *dfu, unsigned short vid, unsigned short pid)
* why the match failed, and if we came across another DFU-capable part.
*/
avrdude_message("%s: Error: No matching USB device found\n", progname);
avrdude_message(MSG_INFO, "%s: Error: No matching USB device found\n", progname);
return -1;
}
if(verbose)
avrdude_message("%s: Found VID=0x%04x PID=0x%04x at %s:%s\n",
avrdude_message(MSG_INFO, "%s: Found VID=0x%04x PID=0x%04x at %s:%s\n",
progname, found->descriptor.idVendor, found->descriptor.idProduct,
found->bus->dirname, found->filename);
dfu->dev_handle = usb_open(found);
if (dfu->dev_handle == NULL) {
avrdude_message("%s: Error: USB device at %s:%s: %s\n",
avrdude_message(MSG_INFO, "%s: Error: USB device at %s:%s: %s\n",
progname, found->bus->dirname, found->filename, usb_strerror());
return -1;
}
@ -271,8 +271,7 @@ int dfu_getstatus(struct dfu_dev *dfu, struct dfu_status *status)
{
int result;
if (verbose > 3)
avrdude_message("%s: dfu_getstatus(): issuing control IN message\n",
avrdude_message(MSG_TRACE, "%s: dfu_getstatus(): issuing control IN message\n",
progname);
result = usb_control_msg(dfu->dev_handle,
@ -280,30 +279,29 @@ int dfu_getstatus(struct dfu_dev *dfu, struct dfu_status *status)
(char*) status, sizeof(struct dfu_status), dfu->timeout);
if (result < 0) {
avrdude_message("%s: Error: Failed to get DFU status: %s\n",
avrdude_message(MSG_INFO, "%s: Error: Failed to get DFU status: %s\n",
progname, usb_strerror());
return -1;
}
if (result < sizeof(struct dfu_status)) {
avrdude_message("%s: Error: Failed to get DFU status: %s\n",
avrdude_message(MSG_INFO, "%s: Error: Failed to get DFU status: %s\n",
progname, "short read");
return -1;
}
if (result > sizeof(struct dfu_status)) {
avrdude_message("%s: Error: Oversize read (should not happen); "
avrdude_message(MSG_INFO, "%s: Error: Oversize read (should not happen); "
"exiting\n", progname);
exit(1);
}
if (verbose > 3)
avrdude_message("%s: dfu_getstatus(): bStatus 0x%02x, bwPollTimeout %d, bState 0x%02x, iString %d\n",
progname,
status->bStatus,
status->bwPollTimeout[0] | (status->bwPollTimeout[1] << 8) | (status->bwPollTimeout[2] << 16),
status->bState,
status->iString);
avrdude_message(MSG_TRACE, "%s: dfu_getstatus(): bStatus 0x%02x, bwPollTimeout %d, bState 0x%02x, iString %d\n",
progname,
status->bStatus,
status->bwPollTimeout[0] | (status->bwPollTimeout[1] << 8) | (status->bwPollTimeout[2] << 16),
status->bState,
status->iString);
return 0;
}
@ -312,16 +310,15 @@ int dfu_clrstatus(struct dfu_dev *dfu)
{
int result;
if (verbose > 3)
avrdude_message("%s: dfu_clrstatus(): issuing control OUT message\n",
progname);
avrdude_message(MSG_TRACE, "%s: dfu_clrstatus(): issuing control OUT message\n",
progname);
result = usb_control_msg(dfu->dev_handle,
USB_TYPE_CLASS | USB_RECIP_INTERFACE, DFU_CLRSTATUS, 0, 0,
NULL, 0, dfu->timeout);
if (result < 0) {
avrdude_message("%s: Error: Failed to clear DFU status: %s\n",
avrdude_message(MSG_INFO, "%s: Error: Failed to clear DFU status: %s\n",
progname, usb_strerror());
return -1;
}
@ -333,16 +330,15 @@ int dfu_abort(struct dfu_dev *dfu)
{
int result;
if (verbose > 3)
avrdude_message("%s: dfu_abort(): issuing control OUT message\n",
progname);
avrdude_message(MSG_TRACE, "%s: dfu_abort(): issuing control OUT message\n",
progname);
result = usb_control_msg(dfu->dev_handle,
USB_TYPE_CLASS | USB_RECIP_INTERFACE, DFU_ABORT, 0, 0,
NULL, 0, dfu->timeout);
if (result < 0) {
avrdude_message("%s: Error: Failed to reset DFU state: %s\n",
avrdude_message(MSG_INFO, "%s: Error: Failed to reset DFU state: %s\n",
progname, usb_strerror());
return -1;
}
@ -355,28 +351,27 @@ int dfu_dnload(struct dfu_dev *dfu, void *ptr, int size)
{
int result;
if (verbose > 3)
avrdude_message("%s: dfu_dnload(): issuing control OUT message, wIndex = %d, ptr = %p, size = %d\n",
progname, wIndex, ptr, size);
avrdude_message(MSG_TRACE, "%s: dfu_dnload(): issuing control OUT message, wIndex = %d, ptr = %p, size = %d\n",
progname, wIndex, ptr, size);
result = usb_control_msg(dfu->dev_handle,
USB_TYPE_CLASS | USB_RECIP_INTERFACE, DFU_DNLOAD, wIndex++, 0,
ptr, size, dfu->timeout);
if (result < 0) {
avrdude_message("%s: Error: DFU_DNLOAD failed: %s\n",
avrdude_message(MSG_INFO, "%s: Error: DFU_DNLOAD failed: %s\n",
progname, usb_strerror());
return -1;
}
if (result < size) {
avrdude_message("%s: Error: DFU_DNLOAD failed: %s\n",
avrdude_message(MSG_INFO, "%s: Error: DFU_DNLOAD failed: %s\n",
progname, "short write");
return -1;
}
if (result > size) {
avrdude_message("%s: Error: Oversize write (should not happen); " \
avrdude_message(MSG_INFO, "%s: Error: Oversize write (should not happen); " \
"exiting\n", progname);
exit(1);
}
@ -388,28 +383,27 @@ int dfu_upload(struct dfu_dev *dfu, void *ptr, int size)
{
int result;
if (verbose > 3)
avrdude_message("%s: dfu_upload(): issuing control IN message, wIndex = %d, ptr = %p, size = %d\n",
progname, wIndex, ptr, size);
avrdude_message(MSG_TRACE, "%s: dfu_upload(): issuing control IN message, wIndex = %d, ptr = %p, size = %d\n",
progname, wIndex, ptr, size);
result = usb_control_msg(dfu->dev_handle,
0x80 | USB_TYPE_CLASS | USB_RECIP_INTERFACE, DFU_UPLOAD, wIndex++, 0,
ptr, size, dfu->timeout);
if (result < 0) {
avrdude_message("%s: Error: DFU_UPLOAD failed: %s\n",
avrdude_message(MSG_INFO, "%s: Error: DFU_UPLOAD failed: %s\n",
progname, usb_strerror());
return -1;
}
if (result < size) {
avrdude_message("%s: Error: DFU_UPLOAD failed: %s\n",
avrdude_message(MSG_INFO, "%s: Error: DFU_UPLOAD failed: %s\n",
progname, "short read");
return -1;
}
if (result > size) {
avrdude_message("%s: Error: Oversize read (should not happen); "
avrdude_message(MSG_INFO, "%s: Error: Oversize read (should not happen); "
"exiting\n", progname);
exit(1);
}
@ -420,26 +414,26 @@ int dfu_upload(struct dfu_dev *dfu, void *ptr, int size)
void dfu_show_info(struct dfu_dev *dfu)
{
if (dfu->manf_str != NULL)
avrdude_message(" USB Vendor : %s (0x%04hX)\n",
avrdude_message(MSG_INFO, " USB Vendor : %s (0x%04hX)\n",
dfu->manf_str, (unsigned short) dfu->dev_desc.idVendor);
else
avrdude_message(" USB Vendor : 0x%04hX\n",
avrdude_message(MSG_INFO, " USB Vendor : 0x%04hX\n",
(unsigned short) dfu->dev_desc.idVendor);
if (dfu->prod_str != NULL)
avrdude_message(" USB Product : %s (0x%04hX)\n",
avrdude_message(MSG_INFO, " USB Product : %s (0x%04hX)\n",
dfu->prod_str, (unsigned short) dfu->dev_desc.idProduct);
else
avrdude_message(" USB Product : 0x%04hX\n",
avrdude_message(MSG_INFO, " USB Product : 0x%04hX\n",
(unsigned short) dfu->dev_desc.idProduct);
avrdude_message(" USB Release : %hu.%hu.%hu\n",
avrdude_message(MSG_INFO, " USB Release : %hu.%hu.%hu\n",
((unsigned short) dfu->dev_desc.bcdDevice >> 8) & 0xFF,
((unsigned short) dfu->dev_desc.bcdDevice >> 4) & 0xF,
((unsigned short) dfu->dev_desc.bcdDevice >> 0) & 0xF);
if (dfu->serno_str != NULL)
avrdude_message(" USB Serial No : %s\n", dfu->serno_str);
avrdude_message(MSG_INFO, " USB Serial No : %s\n", dfu->serno_str);
}
/* INTERNAL FUNCTION DEFINITIONS
@ -456,7 +450,7 @@ char * get_usb_string(usb_dev_handle * dev_handle, int index) {
result = usb_get_string_simple(dev_handle, index, buffer, sizeof(buffer)-1);
if (result < 0) {
avrdude_message("%s: Warning: Failed to read USB device string %d: %s\n",
avrdude_message(MSG_INFO, "%s: Warning: Failed to read USB device string %d: %s\n",
progname, index, usb_strerror());
return NULL;
}
@ -464,7 +458,7 @@ char * get_usb_string(usb_dev_handle * dev_handle, int index) {
str = malloc(result+1);
if (str == NULL) {
avrdude_message("%s: Out of memory allocating a string\n", progname);
avrdude_message(MSG_INFO, "%s: Out of memory allocating a string\n", progname);
return 0;
}

156
fileio.c
View File

@ -125,7 +125,7 @@ static int b2ihex(unsigned char * inbuf, int bufsize,
unsigned char cksum;
if (recsize > 255) {
avrdude_message("%s: recsize=%d, must be < 256\n",
avrdude_message(MSG_INFO, "%s: recsize=%d, must be < 256\n",
progname, recsize);
return -1;
}
@ -305,14 +305,14 @@ static int ihex2b(char * infile, FILE * inf,
continue;
rc = ihex_readrec(&ihex, buffer);
if (rc < 0) {
avrdude_message("%s: invalid record at line %d of \"%s\"\n",
avrdude_message(MSG_INFO, "%s: invalid record at line %d of \"%s\"\n",
progname, lineno, infile);
return -1;
}
else if (rc != ihex.cksum) {
avrdude_message("%s: ERROR: checksum mismatch at line %d of \"%s\"\n",
avrdude_message(MSG_INFO, "%s: ERROR: checksum mismatch at line %d of \"%s\"\n",
progname, lineno, infile);
avrdude_message("%s: checksum=0x%02x, computed checksum=0x%02x\n",
avrdude_message(MSG_INFO, "%s: checksum=0x%02x, computed checksum=0x%02x\n",
progname, ihex.cksum, rc);
return -1;
}
@ -320,13 +320,13 @@ static int ihex2b(char * infile, FILE * inf,
switch (ihex.rectyp) {
case 0: /* data record */
if (fileoffset != 0 && baseaddr < fileoffset) {
avrdude_message("%s: ERROR: address 0x%04x out of range (below fileoffset 0x%x) at line %d of %s\n",
avrdude_message(MSG_INFO, "%s: ERROR: address 0x%04x out of range (below fileoffset 0x%x) at line %d of %s\n",
progname, baseaddr, fileoffset, lineno, infile);
return -1;
}
nextaddr = ihex.loadofs + baseaddr - fileoffset;
if (nextaddr + ihex.reclen > bufsize) {
avrdude_message("%s: ERROR: address 0x%04x out of range at line %d of %s\n",
avrdude_message(MSG_INFO, "%s: ERROR: address 0x%04x out of range at line %d of %s\n",
progname, nextaddr+ihex.reclen, lineno, infile);
return -1;
}
@ -359,7 +359,7 @@ static int ihex2b(char * infile, FILE * inf,
break;
default:
avrdude_message("%s: don't know how to deal with rectype=%d "
avrdude_message(MSG_INFO, "%s: don't know how to deal with rectype=%d "
"at line %d of %s\n",
progname, ihex.rectyp, lineno, infile);
return -1;
@ -369,14 +369,14 @@ static int ihex2b(char * infile, FILE * inf,
} /* while */
if (maxaddr == 0) {
avrdude_message("%s: ERROR: No valid record found in Intel Hex "
avrdude_message(MSG_INFO, "%s: ERROR: No valid record found in Intel Hex "
"file \"%s\"\n",
progname, infile);
return -1;
}
else {
avrdude_message("%s: WARNING: no end of file record found for Intel Hex "
avrdude_message(MSG_INFO, "%s: WARNING: no end of file record found for Intel Hex "
"file \"%s\"\n",
progname, infile);
@ -397,7 +397,7 @@ static int b2srec(unsigned char * inbuf, int bufsize,
char * tmpl=0;
if (recsize > 255) {
avrdude_message("%s: ERROR: recsize=%d, must be < 256\n",
avrdude_message(MSG_INFO, "%s: ERROR: recsize=%d, must be < 256\n",
progname, recsize);
return -1;
}
@ -430,7 +430,7 @@ static int b2srec(unsigned char * inbuf, int bufsize,
tmpl="S3%02X%08X";
}
else {
avrdude_message("%s: ERROR: address=%d, out of range\n",
avrdude_message(MSG_INFO, "%s: ERROR: address=%d, out of range\n",
progname, nextaddr);
return -1;
}
@ -595,14 +595,14 @@ static int srec2b(char * infile, FILE * inf,
rc = srec_readrec(&srec, buffer);
if (rc < 0) {
avrdude_message("%s: ERROR: invalid record at line %d of \"%s\"\n",
avrdude_message(MSG_INFO, "%s: ERROR: invalid record at line %d of \"%s\"\n",
progname, lineno, infile);
return -1;
}
else if (rc != srec.cksum) {
avrdude_message("%s: ERROR: checksum mismatch at line %d of \"%s\"\n",
avrdude_message(MSG_INFO, "%s: ERROR: checksum mismatch at line %d of \"%s\"\n",
progname, lineno, infile);
avrdude_message("%s: checksum=0x%02x, computed checksum=0x%02x\n",
avrdude_message(MSG_INFO, "%s: checksum=0x%02x, computed checksum=0x%02x\n",
progname, srec.cksum, rc);
return -1;
}
@ -629,16 +629,16 @@ static int srec2b(char * infile, FILE * inf,
break;
case 0x34: /* S4 - symbol record (LSI extension) */
avrdude_message("%s: ERROR: not supported record at line %d of %s\n",
avrdude_message(MSG_INFO, "%s: ERROR: not supported record at line %d of %s\n",
progname, lineno, infile);
return -1;
case 0x35: /* S5 - count of S1,S2 and S3 records previously tx'd */
if (srec.loadofs != reccount){
avrdude_message("%s: ERROR: count of transmitted data records mismatch "
avrdude_message(MSG_INFO, "%s: ERROR: count of transmitted data records mismatch "
"at line %d of \"%s\"\n",
progname, lineno, infile);
avrdude_message("%s: transmitted data records= %d, expected "
avrdude_message(MSG_INFO, "%s: transmitted data records= %d, expected "
"value= %d\n",
progname, reccount, srec.loadofs);
return -1;
@ -651,7 +651,7 @@ static int srec2b(char * infile, FILE * inf,
return maxaddr;
default:
avrdude_message("%s: ERROR: don't know how to deal with rectype S%d "
avrdude_message(MSG_INFO, "%s: ERROR: don't know how to deal with rectype S%d "
"at line %d of %s\n",
progname, srec.rectyp, lineno, infile);
return -1;
@ -660,14 +660,14 @@ static int srec2b(char * infile, FILE * inf,
if (datarec == 1) {
nextaddr = srec.loadofs;
if (nextaddr < fileoffset) {
avrdude_message(msg, progname, nextaddr,
avrdude_message(MSG_INFO, msg, progname, nextaddr,
"(below fileoffset) ",
lineno, infile);
return -1;
}
nextaddr -= fileoffset;
if (nextaddr + srec.reclen > bufsize) {
avrdude_message(msg, progname, nextaddr+srec.reclen, "",
avrdude_message(MSG_INFO, msg, progname, nextaddr+srec.reclen, "",
lineno, infile);
return -1;
}
@ -682,7 +682,7 @@ static int srec2b(char * infile, FILE * inf,
}
avrdude_message("%s: WARNING: no end of file record found for Motorola S-Records "
avrdude_message(MSG_INFO, "%s: WARNING: no end of file record found for Motorola S-Records "
"file \"%s\"\n",
progname, infile);
@ -727,7 +727,7 @@ static Elf_Scn *elf_get_scn(Elf *e, Elf32_Phdr *ph, Elf32_Shdr **shptr)
Elf32_Shdr *sh;
size_t ndx = elf_ndxscn(s);
if ((sh = elf32_getshdr(s)) == NULL) {
avrdude_message("%s: ERROR: Error reading section #%u header: %s\n",
avrdude_message(MSG_INFO, "%s: ERROR: Error reading section #%u header: %s\n",
progname, (unsigned int)ndx, elf_errmsg(-1));
continue;
}
@ -745,7 +745,7 @@ static Elf_Scn *elf_get_scn(Elf *e, Elf32_Phdr *ph, Elf32_Shdr **shptr)
}
}
avrdude_message("%s: ERROR: Cannot find a matching section for "
avrdude_message(MSG_INFO, "%s: ERROR: Cannot find a matching section for "
"program header entry @p_vaddr 0x%x\n",
progname, ph->p_vaddr);
return NULL;
@ -818,7 +818,7 @@ static int elf2b(char * infile, FILE * inf,
unsigned int low, high, foff;
if (elf_mem_limits(mem, p, &low, &high, &foff) != 0) {
avrdude_message("%s: ERROR: Cannot handle \"%s\" memory region from ELF file\n",
avrdude_message(MSG_INFO, "%s: ERROR: Cannot handle \"%s\" memory region from ELF file\n",
progname, mem->desc);
return -1;
}
@ -836,7 +836,7 @@ static int elf2b(char * infile, FILE * inf,
strcmp(mem->desc, "apptable") == 0)) {
AVRMEM *flashmem = avr_locate_mem(p, "flash");
if (flashmem == NULL) {
avrdude_message("%s: ERROR: No \"flash\" memory region found, "
avrdude_message(MSG_INFO, "%s: ERROR: No \"flash\" memory region found, "
"cannot compute bounds of \"%s\" sub-region.\n",
progname, mem->desc);
return -1;
@ -847,17 +847,17 @@ static int elf2b(char * infile, FILE * inf,
}
if (elf_version(EV_CURRENT) == EV_NONE) {
avrdude_message("%s: ERROR: ELF library initialization failed: %s\n",
avrdude_message(MSG_INFO, "%s: ERROR: ELF library initialization failed: %s\n",
progname, elf_errmsg(-1));
return -1;
}
if ((e = elf_begin(fileno(inf), ELF_C_READ, NULL)) == NULL) {
avrdude_message("%s: ERROR: Cannot open \"%s\" as an ELF file: %s\n",
avrdude_message(MSG_INFO, "%s: ERROR: Cannot open \"%s\" as an ELF file: %s\n",
progname, infile, elf_errmsg(-1));
return -1;
}
if (elf_kind(e) != ELF_K_ELF) {
avrdude_message("%s: ERROR: Cannot use \"%s\" as an ELF input file\n",
avrdude_message(MSG_INFO, "%s: ERROR: Cannot use \"%s\" as an ELF input file\n",
progname, infile);
goto done;
}
@ -866,7 +866,7 @@ static int elf2b(char * infile, FILE * inf,
const char *id = elf_getident(e, &isize);
if (id == NULL) {
avrdude_message("%s: ERROR: Error reading ident area of \"%s\": %s\n",
avrdude_message(MSG_INFO, "%s: ERROR: Error reading ident area of \"%s\": %s\n",
progname, infile, elf_errmsg(-1));
goto done;
}
@ -882,7 +882,7 @@ static int elf2b(char * infile, FILE * inf,
}
if (id[EI_CLASS] != ELFCLASS32 ||
id[EI_DATA] != endianess) {
avrdude_message("%s: ERROR: ELF file \"%s\" is not a "
avrdude_message(MSG_INFO, "%s: ERROR: ELF file \"%s\" is not a "
"32-bit, %s-endian file that was expected\n",
progname, infile, endianname);
goto done;
@ -890,13 +890,13 @@ static int elf2b(char * infile, FILE * inf,
Elf32_Ehdr *eh;
if ((eh = elf32_getehdr(e)) == NULL) {
avrdude_message("%s: ERROR: Error reading ehdr of \"%s\": %s\n",
avrdude_message(MSG_INFO, "%s: ERROR: Error reading ehdr of \"%s\": %s\n",
progname, infile, elf_errmsg(-1));
goto done;
}
if (eh->e_type != ET_EXEC) {
avrdude_message("%s: ERROR: ELF file \"%s\" is not an executable file\n",
avrdude_message(MSG_INFO, "%s: ERROR: ELF file \"%s\" is not an executable file\n",
progname, infile);
goto done;
}
@ -911,12 +911,12 @@ static int elf2b(char * infile, FILE * inf,
mname = "AVR";
}
if (eh->e_machine != machine) {
avrdude_message("%s: ERROR: ELF file \"%s\" is not for machine %s\n",
avrdude_message(MSG_INFO, "%s: ERROR: ELF file \"%s\" is not for machine %s\n",
progname, infile, mname);
goto done;
}
if (eh->e_phnum == 0xffff /* PN_XNUM */) {
avrdude_message("%s: ERROR: ELF file \"%s\" uses extended "
avrdude_message(MSG_INFO, "%s: ERROR: ELF file \"%s\" uses extended "
"program header numbers which are not expected\n",
progname, infile);
goto done;
@ -924,14 +924,14 @@ static int elf2b(char * infile, FILE * inf,
Elf32_Phdr *ph;
if ((ph = elf32_getphdr(e)) == NULL) {
avrdude_message("%s: ERROR: Error reading program header table of \"%s\": %s\n",
avrdude_message(MSG_INFO, "%s: ERROR: Error reading program header table of \"%s\": %s\n",
progname, infile, elf_errmsg(-1));
goto done;
}
size_t sndx;
if (elf_getshdrstrndx(e, &sndx) != 0) {
avrdude_message("%s: ERROR: Error obtaining section name string table: %s\n",
avrdude_message(MSG_INFO, "%s: ERROR: Error obtaining section name string table: %s\n",
progname, elf_errmsg(-1));
sndx = 0;
}
@ -945,11 +945,9 @@ static int elf2b(char * infile, FILE * inf,
ph[i].p_filesz == 0)
continue;
if (verbose >= 2) {
avrdude_message("%s: Considering PT_LOAD program header entry #%d:\n"
" p_vaddr 0x%x, p_paddr 0x%x, p_filesz %d\n",
progname, i, ph[i].p_vaddr, ph[i].p_paddr, ph[i].p_filesz);
}
avrdude_message(MSG_NOTICE2, "%s: Considering PT_LOAD program header entry #%d:\n"
" p_vaddr 0x%x, p_paddr 0x%x, p_filesz %d\n",
progname, i, ph[i].p_vaddr, ph[i].p_paddr, ph[i].p_filesz);
Elf32_Shdr *sh;
Elf_Scn *s = elf_get_scn(e, ph + i, &sh);
@ -968,19 +966,15 @@ static int elf2b(char * infile, FILE * inf,
unsigned int lma;
lma = ph[i].p_paddr + sh->sh_offset - ph[i].p_offset;
if (verbose >= 2) {
avrdude_message("%s: Found section \"%s\", LMA 0x%x, sh_size %u\n",
progname, sname, lma, sh->sh_size);
}
avrdude_message(MSG_NOTICE2, "%s: Found section \"%s\", LMA 0x%x, sh_size %u\n",
progname, sname, lma, sh->sh_size);
if (lma >= low &&
lma + sh->sh_size < high) {
/* OK */
} else {
if (verbose >= 2) {
avrdude_message(" => skipping, inappropriate for \"%s\" memory region\n",
mem->desc);
}
avrdude_message(MSG_NOTICE2, " => skipping, inappropriate for \"%s\" memory region\n",
mem->desc);
continue;
}
/*
@ -993,7 +987,7 @@ static int elf2b(char * infile, FILE * inf,
*/
if (mem->size != 1 &&
sh->sh_size > mem->size) {
avrdude_message("%s: ERROR: section \"%s\" does not fit into \"%s\" memory:\n"
avrdude_message(MSG_INFO, "%s: ERROR: section \"%s\" does not fit into \"%s\" memory:\n"
" 0x%x + %u > %u\n",
progname, sname, mem->desc,
lma, sh->sh_size, mem->size);
@ -1002,22 +996,18 @@ static int elf2b(char * infile, FILE * inf,
Elf_Data *d = NULL;
while ((d = elf_getdata(s, d)) != NULL) {
if (verbose >= 2) {
avrdude_message(" Data block: d_buf %p, d_off 0x%x, d_size %d\n",
d->d_buf, (unsigned int)d->d_off, d->d_size);
}
avrdude_message(MSG_NOTICE2, " Data block: d_buf %p, d_off 0x%x, d_size %d\n",
d->d_buf, (unsigned int)d->d_off, d->d_size);
if (mem->size == 1) {
if (d->d_off != 0) {
avrdude_message("%s: ERROR: unexpected data block at offset != 0\n",
avrdude_message(MSG_INFO, "%s: ERROR: unexpected data block at offset != 0\n",
progname);
} else if (foff >= d->d_size) {
avrdude_message("%s: ERROR: ELF file section does not contain byte at offset %d\n",
avrdude_message(MSG_INFO, "%s: ERROR: ELF file section does not contain byte at offset %d\n",
progname, foff);
} else {
if (verbose >= 2) {
avrdude_message(" Extracting one byte from file offset %d\n",
foff);
}
avrdude_message(MSG_NOTICE2, " Extracting one byte from file offset %d\n",
foff);
mem->buf[0] = ((unsigned char *)d->d_buf)[foff];
mem->tags[0] = TAG_ALLOCATED;
rv = 1;
@ -1028,10 +1018,8 @@ static int elf2b(char * infile, FILE * inf,
idx = lma - low + d->d_off;
if ((int)(idx + d->d_size) > rv)
rv = idx + d->d_size;
if (verbose >= 3) {
avrdude_message(" Writing %d bytes to mem offset 0x%x\n",
d->d_size, idx);
}
avrdude_message(MSG_DEBUG, " Writing %d bytes to mem offset 0x%x\n",
d->d_size, idx);
memcpy(mem->buf + idx, d->d_buf, d->d_size);
memset(mem->tags + idx, TAG_ALLOCATED, d->d_size);
}
@ -1100,13 +1088,13 @@ static int fileio_rbin(struct fioparms * fio,
rc = fwrite(buf, 1, size, f);
break;
default:
avrdude_message("%s: fileio: invalid operation=%d\n",
avrdude_message(MSG_INFO, "%s: fileio: invalid operation=%d\n",
progname, fio->op);
return -1;
}
if (rc < 0 || (fio->op == FIO_WRITE && rc < size)) {
avrdude_message("%s: %s error %s %s: %s; %s %d of the expected %d bytes\n",
avrdude_message(MSG_INFO, "%s: %s error %s %s: %s; %s %d of the expected %d bytes\n",
progname, fio->iodesc, fio->dir, filename, strerror(errno),
fio->rw, rc, size);
return -1;
@ -1135,7 +1123,7 @@ static int fileio_imm(struct fioparms * fio,
strtoul (p, &e, 0):
strtoul (p + 2, &e, 2);
if (*e != 0) {
avrdude_message("%s: invalid byte value (%s) specified for immediate mode\n",
avrdude_message(MSG_INFO, "%s: invalid byte value (%s) specified for immediate mode\n",
progname, p);
return -1;
}
@ -1146,13 +1134,13 @@ static int fileio_imm(struct fioparms * fio,
}
break;
default:
avrdude_message("%s: fileio: invalid operation=%d\n",
avrdude_message(MSG_INFO, "%s: fileio: invalid operation=%d\n",
progname, fio->op);
return -1;
}
if (rc < 0 || (fio->op == FIO_WRITE && rc < size)) {
avrdude_message("%s: %s error %s %s: %s; %s %d of the expected %d bytes\n",
avrdude_message(MSG_INFO, "%s: %s error %s %s: %s; %s %d of the expected %d bytes\n",
progname, fio->iodesc, fio->dir, filename, strerror(errno),
fio->rw, rc, size);
return -1;
@ -1182,7 +1170,7 @@ static int fileio_ihex(struct fioparms * fio,
break;
default:
avrdude_message("%s: invalid Intex Hex file I/O operation=%d\n",
avrdude_message(MSG_INFO, "%s: invalid Intex Hex file I/O operation=%d\n",
progname, fio->op);
return -1;
break;
@ -1212,7 +1200,7 @@ static int fileio_srec(struct fioparms * fio,
break;
default:
avrdude_message("%s: ERROR: invalid Motorola S-Records file I/O "
avrdude_message(MSG_INFO, "%s: ERROR: invalid Motorola S-Records file I/O "
"operation=%d\n",
progname, fio->op);
return -1;
@ -1232,7 +1220,7 @@ static int fileio_elf(struct fioparms * fio,
switch (fio->op) {
case FIO_WRITE:
avrdude_message("%s: ERROR: write operation not (yet) "
avrdude_message(MSG_INFO, "%s: ERROR: write operation not (yet) "
"supported for ELF\n",
progname);
return -1;
@ -1243,7 +1231,7 @@ static int fileio_elf(struct fioparms * fio,
return rc;
default:
avrdude_message("%s: ERROR: invalid ELF file I/O "
avrdude_message(MSG_INFO, "%s: ERROR: invalid ELF file I/O "
"operation=%d\n",
progname, fio->op);
return -1;
@ -1289,7 +1277,7 @@ static int fileio_num(struct fioparms * fio,
case FIO_WRITE:
break;
default:
avrdude_message("%s: fileio: invalid operation=%d\n",
avrdude_message(MSG_INFO, "%s: fileio: invalid operation=%d\n",
progname, fio->op);
return -1;
}
@ -1319,7 +1307,7 @@ static int fileio_num(struct fioparms * fio,
return 0;
writeerr:
avrdude_message("%s: error writing to %s: %s\n",
avrdude_message(MSG_INFO, "%s: error writing to %s: %s\n",
progname, filename, strerror(errno));
return -1;
}
@ -1346,7 +1334,7 @@ int fileio_setparms(int op, struct fioparms * fp,
break;
default:
avrdude_message("%s: invalid I/O operation %d\n",
avrdude_message(MSG_INFO, "%s: invalid I/O operation %d\n",
progname, op);
return -1;
break;
@ -1385,7 +1373,7 @@ static int fmt_autodetect(char * fname)
f = fopen(fname, "rb");
#endif
if (f == NULL) {
avrdude_message("%s: error opening %s: %s\n",
avrdude_message(MSG_INFO, "%s: error opening %s: %s\n",
progname, fname, strerror(errno));
return -1;
}
@ -1468,7 +1456,7 @@ int fileio(int op, char * filename, FILEFMT format,
mem = avr_locate_mem(p, memtype);
if (mem == NULL) {
avrdude_message("fileio(): memory type \"%s\" not configured for device \"%s\"\n",
avrdude_message(MSG_INFO, "fileio(): memory type \"%s\" not configured for device \"%s\"\n",
memtype, p->desc);
return -1;
}
@ -1506,7 +1494,7 @@ int fileio(int op, char * filename, FILEFMT format,
if (format == FMT_AUTO) {
if (using_stdio) {
avrdude_message("%s: can't auto detect file format when using stdin/out.\n"
avrdude_message(MSG_INFO, "%s: can't auto detect file format when using stdin/out.\n"
"%s Please specify a file format and try again.\n",
progname, progbuf);
return -1;
@ -1514,13 +1502,13 @@ int fileio(int op, char * filename, FILEFMT format,
format = fmt_autodetect(fname);
if (format < 0) {
avrdude_message("%s: can't determine file format for %s, specify explicitly\n",
avrdude_message(MSG_INFO, "%s: can't determine file format for %s, specify explicitly\n",
progname, fname);
return -1;
}
if (quell_progress < 2) {
avrdude_message("%s: %s file %s auto detected as %s\n",
avrdude_message(MSG_INFO, "%s: %s file %s auto detected as %s\n",
progname, fio.iodesc, fname, fmtstr(format));
}
}
@ -1544,7 +1532,7 @@ int fileio(int op, char * filename, FILEFMT format,
if (!using_stdio) {
f = fopen(fname, fio.mode);
if (f == NULL) {
avrdude_message("%s: can't open %s file %s: %s\n",
avrdude_message(MSG_INFO, "%s: can't open %s file %s: %s\n",
progname, fio.iodesc, fname, strerror(errno));
return -1;
}
@ -1568,7 +1556,7 @@ int fileio(int op, char * filename, FILEFMT format,
#ifdef HAVE_LIBELF
rc = fileio_elf(&fio, fname, f, mem, p, size);
#else
avrdude_message("%s: can't handle ELF file %s, "
avrdude_message(MSG_INFO, "%s: can't handle ELF file %s, "
"ELF file support was not compiled in\n",
progname, fname);
rc = -1;
@ -1587,7 +1575,7 @@ int fileio(int op, char * filename, FILEFMT format,
break;
default:
avrdude_message("%s: invalid %s file format: %d\n",
avrdude_message(MSG_INFO, "%s: invalid %s file format: %d\n",
progname, fio.iodesc, format);
return -1;
}

94
flip1.c
View File

@ -243,13 +243,13 @@ int flip1_initialize(PROGRAMMER* pgm, AVRPART *part)
if (usbpid) {
pid = *(int *)(ldata(usbpid));
if (lnext(usbpid))
avrdude_message("%s: Warning: using PID 0x%04x, ignoring remaining PIDs in list\n",
avrdude_message(MSG_INFO, "%s: Warning: using PID 0x%04x, ignoring remaining PIDs in list\n",
progname, pid);
} else {
pid = part->usbpid;
}
if (!ovsigck && (part->flags & AVRPART_HAS_PDI)) {
avrdude_message("%s: \"flip1\" (FLIP protocol version 1) is for AT90USB* and ATmega*U* devices.\n"
avrdude_message(MSG_INFO, "%s: \"flip1\" (FLIP protocol version 1) is for AT90USB* and ATmega*U* devices.\n"
"%s For Xmega devices, use \"flip2\".\n"
"%s (Use -F to bypass this check.)\n",
progname, progbuf, progbuf);
@ -264,31 +264,31 @@ int flip1_initialize(PROGRAMMER* pgm, AVRPART *part)
/* Check if descriptor values are what we expect. */
if (dfu->dev_desc.idVendor != vid)
avrdude_message("%s: Warning: USB idVendor = 0x%04X (expected 0x%04X)\n",
avrdude_message(MSG_INFO, "%s: Warning: USB idVendor = 0x%04X (expected 0x%04X)\n",
progname, dfu->dev_desc.idVendor, vid);
if (pid != 0 && dfu->dev_desc.idProduct != pid)
avrdude_message("%s: Warning: USB idProduct = 0x%04X (expected 0x%04X)\n",
avrdude_message(MSG_INFO, "%s: Warning: USB idProduct = 0x%04X (expected 0x%04X)\n",
progname, dfu->dev_desc.idProduct, pid);
if (dfu->dev_desc.bNumConfigurations != 1)
avrdude_message("%s: Warning: USB bNumConfigurations = %d (expected 1)\n",
avrdude_message(MSG_INFO, "%s: Warning: USB bNumConfigurations = %d (expected 1)\n",
progname, (int) dfu->dev_desc.bNumConfigurations);
if (dfu->conf_desc.bNumInterfaces != 1)
avrdude_message("%s: Warning: USB bNumInterfaces = %d (expected 1)\n",
avrdude_message(MSG_INFO, "%s: Warning: USB bNumInterfaces = %d (expected 1)\n",
progname, (int) dfu->conf_desc.bNumInterfaces);
if (dfu->dev_desc.bDeviceClass != 254)
avrdude_message("%s: Warning: USB bDeviceClass = %d (expected 254)\n",
avrdude_message(MSG_INFO, "%s: Warning: USB bDeviceClass = %d (expected 254)\n",
progname, (int) dfu->dev_desc.bDeviceClass);
if (dfu->dev_desc.bDeviceSubClass != 1)
avrdude_message("%s: Warning: USB bDeviceSubClass = %d (expected 1)\n",
avrdude_message(MSG_INFO, "%s: Warning: USB bDeviceSubClass = %d (expected 1)\n",
progname, (int) dfu->dev_desc.bDeviceSubClass);
if (dfu->dev_desc.bDeviceProtocol != 0)
avrdude_message("%s: Warning: USB bDeviceProtocol = %d (expected 0)\n",
avrdude_message(MSG_INFO, "%s: Warning: USB bDeviceProtocol = %d (expected 0)\n",
progname, (int) dfu->dev_desc.bDeviceProtocol);
/*
@ -299,20 +299,20 @@ int flip1_initialize(PROGRAMMER* pgm, AVRPART *part)
*/
if (0) {
if (dfu->intf_desc.bInterfaceClass != 254)
avrdude_message("%s: Warning: USB bInterfaceClass = %d (expected 254)\n",
avrdude_message(MSG_INFO, "%s: Warning: USB bInterfaceClass = %d (expected 254)\n",
progname, (int) dfu->intf_desc.bInterfaceClass);
if (dfu->intf_desc.bInterfaceSubClass != 1)
avrdude_message("%s: Warning: USB bInterfaceSubClass = %d (expected 1)\n",
avrdude_message(MSG_INFO, "%s: Warning: USB bInterfaceSubClass = %d (expected 1)\n",
progname, (int) dfu->intf_desc.bInterfaceSubClass);
if (dfu->intf_desc.bInterfaceProtocol != 0)
avrdude_message("%s: Warning: USB bInterfaceSubClass = %d (expected 0)\n",
avrdude_message(MSG_INFO, "%s: Warning: USB bInterfaceSubClass = %d (expected 0)\n",
progname, (int) dfu->intf_desc.bInterfaceProtocol);
}
if (dfu->dev_desc.bMaxPacketSize0 != 32)
avrdude_message("%s: Warning: bMaxPacketSize0 (%d) != 32, things might go wrong\n",
avrdude_message(MSG_INFO, "%s: Warning: bMaxPacketSize0 (%d) != 32, things might go wrong\n",
progname, dfu->dev_desc.bMaxPacketSize0);
if (verbose)
@ -368,8 +368,7 @@ int flip1_chip_erase(PROGRAMMER* pgm, AVRPART *part)
int aux_result;
unsigned int default_timeout = FLIP1(pgm)->dfu->timeout;
if (verbose > 1)
avrdude_message("%s: flip_chip_erase()\n", progname);
avrdude_message(MSG_NOTICE2, "%s: flip_chip_erase()\n", progname);
struct flip1_cmd cmd = {
FLIP1_CMD_WRITE_COMMAND, { 0, 0xff }
@ -384,7 +383,7 @@ int flip1_chip_erase(PROGRAMMER* pgm, AVRPART *part)
return -1;
if (status.bStatus != DFU_STATUS_OK) {
avrdude_message("%s: failed to send chip erase command: %s\n",
avrdude_message(MSG_INFO, "%s: failed to send chip erase command: %s\n",
progname, flip1_status_str(&status));
if (status.bState == STATE_dfuERROR)
dfu_clrstatus(FLIP1(pgm)->dfu);
@ -406,7 +405,7 @@ int flip1_read_byte(PROGRAMMER* pgm, AVRPART *part, AVRMEM *mem,
if (flip1_read_sig_bytes(pgm, part, mem) < 0)
return -1;
if (addr > mem->size) {
avrdude_message("%s: flip1_read_byte(signature): address %lu out of range\n",
avrdude_message(MSG_INFO, "%s: flip1_read_byte(signature): address %lu out of range\n",
progname, addr);
return -1;
}
@ -417,10 +416,10 @@ int flip1_read_byte(PROGRAMMER* pgm, AVRPART *part, AVRMEM *mem,
mem_unit = flip1_mem_unit(mem->desc);
if (mem_unit == FLIP1_MEM_UNIT_UNKNOWN) {
avrdude_message("%s: Error: "
avrdude_message(MSG_INFO, "%s: Error: "
"\"%s\" memory not accessible using FLIP",
progname, mem->desc);
avrdude_message("\n");
avrdude_message(MSG_INFO, "\n");
return -1;
}
@ -442,10 +441,10 @@ int flip1_write_byte(PROGRAMMER* pgm, AVRPART *part, AVRMEM *mem,
mem_unit = flip1_mem_unit(mem->desc);
if (mem_unit == FLIP1_MEM_UNIT_UNKNOWN) {
avrdude_message("%s: Error: "
avrdude_message(MSG_INFO, "%s: Error: "
"\"%s\" memory not accessible using FLIP",
progname, mem->desc);
avrdude_message("\n");
avrdude_message(MSG_INFO, "\n");
return -1;
}
@ -463,10 +462,10 @@ int flip1_paged_load(PROGRAMMER* pgm, AVRPART *part, AVRMEM *mem,
mem_unit = flip1_mem_unit(mem->desc);
if (mem_unit == FLIP1_MEM_UNIT_UNKNOWN) {
avrdude_message("%s: Error: "
avrdude_message(MSG_INFO, "%s: Error: "
"\"%s\" memory not accessible using FLIP",
progname, mem->desc);
avrdude_message("\n");
avrdude_message(MSG_INFO, "\n");
return -1;
}
@ -489,16 +488,16 @@ int flip1_paged_write(PROGRAMMER* pgm, AVRPART *part, AVRMEM *mem,
mem_unit = flip1_mem_unit(mem->desc);
if (mem_unit == FLIP1_MEM_UNIT_UNKNOWN) {
avrdude_message("%s: Error: "
avrdude_message(MSG_INFO, "%s: Error: "
"\"%s\" memory not accessible using FLIP",
progname, mem->desc);
avrdude_message("\n");
avrdude_message(MSG_INFO, "\n");
return -1;
}
if (n_bytes > INT_MAX) {
/* This should never happen, unless the int type is only 16 bits. */
avrdude_message("%s: Error: Attempting to read more than %d bytes\n",
avrdude_message(MSG_INFO, "%s: Error: Attempting to read more than %d bytes\n",
progname, INT_MAX);
exit(1);
}
@ -511,14 +510,13 @@ int flip1_paged_write(PROGRAMMER* pgm, AVRPART *part, AVRMEM *mem,
int flip1_read_sig_bytes(PROGRAMMER* pgm, AVRPART *part, AVRMEM *mem)
{
if (verbose > 1)
avrdude_message("%s: flip1_read_sig_bytes(): ", progname);
avrdude_message(MSG_NOTICE2, "%s: flip1_read_sig_bytes(): ", progname);
if (FLIP1(pgm)->dfu == NULL)
return -1;
if (mem->size < sizeof(FLIP1(pgm)->part_sig)) {
avrdude_message("%s: Error: Signature read must be at least %u bytes\n",
avrdude_message(MSG_INFO, "%s: Error: Signature read must be at least %u bytes\n",
progname, (unsigned int) sizeof(FLIP1(pgm)->part_sig));
return -1;
}
@ -536,8 +534,7 @@ int flip1_read_sig_bytes(PROGRAMMER* pgm, AVRPART *part, AVRMEM *mem)
FLIP1_CMD_READ_COMMAND, FLIP1_READ_FAMILY_CODE
};
if (verbose > 1)
avrdude_message("from device\n");
avrdude_message(MSG_NOTICE2, "from device\n");
for (i = 0; i < 3; i++)
{
@ -554,7 +551,7 @@ int flip1_read_sig_bytes(PROGRAMMER* pgm, AVRPART *part, AVRMEM *mem)
if (status.bStatus != DFU_STATUS_OK)
{
avrdude_message("%s: failed to send cmd for signature byte %d: %s\n",
avrdude_message(MSG_INFO, "%s: failed to send cmd for signature byte %d: %s\n",
progname, i, flip1_status_str(&status));
if (status.bState == STATE_dfuERROR)
dfu_clrstatus(FLIP1(pgm)->dfu);
@ -569,7 +566,7 @@ int flip1_read_sig_bytes(PROGRAMMER* pgm, AVRPART *part, AVRMEM *mem)
if (status.bStatus != DFU_STATUS_OK)
{
avrdude_message("%s: failed to read signature byte %d: %s\n",
avrdude_message(MSG_INFO, "%s: failed to read signature byte %d: %s\n",
progname, i, flip1_status_str(&status));
if (status.bState == STATE_dfuERROR)
dfu_clrstatus(FLIP1(pgm)->dfu);
@ -579,8 +576,7 @@ int flip1_read_sig_bytes(PROGRAMMER* pgm, AVRPART *part, AVRMEM *mem)
}
else
{
if (verbose > 1)
avrdude_message("cached\n");
avrdude_message(MSG_NOTICE2, "cached\n");
}
memcpy(mem->buf, FLIP1(pgm)->part_sig, sizeof(FLIP1(pgm)->part_sig));
@ -593,7 +589,7 @@ void flip1_setup(PROGRAMMER * pgm)
pgm->cookie = calloc(1, sizeof(struct flip1));
if (pgm->cookie == NULL) {
avrdude_message("%s: Out of memory allocating private data structure\n",
avrdude_message(MSG_INFO, "%s: Out of memory allocating private data structure\n",
progname);
exit(1);
}
@ -611,7 +607,7 @@ void flip1_teardown(PROGRAMMER * pgm)
void flip1_show_info(struct flip1 *flip1)
{
dfu_show_info(flip1->dfu);
avrdude_message(" USB max packet size : %hu\n",
avrdude_message(MSG_INFO, " USB max packet size : %hu\n",
(unsigned short) flip1->dfu->dev_desc.bMaxPacketSize0);
}
@ -629,9 +625,8 @@ int flip1_read_memory(PROGRAMMER * pgm,
unsigned int default_timeout = dfu->timeout;
if (verbose > 1)
avrdude_message("%s: flip_read_memory(%s, 0x%04x, %d)\n",
progname, flip1_mem_unit_str(mem_unit), addr, size);
avrdude_message(MSG_NOTICE2, "%s: flip_read_memory(%s, 0x%04x, %d)\n",
progname, flip1_mem_unit_str(mem_unit), addr, size);
/*
* As this function is called once per page, no need to handle 64
@ -661,7 +656,7 @@ int flip1_read_memory(PROGRAMMER * pgm,
if (status.bStatus != DFU_STATUS_OK)
{
avrdude_message("%s: failed to read %u bytes of %s memory @%u: %s\n",
avrdude_message(MSG_INFO, "%s: failed to read %u bytes of %s memory @%u: %s\n",
progname, size, flip1_mem_unit_str(mem_unit), addr,
flip1_status_str(&status));
if (status.bState == STATE_dfuERROR)
@ -675,7 +670,7 @@ int flip1_read_memory(PROGRAMMER * pgm,
if (cmd_result < 0 && aux_result == 0 &&
status.bStatus == DFU_STATUS_ERR_WRITE) {
if (FLIP1(pgm)->security_mode_flag == 0)
avrdude_message("\n%s:\n"
avrdude_message(MSG_INFO, "\n%s:\n"
"%s***********************************************************************\n"
"%sMaybe the device is in ``security mode´´, and needs a chip erase first?\n"
"%s***********************************************************************\n"
@ -689,7 +684,7 @@ int flip1_read_memory(PROGRAMMER * pgm,
if (status.bStatus != DFU_STATUS_OK)
{
avrdude_message("%s: failed to read %u bytes of %s memory @%u: %s\n",
avrdude_message(MSG_INFO, "%s: failed to read %u bytes of %s memory @%u: %s\n",
progname, size, flip1_mem_unit_str(mem_unit), addr,
flip1_status_str(&status));
if (status.bState == STATE_dfuERROR)
@ -723,14 +718,13 @@ int flip1_write_memory(struct dfu_dev *dfu,
unsigned int default_timeout = dfu->timeout;
unsigned char *buf;
if (verbose > 1)
avrdude_message("%s: flip_write_memory(%s, 0x%04x, %d)\n",
progname, flip1_mem_unit_str(mem_unit), addr, size);
avrdude_message(MSG_NOTICE2, "%s: flip_write_memory(%s, 0x%04x, %d)\n",
progname, flip1_mem_unit_str(mem_unit), addr, size);
if (size < 32) {
/* presumably single-byte updates; must be padded to USB endpoint size */
if ((addr + size - 1) / 32 != addr / 32) {
avrdude_message("%s: flip_write_memory(): begin (0x%x) and end (0x%x) not within same 32-byte block\n",
avrdude_message(MSG_INFO, "%s: flip_write_memory(): begin (0x%x) and end (0x%x) not within same 32-byte block\n",
progname, addr, addr + size - 1);
return -1;
}
@ -742,7 +736,7 @@ int flip1_write_memory(struct dfu_dev *dfu,
if ((buf = malloc(sizeof(struct flip1_cmd_header) +
write_size +
sizeof(struct flip1_prog_footer))) == 0) {
avrdude_message("%s: Out of memory\n", progname);
avrdude_message(MSG_INFO, "%s: Out of memory\n", progname);
return -1;
}
@ -791,7 +785,7 @@ int flip1_write_memory(struct dfu_dev *dfu,
if (status.bStatus != DFU_STATUS_OK)
{
avrdude_message("%s: failed to write %u bytes of %s memory @%u: %s\n",
avrdude_message(MSG_INFO, "%s: failed to write %u bytes of %s memory @%u: %s\n",
progname, size, flip1_mem_unit_str(mem_unit), addr,
flip1_status_str(&status));
if (status.bState == STATE_dfuERROR)
@ -822,7 +816,7 @@ int flip1_set_mem_page(struct dfu_dev *dfu,
if (status.bStatus != DFU_STATUS_OK)
{
avrdude_message("%s: failed to set memory page: %s\n",
avrdude_message(MSG_INFO, "%s: failed to set memory page: %s\n",
progname, flip1_status_str(&status));
if (status.bState == STATE_dfuERROR)
dfu_clrstatus(dfu);

119
flip2.c
View File

@ -236,14 +236,14 @@ int flip2_initialize(PROGRAMMER* pgm, AVRPART *part)
if (usbpid) {
pid = *(int *)(ldata(usbpid));
if (lnext(usbpid))
avrdude_message("%s: Warning: using PID 0x%04x, ignoring remaining PIDs in list\n",
avrdude_message(MSG_INFO, "%s: Warning: using PID 0x%04x, ignoring remaining PIDs in list\n",
progname, pid);
} else {
pid = part->usbpid;
}
if (!ovsigck && !(part->flags & AVRPART_HAS_PDI)) {
avrdude_message("%s: \"flip2\" (FLIP protocol version 2) is for Xmega devices.\n"
avrdude_message(MSG_INFO, "%s: \"flip2\" (FLIP protocol version 2) is for Xmega devices.\n"
"%s For AT90USB* or ATmega*U* devices, use \"flip1\".\n"
"%s (Use -F to bypass this check.)\n",
progname, progbuf, progbuf);
@ -258,43 +258,43 @@ int flip2_initialize(PROGRAMMER* pgm, AVRPART *part)
/* Check if descriptor values are what we expect. */
if (dfu->dev_desc.idVendor != vid)
avrdude_message("%s: Warning: USB idVendor = 0x%04X (expected 0x%04X)\n",
avrdude_message(MSG_INFO, "%s: Warning: USB idVendor = 0x%04X (expected 0x%04X)\n",
progname, dfu->dev_desc.idVendor, vid);
if (pid != 0 && dfu->dev_desc.idProduct != pid)
avrdude_message("%s: Warning: USB idProduct = 0x%04X (expected 0x%04X)\n",
avrdude_message(MSG_INFO, "%s: Warning: USB idProduct = 0x%04X (expected 0x%04X)\n",
progname, dfu->dev_desc.idProduct, pid);
if (dfu->dev_desc.bNumConfigurations != 1)
avrdude_message("%s: Warning: USB bNumConfigurations = %d (expected 1)\n",
avrdude_message(MSG_INFO, "%s: Warning: USB bNumConfigurations = %d (expected 1)\n",
progname, (int) dfu->dev_desc.bNumConfigurations);
if (dfu->conf_desc.bNumInterfaces != 1)
avrdude_message("%s: Warning: USB bNumInterfaces = %d (expected 1)\n",
avrdude_message(MSG_INFO, "%s: Warning: USB bNumInterfaces = %d (expected 1)\n",
progname, (int) dfu->conf_desc.bNumInterfaces);
if (dfu->dev_desc.bDeviceClass != 0)
avrdude_message("%s: Warning: USB bDeviceClass = %d (expected 0)\n",
avrdude_message(MSG_INFO, "%s: Warning: USB bDeviceClass = %d (expected 0)\n",
progname, (int) dfu->dev_desc.bDeviceClass);
if (dfu->dev_desc.bDeviceSubClass != 0)
avrdude_message("%s: Warning: USB bDeviceSubClass = %d (expected 0)\n",
avrdude_message(MSG_INFO, "%s: Warning: USB bDeviceSubClass = %d (expected 0)\n",
progname, (int) dfu->dev_desc.bDeviceSubClass);
if (dfu->dev_desc.bDeviceProtocol != 0)
avrdude_message("%s: Warning: USB bDeviceProtocol = %d (expected 0)\n",
avrdude_message(MSG_INFO, "%s: Warning: USB bDeviceProtocol = %d (expected 0)\n",
progname, (int) dfu->dev_desc.bDeviceProtocol);
if (dfu->intf_desc.bInterfaceClass != 0xFF)
avrdude_message("%s: Warning: USB bInterfaceClass = %d (expected 255)\n",
avrdude_message(MSG_INFO, "%s: Warning: USB bInterfaceClass = %d (expected 255)\n",
progname, (int) dfu->intf_desc.bInterfaceClass);
if (dfu->intf_desc.bInterfaceSubClass != 0)
avrdude_message("%s: Warning: USB bInterfaceSubClass = %d (expected 0)\n",
avrdude_message(MSG_INFO, "%s: Warning: USB bInterfaceSubClass = %d (expected 0)\n",
progname, (int) dfu->intf_desc.bInterfaceSubClass);
if (dfu->intf_desc.bInterfaceProtocol != 0)
avrdude_message("%s: Warning: USB bInterfaceSubClass = %d (expected 0)\n",
avrdude_message(MSG_INFO, "%s: Warning: USB bInterfaceSubClass = %d (expected 0)\n",
progname, (int) dfu->intf_desc.bInterfaceProtocol);
result = flip2_read_memory(FLIP2(pgm)->dfu,
@ -359,8 +359,7 @@ int flip2_chip_erase(PROGRAMMER* pgm, AVRPART *part)
int cmd_result = 0;
int aux_result;
if (verbose > 1)
avrdude_message("%s: flip_chip_erase()\n", progname);
avrdude_message(MSG_NOTICE2, "%s: flip_chip_erase()\n", progname);
struct flip2_cmd cmd = {
FLIP2_CMD_GROUP_EXEC, FLIP2_CMD_CHIP_ERASE, { 0xFF, 0, 0, 0 }
@ -379,7 +378,7 @@ int flip2_chip_erase(PROGRAMMER* pgm, AVRPART *part)
{
continue;
} else
avrdude_message("%s: Error: DFU status %s\n", progname,
avrdude_message(MSG_INFO, "%s: Error: DFU status %s\n", progname,
flip2_status_str(&status));
dfu_clrstatus(FLIP2(pgm)->dfu);
} else
@ -400,12 +399,12 @@ int flip2_read_byte(PROGRAMMER* pgm, AVRPART *part, AVRMEM *mem,
mem_unit = flip2_mem_unit(mem->desc);
if (mem_unit == FLIP2_MEM_UNIT_UNKNOWN) {
avrdude_message("%s: Error: "
avrdude_message(MSG_INFO, "%s: Error: "
"\"%s\" memory not accessible using FLIP",
progname, mem->desc);
if (strcmp(mem->desc, "flash") == 0)
avrdude_message(" (did you mean \"application\"?)");
avrdude_message("\n");
avrdude_message(MSG_INFO, " (did you mean \"application\"?)");
avrdude_message(MSG_INFO, "\n");
return -1;
}
@ -423,12 +422,12 @@ int flip2_write_byte(PROGRAMMER* pgm, AVRPART *part, AVRMEM *mem,
mem_unit = flip2_mem_unit(mem->desc);
if (mem_unit == FLIP2_MEM_UNIT_UNKNOWN) {
avrdude_message("%s: Error: "
avrdude_message(MSG_INFO, "%s: Error: "
"\"%s\" memory not accessible using FLIP",
progname, mem->desc);
if (strcmp(mem->desc, "flash") == 0)
avrdude_message(" (did you mean \"application\"?)");
avrdude_message("\n");
avrdude_message(MSG_INFO, " (did you mean \"application\"?)");
avrdude_message(MSG_INFO, "\n");
return -1;
}
@ -447,18 +446,18 @@ int flip2_paged_load(PROGRAMMER* pgm, AVRPART *part, AVRMEM *mem,
mem_unit = flip2_mem_unit(mem->desc);
if (mem_unit == FLIP2_MEM_UNIT_UNKNOWN) {
avrdude_message("%s: Error: "
avrdude_message(MSG_INFO, "%s: Error: "
"\"%s\" memory not accessible using FLIP",
progname, mem->desc);
if (strcmp(mem->desc, "flash") == 0)
avrdude_message(" (did you mean \"application\"?)");
avrdude_message("\n");
avrdude_message(MSG_INFO, " (did you mean \"application\"?)");
avrdude_message(MSG_INFO, "\n");
return -1;
}
if (n_bytes > INT_MAX) {
/* This should never happen, unless the int type is only 16 bits. */
avrdude_message("%s: Error: Attempting to read more than %d bytes\n",
avrdude_message(MSG_INFO, "%s: Error: Attempting to read more than %d bytes\n",
progname, INT_MAX);
exit(1);
}
@ -481,18 +480,18 @@ int flip2_paged_write(PROGRAMMER* pgm, AVRPART *part, AVRMEM *mem,
mem_unit = flip2_mem_unit(mem->desc);
if (mem_unit == FLIP2_MEM_UNIT_UNKNOWN) {
avrdude_message("%s: Error: "
avrdude_message(MSG_INFO, "%s: Error: "
"\"%s\" memory not accessible using FLIP",
progname, mem->desc);
if (strcmp(mem->desc, "flash") == 0)
avrdude_message(" (did you mean \"application\"?)");
avrdude_message("\n");
avrdude_message(MSG_INFO, " (did you mean \"application\"?)");
avrdude_message(MSG_INFO, "\n");
return -1;
}
if (n_bytes > INT_MAX) {
/* This should never happen, unless the int type is only 16 bits. */
avrdude_message("%s: Error: Attempting to read more than %d bytes\n",
avrdude_message(MSG_INFO, "%s: Error: Attempting to read more than %d bytes\n",
progname, INT_MAX);
exit(1);
}
@ -509,7 +508,7 @@ int flip2_read_sig_bytes(PROGRAMMER* pgm, AVRPART *part, AVRMEM *mem)
return -1;
if (mem->size < sizeof(FLIP2(pgm)->part_sig)) {
avrdude_message("%s: Error: Signature read must be at least %u bytes\n",
avrdude_message(MSG_INFO, "%s: Error: Signature read must be at least %u bytes\n",
progname, (unsigned int) sizeof(FLIP2(pgm)->part_sig));
return -1;
}
@ -523,7 +522,7 @@ void flip2_setup(PROGRAMMER * pgm)
pgm->cookie = calloc(1, sizeof(struct flip2));
if (pgm->cookie == NULL) {
avrdude_message("%s: Out of memory allocating private data structure\n",
avrdude_message(MSG_INFO, "%s: Out of memory allocating private data structure\n",
progname);
exit(1);
}
@ -542,24 +541,24 @@ void flip2_show_info(struct flip2 *flip2)
{
dfu_show_info(flip2->dfu);
avrdude_message(" Part signature : 0x%02X%02X%02X\n",
avrdude_message(MSG_INFO, " Part signature : 0x%02X%02X%02X\n",
(int) flip2->part_sig[0],
(int) flip2->part_sig[1],
(int) flip2->part_sig[2]);
if (flip2->part_rev < 26)
avrdude_message(" Part revision : %c\n",
avrdude_message(MSG_INFO, " Part revision : %c\n",
(char) (flip2->part_rev + 'A'));
else
avrdude_message(" Part revision : %c%c\n",
avrdude_message(MSG_INFO, " Part revision : %c%c\n",
(char) (flip2->part_rev / 26 - 1 + 'A'),
(char) (flip2->part_rev % 26 + 'A'));
avrdude_message(" Bootloader version : 2.%hu.%hu\n",
avrdude_message(MSG_INFO, " Bootloader version : 2.%hu.%hu\n",
((unsigned short) flip2->boot_ver >> 4) & 0xF,
((unsigned short) flip2->boot_ver >> 0) & 0xF);
avrdude_message(" USB max packet size : %hu\n",
avrdude_message(MSG_INFO, " USB max packet size : %hu\n",
(unsigned short) flip2->dfu->dev_desc.bMaxPacketSize0);
}
@ -572,18 +571,17 @@ int flip2_read_memory(struct dfu_dev *dfu,
int read_size;
int result;
if (verbose > 1)
avrdude_message("%s: flip_read_memory(%s, 0x%04x, %d)\n",
progname, flip2_mem_unit_str(mem_unit), addr, size);
avrdude_message(MSG_NOTICE2, "%s: flip_read_memory(%s, 0x%04x, %d)\n",
progname, flip2_mem_unit_str(mem_unit), addr, size);
result = flip2_set_mem_unit(dfu, mem_unit);
if (result != 0) {
if ((mem_name = flip2_mem_unit_str(mem_unit)) != NULL)
avrdude_message("%s: Error: Failed to set memory unit 0x%02X (%s)\n",
avrdude_message(MSG_INFO, "%s: Error: Failed to set memory unit 0x%02X (%s)\n",
progname, (int) mem_unit, mem_name);
else
avrdude_message("%s: Error: Failed to set memory unit 0x%02X\n",
avrdude_message(MSG_INFO, "%s: Error: Failed to set memory unit 0x%02X\n",
progname, (int) mem_unit);
return -1;
}
@ -592,7 +590,7 @@ int flip2_read_memory(struct dfu_dev *dfu,
result = flip2_set_mem_page(dfu, page_addr);
if (result != 0) {
avrdude_message("%s: Error: Failed to set memory page 0x%04hX\n",
avrdude_message(MSG_INFO, "%s: Error: Failed to set memory page 0x%04hX\n",
progname, page_addr);
return -1;
}
@ -604,7 +602,7 @@ int flip2_read_memory(struct dfu_dev *dfu,
if (page_addr != prev_page_addr) {
result = flip2_set_mem_page(dfu, page_addr);
if (result != 0) {
avrdude_message("%s: Error: Failed to set memory page 0x%04hX\n",
avrdude_message(MSG_INFO, "%s: Error: Failed to set memory page 0x%04hX\n",
progname, page_addr);
return -1;
}
@ -614,7 +612,7 @@ int flip2_read_memory(struct dfu_dev *dfu,
result = flip2_read_max1k(dfu, addr & 0xFFFF, ptr, read_size);
if (result != 0) {
avrdude_message("%s: Error: Failed to read 0x%04X bytes at 0x%04lX\n",
avrdude_message(MSG_INFO, "%s: Error: Failed to read 0x%04X bytes at 0x%04lX\n",
progname, read_size, (unsigned long) addr);
return -1;
}
@ -636,18 +634,17 @@ int flip2_write_memory(struct dfu_dev *dfu,
int write_size;
int result;
if (verbose > 1)
avrdude_message("%s: flip_write_memory(%s, 0x%04x, %d)\n",
progname, flip2_mem_unit_str(mem_unit), addr, size);
avrdude_message(MSG_NOTICE2, "%s: flip_write_memory(%s, 0x%04x, %d)\n",
progname, flip2_mem_unit_str(mem_unit), addr, size);
result = flip2_set_mem_unit(dfu, mem_unit);
if (result != 0) {
if ((mem_name = flip2_mem_unit_str(mem_unit)) != NULL)
avrdude_message("%s: Error: Failed to set memory unit 0x%02X (%s)\n",
avrdude_message(MSG_INFO, "%s: Error: Failed to set memory unit 0x%02X (%s)\n",
progname, (int) mem_unit, mem_name);
else
avrdude_message("%s: Error: Failed to set memory unit 0x%02X\n",
avrdude_message(MSG_INFO, "%s: Error: Failed to set memory unit 0x%02X\n",
progname, (int) mem_unit);
return -1;
}
@ -656,7 +653,7 @@ int flip2_write_memory(struct dfu_dev *dfu,
result = flip2_set_mem_page(dfu, page_addr);
if (result != 0) {
avrdude_message("%s: Error: Failed to set memory page 0x%04hX\n",
avrdude_message(MSG_INFO, "%s: Error: Failed to set memory page 0x%04hX\n",
progname, page_addr);
return -1;
}
@ -668,7 +665,7 @@ int flip2_write_memory(struct dfu_dev *dfu,
if (page_addr != prev_page_addr) {
result = flip2_set_mem_page(dfu, page_addr);
if (result != 0) {
avrdude_message("%s: Error: Failed to set memory page 0x%04hX\n",
avrdude_message(MSG_INFO, "%s: Error: Failed to set memory page 0x%04hX\n",
progname, page_addr);
return -1;
}
@ -678,7 +675,7 @@ int flip2_write_memory(struct dfu_dev *dfu,
result = flip2_write_max1k(dfu, addr & 0xFFFF, ptr, write_size);
if (result != 0) {
avrdude_message("%s: Error: Failed to write 0x%04X bytes at 0x%04lX\n",
avrdude_message(MSG_INFO, "%s: Error: Failed to write 0x%04X bytes at 0x%04lX\n",
progname, write_size, (unsigned long) addr);
return -1;
}
@ -715,10 +712,10 @@ int flip2_set_mem_unit(struct dfu_dev *dfu, enum flip2_mem_unit mem_unit)
if (status.bStatus == ((FLIP2_STATUS_OUTOFRANGE >> 8) & 0xFF) &&
status.bState == ((FLIP2_STATUS_OUTOFRANGE >> 0) & 0xFF))
{
avrdude_message("%s: Error: Unknown memory unit (0x%02x)\n",
avrdude_message(MSG_INFO, "%s: Error: Unknown memory unit (0x%02x)\n",
progname, (unsigned int) mem_unit);
} else
avrdude_message("%s: Error: DFU status %s\n", progname,
avrdude_message(MSG_INFO, "%s: Error: DFU status %s\n", progname,
flip2_status_str(&status));
dfu_clrstatus(dfu);
}
@ -752,10 +749,10 @@ int flip2_set_mem_page(struct dfu_dev *dfu,
if (status.bStatus == ((FLIP2_STATUS_OUTOFRANGE >> 8) & 0xFF) &&
status.bState == ((FLIP2_STATUS_OUTOFRANGE >> 0) & 0xFF))
{
avrdude_message("%s: Error: Page address out of range (0x%04hx)\n",
avrdude_message(MSG_INFO, "%s: Error: Page address out of range (0x%04hx)\n",
progname, page_addr);
} else
avrdude_message("%s: Error: DFU status %s\n", progname,
avrdude_message(MSG_INFO, "%s: Error: DFU status %s\n", progname,
flip2_status_str(&status));
dfu_clrstatus(dfu);
}
@ -797,10 +794,10 @@ flip2_read_max1k_status:
if (status.bStatus == ((FLIP2_STATUS_OUTOFRANGE >> 8) & 0xFF) &&
status.bState == ((FLIP2_STATUS_OUTOFRANGE >> 0) & 0xFF))
{
avrdude_message("%s: Error: Address out of range [0x%04hX,0x%04hX]\n",
avrdude_message(MSG_INFO, "%s: Error: Address out of range [0x%04hX,0x%04hX]\n",
progname, offset, offset+size-1);
} else
avrdude_message("%s: Error: DFU status %s\n", progname,
avrdude_message(MSG_INFO, "%s: Error: DFU status %s\n", progname,
flip2_status_str(&status));
dfu_clrstatus(dfu);
}
@ -827,7 +824,7 @@ int flip2_write_max1k(struct dfu_dev *dfu,
cmd.args[3] = ((offset+size-1) >> 0) & 0xFF;
if (size > 0x400) {
avrdude_message("%s: Error: Write block too large (%hu > 1024)\n",
avrdude_message(MSG_INFO, "%s: Error: Write block too large (%hu > 1024)\n",
progname, size);
return -1;
}
@ -858,10 +855,10 @@ int flip2_write_max1k(struct dfu_dev *dfu,
if (status.bStatus == ((FLIP2_STATUS_OUTOFRANGE >> 8) & 0xFF) &&
status.bState == ((FLIP2_STATUS_OUTOFRANGE >> 0) & 0xFF))
{
avrdude_message("%s: Error: Address out of range [0x%04hX,0x%04hX]\n",
avrdude_message(MSG_INFO, "%s: Error: Address out of range [0x%04hX,0x%04hX]\n",
progname, offset, offset+size-1);
} else
avrdude_message("%s: Error: DFU status %s\n", progname,
avrdude_message(MSG_INFO, "%s: Error: DFU status %s\n", progname,
flip2_status_str(&status));
dfu_clrstatus(dfu);
}

View File

@ -89,7 +89,7 @@
#ifndef HAVE_PTHREAD_H
static int ft245r_nopthread_open (struct programmer_t *pgm, char * name) {
avrdude_message("%s: error: no pthread support. Please compile again with pthread installed."
avrdude_message(MSG_INFO, "%s: error: no pthread support. Please compile again with pthread installed."
#if defined(_WIN32)
" See http://sourceware.org/pthreads-win32/."
#endif
@ -107,7 +107,7 @@ void ft245r_initpgm(PROGRAMMER * pgm) {
#elif defined(DO_NOT_BUILD_FT245R)
static int ft245r_noftdi_open (struct programmer_t *pgm, char * name) {
avrdude_message("%s: error: no libftdi or libusb support. Install libftdi1/libusb-1.0 or libftdi/libusb and run configure/make again.\n",
avrdude_message(MSG_INFO, "%s: error: no libftdi or libusb support. Install libftdi1/libusb-1.0 or libftdi/libusb and run configure/make again.\n",
progname);
return -1;
@ -165,7 +165,7 @@ static void add_to_buf (unsigned char c) {
else nh = head + 1;
if (nh == tail) {
avrdude_message("buffer overflow. Cannot happen!\n");
avrdude_message(MSG_INFO, "buffer overflow. Cannot happen!\n");
}
buffer[head] = c;
head = nh;
@ -235,7 +235,7 @@ static int ft245r_chip_erase(PROGRAMMER * pgm, AVRPART * p) {
unsigned char res[4];
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;
}
@ -260,13 +260,13 @@ static int ft245r_set_bitclock(PROGRAMMER * pgm) {
rate = 150000; /* should work for all ftdi chips and the avr default internal clock of 1MHz */
}
if ((verbose>1) || FT245R_DEBUG) {
avrdude_message(" ft245r: spi bitclk %d -> ft baudrate %d\n",
if (FT245R_DEBUG) {
avrdude_message(MSG_NOTICE2, " ft245r: spi bitclk %d -> ft baudrate %d\n",
rate / 2, rate);
}
r = ftdi_set_baudrate(handle, rate);
if (r) {
avrdude_message("Set baudrate (%d) failed with error '%s'.\n",
avrdude_message(MSG_INFO, "Set baudrate (%d) failed with error '%s'.\n",
rate, ftdi_get_error_string (handle));
return -1;
}
@ -373,7 +373,7 @@ static int ft245r_program_enable(PROGRAMMER * pgm, AVRPART * p) {
int i;
if (p->op[AVR_OP_PGM_ENABLE] == NULL) {
avrdude_message("%s: AVR_OP_PGM_ENABLE command not defined for %s\n",
avrdude_message(MSG_INFO, "%s: AVR_OP_PGM_ENABLE command not defined for %s\n",
progname, p->desc);
fflush(stderr);
return -1;
@ -386,8 +386,8 @@ static int ft245r_program_enable(PROGRAMMER * pgm, AVRPART * p) {
if (res[p->pollindex-1] == p->pollvalue) return 0;
if ((verbose>=1) || FT245R_DEBUG) {
avrdude_message("%s: Program enable command not successful. Retrying.\n",
if (FT245R_DEBUG) {
avrdude_message(MSG_NOTICE, "%s: Program enable command not successful. Retrying.\n",
progname);
fflush(stderr);
}
@ -401,7 +401,7 @@ static int ft245r_program_enable(PROGRAMMER * pgm, AVRPART * p) {
}
}
avrdude_message("%s: Device is not responding to program enable. Check connection.\n",
avrdude_message(MSG_INFO, "%s: Device is not responding to program enable. Check connection.\n",
progname);
fflush(stderr);
@ -541,7 +541,7 @@ static int ft245r_open(PROGRAMMER * pgm, char * port) {
}
}
if (devnum < 0) {
avrdude_message("%s: invalid portname '%s': use 'ft[0-9]+'\n",
avrdude_message(MSG_INFO, "%s: invalid portname '%s': use 'ft[0-9]+'\n",
progname,port);
return -1;
}
@ -556,7 +556,7 @@ static int ft245r_open(PROGRAMMER * pgm, char * port) {
if (usbpid) {
pid = *(int *)(ldata(usbpid));
if (lnext(usbpid))
avrdude_message("%s: Warning: using PID 0x%04x, ignoring remaining PIDs in list\n",
avrdude_message(MSG_INFO, "%s: Warning: using PID 0x%04x, ignoring remaining PIDs in list\n",
progname, pid);
} else {
pid = USB_DEVICE_FT245;
@ -568,7 +568,7 @@ static int ft245r_open(PROGRAMMER * pgm, char * port) {
pgm->usbsn[0]?pgm->usbsn:NULL,
devnum);
if (rv) {
avrdude_message("can't open ftdi device %d. (%s)\n", devnum, ftdi_get_error_string(handle));
avrdude_message(MSG_INFO, "can't open ftdi device %d. (%s)\n", devnum, ftdi_get_error_string(handle));
goto cleanup_no_usb;
}
@ -598,7 +598,7 @@ static int ft245r_open(PROGRAMMER * pgm, char * port) {
rv = ftdi_set_bitmode(handle, ft245r_ddr, BITMODE_SYNCBB); // set Synchronous BitBang
if (rv) {
avrdude_message("%s: Synchronous BitBangMode is not supported (%s)\n",
avrdude_message(MSG_INFO, "%s: Synchronous BitBangMode is not supported (%s)\n",
progname, ftdi_get_error_string(handle));
goto cleanup;
}
@ -652,7 +652,7 @@ static void ft245r_close(PROGRAMMER * pgm) {
}
static void ft245r_display(PROGRAMMER * pgm, const char * p) {
avrdude_message("%sPin assignment : 0..7 = DBUS0..7\n",p);/* , 8..11 = GPIO0..3\n",p);*/
avrdude_message(MSG_INFO, "%sPin assignment : 0..7 = DBUS0..7\n",p);/* , 8..11 = GPIO0..3\n",p);*/
pgm_display_generic_mask(pgm, p, SHOW_ALL_PINS);
}
@ -705,7 +705,7 @@ static void put_request(int addr, int bytes, int n) {
} else {
p = malloc(sizeof(struct ft245r_request));
if (!p) {
avrdude_message("can't alloc memory\n");
avrdude_message(MSG_INFO, "can't alloc memory\n");
exit(1);
}
}
@ -799,7 +799,7 @@ static int ft245r_paged_write_flash(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m,
put_request(addr_save, buf_pos, 0);
//ft245r_sync(pgm);
#if 0
avrdude_message("send addr 0x%04x bufsize %d [%02x %02x] page_write %d\n",
avrdude_message(MSG_INFO, "send addr 0x%04x bufsize %d [%02x %02x] page_write %d\n",
addr_save,buf_pos,
extract_data_out(pgm, buf , (0*4 + 3) ),
extract_data_out(pgm, buf , (1*4 + 3) ),

298
jtag3.c
View File

@ -109,7 +109,7 @@ static unsigned int jtag3_memaddr(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m, uns
void jtag3_setup(PROGRAMMER * pgm)
{
if ((pgm->cookie = malloc(sizeof(struct pdata))) == 0) {
avrdude_message("%s: jtag3_setup(): Out of memory allocating private data\n",
avrdude_message(MSG_INFO, "%s: jtag3_setup(): Out of memory allocating private data\n",
progname);
exit(1);
}
@ -168,7 +168,7 @@ static void jtag3_print_data(unsigned char *b, size_t s)
return;
for (i = 0; i < s; i++) {
avrdude_message("0x%02x", b[i]);
avrdude_message(MSG_INFO, "0x%02x", b[i]);
if (i % 16 == 15)
putc('\n', stderr);
else
@ -183,10 +183,10 @@ static void jtag3_prmsg(PROGRAMMER * pgm, unsigned char * data, size_t len)
int i;
if (verbose >= 4) {
avrdude_message("Raw message:\n");
avrdude_message(MSG_TRACE, "Raw message:\n");
for (i = 0; i < len; i++) {
avrdude_message("%02x ", data[i]);
avrdude_message(MSG_TRACE, "%02x ", data[i]);
if (i % 16 == 15)
putc('\n', stderr);
else
@ -198,34 +198,34 @@ static void jtag3_prmsg(PROGRAMMER * pgm, unsigned char * data, size_t len)
switch (data[0]) {
case SCOPE_INFO:
avrdude_message("[info] ");
avrdude_message(MSG_INFO, "[info] ");
break;
case SCOPE_GENERAL:
avrdude_message("[general] ");
avrdude_message(MSG_INFO, "[general] ");
break;
case SCOPE_AVR_ISP:
avrdude_message("[AVRISP] ");
avrdude_message(MSG_INFO, "[AVRISP] ");
jtag3_print_data(data + 1, len - 1);
return;
case SCOPE_AVR:
avrdude_message("[AVR] ");
avrdude_message(MSG_INFO, "[AVR] ");
break;
default:
avrdude_message("[scope 0x%02x] ", data[0]);
avrdude_message(MSG_INFO, "[scope 0x%02x] ", data[0]);
break;
}
switch (data[1]) {
case RSP3_OK:
avrdude_message("OK\n");
avrdude_message(MSG_INFO, "OK\n");
break;
case RSP3_FAILED:
avrdude_message("FAILED");
avrdude_message(MSG_INFO, "FAILED");
if (len > 3)
{
char reason[50];
@ -264,26 +264,26 @@ static void jtag3_prmsg(PROGRAMMER * pgm, unsigned char * data, size_t len)
strcpy(reason, "debugWIRE communication failed");
break;
}
avrdude_message(", reason: %s\n", reason);
avrdude_message(MSG_INFO, ", reason: %s\n", reason);
}
else
{
avrdude_message(", unspecified reason\n");
avrdude_message(MSG_INFO, ", unspecified reason\n");
}
break;
case RSP3_DATA:
avrdude_message("Data returned:\n");
avrdude_message(MSG_INFO, "Data returned:\n");
jtag3_print_data(data + 2, len - 2);
break;
case RSP3_INFO:
avrdude_message("Info returned:\n");
avrdude_message(MSG_INFO, "Info returned:\n");
for (i = 2; i < len; i++) {
if (isprint(data[i]))
putc(data[i], stderr);
else
avrdude_message("\\%03o", data[i]);
avrdude_message(MSG_INFO, "\\%03o", data[i]);
}
putc('\n', stderr);
break;
@ -291,18 +291,18 @@ static void jtag3_prmsg(PROGRAMMER * pgm, unsigned char * data, size_t len)
case RSP3_PC:
if (len < 7)
{
avrdude_message("PC reply too short\n");
avrdude_message(MSG_INFO, "PC reply too short\n");
}
else
{
unsigned long pc = (data[6] << 24) | (data[5] << 16)
| (data[4] << 8) | data[3];
avrdude_message("PC 0x%0lx\n", pc);
avrdude_message(MSG_INFO, "PC 0x%0lx\n", pc);
}
break;
default:
avrdude_message("unknown message 0x%02x\n", data[1]);
avrdude_message(MSG_INFO, "unknown message 0x%02x\n", data[1]);
}
}
@ -311,10 +311,10 @@ static void jtag3_prevent(PROGRAMMER * pgm, unsigned char * data, size_t len)
int i;
if (verbose >= 4) {
avrdude_message("Raw event:\n");
avrdude_message(MSG_TRACE, "Raw event:\n");
for (i = 0; i < len; i++) {
avrdude_message("%02x ", data[i]);
avrdude_message(MSG_TRACE, "%02x ", data[i]);
if (i % 16 == 15)
putc('\n', stderr);
else
@ -324,47 +324,47 @@ static void jtag3_prevent(PROGRAMMER * pgm, unsigned char * data, size_t len)
putc('\n', stderr);
}
avrdude_message("Event serial 0x%04x, ",
avrdude_message(MSG_INFO, "Event serial 0x%04x, ",
(data[3] << 8) | data[2]);
switch (data[4]) {
case SCOPE_INFO:
avrdude_message("[info] ");
avrdude_message(MSG_INFO, "[info] ");
break;
case SCOPE_GENERAL:
avrdude_message("[general] ");
avrdude_message(MSG_INFO, "[general] ");
break;
case SCOPE_AVR:
avrdude_message("[AVR] ");
avrdude_message(MSG_INFO, "[AVR] ");
break;
default:
avrdude_message("[scope 0x%02x] ", data[0]);
avrdude_message(MSG_INFO, "[scope 0x%02x] ", data[0]);
break;
}
switch (data[5]) {
case EVT3_BREAK:
avrdude_message("BREAK");
avrdude_message(MSG_INFO, "BREAK");
if (len >= 11) {
avrdude_message(", PC = 0x%lx, reason ", b4_to_u32(data + 6));
avrdude_message(MSG_INFO, ", PC = 0x%lx, reason ", b4_to_u32(data + 6));
switch (data[10]) {
case 0x00:
avrdude_message("unspecified");
avrdude_message(MSG_INFO, "unspecified");
break;
case 0x01:
avrdude_message("program break");
avrdude_message(MSG_INFO, "program break");
break;
case 0x02:
avrdude_message("data break PDSB");
avrdude_message(MSG_INFO, "data break PDSB");
break;
case 0x03:
avrdude_message("data break PDMSB");
avrdude_message(MSG_INFO, "data break PDMSB");
break;
default:
avrdude_message("unknown: 0x%02x", data[10]);
avrdude_message(MSG_INFO, "unknown: 0x%02x", data[10]);
}
/* There are two more bytes of data which always appear to be
* 0x01, 0x00. Purpose unknown. */
@ -373,24 +373,24 @@ static void jtag3_prevent(PROGRAMMER * pgm, unsigned char * data, size_t len)
case EVT3_SLEEP:
if (len >= 8 && data[7] == 0)
avrdude_message("sleeping");
avrdude_message(MSG_INFO, "sleeping");
else if (len >= 8 && data[7] == 1)
avrdude_message("wakeup");
avrdude_message(MSG_INFO, "wakeup");
else
avrdude_message("unknown SLEEP event");
avrdude_message(MSG_INFO, "unknown SLEEP event");
break;
case EVT3_POWER:
if (len >= 8 && data[7] == 0)
avrdude_message("power-down");
avrdude_message(MSG_INFO, "power-down");
else if (len >= 8 && data[7] == 1)
avrdude_message("power-up");
avrdude_message(MSG_INFO, "power-up");
else
avrdude_message("unknown POWER event");
avrdude_message(MSG_INFO, "unknown POWER event");
break;
default:
avrdude_message("UNKNOWN 0x%02x", data[5]);
avrdude_message(MSG_INFO, "UNKNOWN 0x%02x", data[5]);
break;
}
putc('\n', stderr);
@ -405,13 +405,12 @@ int jtag3_send(PROGRAMMER * pgm, unsigned char * data, size_t len)
if (pgm->flag & PGM_FL_IS_EDBG)
return jtag3_edbg_send(pgm, data, len);
if (verbose >= 3)
avrdude_message("\n%s: jtag3_send(): sending %lu bytes\n",
avrdude_message(MSG_DEBUG, "\n%s: jtag3_send(): sending %lu bytes\n",
progname, (unsigned long)len);
if ((buf = malloc(len + 4)) == NULL)
{
avrdude_message("%s: jtag3_send(): out of memory",
avrdude_message(MSG_INFO, "%s: jtag3_send(): out of memory",
progname);
return -1;
}
@ -422,7 +421,7 @@ int jtag3_send(PROGRAMMER * pgm, unsigned char * data, size_t len)
memcpy(buf + 4, data, len);
if (serial_send(&pgm->fd, buf, len + 4) != 0) {
avrdude_message("%s: jtag3_send(): failed to send command to serial port\n",
avrdude_message(MSG_INFO, "%s: jtag3_send(): failed to send command to serial port\n",
progname);
return -1;
}
@ -444,13 +443,12 @@ static int jtag3_edbg_send(PROGRAMMER * pgm, unsigned char * data, size_t len)
memset(status, 0, USBDEV_MAX_XFER_3);
}
if (verbose >= 3)
avrdude_message("\n%s: jtag3_edbg_send(): sending %lu bytes\n",
avrdude_message(MSG_DEBUG, "\n%s: jtag3_edbg_send(): sending %lu bytes\n",
progname, (unsigned long)len);
if (len + 8 > USBDEV_MAX_XFER_3)
{
avrdude_message("%s: jtag3_edbg_send(): Fragmentation not (yet) implemented!\n",
avrdude_message(MSG_INFO, "%s: jtag3_edbg_send(): Fragmentation not (yet) implemented!\n",
progname);
return -1;
}
@ -464,7 +462,7 @@ static int jtag3_edbg_send(PROGRAMMER * pgm, unsigned char * data, size_t len)
memcpy(buf + 8, data, len);
if (serial_send(&pgm->fd, buf, USBDEV_MAX_XFER_3) != 0) {
avrdude_message("%s: jtag3_edbg_send(): failed to send command to serial port\n",
avrdude_message(MSG_INFO, "%s: jtag3_edbg_send(): failed to send command to serial port\n",
progname);
return -1;
}
@ -472,15 +470,14 @@ static int jtag3_edbg_send(PROGRAMMER * pgm, unsigned char * data, size_t len)
if (rv < 0) {
/* timeout in receive */
if (verbose > 1)
avrdude_message("%s: jtag3_edbg_send(): Timeout receiving packet\n",
avrdude_message(MSG_NOTICE2, "%s: jtag3_edbg_send(): Timeout receiving packet\n",
progname);
return -1;
}
if (status[0] != EDBG_VENDOR_AVR_CMD || status[1] != 0x01)
{
/* what to do in this case? */
avrdude_message("%s: jtag3_edbg_send(): Unexpected response 0x%02x, 0x%02x\n",
avrdude_message(MSG_INFO, "%s: jtag3_edbg_send(): Unexpected response 0x%02x, 0x%02x\n",
progname, status[0], status[1]);
}
@ -496,8 +493,7 @@ static int jtag3_edbg_prepare(PROGRAMMER * pgm)
unsigned char status[USBDEV_MAX_XFER_3];
int rv;
if (verbose >= 3)
avrdude_message("\n%s: jtag3_edbg_prepare()\n",
avrdude_message(MSG_DEBUG, "\n%s: jtag3_edbg_prepare()\n",
progname);
if (verbose >= 4)
@ -506,41 +502,40 @@ static int jtag3_edbg_prepare(PROGRAMMER * pgm)
buf[0] = CMSISDAP_CMD_CONNECT;
buf[1] = CMSISDAP_CONN_SWD;
if (serial_send(&pgm->fd, buf, USBDEV_MAX_XFER_3) != 0) {
avrdude_message("%s: jtag3_edbg_prepare(): failed to send command to serial port\n",
avrdude_message(MSG_INFO, "%s: jtag3_edbg_prepare(): failed to send command to serial port\n",
progname);
return -1;
}
rv = serial_recv(&pgm->fd, status, USBDEV_MAX_XFER_3);
if (rv != USBDEV_MAX_XFER_3) {
avrdude_message("%s: jtag3_edbg_prepare(): failed to read from serial port (%d)\n",
avrdude_message(MSG_INFO, "%s: jtag3_edbg_prepare(): failed to read from serial port (%d)\n",
progname, rv);
return -1;
}
if (status[0] != CMSISDAP_CMD_CONNECT ||
status[1] == 0)
avrdude_message("%s: jtag3_edbg_prepare(): unexpected response 0x%02x, 0x%02x\n",
avrdude_message(MSG_INFO, "%s: jtag3_edbg_prepare(): unexpected response 0x%02x, 0x%02x\n",
progname, status[0], status[1]);
if (verbose >= 2)
avrdude_message("%s: jtag3_edbg_prepare(): connection status 0x%02x\n",
avrdude_message(MSG_NOTICE2, "%s: jtag3_edbg_prepare(): connection status 0x%02x\n",
progname, status[1]);
buf[0] = CMSISDAP_CMD_LED;
buf[1] = CMSISDAP_LED_CONNECT;
buf[2] = 1;
if (serial_send(&pgm->fd, buf, USBDEV_MAX_XFER_3) != 0) {
avrdude_message("%s: jtag3_edbg_prepare(): failed to send command to serial port\n",
avrdude_message(MSG_INFO, "%s: jtag3_edbg_prepare(): failed to send command to serial port\n",
progname);
return -1;
}
rv = serial_recv(&pgm->fd, status, USBDEV_MAX_XFER_3);
if (rv != USBDEV_MAX_XFER_3) {
avrdude_message("%s: jtag3_edbg_prepare(): failed to read from serial port (%d)\n",
avrdude_message(MSG_INFO, "%s: jtag3_edbg_prepare(): failed to read from serial port (%d)\n",
progname, rv);
return -1;
}
if (status[0] != CMSISDAP_CMD_LED ||
status[1] != 0)
avrdude_message("%s: jtag3_edbg_prepare(): unexpected response 0x%02x, 0x%02x\n",
avrdude_message(MSG_INFO, "%s: jtag3_edbg_prepare(): unexpected response 0x%02x, 0x%02x\n",
progname, status[0], status[1]);
return 0;
@ -556,8 +551,7 @@ static int jtag3_edbg_signoff(PROGRAMMER * pgm)
unsigned char status[USBDEV_MAX_XFER_3];
int rv;
if (verbose >= 3)
avrdude_message("\n%s: jtag3_edbg_signoff()\n",
avrdude_message(MSG_DEBUG, "\n%s: jtag3_edbg_signoff()\n",
progname);
if (verbose >= 4)
@ -567,36 +561,36 @@ static int jtag3_edbg_signoff(PROGRAMMER * pgm)
buf[1] = CMSISDAP_LED_CONNECT;
buf[2] = 0;
if (serial_send(&pgm->fd, buf, USBDEV_MAX_XFER_3) != 0) {
avrdude_message("%s: jtag3_edbg_signoff(): failed to send command to serial port\n",
avrdude_message(MSG_INFO, "%s: jtag3_edbg_signoff(): failed to send command to serial port\n",
progname);
return -1;
}
rv = serial_recv(&pgm->fd, status, USBDEV_MAX_XFER_3);
if (rv != USBDEV_MAX_XFER_3) {
avrdude_message("%s: jtag3_edbg_signoff(): failed to read from serial port (%d)\n",
avrdude_message(MSG_INFO, "%s: jtag3_edbg_signoff(): failed to read from serial port (%d)\n",
progname, rv);
return -1;
}
if (status[0] != CMSISDAP_CMD_LED ||
status[1] != 0)
avrdude_message("%s: jtag3_edbg_signoff(): unexpected response 0x%02x, 0x%02x\n",
avrdude_message(MSG_INFO, "%s: jtag3_edbg_signoff(): unexpected response 0x%02x, 0x%02x\n",
progname, status[0], status[1]);
buf[0] = CMSISDAP_CMD_DISCONNECT;
if (serial_send(&pgm->fd, buf, USBDEV_MAX_XFER_3) != 0) {
avrdude_message("%s: jtag3_edbg_signoff(): failed to send command to serial port\n",
avrdude_message(MSG_INFO, "%s: jtag3_edbg_signoff(): failed to send command to serial port\n",
progname);
return -1;
}
rv = serial_recv(&pgm->fd, status, USBDEV_MAX_XFER_3);
if (rv != USBDEV_MAX_XFER_3) {
avrdude_message("%s: jtag3_edbg_signoff(): failed to read from serial port (%d)\n",
avrdude_message(MSG_INFO, "%s: jtag3_edbg_signoff(): failed to read from serial port (%d)\n",
progname, rv);
return -1;
}
if (status[0] != CMSISDAP_CMD_DISCONNECT ||
status[1] != 0)
avrdude_message("%s: jtag3_edbg_signoff(): unexpected response 0x%02x, 0x%02x\n",
avrdude_message(MSG_INFO, "%s: jtag3_edbg_signoff(): unexpected response 0x%02x, 0x%02x\n",
progname, status[0], status[1]);
return 0;
@ -624,11 +618,10 @@ static int jtag3_recv_frame(PROGRAMMER * pgm, unsigned char **msg) {
if (pgm->flag & PGM_FL_IS_EDBG)
return jtag3_edbg_recv_frame(pgm, msg);
if (verbose >= 4)
avrdude_message("%s: jtag3_recv():\n", progname);
avrdude_message(MSG_TRACE, "%s: jtag3_recv():\n", progname);
if ((buf = malloc(pgm->fd.usb.max_xfer)) == NULL) {
avrdude_message("%s: jtag3_recv(): out of memory\n",
avrdude_message(MSG_INFO, "%s: jtag3_recv(): out of memory\n",
progname);
return -1;
}
@ -639,8 +632,7 @@ static int jtag3_recv_frame(PROGRAMMER * pgm, unsigned char **msg) {
if (rv < 0) {
/* timeout in receive */
if (verbose > 1)
avrdude_message("%s: jtag3_recv(): Timeout receiving packet\n",
avrdude_message(MSG_NOTICE2, "%s: jtag3_recv(): Timeout receiving packet\n",
progname);
free(buf);
return -1;
@ -655,11 +647,10 @@ static int jtag3_edbg_recv_frame(PROGRAMMER * pgm, unsigned char **msg) {
int rv, len;
unsigned char *buf = NULL;
if (verbose >= 4)
avrdude_message("%s: jtag3_edbg_recv():\n", progname);
avrdude_message(MSG_TRACE, "%s: jtag3_edbg_recv():\n", progname);
if ((buf = malloc(USBDEV_MAX_XFER_3)) == NULL) {
avrdude_message("%s: jtag3_edbg_recv(): out of memory\n",
avrdude_message(MSG_INFO, "%s: jtag3_edbg_recv(): out of memory\n",
progname);
return -1;
}
@ -667,7 +658,7 @@ static int jtag3_edbg_recv_frame(PROGRAMMER * pgm, unsigned char **msg) {
buf[0] = EDBG_VENDOR_AVR_RSP;
if (serial_send(&pgm->fd, buf, USBDEV_MAX_XFER_3) != 0) {
avrdude_message("%s: jtag3_edbg_recv(): error sending CMSIS-DAP vendor command\n",
avrdude_message(MSG_INFO, "%s: jtag3_edbg_recv(): error sending CMSIS-DAP vendor command\n",
progname);
return -1;
}
@ -676,8 +667,7 @@ static int jtag3_edbg_recv_frame(PROGRAMMER * pgm, unsigned char **msg) {
if (rv < 0) {
/* timeout in receive */
if (verbose > 1)
avrdude_message("%s: jtag3_edbg_recv(): Timeout receiving packet\n",
avrdude_message(MSG_NOTICE2, "%s: jtag3_edbg_recv(): Timeout receiving packet\n",
progname);
free(buf);
return -1;
@ -685,14 +675,14 @@ static int jtag3_edbg_recv_frame(PROGRAMMER * pgm, unsigned char **msg) {
if (buf[0] != EDBG_VENDOR_AVR_RSP ||
buf[1] != ((1 << 4) | 1)) {
avrdude_message("%s: jtag3_edbg_recv(): Unexpected response 0x%02x, 0x%02x\n",
avrdude_message(MSG_INFO, "%s: jtag3_edbg_recv(): Unexpected response 0x%02x, 0x%02x\n",
progname, buf[0], buf[1]);
return -1;
}
/* calculate length from response; CMSIS-DAP response might be larger */
len = (buf[2] << 8) | buf[3];
if (len > rv + 4) {
avrdude_message("%s: jtag3_edbg_recv(): Unexpected length value (%d > %d)\n",
avrdude_message(MSG_INFO, "%s: jtag3_edbg_recv(): Unexpected length value (%d > %d)\n",
progname, len, rv + 4);
len = rv + 4;
}
@ -721,8 +711,7 @@ int jtag3_recv(PROGRAMMER * pgm, unsigned char **msg) {
rv &= USB_RECV_LENGTH_MASK;
r_seqno = ((*msg)[2] << 8) | (*msg)[1];
if (verbose >= 3)
avrdude_message("%s: jtag3_recv(): "
avrdude_message(MSG_DEBUG, "%s: jtag3_recv(): "
"Got message seqno %d (command_sequence == %d)\n",
progname, r_seqno, PDATA(pgm)->command_sequence);
if (r_seqno == PDATA(pgm)->command_sequence) {
@ -738,8 +727,7 @@ int jtag3_recv(PROGRAMMER * pgm, unsigned char **msg) {
return rv;
}
if (verbose >= 2)
avrdude_message("%s: jtag3_recv(): "
avrdude_message(MSG_NOTICE2, "%s: jtag3_recv(): "
"got wrong sequence number, %u != %u\n",
progname, r_seqno, PDATA(pgm)->command_sequence);
@ -753,8 +741,7 @@ int jtag3_recv(PROGRAMMER * pgm, unsigned char **msg) {
int status;
unsigned char c;
if (verbose >= 2)
avrdude_message("%s: Sending %s command: ",
avrdude_message(MSG_NOTICE2, "%s: Sending %s command: ",
progname, descr);
jtag3_send(pgm, cmd, cmdlen);
@ -762,18 +749,19 @@ int jtag3_recv(PROGRAMMER * pgm, unsigned char **msg) {
if (status <= 0) {
if (verbose >= 2)
putc('\n', stderr);
avrdude_message("%s: %s command: timeout/error communicating with programmer (status %d)\n",
avrdude_message(MSG_NOTICE2, "%s: %s command: timeout/error communicating with programmer (status %d)\n",
progname, descr, status);
return -1;
} else if (verbose >= 3) {
putc('\n', stderr);
jtag3_prmsg(pgm, *resp, status);
} else if (verbose == 2)
avrdude_message("0x%02x (%d bytes msg)\n", (*resp)[1], status);
} else {
avrdude_message(MSG_NOTICE2, "0x%02x (%d bytes msg)\n", (*resp)[1], status);
}
c = (*resp)[1];
if ((c & RSP3_STATUS_MASK) != RSP3_OK) {
avrdude_message("%s: bad response to %s command: 0x%02x\n",
avrdude_message(MSG_INFO, "%s: bad response to %s command: 0x%02x\n",
progname, descr, c);
free(*resp);
resp = 0;
@ -788,8 +776,7 @@ int jtag3_getsync(PROGRAMMER * pgm, int mode) {
unsigned char buf[3], *resp;
if (verbose >= 3)
avrdude_message("%s: jtag3_getsync()\n", progname);
avrdude_message(MSG_DEBUG, "%s: jtag3_getsync()\n", progname);
if (pgm->flag & PGM_FL_IS_EDBG) {
if (jtag3_edbg_prepare(pgm) < 0)
@ -835,7 +822,7 @@ static int jtag3_chip_erase(PROGRAMMER * pgm, AVRPART * p)
static int jtag3_chip_erase_dw(PROGRAMMER * pgm, AVRPART * p)
{
avrdude_message("%s: Chip erase not supported in debugWire mode\n",
avrdude_message(MSG_INFO, "%s: Chip erase not supported in debugWire mode\n",
progname);
return 0;
@ -865,8 +852,7 @@ static int jtag3_program_enable(PROGRAMMER * pgm)
}
/* XXX activate external reset here */
if (verbose > 0)
avrdude_message("%s: retrying with external reset applied\n",
avrdude_message(MSG_NOTICE, "%s: retrying with external reset applied\n",
progname);
}
@ -939,10 +925,10 @@ static int jtag3_initialize(PROGRAMMER * pgm, AVRPART * p)
if (jtag3_getparm(pgm, SCOPE_GENERAL, 0, PARM3_FW_MAJOR, parm, 2) < 0)
return -1;
if (pgm->fd.usb.max_xfer < USBDEV_MAX_XFER_3 && (pgm->flag & PGM_FL_IS_EDBG) == 0) {
avrdude_message("%s: the JTAGICE3's firmware %d.%d is broken on USB 1.1 connections, sorry\n",
avrdude_message(MSG_INFO, "%s: the JTAGICE3's firmware %d.%d is broken on USB 1.1 connections, sorry\n",
progname, parm[0], parm[1]);
if (ovsigck) {
avrdude_message("%s: forced to continue by option -F; THIS PUTS THE DEVICE'S DATA INTEGRITY AT RISK!\n",
avrdude_message(MSG_INFO, "%s: forced to continue by option -F; THIS PUTS THE DEVICE'S DATA INTEGRITY AT RISK!\n",
progname);
} else {
return -1;
@ -964,7 +950,7 @@ static int jtag3_initialize(PROGRAMMER * pgm, AVRPART * p)
}
if (conn == 0) {
avrdude_message("%s: jtag3_initialize(): part %s has no %s interface\n",
avrdude_message(MSG_INFO, "%s: jtag3_initialize(): part %s has no %s interface\n",
progname, p->desc, ifname);
return -1;
}
@ -997,8 +983,7 @@ static int jtag3_initialize(PROGRAMMER * pgm, AVRPART * p)
if (pgm->bitclock != 0.0 && PDATA(pgm)->set_sck != NULL)
{
unsigned int clock = 1E-3 / pgm->bitclock; /* kHz */
if (verbose >= 2)
avrdude_message("%s: jtag3_initialize(): "
avrdude_message(MSG_NOTICE2, "%s: jtag3_initialize(): "
"trying to set JTAG clock to %u kHz\n",
progname, clock);
parm[0] = clock & 0xff;
@ -1009,8 +994,7 @@ static int jtag3_initialize(PROGRAMMER * pgm, AVRPART * p)
if (conn == PARM3_CONN_JTAG)
{
if (verbose >= 2)
avrdude_message("%s: jtag3_initialize(): "
avrdude_message(MSG_NOTICE2, "%s: jtag3_initialize(): "
"trying to set JTAG daisy-chain info to %d,%d,%d,%d\n",
progname,
PDATA(pgm)->jtagchain[0], PDATA(pgm)->jtagchain[1],
@ -1102,7 +1086,7 @@ static int jtag3_initialize(PROGRAMMER * pgm, AVRPART * p)
ocdrev = 4;
else
ocdrev = 3; /* many exceptions from that, actually */
avrdude_message("%s: part definition for %s lacks \"ocdrev\"; guessing %d\n",
avrdude_message(MSG_INFO, "%s: part definition for %s lacks \"ocdrev\"; guessing %d\n",
progname, p->desc, ocdrev);
md.ocd_revision = ocdrev;
} else {
@ -1141,9 +1125,9 @@ static int jtag3_initialize(PROGRAMMER * pgm, AVRPART * p)
* (except ISP which is handled completely differently, but that
* doesn't apply here anyway), the response is just RSP_OK.
*/
if (resp[1] == RSP3_DATA && status >= 7 && verbose >= 1)
if (resp[1] == RSP3_DATA && status >= 7)
/* JTAG ID has been returned */
avrdude_message("%s: JTAG ID returned: 0x%02x 0x%02x 0x%02x 0x%02x\n",
avrdude_message(MSG_NOTICE, "%s: JTAG ID returned: 0x%02x 0x%02x 0x%02x 0x%02x\n",
progname, resp[3], resp[4], resp[5], resp[6]);
free(resp);
@ -1157,7 +1141,7 @@ static int jtag3_initialize(PROGRAMMER * pgm, AVRPART * p)
AVRMEM *bootmem = avr_locate_mem(p, "boot");
AVRMEM *flashmem = avr_locate_mem(p, "flash");
if (bootmem == NULL || flashmem == NULL) {
avrdude_message("%s: jtagmk3_initialize(): Cannot locate \"flash\" and \"boot\" memories in description\n",
avrdude_message(MSG_INFO, "%s: jtagmk3_initialize(): Cannot locate \"flash\" and \"boot\" memories in description\n",
progname);
} else {
PDATA(pgm)->boot_start = bootmem->offset - flashmem->offset;
@ -1167,12 +1151,12 @@ static int jtag3_initialize(PROGRAMMER * pgm, AVRPART * p)
free(PDATA(pgm)->flash_pagecache);
free(PDATA(pgm)->eeprom_pagecache);
if ((PDATA(pgm)->flash_pagecache = malloc(PDATA(pgm)->flash_pagesize)) == NULL) {
avrdude_message("%s: jtag3_initialize(): Out of memory\n",
avrdude_message(MSG_INFO, "%s: jtag3_initialize(): Out of memory\n",
progname);
return -1;
}
if ((PDATA(pgm)->eeprom_pagecache = malloc(PDATA(pgm)->eeprom_pagesize)) == NULL) {
avrdude_message("%s: jtag3_initialize(): Out of memory\n",
avrdude_message(MSG_INFO, "%s: jtag3_initialize(): Out of memory\n",
progname);
free(PDATA(pgm)->flash_pagecache);
return -1;
@ -1216,17 +1200,15 @@ static int jtag3_parseextparms(PROGRAMMER * pgm, LISTID extparms)
unsigned int ub, ua, bb, ba;
if (sscanf(extended_param, "jtagchain=%u,%u,%u,%u", &ub, &ua, &bb, &ba)
!= 4) {
avrdude_message("%s: jtag3_parseextparms(): invalid JTAG chain '%s'\n",
avrdude_message(MSG_INFO, "%s: jtag3_parseextparms(): invalid JTAG chain '%s'\n",
progname, extended_param);
rv = -1;
continue;
}
if (verbose >= 2) {
avrdude_message("%s: jtag3_parseextparms(): JTAG chain parsed as:\n"
avrdude_message(MSG_NOTICE2, "%s: jtag3_parseextparms(): JTAG chain parsed as:\n"
"%s %u units before, %u units after, %u bits before, %u bits after\n",
progname,
progbuf, ub, ua, bb, ba);
}
PDATA(pgm)->jtagchain[0] = ub;
PDATA(pgm)->jtagchain[1] = ua;
PDATA(pgm)->jtagchain[2] = bb;
@ -1235,7 +1217,7 @@ static int jtag3_parseextparms(PROGRAMMER * pgm, LISTID extparms)
continue;
}
avrdude_message("%s: jtag3_parseextparms(): invalid extended parameter '%s'\n",
avrdude_message(MSG_INFO, "%s: jtag3_parseextparms(): invalid extended parameter '%s'\n",
progname, extended_param);
rv = -1;
}
@ -1250,12 +1232,12 @@ int jtag3_open_common(PROGRAMMER * pgm, char * port)
int rv = -1;
#if !defined(HAVE_LIBUSB)
avrdude_message("avrdude was compiled without usb support.\n");
avrdude_message(MSG_INFO, "avrdude was compiled without usb support.\n");
return -1;
#endif
if (strncmp(port, "usb", 3) != 0) {
avrdude_message("%s: jtag3_open_common(): JTAGICE3/EDBG port names must start with \"usb\"\n",
avrdude_message(MSG_INFO, "%s: jtag3_open_common(): JTAGICE3/EDBG port names must start with \"usb\"\n",
progname);
return -1;
}
@ -1282,13 +1264,13 @@ int jtag3_open_common(PROGRAMMER * pgm, char * port)
rv = serial_open(port, pinfo, &pgm->fd);
}
if (rv < 0) {
avrdude_message("%s: jtag3_open_common(): Did not find any device matching VID 0x%04x and PID list: ",
avrdude_message(MSG_INFO, "%s: jtag3_open_common(): Did not find any device matching VID 0x%04x and PID list: ",
progname, (unsigned)pinfo.usbinfo.vid);
int notfirst = 0;
for (usbpid = lfirst(pgm->usbpid); usbpid != NULL; usbpid = lnext(usbpid)) {
if (notfirst)
avrdude_message(", ");
avrdude_message("0x%04x", (unsigned int)(*(int *)(ldata(usbpid))));
avrdude_message(MSG_INFO, ", ");
avrdude_message(MSG_INFO, "0x%04x", (unsigned int)(*(int *)(ldata(usbpid))));
notfirst = 1;
}
fputc('\n', stderr);
@ -1301,8 +1283,7 @@ int jtag3_open_common(PROGRAMMER * pgm, char * port)
/* The event EP has been deleted by usb_open(), so we are
running on a CMSIS-DAP device, using EDBG protocol */
pgm->flag |= PGM_FL_IS_EDBG;
if (verbose)
avrdude_message("%s: Found CMSIS-DAP compliant device, using EDBG protocol\n",
avrdude_message(MSG_NOTICE, "%s: Found CMSIS-DAP compliant device, using EDBG protocol\n",
progname);
}
@ -1318,8 +1299,7 @@ int jtag3_open_common(PROGRAMMER * pgm, char * port)
static int jtag3_open(PROGRAMMER * pgm, char * port)
{
if (verbose >= 2)
avrdude_message("%s: jtag3_open()\n", progname);
avrdude_message(MSG_NOTICE2, "%s: jtag3_open()\n", progname);
if (jtag3_open_common(pgm, port) < 0)
return -1;
@ -1332,8 +1312,7 @@ static int jtag3_open(PROGRAMMER * pgm, char * port)
static int jtag3_open_dw(PROGRAMMER * pgm, char * port)
{
if (verbose >= 2)
avrdude_message("%s: jtag3_open_dw()\n", progname);
avrdude_message(MSG_NOTICE2, "%s: jtag3_open_dw()\n", progname);
if (jtag3_open_common(pgm, port) < 0)
return -1;
@ -1346,8 +1325,7 @@ static int jtag3_open_dw(PROGRAMMER * pgm, char * port)
static int jtag3_open_pdi(PROGRAMMER * pgm, char * port)
{
if (verbose >= 2)
avrdude_message("%s: jtag3_open_pdi()\n", progname);
avrdude_message(MSG_NOTICE2, "%s: jtag3_open_pdi()\n", progname);
if (jtag3_open_common(pgm, port) < 0)
return -1;
@ -1363,8 +1341,7 @@ void jtag3_close(PROGRAMMER * pgm)
{
unsigned char buf[4], *resp;
if (verbose >= 2)
avrdude_message("%s: jtag3_close()\n", progname);
avrdude_message(MSG_NOTICE2, "%s: jtag3_close()\n", progname);
buf[0] = SCOPE_AVR;
buf[1] = CMD3_SIGN_OFF;
@ -1391,12 +1368,11 @@ static int jtag3_page_erase(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m,
{
unsigned char cmd[8], *resp;
if (verbose >= 2)
avrdude_message("%s: jtag3_page_erase(.., %s, 0x%x)\n",
avrdude_message(MSG_NOTICE2, "%s: jtag3_page_erase(.., %s, 0x%x)\n",
progname, m->desc, addr);
if (!(p->flags & AVRPART_HAS_PDI)) {
avrdude_message("%s: jtag3_page_erase: not an Xmega device\n",
avrdude_message(MSG_INFO, "%s: jtag3_page_erase: not an Xmega device\n",
progname);
return -1;
}
@ -1443,8 +1419,7 @@ static int jtag3_paged_write(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m,
int status, dynamic_memtype = 0;
long otimeout = serial_recv_timeout;
if (verbose >= 2)
avrdude_message("%s: jtag3_paged_write(.., %s, %d, %d)\n",
avrdude_message(MSG_NOTICE2, "%s: jtag3_paged_write(.., %s, %d, %d)\n",
progname, m->desc, page_size, n_bytes);
if (!(pgm->flag & PGM_FL_IS_DW) && jtag3_program_enable(pgm) < 0)
@ -1453,7 +1428,7 @@ static int jtag3_paged_write(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m,
if (page_size == 0) page_size = 256;
if ((cmd = malloc(page_size + 13)) == NULL) {
avrdude_message("%s: jtag3_paged_write(): Out of memory\n",
avrdude_message(MSG_INFO, "%s: jtag3_paged_write(): Out of memory\n",
progname);
return -1;
}
@ -1500,8 +1475,7 @@ static int jtag3_paged_write(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m,
block_size = maxaddr - addr;
else
block_size = page_size;
if (verbose >= 3)
avrdude_message("%s: jtag3_paged_write(): "
avrdude_message(MSG_DEBUG, "%s: jtag3_paged_write(): "
"block_size at addr %d is %d\n",
progname, addr, block_size);
@ -1549,8 +1523,7 @@ static int jtag3_paged_load(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m,
int status, dynamic_memtype = 0;
long otimeout = serial_recv_timeout;
if (verbose >= 2)
avrdude_message("%s: jtag3_paged_load(.., %s, %d, %d)\n",
avrdude_message(MSG_NOTICE2, "%s: jtag3_paged_load(.., %s, %d, %d)\n",
progname, m->desc, page_size, n_bytes);
if (!(pgm->flag & PGM_FL_IS_DW) && jtag3_program_enable(pgm) < 0)
@ -1588,8 +1561,7 @@ static int jtag3_paged_load(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m,
block_size = maxaddr - addr;
else
block_size = page_size;
if (verbose >= 3)
avrdude_message("%s: jtag3_paged_load(): "
avrdude_message(MSG_DEBUG, "%s: jtag3_paged_load(): "
"block_size at addr %d is %d\n",
progname, addr, block_size);
@ -1604,7 +1576,7 @@ static int jtag3_paged_load(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m,
if (resp[1] != RSP3_DATA ||
status < block_size + 4) {
avrdude_message("%s: wrong/short reply to read memory command\n",
avrdude_message(MSG_INFO, "%s: wrong/short reply to read memory command\n",
progname);
serial_recv_timeout = otimeout;
free(resp);
@ -1627,8 +1599,7 @@ static int jtag3_read_byte(PROGRAMMER * pgm, AVRPART * p, AVRMEM * mem,
unsigned long paddr = 0UL, *paddr_ptr = NULL;
unsigned int pagesize = 0;
if (verbose >= 2)
avrdude_message("%s: jtag3_read_byte(.., %s, 0x%lx, ...)\n",
avrdude_message(MSG_NOTICE2, "%s: jtag3_read_byte(.., %s, 0x%lx, ...)\n",
progname, mem->desc, addr);
if (!(pgm->flag & PGM_FL_IS_DW) && jtag3_program_enable(pgm) < 0)
@ -1716,7 +1687,7 @@ static int jtag3_read_byte(PROGRAMMER * pgm, AVRPART * p, AVRMEM * mem,
return 0;
} else {
/* should not happen */
avrdude_message("address out of range for signature memory: %lu\n", addr);
avrdude_message(MSG_INFO, "address out of range for signature memory: %lu\n", addr);
return -1;
}
}
@ -1757,7 +1728,7 @@ static int jtag3_read_byte(PROGRAMMER * pgm, AVRPART * p, AVRMEM * mem,
if (resp[1] != RSP3_DATA ||
status < (pagesize? pagesize: 1) + 4) {
avrdude_message("%s: wrong/short reply to read memory command\n",
avrdude_message(MSG_INFO, "%s: wrong/short reply to read memory command\n",
progname);
free(resp);
return -1;
@ -1783,8 +1754,7 @@ static int jtag3_write_byte(PROGRAMMER * pgm, AVRPART * p, AVRMEM * mem,
int status, unsupp = 0;
unsigned int pagesize = 0;
if (verbose >= 2)
avrdude_message("%s: jtag3_write_byte(.., %s, 0x%lx, ...)\n",
avrdude_message(MSG_NOTICE2, "%s: jtag3_write_byte(.., %s, 0x%lx, ...)\n",
progname, mem->desc, addr);
cmd[0] = SCOPE_AVR;
@ -1901,7 +1871,7 @@ static int jtag3_set_sck_period(PROGRAMMER * pgm, double v)
parm[1] = (clock >> 8) & 0xff;
if (PDATA(pgm)->set_sck == NULL) {
avrdude_message("%s: No backend to set the SCK period for\n",
avrdude_message(MSG_INFO, "%s: No backend to set the SCK period for\n",
progname);
return -1;
}
@ -1921,8 +1891,7 @@ int jtag3_getparm(PROGRAMMER * pgm, unsigned char scope,
unsigned char buf[6], *resp, c;
char descr[60];
if (verbose >= 2)
avrdude_message("%s: jtag3_getparm()\n", progname);
avrdude_message(MSG_NOTICE2, "%s: jtag3_getparm()\n", progname);
buf[0] = scope;
buf[1] = CMD3_GET_PARAMETER;
@ -1939,7 +1908,7 @@ int jtag3_getparm(PROGRAMMER * pgm, unsigned char scope,
c = resp[1];
if (c != RSP3_DATA || status < 3) {
avrdude_message("%s: jtag3_getparm(): "
avrdude_message(MSG_INFO, "%s: jtag3_getparm(): "
"bad response to %s\n",
progname, descr);
free(resp);
@ -1964,15 +1933,14 @@ int jtag3_setparm(PROGRAMMER * pgm, unsigned char scope,
unsigned char *buf, *resp;
char descr[60];
if (verbose >= 2)
avrdude_message("%s: jtag3_setparm()\n", progname);
avrdude_message(MSG_NOTICE2, "%s: jtag3_setparm()\n", progname);
sprintf(descr, "set parameter (scope 0x%02x, section %d, parm %d)",
scope, section, parm);
if ((buf = malloc(6 + length)) == NULL)
{
avrdude_message("%s: jtag3_setparm(): Out of memory\n",
avrdude_message(MSG_INFO, "%s: jtag3_setparm(): Out of memory\n",
progname);
return -1;
}
@ -2021,7 +1989,7 @@ static void jtag3_display(PROGRAMMER * pgm, const char * p)
c = resp[1];
if (c != RSP3_INFO) {
avrdude_message("%s: jtag3_display(): response is not RSP3_INFO\n",
avrdude_message(MSG_INFO, "%s: jtag3_display(): response is not RSP3_INFO\n",
progname);
free(resp);
return;
@ -2029,11 +1997,11 @@ static void jtag3_display(PROGRAMMER * pgm, const char * p)
memmove(resp, resp + 3, status - 3);
resp[status - 3] = 0;
avrdude_message("%sICE hardware version: %d\n", p, parms[0]);
avrdude_message("%sICE firmware version: %d.%02d (rel. %d)\n", p,
avrdude_message(MSG_INFO, "%sICE hardware version: %d\n", p, parms[0]);
avrdude_message(MSG_INFO, "%sICE firmware version: %d.%02d (rel. %d)\n", p,
parms[1], parms[2],
(parms[3] | (parms[4] << 8)));
avrdude_message("%sSerial number : %s\n", p, resp);
avrdude_message(MSG_INFO, "%sSerial number : %s\n", p, resp);
free(resp);
jtag3_print_parms1(pgm, p);
@ -2047,27 +2015,27 @@ static void jtag3_print_parms1(PROGRAMMER * pgm, const char * p)
if (jtag3_getparm(pgm, SCOPE_GENERAL, 1, PARM3_VTARGET, buf, 2) < 0)
return;
avrdude_message("%sVtarget : %.2f V\n", p,
avrdude_message(MSG_INFO, "%sVtarget : %.2f V\n", p,
b2_to_u16(buf) / 1000.0);
if (jtag3_getparm(pgm, SCOPE_AVR, 1, PARM3_CLK_MEGA_PROG, buf, 2) < 0)
return;
avrdude_message("%sJTAG clock megaAVR/program: %u kHz\n", p,
avrdude_message(MSG_INFO, "%sJTAG clock megaAVR/program: %u kHz\n", p,
b2_to_u16(buf));
if (jtag3_getparm(pgm, SCOPE_AVR, 1, PARM3_CLK_MEGA_DEBUG, buf, 2) < 0)
return;
avrdude_message("%sJTAG clock megaAVR/debug: %u kHz\n", p,
avrdude_message(MSG_INFO, "%sJTAG clock megaAVR/debug: %u kHz\n", p,
b2_to_u16(buf));
if (jtag3_getparm(pgm, SCOPE_AVR, 1, PARM3_CLK_XMEGA_JTAG, buf, 2) < 0)
return;
avrdude_message("%sJTAG clock Xmega: %u kHz\n", p,
avrdude_message(MSG_INFO, "%sJTAG clock Xmega: %u kHz\n", p,
b2_to_u16(buf));
if (jtag3_getparm(pgm, SCOPE_AVR, 1, PARM3_CLK_XMEGA_PDI, buf, 2) < 0)
return;
avrdude_message("%sPDI clock Xmega : %u kHz\n", p,
avrdude_message(MSG_INFO, "%sPDI clock Xmega : %u kHz\n", p,
b2_to_u16(buf));
}

219
jtagmkI.c
View File

@ -111,7 +111,7 @@ static int jtagmkI_resync(PROGRAMMER *pgm, int maxtries, int signon);
static void jtagmkI_setup(PROGRAMMER * pgm)
{
if ((pgm->cookie = malloc(sizeof(struct pdata))) == 0) {
avrdude_message("%s: jtagmkI_setup(): Out of memory allocating private data\n",
avrdude_message(MSG_INFO, "%s: jtagmkI_setup(): Out of memory allocating private data\n",
progname);
exit(1);
}
@ -144,10 +144,10 @@ static void jtagmkI_prmsg(PROGRAMMER * pgm, unsigned char * data, size_t len)
int i;
if (verbose >= 4) {
avrdude_message("Raw message:\n");
avrdude_message(MSG_TRACE, "Raw message:\n");
for (i = 0; i < len; i++) {
avrdude_message("0x%02x ", data[i]);
avrdude_message(MSG_TRACE, "0x%02x ", data[i]);
if (i % 16 == 15)
putc('\n', stderr);
else
@ -159,34 +159,34 @@ static void jtagmkI_prmsg(PROGRAMMER * pgm, unsigned char * data, size_t len)
switch (data[0]) {
case RESP_OK:
avrdude_message("OK\n");
avrdude_message(MSG_INFO, "OK\n");
break;
case RESP_FAILED:
avrdude_message("FAILED\n");
avrdude_message(MSG_INFO, "FAILED\n");
break;
case RESP_BREAK:
avrdude_message("breakpoint hit\n");
avrdude_message(MSG_INFO, "breakpoint hit\n");
break;
case RESP_INFO:
avrdude_message("IDR dirty\n");
avrdude_message(MSG_INFO, "IDR dirty\n");
break;
case RESP_SYNC_ERROR:
avrdude_message("Synchronization lost\n");
avrdude_message(MSG_INFO, "Synchronization lost\n");
break;
case RESP_SLEEP:
avrdude_message("sleep instruction hit\n");
avrdude_message(MSG_INFO, "sleep instruction hit\n");
break;
case RESP_POWER:
avrdude_message("target power lost\n");
avrdude_message(MSG_INFO, "target power lost\n");
default:
avrdude_message("unknown message 0x%02x\n", data[0]);
avrdude_message(MSG_INFO, "unknown message 0x%02x\n", data[0]);
}
putc('\n', stderr);
@ -197,13 +197,12 @@ static int jtagmkI_send(PROGRAMMER * pgm, unsigned char * data, size_t len)
{
unsigned char *buf;
if (verbose >= 3)
avrdude_message("\n%s: jtagmkI_send(): sending %u bytes\n",
avrdude_message(MSG_DEBUG, "\n%s: jtagmkI_send(): sending %u bytes\n",
progname, (unsigned int)len);
if ((buf = malloc(len + 2)) == NULL)
{
avrdude_message("%s: jtagmkI_send(): out of memory",
avrdude_message(MSG_INFO, "%s: jtagmkI_send(): out of memory",
progname);
exit(1);
}
@ -213,7 +212,7 @@ static int jtagmkI_send(PROGRAMMER * pgm, unsigned char * data, size_t len)
buf[len + 1] = ' '; /* EOP */
if (serial_send(&pgm->fd, buf, len + 2) != 0) {
avrdude_message("%s: jtagmkI_send(): failed to send command to serial port\n",
avrdude_message(MSG_INFO, "%s: jtagmkI_send(): failed to send command to serial port\n",
progname);
return -1;
}
@ -226,7 +225,7 @@ static int jtagmkI_send(PROGRAMMER * pgm, unsigned char * data, size_t len)
static int jtagmkI_recv(PROGRAMMER * pgm, unsigned char * buf, size_t len)
{
if (serial_recv(&pgm->fd, buf, len) != 0) {
avrdude_message("\n%s: jtagmkI_recv(): failed to send command to serial port\n",
avrdude_message(MSG_INFO, "\n%s: jtagmkI_recv(): failed to send command to serial port\n",
progname);
return -1;
}
@ -252,8 +251,7 @@ static int jtagmkI_resync(PROGRAMMER * pgm, int maxtries, int signon)
serial_recv_timeout = 200;
if (verbose >= 3)
avrdude_message("%s: jtagmkI_resync()\n", progname);
avrdude_message(MSG_TRACE, "%s: jtagmkI_resync()\n", progname);
jtagmkI_drain(pgm, 0);
@ -261,19 +259,17 @@ static int jtagmkI_resync(PROGRAMMER * pgm, int maxtries, int signon)
/* Get the sign-on information. */
buf[0] = CMD_GET_SYNC;
if (verbose >= 2)
avrdude_message("%s: jtagmkI_resync(): Sending sync command: ",
avrdude_message(MSG_NOTICE2, "%s: jtagmkI_resync(): Sending sync command: ",
progname);
if (serial_send(&pgm->fd, buf, 1) != 0) {
avrdude_message("\n%s: jtagmkI_resync(): failed to send command to serial port\n",
avrdude_message(MSG_INFO, "\n%s: jtagmkI_resync(): failed to send command to serial port\n",
progname);
serial_recv_timeout = otimeout;
return -1;
}
if (serial_recv(&pgm->fd, resp, 1) == 0 && resp[0] == RESP_OK) {
if (verbose >= 2)
avrdude_message("got RESP_OK\n");
avrdude_message(MSG_NOTICE2, "got RESP_OK\n");
break;
}
@ -292,26 +288,23 @@ static int jtagmkI_resync(PROGRAMMER * pgm, int maxtries, int signon)
buf[1] = 'E';
buf[2] = ' ';
buf[3] = ' ';
if (verbose >= 2)
avrdude_message("%s: jtagmkI_resync(): Sending sign-on command: ",
avrdude_message(MSG_NOTICE2, "%s: jtagmkI_resync(): Sending sign-on command: ",
progname);
if (serial_send(&pgm->fd, buf, 4) != 0) {
avrdude_message("\n%s: jtagmkI_resync(): failed to send command to serial port\n",
avrdude_message(MSG_INFO, "\n%s: jtagmkI_resync(): failed to send command to serial port\n",
progname);
serial_recv_timeout = otimeout;
return -1;
}
if (serial_recv(&pgm->fd, resp, 9) == 0 && resp[0] == RESP_OK) {
if (verbose >= 2)
avrdude_message("got RESP_OK\n");
avrdude_message(MSG_NOTICE2, "got RESP_OK\n");
break;
}
}
}
if (tries >= maxtries) {
if (verbose >= 2)
avrdude_message("%s: jtagmkI_resync(): "
avrdude_message(MSG_NOTICE2, "%s: jtagmkI_resync(): "
"timeout/error communicating with programmer\n",
progname);
serial_recv_timeout = otimeout;
@ -333,8 +326,7 @@ static int jtagmkI_getsync(PROGRAMMER * pgm)
jtagmkI_drain(pgm, 0);
if (verbose >= 2)
avrdude_message("%s: jtagmkI_getsync(): Sending sign-on command: ",
avrdude_message(MSG_NOTICE2, "%s: jtagmkI_getsync(): Sending sign-on command: ",
progname);
buf[0] = CMD_GET_SIGNON;
@ -343,7 +335,7 @@ static int jtagmkI_getsync(PROGRAMMER * pgm)
return -1;
if (verbose >= 2) {
resp[8] = '\0';
avrdude_message("got %s\n", resp + 1);
avrdude_message(MSG_NOTICE2, "got %s\n", resp + 1);
}
return 0;
@ -357,8 +349,7 @@ static int jtagmkI_chip_erase(PROGRAMMER * pgm, AVRPART * p)
unsigned char buf[1], resp[2];
buf[0] = CMD_CHIP_ERASE;
if (verbose >= 2)
avrdude_message("%s: jtagmkI_chip_erase(): Sending chip erase command: ",
avrdude_message(MSG_NOTICE2, "%s: jtagmkI_chip_erase(): Sending chip erase command: ",
progname);
jtagmkI_send(pgm, buf, 1);
if (jtagmkI_recv(pgm, resp, 2) < 0)
@ -366,13 +357,13 @@ static int jtagmkI_chip_erase(PROGRAMMER * pgm, AVRPART * p)
if (resp[0] != RESP_OK) {
if (verbose >= 2)
putc('\n', stderr);
avrdude_message("%s: jtagmkI_chip_erase(): "
avrdude_message(MSG_INFO, "%s: jtagmkI_chip_erase(): "
"timeout/error communicating with programmer (resp %c)\n",
progname, resp[0]);
return -1;
} else {
if (verbose == 2)
avrdude_message("OK\n");
avrdude_message(MSG_NOTICE2, "OK\n");
}
pgm->initialize(pgm, p);
@ -405,8 +396,7 @@ static void jtagmkI_set_devdescr(PROGRAMMER * pgm, AVRPART * p)
}
}
if (verbose >= 2)
avrdude_message("%s: jtagmkI_set_devdescr(): "
avrdude_message(MSG_NOTICE2, "%s: jtagmkI_set_devdescr(): "
"Sending set device descriptor command: ",
progname);
jtagmkI_send(pgm, (unsigned char *)&sendbuf, sizeof(sendbuf));
@ -416,12 +406,12 @@ static void jtagmkI_set_devdescr(PROGRAMMER * pgm, AVRPART * p)
if (resp[0] != RESP_OK) {
if (verbose >= 2)
putc('\n', stderr);
avrdude_message("%s: jtagmkI_set_devdescr(): "
avrdude_message(MSG_INFO, "%s: jtagmkI_set_devdescr(): "
"timeout/error communicating with programmer (resp %c)\n",
progname, resp[0]);
} else {
if (verbose == 2)
avrdude_message("OK\n");
avrdude_message(MSG_NOTICE2, "OK\n");
}
}
@ -433,8 +423,7 @@ static int jtagmkI_reset(PROGRAMMER * pgm)
unsigned char buf[1], resp[2];
buf[0] = CMD_RESET;
if (verbose >= 2)
avrdude_message("%s: jtagmkI_reset(): Sending reset command: ",
avrdude_message(MSG_NOTICE2, "%s: jtagmkI_reset(): Sending reset command: ",
progname);
jtagmkI_send(pgm, buf, 1);
@ -443,13 +432,13 @@ static int jtagmkI_reset(PROGRAMMER * pgm)
if (resp[0] != RESP_OK) {
if (verbose >= 2)
putc('\n', stderr);
avrdude_message("%s: jtagmkI_reset(): "
avrdude_message(MSG_INFO, "%s: jtagmkI_reset(): "
"timeout/error communicating with programmer (resp %c)\n",
progname, resp[0]);
return -1;
} else {
if (verbose == 2)
avrdude_message("OK\n");
avrdude_message(MSG_NOTICE2, "OK\n");
}
return 0;
@ -469,8 +458,7 @@ static int jtagmkI_program_enable(PROGRAMMER * pgm)
return 0;
buf[0] = CMD_ENTER_PROGMODE;
if (verbose >= 2)
avrdude_message("%s: jtagmkI_program_enable(): "
avrdude_message(MSG_NOTICE2, "%s: jtagmkI_program_enable(): "
"Sending enter progmode command: ",
progname);
jtagmkI_send(pgm, buf, 1);
@ -480,13 +468,13 @@ static int jtagmkI_program_enable(PROGRAMMER * pgm)
if (resp[0] != RESP_OK) {
if (verbose >= 2)
putc('\n', stderr);
avrdude_message("%s: jtagmkI_program_enable(): "
avrdude_message(MSG_INFO, "%s: jtagmkI_program_enable(): "
"timeout/error communicating with programmer (resp %c)\n",
progname, resp[0]);
return -1;
} else {
if (verbose == 2)
avrdude_message("OK\n");
avrdude_message(MSG_NOTICE2, "OK\n");
}
PDATA(pgm)->prog_enabled = 1;
@ -503,8 +491,7 @@ static int jtagmkI_program_disable(PROGRAMMER * pgm)
if (pgm->fd.ifd != -1) {
buf[0] = CMD_LEAVE_PROGMODE;
if (verbose >= 2)
avrdude_message("%s: jtagmkI_program_disable(): "
avrdude_message(MSG_NOTICE2, "%s: jtagmkI_program_disable(): "
"Sending leave progmode command: ",
progname);
jtagmkI_send(pgm, buf, 1);
@ -514,13 +501,13 @@ static int jtagmkI_program_disable(PROGRAMMER * pgm)
if (resp[0] != RESP_OK) {
if (verbose >= 2)
putc('\n', stderr);
avrdude_message("%s: jtagmkI_program_disable(): "
avrdude_message(MSG_INFO, "%s: jtagmkI_program_disable(): "
"timeout/error communicating with programmer (resp %c)\n",
progname, resp[0]);
return -1;
} else {
if (verbose == 2)
avrdude_message("OK\n");
avrdude_message(MSG_NOTICE2, "OK\n");
}
}
PDATA(pgm)->prog_enabled = 0;
@ -549,7 +536,7 @@ static int jtagmkI_initialize(PROGRAMMER * pgm, AVRPART * p)
unsigned char b;
if (!(p->flags & AVRPART_HAS_JTAG)) {
avrdude_message("%s: jtagmkI_initialize(): part %s has no JTAG interface\n",
avrdude_message(MSG_INFO, "%s: jtagmkI_initialize(): part %s has no JTAG interface\n",
progname, p->desc);
return -1;
}
@ -558,11 +545,10 @@ static int jtagmkI_initialize(PROGRAMMER * pgm, AVRPART * p)
if ((serdev->flags & SERDEV_FL_CANSETSPEED) && PDATA(pgm)->initial_baudrate != pgm->baudrate) {
if ((b = jtagmkI_get_baud(pgm->baudrate)) == 0) {
avrdude_message("%s: jtagmkI_initialize(): unsupported baudrate %d\n",
avrdude_message(MSG_INFO, "%s: jtagmkI_initialize(): unsupported baudrate %d\n",
progname, pgm->baudrate);
} else {
if (verbose >= 2)
avrdude_message("%s: jtagmkI_initialize(): "
avrdude_message(MSG_NOTICE2, "%s: jtagmkI_initialize(): "
"trying to set baudrate to %d\n",
progname, pgm->baudrate);
if (jtagmkI_setparm(pgm, PARM_BITRATE, b) == 0) {
@ -573,8 +559,7 @@ static int jtagmkI_initialize(PROGRAMMER * pgm, AVRPART * p)
}
if (pgm->bitclock != 0.0) {
if (verbose >= 2)
avrdude_message("%s: jtagmkI_initialize(): "
avrdude_message(MSG_NOTICE2, "%s: jtagmkI_initialize(): "
"trying to set JTAG clock period to %.1f us\n",
progname, pgm->bitclock);
if (jtagmkI_set_sck_period(pgm, pgm->bitclock) != 0)
@ -588,12 +573,12 @@ static int jtagmkI_initialize(PROGRAMMER * pgm, AVRPART * p)
if (resp[0] != RESP_OK) {
if (verbose >= 2)
putc('\n', stderr);
avrdude_message("%s: jtagmkI_initialize(): "
avrdude_message(MSG_INFO, "%s: jtagmkI_initialize(): "
"timeout/error communicating with programmer (resp %c)\n",
progname, resp[0]);
} else {
if (verbose == 2)
avrdude_message("OK\n");
avrdude_message(MSG_NOTICE2, "OK\n");
}
/*
@ -608,12 +593,12 @@ static int jtagmkI_initialize(PROGRAMMER * pgm, AVRPART * p)
free(PDATA(pgm)->flash_pagecache);
free(PDATA(pgm)->eeprom_pagecache);
if ((PDATA(pgm)->flash_pagecache = malloc(PDATA(pgm)->flash_pagesize)) == NULL) {
avrdude_message("%s: jtagmkI_initialize(): Out of memory\n",
avrdude_message(MSG_INFO, "%s: jtagmkI_initialize(): Out of memory\n",
progname);
return -1;
}
if ((PDATA(pgm)->eeprom_pagecache = malloc(PDATA(pgm)->eeprom_pagesize)) == NULL) {
avrdude_message("%s: jtagmkI_initialize(): Out of memory\n",
avrdude_message(MSG_INFO, "%s: jtagmkI_initialize(): Out of memory\n",
progname);
free(PDATA(pgm)->flash_pagecache);
return -1;
@ -627,7 +612,7 @@ static int jtagmkI_initialize(PROGRAMMER * pgm, AVRPART * p)
if (jtagmkI_read_byte(pgm, p, &hfuse, 1, &b) < 0)
return -1;
if ((b & OCDEN) != 0)
avrdude_message("%s: jtagmkI_initialize(): warning: OCDEN fuse not programmed, "
avrdude_message(MSG_INFO, "%s: jtagmkI_initialize(): warning: OCDEN fuse not programmed, "
"single-byte EEPROM updates not possible\n",
progname);
@ -656,8 +641,7 @@ static int jtagmkI_open(PROGRAMMER * pgm, char * port)
{
size_t i;
if (verbose >= 2)
avrdude_message("%s: jtagmkI_open()\n", progname);
avrdude_message(MSG_NOTICE2, "%s: jtagmkI_open()\n", progname);
strcpy(pgm->port, port);
PDATA(pgm)->initial_baudrate = -1L;
@ -665,8 +649,7 @@ static int jtagmkI_open(PROGRAMMER * pgm, char * port)
for (i = 0; i < sizeof(baudtab) / sizeof(baudtab[0]); i++) {
union pinfo pinfo;
pinfo.baud = baudtab[i].baud;
if (verbose >= 2)
avrdude_message("%s: jtagmkI_open(): trying to sync at baud rate %ld:\n",
avrdude_message(MSG_NOTICE2, "%s: jtagmkI_open(): trying to sync at baud rate %ld:\n",
progname, pinfo.baud);
if (serial_open(port, pinfo, &pgm->fd)==-1) {
return -1;
@ -679,15 +662,14 @@ static int jtagmkI_open(PROGRAMMER * pgm, char * port)
if (jtagmkI_getsync(pgm) == 0) {
PDATA(pgm)->initial_baudrate = baudtab[i].baud;
if (verbose >= 2)
avrdude_message("%s: jtagmkI_open(): succeeded\n", progname);
avrdude_message(MSG_NOTICE2, "%s: jtagmkI_open(): succeeded\n", progname);
return 0;
}
serial_close(&pgm->fd);
}
avrdude_message("%s: jtagmkI_open(): failed to synchronize to ICE\n",
avrdude_message(MSG_INFO, "%s: jtagmkI_open(): failed to synchronize to ICE\n",
progname);
pgm->fd.ifd = -1;
@ -699,8 +681,7 @@ static void jtagmkI_close(PROGRAMMER * pgm)
{
unsigned char b;
if (verbose >= 2)
avrdude_message("%s: jtagmkI_close()\n", progname);
avrdude_message(MSG_NOTICE2, "%s: jtagmkI_close()\n", progname);
/*
* Revert baud rate to what it used to be when we started. This
@ -709,11 +690,10 @@ static void jtagmkI_close(PROGRAMMER * pgm)
*/
if ((serdev->flags & SERDEV_FL_CANSETSPEED) && PDATA(pgm)->initial_baudrate != pgm->baudrate) {
if ((b = jtagmkI_get_baud(PDATA(pgm)->initial_baudrate)) == 0) {
avrdude_message("%s: jtagmkI_close(): unsupported baudrate %d\n",
avrdude_message(MSG_INFO, "%s: jtagmkI_close(): unsupported baudrate %d\n",
progname, PDATA(pgm)->initial_baudrate);
} else {
if (verbose >= 2)
avrdude_message("%s: jtagmkI_close(): "
avrdude_message(MSG_NOTICE2, "%s: jtagmkI_close(): "
"trying to set baudrate to %d\n",
progname, PDATA(pgm)->initial_baudrate);
if (jtagmkI_setparm(pgm, PARM_BITRATE, b) == 0) {
@ -742,8 +722,7 @@ static int jtagmkI_paged_write(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m,
long otimeout = serial_recv_timeout;
#define MAXTRIES 3
if (verbose >= 2)
avrdude_message("%s: jtagmkI_paged_write(.., %s, %d, %d)\n",
avrdude_message(MSG_NOTICE2, "%s: jtagmkI_paged_write(.., %s, %d, %d)\n",
progname, m->desc, page_size, n_bytes);
if (jtagmkI_program_enable(pgm) < 0)
@ -752,13 +731,13 @@ static int jtagmkI_paged_write(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m,
if (page_size == 0) page_size = 256;
if (page_size > 256) {
avrdude_message("%s: jtagmkI_paged_write(): page size %d too large\n",
avrdude_message(MSG_INFO, "%s: jtagmkI_paged_write(): page size %d too large\n",
progname, page_size);
return -1;
}
if ((datacmd = malloc(page_size + 1)) == NULL) {
avrdude_message("%s: jtagmkI_paged_write(): Out of memory\n",
avrdude_message(MSG_INFO, "%s: jtagmkI_paged_write(): Out of memory\n",
progname);
return -1;
}
@ -782,7 +761,7 @@ static int jtagmkI_paged_write(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m,
again:
if (tries != 0 && jtagmkI_resync(pgm, 2000, 0) < 0) {
avrdude_message("%s: jtagmkI_paged_write(): sync loss, retries exhausted\n",
avrdude_message(MSG_INFO, "%s: jtagmkI_paged_write(): sync loss, retries exhausted\n",
progname);
return -1;
}
@ -791,8 +770,7 @@ static int jtagmkI_paged_write(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m,
block_size = n_bytes - addr;
else
block_size = page_size;
if (verbose >= 3)
avrdude_message("%s: jtagmkI_paged_write(): "
avrdude_message(MSG_DEBUG, "%s: jtagmkI_paged_write(): "
"block_size at addr %d is %d\n",
progname, addr, block_size);
@ -806,8 +784,7 @@ static int jtagmkI_paged_write(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m,
u32_to_b3(cmd + 3, addr);
}
if (verbose >= 2)
avrdude_message("%s: jtagmkI_paged_write(): "
avrdude_message(MSG_NOTICE2, "%s: jtagmkI_paged_write(): "
"Sending write memory command: ",
progname);
@ -818,7 +795,7 @@ static int jtagmkI_paged_write(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m,
if (resp[0] != RESP_OK) {
if (verbose >= 2)
putc('\n', stderr);
avrdude_message("%s: jtagmkI_paged_write(): "
avrdude_message(MSG_INFO, "%s: jtagmkI_paged_write(): "
"timeout/error communicating with programmer (resp %c)\n",
progname, resp[0]);
if (tries++ < MAXTRIES)
@ -827,7 +804,7 @@ static int jtagmkI_paged_write(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m,
return -1;
} else {
if (verbose == 2)
avrdude_message("OK\n");
avrdude_message(MSG_NOTICE2, "OK\n");
}
/*
@ -847,7 +824,7 @@ static int jtagmkI_paged_write(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m,
if (resp[1] != RESP_OK) {
if (verbose >= 2)
putc('\n', stderr);
avrdude_message("%s: jtagmkI_paged_write(): "
avrdude_message(MSG_INFO, "%s: jtagmkI_paged_write(): "
"timeout/error communicating with programmer (resp %c)\n",
progname, resp[0]);
if (tries++ < MAXTRIES)
@ -856,7 +833,7 @@ static int jtagmkI_paged_write(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m,
return -1;
} else {
if (verbose == 2)
avrdude_message("OK\n");
avrdude_message(MSG_NOTICE2, "OK\n");
}
}
@ -877,8 +854,7 @@ static int jtagmkI_paged_load(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m,
long otimeout = serial_recv_timeout;
#define MAXTRIES 3
if (verbose >= 2)
avrdude_message("%s: jtagmkI_paged_load(.., %s, %d, %d)\n",
avrdude_message(MSG_NOTICE2, "%s: jtagmkI_paged_load(.., %s, %d, %d)\n",
progname, m->desc, page_size, n_bytes);
if (jtagmkI_program_enable(pgm) < 0)
@ -895,7 +871,7 @@ static int jtagmkI_paged_load(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m,
}
if (page_size > (is_flash? 512: 256)) {
avrdude_message("%s: jtagmkI_paged_load(): page size %d too large\n",
avrdude_message(MSG_INFO, "%s: jtagmkI_paged_load(): page size %d too large\n",
progname, page_size);
return -1;
}
@ -905,7 +881,7 @@ static int jtagmkI_paged_load(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m,
tries = 0;
again:
if (tries != 0 && jtagmkI_resync(pgm, 2000, 0) < 0) {
avrdude_message("%s: jtagmkI_paged_load(): sync loss, retries exhausted\n",
avrdude_message(MSG_INFO, "%s: jtagmkI_paged_load(): sync loss, retries exhausted\n",
progname);
return -1;
}
@ -914,8 +890,7 @@ static int jtagmkI_paged_load(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m,
block_size = n_bytes - addr;
else
block_size = page_size;
if (verbose >= 3)
avrdude_message("%s: jtagmkI_paged_load(): "
avrdude_message(MSG_DEBUG, "%s: jtagmkI_paged_load(): "
"block_size at addr %d is %d\n",
progname, addr, block_size);
@ -929,8 +904,7 @@ static int jtagmkI_paged_load(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m,
u32_to_b3(cmd + 3, addr);
}
if (verbose >= 2)
avrdude_message("%s: jtagmkI_paged_load(): Sending read memory command: ",
avrdude_message(MSG_NOTICE2, "%s: jtagmkI_paged_load(): Sending read memory command: ",
progname);
jtagmkI_send(pgm, cmd, 6);
@ -940,7 +914,7 @@ static int jtagmkI_paged_load(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m,
if (resp[read_size + 3 - 1] != RESP_OK) {
if (verbose >= 2)
putc('\n', stderr);
avrdude_message("%s: jtagmkI_paged_load(): "
avrdude_message(MSG_INFO, "%s: jtagmkI_paged_load(): "
"timeout/error communicating with programmer (resp %c)\n",
progname, resp[read_size + 3 - 1]);
if (tries++ < MAXTRIES)
@ -950,7 +924,7 @@ static int jtagmkI_paged_load(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m,
return -1;
} else {
if (verbose == 2)
avrdude_message("OK\n");
avrdude_message(MSG_NOTICE2, "OK\n");
}
memcpy(m->buf + addr, resp + 1, block_size);
@ -971,8 +945,7 @@ static int jtagmkI_read_byte(PROGRAMMER * pgm, AVRPART * p, AVRMEM * mem,
int respsize = 3 + 1;
int is_flash = 0;
if (verbose >= 2)
avrdude_message("%s: jtagmkI_read_byte(.., %s, 0x%lx, ...)\n",
avrdude_message(MSG_NOTICE2, "%s: jtagmkI_read_byte(.., %s, 0x%lx, ...)\n",
progname, mem->desc, addr);
if (jtagmkI_program_enable(pgm) < 0)
@ -1056,13 +1029,13 @@ static int jtagmkI_read_byte(PROGRAMMER * pgm, AVRPART * p, AVRMEM * mem,
if (resp[respsize - 1] != RESP_OK) {
if (verbose >= 2)
putc('\n', stderr);
avrdude_message("%s: jtagmkI_read_byte(): "
avrdude_message(MSG_INFO, "%s: jtagmkI_read_byte(): "
"timeout/error communicating with programmer (resp %c)\n",
progname, resp[respsize - 1]);
return -1;
} else {
if (verbose == 2)
avrdude_message("OK\n");
avrdude_message(MSG_NOTICE2, "OK\n");
}
if (pagesize) {
@ -1085,8 +1058,7 @@ static int jtagmkI_write_byte(PROGRAMMER * pgm, AVRPART * p, AVRMEM * mem,
unsigned char resp[1], writedata;
int len, need_progmode = 1;
if (verbose >= 2)
avrdude_message("%s: jtagmkI_write_byte(.., %s, 0x%lx, ...)\n",
avrdude_message(MSG_NOTICE2, "%s: jtagmkI_write_byte(.., %s, 0x%lx, ...)\n",
progname, mem->desc, addr);
writedata = data;
@ -1141,13 +1113,13 @@ static int jtagmkI_write_byte(PROGRAMMER * pgm, AVRPART * p, AVRMEM * mem,
if (resp[0] != RESP_OK) {
if (verbose >= 2)
putc('\n', stderr);
avrdude_message("%s: jtagmkI_write_byte(): "
avrdude_message(MSG_INFO, "%s: jtagmkI_write_byte(): "
"timeout/error communicating with programmer (resp %c)\n",
progname, resp[0]);
return -1;
} else {
if (verbose == 2)
avrdude_message("OK\n");
avrdude_message(MSG_NOTICE2, "OK\n");
}
/* Now, send the data buffer. */
@ -1171,13 +1143,13 @@ static int jtagmkI_write_byte(PROGRAMMER * pgm, AVRPART * p, AVRMEM * mem,
if (resp[0] != RESP_OK) {
if (verbose >= 2)
putc('\n', stderr);
avrdude_message("%s: jtagmkI_write_byte(): "
avrdude_message(MSG_INFO, "%s: jtagmkI_write_byte(): "
"timeout/error communicating with programmer (resp %c)\n",
progname, resp[0]);
return -1;
} else {
if (verbose == 2)
avrdude_message("OK\n");
avrdude_message(MSG_NOTICE2, "OK\n");
}
return 0;
@ -1221,13 +1193,12 @@ static int jtagmkI_getparm(PROGRAMMER * pgm, unsigned char parm,
{
unsigned char buf[2], resp[3];
if (verbose >= 2)
avrdude_message("%s: jtagmkI_getparm()\n", progname);
avrdude_message(MSG_NOTICE2, "%s: jtagmkI_getparm()\n", progname);
buf[0] = CMD_GET_PARAM;
buf[1] = parm;
if (verbose >= 2)
avrdude_message("%s: jtagmkI_getparm(): "
avrdude_message(MSG_NOTICE2, "%s: jtagmkI_getparm(): "
"Sending get parameter command (parm 0x%02x): ",
progname, parm);
jtagmkI_send(pgm, buf, 2);
@ -1237,20 +1208,20 @@ static int jtagmkI_getparm(PROGRAMMER * pgm, unsigned char parm,
if (resp[0] != RESP_OK) {
if (verbose >= 2)
putc('\n', stderr);
avrdude_message("%s: jtagmkI_getparm(): "
avrdude_message(MSG_INFO, "%s: jtagmkI_getparm(): "
"timeout/error communicating with programmer (resp %c)\n",
progname, resp[0]);
return -1;
} else if (resp[2] != RESP_OK) {
if (verbose >= 2)
putc('\n', stderr);
avrdude_message("%s: jtagmkI_getparm(): "
avrdude_message(MSG_INFO, "%s: jtagmkI_getparm(): "
"unknown parameter 0x%02x\n",
progname, parm);
return -1;
} else {
if (verbose == 2)
avrdude_message("OK, value 0x%02x\n", resp[1]);
avrdude_message(MSG_NOTICE2, "OK, value 0x%02x\n", resp[1]);
}
*value = resp[1];
@ -1266,14 +1237,12 @@ static int jtagmkI_setparm(PROGRAMMER * pgm, unsigned char parm,
{
unsigned char buf[3], resp[2];
if (verbose >= 2)
avrdude_message("%s: jtagmkI_setparm()\n", progname);
avrdude_message(MSG_NOTICE2, "%s: jtagmkI_setparm()\n", progname);
buf[0] = CMD_SET_PARAM;
buf[1] = parm;
buf[2] = value;
if (verbose >= 2)
avrdude_message("%s: jtagmkI_setparm(): "
avrdude_message(MSG_NOTICE2, "%s: jtagmkI_setparm(): "
"Sending set parameter command (parm 0x%02x): ",
progname, parm);
jtagmkI_send(pgm, buf, 3);
@ -1282,13 +1251,13 @@ static int jtagmkI_setparm(PROGRAMMER * pgm, unsigned char parm,
if (resp[0] != RESP_OK) {
if (verbose >= 2)
putc('\n', stderr);
avrdude_message("%s: jtagmkI_setparm(): "
avrdude_message(MSG_INFO, "%s: jtagmkI_setparm(): "
"timeout/error communicating with programmer (resp %c)\n",
progname, resp[0]);
return -1;
} else {
if (verbose == 2)
avrdude_message("OK\n");
avrdude_message(MSG_NOTICE2, "OK\n");
}
return 0;
@ -1304,8 +1273,8 @@ static void jtagmkI_display(PROGRAMMER * pgm, const char * p)
jtagmkI_getparm(pgm, PARM_SW_VERSION, &fw) < 0)
return;
avrdude_message("%sICE hardware version: 0x%02x\n", p, hw);
avrdude_message("%sICE firmware version: 0x%02x\n", p, fw);
avrdude_message(MSG_INFO, "%sICE hardware version: 0x%02x\n", p, hw);
avrdude_message(MSG_INFO, "%sICE firmware version: 0x%02x\n", p, fw);
jtagmkI_print_parms1(pgm, p);
@ -1349,9 +1318,9 @@ static void jtagmkI_print_parms1(PROGRAMMER * pgm, const char * p)
clk = 1e6;
}
avrdude_message("%sVtarget : %.1f V\n", p,
avrdude_message(MSG_INFO, "%sVtarget : %.1f V\n", p,
6.25 * (unsigned)vtarget / 255.0);
avrdude_message("%sJTAG clock : %s (%.1f us)\n", p, clkstr,
avrdude_message(MSG_INFO, "%sJTAG clock : %s (%.1f us)\n", p, clkstr,
1.0e6 / clk);
return;

File diff suppressed because it is too large Load Diff

10
lexer.l
View File

@ -94,9 +94,9 @@ SIGN [+-]
}
if (c == EOF) {
avrdude_message("error at %s:%d: EOF in comment\n",
avrdude_message(MSG_INFO, "error at %s:%d: EOF in comment\n",
infile, lineno);
avrdude_message(" comment started on line %d\n",
avrdude_message(MSG_INFO, " comment started on line %d\n",
comment_start);
exit(1);
break;
@ -115,7 +115,7 @@ SIGN [+-]
<strng>\\(.|\n) *(string_buf_ptr++) = yytext[1];
<strng>[^\\\n\"]+ { char *yptr = yytext; while (*yptr)
*(string_buf_ptr++) = *(yptr++); }
<strng>\n { avrdude_message("error at line %d: unterminated character constant\n",
<strng>\n { avrdude_message(MSG_INFO, "error at line %d: unterminated character constant\n",
lineno);
exit(1); }
@ -254,9 +254,9 @@ yes { yylval=new_token(K_YES); return K_YES; }
"\n" { lineno++; }
[ \r\t]+ { /* ignore whitespace */ }
c: { avrdude_message("error at %s:%d: possible old-style config file entry\n",
c: { avrdude_message(MSG_INFO, "error at %s:%d: possible old-style config file entry\n",
infile, lineno);
avrdude_message(" Update your config file (see %s%s for a sample)\n",
avrdude_message(MSG_INFO, " Update your config file (see %s%s for a sample)\n",
CONFIG_DIR, "/avrdude.conf.sample");
return YYERRCODE; }

View File

@ -812,10 +812,10 @@ extern "C" {
/* Writes the specified fuse in fusename (can be "lfuse", "hfuse", or "efuse") and verifies it. Will try up to tries
amount of times before giving up */
int safemode_writefuse (unsigned char fuse, char * fusename, PROGRAMMER * pgm, AVRPART * p, int tries, int verbose);
int safemode_writefuse (unsigned char fuse, char * fusename, PROGRAMMER * pgm, AVRPART * p, int tries);
/* Reads the fuses three times, checking that all readings are the same. This will ensure that the before values aren't in error! */
int safemode_readfuses (unsigned char * lfuse, unsigned char * hfuse, unsigned char * efuse, unsigned char * fuse, PROGRAMMER * pgm, AVRPART * p, int verbose);
int safemode_readfuses (unsigned char * lfuse, unsigned char * hfuse, unsigned char * efuse, unsigned char * fuse, PROGRAMMER * pgm, AVRPART * p);
/* This routine will store the current values pointed to by lfuse, hfuse, and efuse into an internal buffer in this routine
when save is set to 1. When save is 0 (or not 1 really) it will copy the values from the internal buffer into the locations

View File

@ -218,7 +218,7 @@ static int linuxgpio_highpulsepin(PROGRAMMER * pgm, int pinfunc)
static void linuxgpio_display(PROGRAMMER *pgm, const char *p)
{
avrdude_message("%sPin assignment : /sys/class/gpio/gpio{n}\n",p);
avrdude_message(MSG_INFO, "%sPin assignment : /sys/class/gpio/gpio{n}\n",p);
pgm_display_generic_mask(pgm, p, SHOW_AVR_PINS);
}
@ -268,7 +268,7 @@ static int linuxgpio_open(PROGRAMMER *pgm, char *port)
i == PIN_AVR_MISO ) {
pin = pgm->pinno[i] & PIN_MASK;
if ((r=linuxgpio_export(pin)) < 0) {
avrdude_message("Can't export GPIO %d, already exported/busy?: %s",
avrdude_message(MSG_INFO, "Can't export GPIO %d, already exported/busy?: %s",
pin, strerror(errno));
return r;
}
@ -345,7 +345,7 @@ const char linuxgpio_desc[] = "GPIO bitbanging using the Linux sysfs interface";
void linuxgpio_initpgm(PROGRAMMER * pgm)
{
avrdude_message("%s: Linux sysfs GPIO support not available in this configuration\n",
avrdude_message(MSG_INFO, "%s: Linux sysfs GPIO support not available in this configuration\n",
progname);
}

289
main.c
View File

@ -59,19 +59,21 @@ char progbuf[PATH_MAX]; /* temporary buffer of spaces the same
length as progname; used for lining up
multiline messages */
int avrdude_message(const char *format, ...)
int avrdude_message(const int msglvl, const char *format, ...)
{
int rc;
int rc = 0;
va_list ap;
va_start(ap, format);
rc = vfprintf(stderr, format, ap);
va_end(ap);
if (verbose >= msglvl) {
va_start(ap, format);
rc = vfprintf(stderr, format, ap);
va_end(ap);
}
return rc;
}
int yyerror(char * errmsg)
{
avrdude_message("%s: %s at %s:%d\n", progname, errmsg, infile, lineno);
avrdude_message(MSG_INFO, "%s: %s at %s:%d\n", progname, errmsg, infile, lineno);
exit(1);
}
@ -104,7 +106,7 @@ int ovsigck; /* 1=override sig check, 0=don't */
*/
static void usage(void)
{
avrdude_message(
avrdude_message(MSG_INFO,
"Usage: %s [options]\n"
"Options:\n"
" -p <partno> Required. Specify AVR device.\n"
@ -158,18 +160,18 @@ static void update_progress_tty (int percent, double etime, char *hdr)
}
if (hdr) {
avrdude_message("\n");
avrdude_message(MSG_INFO, "\n");
last = 0;
header = hdr;
}
if (last == 0) {
avrdude_message("\r%s | %s | %d%% %0.2fs",
avrdude_message(MSG_INFO, "\r%s | %s | %d%% %0.2fs",
header, hashes, percent, etime);
}
if (percent == 100) {
if (!last) avrdude_message("\n\n");
if (!last) avrdude_message(MSG_INFO, "\n\n");
last = 1;
}
@ -185,19 +187,19 @@ static void update_progress_no_tty (int percent, double etime, char *hdr)
setvbuf(stderr, (char*)NULL, _IONBF, 0);
if (hdr) {
avrdude_message("\n%s | ", hdr);
avrdude_message(MSG_INFO, "\n%s | ", hdr);
last = 0;
done = 0;
}
else {
while ((cnt > last) && (done == 0)) {
avrdude_message("#");
avrdude_message(MSG_INFO, "#");
cnt -= 2;
}
}
if ((percent == 100) && (done == 0)) {
avrdude_message(" | 100%% %0.2fs\n\n", etime);
avrdude_message(MSG_INFO, " | 100%% %0.2fs\n\n", etime);
last = 0;
done = 1;
}
@ -386,19 +388,19 @@ int main(int argc, char * argv [])
updates = lcreat(NULL, 0);
if (updates == NULL) {
avrdude_message("%s: cannot initialize updater list\n", progname);
avrdude_message(MSG_INFO, "%s: cannot initialize updater list\n", progname);
exit(1);
}
extended_params = lcreat(NULL, 0);
if (extended_params == NULL) {
avrdude_message("%s: cannot initialize extended parameter list\n", progname);
avrdude_message(MSG_INFO, "%s: cannot initialize extended parameter list\n", progname);
exit(1);
}
additional_config_files = lcreat(NULL, 0);
if (additional_config_files == NULL) {
avrdude_message("%s: cannot initialize additional config files list\n", progname);
avrdude_message(MSG_INFO, "%s: cannot initialize additional config files list\n", progname);
exit(1);
}
@ -471,7 +473,7 @@ int main(int argc, char * argv [])
case 'b': /* override default programmer baud rate */
baudrate = strtol(optarg, &e, 0);
if ((e == optarg) || (*e != 0)) {
avrdude_message("%s: invalid baud rate specified '%s'\n",
avrdude_message(MSG_INFO, "%s: invalid baud rate specified '%s'\n",
progname, optarg);
exit(1);
}
@ -480,7 +482,7 @@ int main(int argc, char * argv [])
case 'B': /* specify JTAG ICE bit clock period */
bitclock = strtod(optarg, &e);
if ((e == optarg) || (*e != 0) || bitclock == 0.0) {
avrdude_message("%s: invalid bit clock period specified '%s'\n",
avrdude_message(MSG_INFO, "%s: invalid bit clock period specified '%s'\n",
progname, optarg);
exit(1);
}
@ -489,7 +491,7 @@ int main(int argc, char * argv [])
case 'i': /* specify isp clock delay */
ispdelay = strtol(optarg, &e,10);
if ((e == optarg) || (*e != 0) || ispdelay == 0) {
avrdude_message("%s: invalid isp clock delay specified '%s'\n",
avrdude_message(MSG_INFO, "%s: invalid isp clock delay specified '%s'\n",
progname, optarg);
exit(1);
}
@ -565,7 +567,7 @@ int main(int argc, char * argv [])
case 'U':
upd = parse_op(optarg);
if (upd == NULL) {
avrdude_message("%s: error parsing update operation '%s'\n",
avrdude_message(MSG_INFO, "%s: error parsing update operation '%s'\n",
progname, optarg);
exit(1);
}
@ -591,12 +593,12 @@ int main(int argc, char * argv [])
break;
case 'y':
avrdude_message("%s: erase cycle counter no longer supported\n",
avrdude_message(MSG_INFO, "%s: erase cycle counter no longer supported\n",
progname);
break;
case 'Y':
avrdude_message("%s: erase cycle counter no longer supported\n",
avrdude_message(MSG_INFO, "%s: erase cycle counter no longer supported\n",
progname);
break;
@ -606,7 +608,7 @@ int main(int argc, char * argv [])
break;
default:
avrdude_message("%s: invalid option -%c\n\n", progname, ch);
avrdude_message(MSG_INFO, "%s: invalid option -%c\n\n", progname, ch);
usage();
exit(1);
break;
@ -637,47 +639,38 @@ int main(int argc, char * argv [])
}
}
if (verbose) {
/*
* Print out an identifying string so folks can tell what version
* they are running
*/
avrdude_message("\n%s: Version %s, compiled on %s at %s\n"
/*
* Print out an identifying string so folks can tell what version
* they are running
*/
avrdude_message(MSG_NOTICE, "\n%s: Version %s, compiled on %s at %s\n"
"%sCopyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/\n"
"%sCopyright (c) 2007-2014 Joerg Wunsch\n\n",
progname, version, __DATE__, __TIME__, progbuf, progbuf);
}
if (verbose) {
avrdude_message("%sSystem wide configuration file is \"%s\"\n",
avrdude_message(MSG_NOTICE, "%sSystem wide configuration file is \"%s\"\n",
progbuf, sys_config);
}
rc = read_config(sys_config);
if (rc) {
avrdude_message("%s: error reading system wide configuration file \"%s\"\n",
avrdude_message(MSG_INFO, "%s: error reading system wide configuration file \"%s\"\n",
progname, sys_config);
exit(1);
}
if (usr_config[0] != 0) {
if (verbose) {
avrdude_message("%sUser configuration file is \"%s\"\n",
avrdude_message(MSG_NOTICE, "%sUser configuration file is \"%s\"\n",
progbuf, usr_config);
}
rc = stat(usr_config, &sb);
if ((rc < 0) || ((sb.st_mode & S_IFREG) == 0)) {
if (verbose) {
avrdude_message("%sUser configuration file does not exist or is not a "
"regular file, skipping\n",
progbuf);
}
avrdude_message(MSG_NOTICE, "%sUser configuration file does not exist or is not a "
"regular file, skipping\n",
progbuf);
}
else {
rc = read_config(usr_config);
if (rc) {
avrdude_message("%s: error reading user configuration file \"%s\"\n",
avrdude_message(MSG_INFO, "%s: error reading user configuration file \"%s\"\n",
progname, usr_config);
exit(1);
}
@ -690,14 +683,12 @@ int main(int argc, char * argv [])
for (ln1=lfirst(additional_config_files); ln1; ln1=lnext(ln1)) {
p = ldata(ln1);
if (verbose) {
avrdude_message("%sAdditional configuration file is \"%s\"\n",
progbuf, p);
}
avrdude_message(MSG_NOTICE, "%sAdditional configuration file is \"%s\"\n",
progbuf, p);
rc = read_config(p);
if (rc) {
avrdude_message("%s: error reading additional configuration file \"%s\"\n",
avrdude_message(MSG_INFO, "%s: error reading additional configuration file \"%s\"\n",
progname, p);
exit(1);
}
@ -709,62 +700,60 @@ int main(int argc, char * argv [])
bitclock = default_bitclock;
}
if (verbose) {
avrdude_message("\n");
}
avrdude_message(MSG_NOTICE, "\n");
if (partdesc) {
if (strcmp(partdesc, "?") == 0) {
avrdude_message("\n");
avrdude_message("Valid parts are:\n");
avrdude_message(MSG_INFO, "\n");
avrdude_message(MSG_INFO, "Valid parts are:\n");
list_parts(stderr, " ", part_list);
avrdude_message("\n");
avrdude_message(MSG_INFO, "\n");
exit(1);
}
}
if (programmer) {
if (strcmp(programmer, "?") == 0) {
avrdude_message("\n");
avrdude_message("Valid programmers are:\n");
avrdude_message(MSG_INFO, "\n");
avrdude_message(MSG_INFO, "Valid programmers are:\n");
list_programmers(stderr, " ", programmers);
avrdude_message("\n");
avrdude_message(MSG_INFO, "\n");
exit(1);
}
if (strcmp(programmer, "?type") == 0) {
avrdude_message("\n");
avrdude_message("Valid programmer types are:\n");
avrdude_message(MSG_INFO, "\n");
avrdude_message(MSG_INFO, "Valid programmer types are:\n");
list_programmer_types(stderr, " ");
avrdude_message("\n");
avrdude_message(MSG_INFO, "\n");
exit(1);
}
}
if (programmer[0] == 0) {
avrdude_message("\n%s: no programmer has been specified on the command line "
avrdude_message(MSG_INFO, "\n%s: no programmer has been specified on the command line "
"or the config file\n",
progname);
avrdude_message("%sSpecify a programmer using the -c option and try again\n\n",
avrdude_message(MSG_INFO, "%sSpecify a programmer using the -c option and try again\n\n",
progbuf);
exit(1);
}
pgm = locate_programmer(programmers, programmer);
if (pgm == NULL) {
avrdude_message("\n");
avrdude_message("%s: Can't find programmer id \"%s\"\n",
avrdude_message(MSG_INFO, "\n");
avrdude_message(MSG_INFO, "%s: Can't find programmer id \"%s\"\n",
progname, programmer);
avrdude_message("\nValid programmers are:\n");
avrdude_message(MSG_INFO, "\nValid programmers are:\n");
list_programmers(stderr, " ", programmers);
avrdude_message("\n");
avrdude_message(MSG_INFO, "\n");
exit(1);
}
if (pgm->initpgm) {
pgm->initpgm(pgm);
} else {
avrdude_message("\n%s: Can't initialize the programmer.\n\n",
avrdude_message(MSG_INFO, "\n%s: Can't initialize the programmer.\n\n",
progname);
exit(1);
}
@ -778,12 +767,12 @@ int main(int argc, char * argv [])
if (lsize(extended_params) > 0) {
if (pgm->parseextparams == NULL) {
avrdude_message("%s: WARNING: Programmer doesn't support extended parameters,"
avrdude_message(MSG_INFO, "%s: WARNING: Programmer doesn't support extended parameters,"
" -x option(s) ignored\n",
progname);
} else {
if (pgm->parseextparams(pgm, extended_params) < 0) {
avrdude_message("%s: Error parsing extended parameter list\n",
avrdude_message(MSG_INFO, "%s: Error parsing extended parameter list\n",
progname);
exit(1);
}
@ -808,29 +797,29 @@ int main(int argc, char * argv [])
}
if (partdesc == NULL) {
avrdude_message("%s: No AVR part has been specified, use \"-p Part\"\n\n",
avrdude_message(MSG_INFO, "%s: No AVR part has been specified, use \"-p Part\"\n\n",
progname);
avrdude_message("Valid parts are:\n");
avrdude_message(MSG_INFO, "Valid parts are:\n");
list_parts(stderr, " ", part_list);
avrdude_message("\n");
avrdude_message(MSG_INFO, "\n");
exit(1);
}
p = locate_part(part_list, partdesc);
if (p == NULL) {
avrdude_message("%s: AVR Part \"%s\" not found.\n\n",
avrdude_message(MSG_INFO, "%s: AVR Part \"%s\" not found.\n\n",
progname, partdesc);
avrdude_message("Valid parts are:\n");
avrdude_message(MSG_INFO, "Valid parts are:\n");
list_parts(stderr, " ", part_list);
avrdude_message("\n");
avrdude_message(MSG_INFO, "\n");
exit(1);
}
if (exitspecs != NULL) {
if (pgm->parseexitspecs == NULL) {
avrdude_message("%s: WARNING: -E option not supported by this programmer type\n",
avrdude_message(MSG_INFO, "%s: WARNING: -E option not supported by this programmer type\n",
progname);
exitspecs = NULL;
}
@ -865,7 +854,7 @@ int main(int argc, char * argv [])
if (avr_initmem(p) != 0)
{
avrdude_message("\n%s: failed to initialize memories\n",
avrdude_message(MSG_INFO, "\n%s: failed to initialize memories\n",
progname);
exit(1);
}
@ -880,14 +869,12 @@ int main(int argc, char * argv [])
upd = ldata(ln);
if (upd->memtype == NULL) {
const char *mtype = (p->flags & AVRPART_HAS_PDI)? "application": "flash";
if (verbose >= 2) {
avrdude_message("%s: defaulting memtype in -U %c:%s option to \"%s\"\n",
progname,
(upd->op == DEVICE_READ)? 'r': (upd->op == DEVICE_WRITE)? 'w': 'v',
upd->filename, mtype);
}
avrdude_message(MSG_NOTICE2, "%s: defaulting memtype in -U %c:%s option to \"%s\"\n",
progname,
(upd->op == DEVICE_READ)? 'r': (upd->op == DEVICE_WRITE)? 'w': 'v',
upd->filename, mtype);
if ((upd->memtype = strdup(mtype)) == NULL) {
avrdude_message("%s: out of memory\n", progname);
avrdude_message(MSG_INFO, "%s: out of memory\n", progname);
exit(1);
}
}
@ -897,42 +884,36 @@ int main(int argc, char * argv [])
* open the programmer
*/
if (port[0] == 0) {
avrdude_message("\n%s: no port has been specified on the command line "
avrdude_message(MSG_INFO, "\n%s: no port has been specified on the command line "
"or the config file\n",
progname);
avrdude_message("%sSpecify a port using the -P option and try again\n\n",
avrdude_message(MSG_INFO, "%sSpecify a port using the -P option and try again\n\n",
progbuf);
exit(1);
}
if (verbose) {
avrdude_message("%sUsing Port : %s\n", progbuf, port);
avrdude_message("%sUsing Programmer : %s\n", progbuf, programmer);
avrdude_message(MSG_NOTICE, "%sUsing Port : %s\n", progbuf, port);
avrdude_message(MSG_NOTICE, "%sUsing Programmer : %s\n", progbuf, programmer);
if ((strcmp(pgm->type, "avr910") == 0)) {
avrdude_message("%savr910_devcode (avrdude.conf) : ", progbuf);
if(p->avr910_devcode)avrdude_message("0x%x\n", p->avr910_devcode);
else avrdude_message("none\n");
avrdude_message(MSG_NOTICE, "%savr910_devcode (avrdude.conf) : ", progbuf);
if(p->avr910_devcode)avrdude_message(MSG_INFO, "0x%x\n", p->avr910_devcode);
else avrdude_message(MSG_NOTICE, "none\n");
}
}
if (baudrate != 0) {
if (verbose) {
avrdude_message("%sOverriding Baud Rate : %d\n", progbuf, baudrate);
}
avrdude_message(MSG_NOTICE, "%sOverriding Baud Rate : %d\n", progbuf, baudrate);
pgm->baudrate = baudrate;
}
if (bitclock != 0.0) {
if (verbose) {
avrdude_message("%sSetting bit clk period : %.1f\n", progbuf, bitclock);
}
avrdude_message(MSG_NOTICE, "%sSetting bit clk period : %.1f\n", progbuf, bitclock);
pgm->bitclock = bitclock * 1e-6;
}
if (ispdelay != 0) {
if (verbose) {
avrdude_message("%sSetting isp clock delay : %3i\n", progbuf, ispdelay);
}
avrdude_message(MSG_NOTICE, "%sSetting isp clock delay : %3i\n", progbuf, ispdelay);
pgm->ispdelay = ispdelay;
}
@ -950,15 +931,15 @@ int main(int argc, char * argv [])
* as outlined in appnote AVR053
*/
if (pgm->perform_osccal == 0) {
avrdude_message("%s: programmer does not support RC oscillator calibration\n",
avrdude_message(MSG_INFO, "%s: programmer does not support RC oscillator calibration\n",
progname);
exitrc = 1;
} else {
avrdude_message("%s: performing RC oscillator calibration\n", progname);
avrdude_message(MSG_INFO, "%s: performing RC oscillator calibration\n", progname);
exitrc = pgm->perform_osccal(pgm);
}
if (exitrc == 0 && quell_progress < 2) {
avrdude_message("%s: calibration value is now stored in EEPROM at address 0\n",
avrdude_message(MSG_INFO, "%s: calibration value is now stored in EEPROM at address 0\n",
progname);
}
goto main_exit;
@ -966,12 +947,12 @@ int main(int argc, char * argv [])
if (verbose) {
avr_display(stderr, p, progbuf, verbose);
avrdude_message("\n");
avrdude_message(MSG_NOTICE, "\n");
programmer_display(pgm, progbuf);
}
if (quell_progress < 2) {
avrdude_message("\n");
avrdude_message(MSG_INFO, "\n");
}
exitrc = 0;
@ -994,9 +975,9 @@ int main(int argc, char * argv [])
*/
init_ok = (rc = pgm->initialize(pgm, p)) >= 0;
if (!init_ok) {
avrdude_message("%s: initialization failed, rc=%d\n", progname, rc);
avrdude_message(MSG_INFO, "%s: initialization failed, rc=%d\n", progname, rc);
if (!ovsigck) {
avrdude_message("%sDouble check connections and try again, "
avrdude_message(MSG_INFO, "%sDouble check connections and try again, "
"or use -F to override\n"
"%sthis check.\n\n",
progbuf, progbuf);
@ -1009,7 +990,7 @@ int main(int argc, char * argv [])
pgm->rdy_led(pgm, ON);
if (quell_progress < 2) {
avrdude_message("%s: AVR device initialized and ready to accept instructions\n",
avrdude_message(MSG_INFO, "%s: AVR device initialized and ready to accept instructions\n",
progname);
}
@ -1028,7 +1009,7 @@ int main(int argc, char * argv [])
if (init_ok) {
rc = avr_signature(pgm, p);
if (rc != 0) {
avrdude_message("%s: error reading signature data, rc=%d\n",
avrdude_message(MSG_INFO, "%s: error reading signature data, rc=%d\n",
progname, rc);
exitrc = 1;
goto main_exit;
@ -1037,7 +1018,7 @@ int main(int argc, char * argv [])
sig = avr_locate_mem(p, "signature");
if (sig == NULL) {
avrdude_message("%s: WARNING: signature data not defined for device \"%s\"\n",
avrdude_message(MSG_INFO, "%s: WARNING: signature data not defined for device \"%s\"\n",
progname, p->desc);
}
@ -1045,12 +1026,12 @@ int main(int argc, char * argv [])
int ff, zz;
if (quell_progress < 2) {
avrdude_message("%s: Device signature = 0x", progname);
avrdude_message(MSG_INFO, "%s: Device signature = 0x", progname);
}
ff = zz = 1;
for (i=0; i<sig->size; i++) {
if (quell_progress < 2) {
avrdude_message("%02x", sig->buf[i]);
avrdude_message(MSG_INFO, "%02x", sig->buf[i]);
}
if (sig->buf[i] != 0xff)
ff = 0;
@ -1061,16 +1042,16 @@ int main(int argc, char * argv [])
if (++attempt < 3) {
waittime *= 5;
if (quell_progress < 2) {
avrdude_message(" (retrying)\n");
avrdude_message(MSG_INFO, " (retrying)\n");
}
goto sig_again;
}
if (quell_progress < 2) {
avrdude_message("\n");
avrdude_message(MSG_INFO, "\n");
}
avrdude_message("%s: Yikes! Invalid device signature.\n", progname);
avrdude_message(MSG_INFO, "%s: Yikes! Invalid device signature.\n", progname);
if (!ovsigck) {
avrdude_message("%sDouble check connections and try again, "
avrdude_message(MSG_INFO, "%sDouble check connections and try again, "
"or use -F to override\n"
"%sthis check.\n\n",
progbuf, progbuf);
@ -1079,7 +1060,7 @@ int main(int argc, char * argv [])
}
} else {
if (quell_progress < 2) {
avrdude_message("\n");
avrdude_message(MSG_INFO, "\n");
}
}
@ -1087,11 +1068,11 @@ int main(int argc, char * argv [])
sig->buf[0] != p->signature[0] ||
sig->buf[1] != p->signature[1] ||
sig->buf[2] != p->signature[2]) {
avrdude_message("%s: Expected signature for %s is %02X %02X %02X\n",
avrdude_message(MSG_INFO, "%s: Expected signature for %s is %02X %02X %02X\n",
progname, p->desc,
p->signature[0], p->signature[1], p->signature[2]);
if (!ovsigck) {
avrdude_message("%sDouble check chip, "
avrdude_message(MSG_INFO, "%sDouble check chip, "
"or use -F to override this check.\n",
progbuf);
exitrc = 1;
@ -1106,24 +1087,20 @@ int main(int argc, char * argv [])
and extended fuse bytes as needed */
rc = safemode_readfuses(&safemode_lfuse, &safemode_hfuse,
&safemode_efuse, &safemode_fuse, pgm, p, verbose);
&safemode_efuse, &safemode_fuse, pgm, p);
if (rc != 0) {
//Check if the programmer just doesn't support reading
if (rc == -5)
{
if (verbose > 0)
{
avrdude_message("%s: safemode: Fuse reading not support by programmer.\n"
" Safemode disabled.\n", progname);
}
safemode = 0;
avrdude_message(MSG_NOTICE, "%s: safemode: Fuse reading not support by programmer.\n"
" Safemode disabled.\n", progname);
}
else
{
avrdude_message("%s: safemode: To protect your AVR the programming "
avrdude_message(MSG_INFO, "%s: safemode: To protect your AVR the programming "
"will be aborted\n",
progname);
exitrc = 1;
@ -1139,7 +1116,7 @@ int main(int argc, char * argv [])
if ((p->flags & AVRPART_HAS_PDI) && pgm->page_erase != NULL &&
lsize(updates) > 0) {
if (quell_progress < 2) {
avrdude_message("%s: NOTE: Programmer supports page erase for Xmega devices.\n"
avrdude_message(MSG_INFO, "%s: NOTE: Programmer supports page erase for Xmega devices.\n"
"%sEach page will be erased before programming it, but no chip erase is performed.\n"
"%sTo disable page erases, specify the -D option; for a chip-erase, use the -e option.\n",
progname, progbuf, progbuf);
@ -1157,7 +1134,7 @@ int main(int argc, char * argv [])
if ((strcasecmp(m->desc, memname) == 0) && (upd->op == DEVICE_WRITE)) {
erase = 1;
if (quell_progress < 2) {
avrdude_message("%s: NOTE: \"%s\" memory has been specified, an erase cycle "
avrdude_message(MSG_INFO, "%s: NOTE: \"%s\" memory has been specified, an erase cycle "
"will be performed\n"
"%sTo disable this feature, specify the -D option.\n",
progname, memname, progbuf);
@ -1174,11 +1151,11 @@ int main(int argc, char * argv [])
* before the chip can accept new programming
*/
if (uflags & UF_NOWRITE) {
avrdude_message("%s: conflicting -e and -n options specified, NOT erasing chip\n",
avrdude_message(MSG_INFO, "%s: conflicting -e and -n options specified, NOT erasing chip\n",
progname);
} else {
if (quell_progress < 2) {
avrdude_message("%s: erasing chip\n", progname);
avrdude_message(MSG_INFO, "%s: erasing chip\n", progname);
}
exitrc = avr_chip_erase(pgm, p);
if(exitrc) goto main_exit;
@ -1223,7 +1200,7 @@ int main(int argc, char * argv [])
char yes[1] = {'y'};
if (quell_progress < 2) {
avrdude_message("\n");
avrdude_message(MSG_INFO, "\n");
}
//Restore the default fuse values
@ -1231,11 +1208,11 @@ int main(int argc, char * argv [])
/* Try reading back fuses, make sure they are reliable to read back */
if (safemode_readfuses(&safemodeafter_lfuse, &safemodeafter_hfuse,
&safemodeafter_efuse, &safemodeafter_fuse, pgm, p, verbose) != 0) {
&safemodeafter_efuse, &safemodeafter_fuse, pgm, p) != 0) {
/* Uh-oh.. try once more to read back fuses */
if (safemode_readfuses(&safemodeafter_lfuse, &safemodeafter_hfuse,
&safemodeafter_efuse, &safemodeafter_fuse, pgm, p, verbose) != 0) {
avrdude_message("%s: safemode: Sorry, reading back fuses was unreliable. "
&safemodeafter_efuse, &safemodeafter_fuse, pgm, p) != 0) {
avrdude_message(MSG_INFO, "%s: safemode: Sorry, reading back fuses was unreliable. "
"I have given up and exited programming mode\n",
progname);
exitrc = 1;
@ -1246,7 +1223,7 @@ int main(int argc, char * argv [])
/* Now check what fuses are against what they should be */
if (safemodeafter_fuse != safemode_fuse) {
fuses_updated = 1;
avrdude_message("%s: safemode: fuse changed! Was %x, and is now %x\n",
avrdude_message(MSG_INFO, "%s: safemode: fuse changed! Was %x, and is now %x\n",
progname, safemode_fuse, safemodeafter_fuse);
@ -1261,11 +1238,11 @@ int main(int argc, char * argv [])
/* Enough chit-chat, time to program some fuses and check them */
if (safemode_writefuse (safemode_fuse, "fuse", pgm, p,
10, verbose) == 0) {
avrdude_message("%s: safemode: and is now rescued\n", progname);
10) == 0) {
avrdude_message(MSG_INFO, "%s: safemode: and is now rescued\n", progname);
}
else {
avrdude_message("%s: and COULD NOT be changed\n", progname);
avrdude_message(MSG_INFO, "%s: and COULD NOT be changed\n", progname);
failures++;
}
}
@ -1274,7 +1251,7 @@ int main(int argc, char * argv [])
/* Now check what fuses are against what they should be */
if (safemodeafter_lfuse != safemode_lfuse) {
fuses_updated = 1;
avrdude_message("%s: safemode: lfuse changed! Was %x, and is now %x\n",
avrdude_message(MSG_INFO, "%s: safemode: lfuse changed! Was %x, and is now %x\n",
progname, safemode_lfuse, safemodeafter_lfuse);
@ -1289,11 +1266,11 @@ int main(int argc, char * argv [])
/* Enough chit-chat, time to program some fuses and check them */
if (safemode_writefuse (safemode_lfuse, "lfuse", pgm, p,
10, verbose) == 0) {
avrdude_message("%s: safemode: and is now rescued\n", progname);
10) == 0) {
avrdude_message(MSG_INFO, "%s: safemode: and is now rescued\n", progname);
}
else {
avrdude_message("%s: and COULD NOT be changed\n", progname);
avrdude_message(MSG_INFO, "%s: and COULD NOT be changed\n", progname);
failures++;
}
}
@ -1302,7 +1279,7 @@ int main(int argc, char * argv [])
/* Now check what fuses are against what they should be */
if (safemodeafter_hfuse != safemode_hfuse) {
fuses_updated = 1;
avrdude_message("%s: safemode: hfuse changed! Was %x, and is now %x\n",
avrdude_message(MSG_INFO, "%s: safemode: hfuse changed! Was %x, and is now %x\n",
progname, safemode_hfuse, safemodeafter_hfuse);
/* Ask user - should we change them */
@ -1314,11 +1291,11 @@ int main(int argc, char * argv [])
/* Enough chit-chat, time to program some fuses and check them */
if (safemode_writefuse(safemode_hfuse, "hfuse", pgm, p,
10, verbose) == 0) {
avrdude_message("%s: safemode: and is now rescued\n", progname);
10) == 0) {
avrdude_message(MSG_INFO, "%s: safemode: and is now rescued\n", progname);
}
else {
avrdude_message("%s: and COULD NOT be changed\n", progname);
avrdude_message(MSG_INFO, "%s: and COULD NOT be changed\n", progname);
failures++;
}
}
@ -1327,7 +1304,7 @@ int main(int argc, char * argv [])
/* Now check what fuses are against what they should be */
if (safemodeafter_efuse != safemode_efuse) {
fuses_updated = 1;
avrdude_message("%s: safemode: efuse changed! Was %x, and is now %x\n",
avrdude_message(MSG_INFO, "%s: safemode: efuse changed! Was %x, and is now %x\n",
progname, safemode_efuse, safemodeafter_efuse);
/* Ask user - should we change them */
@ -1339,24 +1316,24 @@ int main(int argc, char * argv [])
/* Enough chit-chat, time to program some fuses and check them */
if (safemode_writefuse (safemode_efuse, "efuse", pgm, p,
10, verbose) == 0) {
avrdude_message("%s: safemode: and is now rescued\n", progname);
10) == 0) {
avrdude_message(MSG_INFO, "%s: safemode: and is now rescued\n", progname);
}
else {
avrdude_message("%s: and COULD NOT be changed\n", progname);
avrdude_message(MSG_INFO, "%s: and COULD NOT be changed\n", progname);
failures++;
}
}
}
if (quell_progress < 2) {
avrdude_message("%s: safemode: ", progname);
avrdude_message(MSG_INFO, "%s: safemode: ", progname);
if (failures == 0) {
avrdude_message("Fuses OK (E:%02X, H:%02X, L:%02X)\n",
avrdude_message(MSG_INFO, "Fuses OK (E:%02X, H:%02X, L:%02X)\n",
safemode_efuse, safemode_hfuse, safemode_lfuse);
}
else {
avrdude_message("Fuses not recovered, sorry\n");
avrdude_message(MSG_INFO, "Fuses not recovered, sorry\n");
}
}
@ -1384,7 +1361,7 @@ main_exit:
}
if (quell_progress < 2) {
avrdude_message("\n%s done. Thank you.\n\n", progname);
avrdude_message(MSG_INFO, "\n%s done. Thank you.\n\n", progname);
}
return exitrc;

8
par.c
View File

@ -241,7 +241,7 @@ static int par_open(PROGRAMMER * pgm, char * port)
ppi_open(port, &pgm->fd);
if (pgm->fd.ifd < 0) {
avrdude_message("%s: failed to open parallel port \"%s\"\n\n",
avrdude_message(MSG_INFO, "%s: failed to open parallel port \"%s\"\n\n",
progname, port);
return -1;
}
@ -251,14 +251,14 @@ static int par_open(PROGRAMMER * pgm, char * port)
*/
rc = ppi_getall(&pgm->fd, PPIDATA);
if (rc < 0) {
avrdude_message("%s: error reading status of ppi data port\n", progname);
avrdude_message(MSG_INFO, "%s: error reading status of ppi data port\n", progname);
return -1;
}
pgm->ppidata = rc;
rc = ppi_getall(&pgm->fd, PPICTRL);
if (rc < 0) {
avrdude_message("%s: error reading status of ppi ctrl port\n", progname);
avrdude_message(MSG_INFO, "%s: error reading status of ppi ctrl port\n", progname);
return -1;
}
pgm->ppictrl = rc;
@ -402,7 +402,7 @@ void par_initpgm(PROGRAMMER * pgm)
void par_initpgm(PROGRAMMER * pgm)
{
avrdude_message("%s: parallel port access not available in this configuration\n",
avrdude_message(MSG_INFO, "%s: parallel port access not available in this configuration\n",
progname);
}

34
pgm.c
View File

@ -39,7 +39,7 @@ static void pgm_default_6 (struct programmer_t *, const char *);
static int pgm_default_open (struct programmer_t *pgm, char * name)
{
avrdude_message("\n%s: Fatal error: Programmer does not support open()",
avrdude_message(MSG_INFO, "\n%s: Fatal error: Programmer does not support open()",
progname);
return -1;
}
@ -68,7 +68,7 @@ PROGRAMMER * pgm_new(void)
pgm = (PROGRAMMER *)malloc(sizeof(*pgm));
if (pgm == NULL) {
avrdude_message("%s: out of memory allocating programmer structure\n",
avrdude_message(MSG_INFO, "%s: out of memory allocating programmer structure\n",
progname);
exit(1);
}
@ -159,7 +159,7 @@ PROGRAMMER * pgm_dup(const PROGRAMMER * const src)
pgm = (PROGRAMMER *)malloc(sizeof(*pgm));
if (pgm == NULL) {
avrdude_message("%s: out of memory allocating programmer structure\n",
avrdude_message(MSG_INFO, "%s: out of memory allocating programmer structure\n",
progname);
exit(1);
}
@ -172,7 +172,7 @@ PROGRAMMER * pgm_dup(const PROGRAMMER * const src)
for (ln = lfirst(src->usbpid); ln; ln = lnext(ln)) {
int *ip = malloc(sizeof(int));
if (ip == NULL) {
avrdude_message("%s: out of memory allocating programmer structure\n",
avrdude_message(MSG_INFO, "%s: out of memory allocating programmer structure\n",
progname);
exit(1);
}
@ -186,7 +186,7 @@ PROGRAMMER * pgm_dup(const PROGRAMMER * const src)
static void pgm_default(void)
{
avrdude_message("%s: programmer operation not supported\n", progname);
avrdude_message(MSG_INFO, "%s: programmer operation not supported\n", progname);
}
@ -223,8 +223,8 @@ static void pgm_default_6 (struct programmer_t * pgm, const char * p)
void programmer_display(PROGRAMMER * pgm, const char * p)
{
avrdude_message("%sProgrammer Type : %s\n", p, pgm->type);
avrdude_message("%sDescription : %s\n", p, pgm->desc);
avrdude_message(MSG_INFO, "%sProgrammer Type : %s\n", p, pgm->type);
avrdude_message(MSG_INFO, "%sDescription : %s\n", p, pgm->desc);
pgm->display(pgm, p);
}
@ -233,25 +233,25 @@ void programmer_display(PROGRAMMER * pgm, const char * p)
void pgm_display_generic_mask(PROGRAMMER * pgm, const char * p, unsigned int show)
{
if(show & (1<<PPI_AVR_VCC))
avrdude_message("%s VCC = %s\n", p, pins_to_str(&pgm->pin[PPI_AVR_VCC]));
avrdude_message(MSG_INFO, "%s VCC = %s\n", p, pins_to_str(&pgm->pin[PPI_AVR_VCC]));
if(show & (1<<PPI_AVR_BUFF))
avrdude_message("%s BUFF = %s\n", p, pins_to_str(&pgm->pin[PPI_AVR_BUFF]));
avrdude_message(MSG_INFO, "%s BUFF = %s\n", p, pins_to_str(&pgm->pin[PPI_AVR_BUFF]));
if(show & (1<<PIN_AVR_RESET))
avrdude_message("%s RESET = %s\n", p, pins_to_str(&pgm->pin[PIN_AVR_RESET]));
avrdude_message(MSG_INFO, "%s RESET = %s\n", p, pins_to_str(&pgm->pin[PIN_AVR_RESET]));
if(show & (1<<PIN_AVR_SCK))
avrdude_message("%s SCK = %s\n", p, pins_to_str(&pgm->pin[PIN_AVR_SCK]));
avrdude_message(MSG_INFO, "%s SCK = %s\n", p, pins_to_str(&pgm->pin[PIN_AVR_SCK]));
if(show & (1<<PIN_AVR_MOSI))
avrdude_message("%s MOSI = %s\n", p, pins_to_str(&pgm->pin[PIN_AVR_MOSI]));
avrdude_message(MSG_INFO, "%s MOSI = %s\n", p, pins_to_str(&pgm->pin[PIN_AVR_MOSI]));
if(show & (1<<PIN_AVR_MISO))
avrdude_message("%s MISO = %s\n", p, pins_to_str(&pgm->pin[PIN_AVR_MISO]));
avrdude_message(MSG_INFO, "%s MISO = %s\n", p, pins_to_str(&pgm->pin[PIN_AVR_MISO]));
if(show & (1<<PIN_LED_ERR))
avrdude_message("%s ERR LED = %s\n", p, pins_to_str(&pgm->pin[PIN_LED_ERR]));
avrdude_message(MSG_INFO, "%s ERR LED = %s\n", p, pins_to_str(&pgm->pin[PIN_LED_ERR]));
if(show & (1<<PIN_LED_RDY))
avrdude_message("%s RDY LED = %s\n", p, pins_to_str(&pgm->pin[PIN_LED_RDY]));
avrdude_message(MSG_INFO, "%s RDY LED = %s\n", p, pins_to_str(&pgm->pin[PIN_LED_RDY]));
if(show & (1<<PIN_LED_PGM))
avrdude_message("%s PGM LED = %s\n", p, pins_to_str(&pgm->pin[PIN_LED_PGM]));
avrdude_message(MSG_INFO, "%s PGM LED = %s\n", p, pins_to_str(&pgm->pin[PIN_LED_PGM]));
if(show & (1<<PIN_LED_VFY))
avrdude_message("%s VFY LED = %s\n", p, pins_to_str(&pgm->pin[PIN_LED_VFY]));
avrdude_message(MSG_INFO, "%s VFY LED = %s\n", p, pins_to_str(&pgm->pin[PIN_LED_VFY]));
}
void pgm_display_generic(PROGRAMMER * pgm, const char * p)

View File

@ -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

View File

@ -63,7 +63,7 @@ static int pin_fill_old_pinno(const struct pindef_t * const pindef, unsigned int
for(i = 0; i < PIN_MAX; i++) {
if(pindef->mask[i / PIN_FIELD_ELEMENT_SIZE] & (1 << (i % PIN_FIELD_ELEMENT_SIZE))) {
if(found) {
avrdude_message("Multiple pins found\n"); //TODO
avrdude_message(MSG_INFO, "Multiple pins found\n"); //TODO
return -1;
}
found = true;
@ -88,7 +88,7 @@ static int pin_fill_old_pinlist(const struct pindef_t * const pindef, unsigned i
for(i = 0; i < PIN_FIELD_SIZE; i++) {
if(i == 0) {
if((pindef->mask[i] & ~PIN_MASK) != 0) {
avrdude_message("Pins of higher index than max field size for old pinno found\n");
avrdude_message(MSG_INFO, "Pins of higher index than max field size for old pinno found\n");
return -1;
}
if (pindef->mask[i] == 0) {
@ -100,11 +100,11 @@ static int pin_fill_old_pinlist(const struct pindef_t * const pindef, unsigned i
} else if(pindef->mask[i] == ((~pindef->inverse[i]) & pindef->mask[i])) { /* all set bits in mask are cleared in inverse */
*pinno = pindef->mask[i];
} else {
avrdude_message("pins have different polarity set\n");
avrdude_message(MSG_INFO, "pins have different polarity set\n");
return -1;
}
} else if(pindef->mask[i] != 0) {
avrdude_message("Pins have higher number than fit in old format\n");
avrdude_message(MSG_INFO, "Pins have higher number than fit in old format\n");
return -1;
}
}
@ -270,44 +270,40 @@ int pins_check(const struct programmer_t * const pgm, const struct pin_checklist
}
if(invalid) {
if(output) {
avrdude_message("%s: %s: Following pins are not valid pins for this function: %s\n",
avrdude_message(MSG_INFO, "%s: %s: Following pins are not valid pins for this function: %s\n",
progname, avr_pin_name(pinname), pinmask_to_str(invalid_used));
if(verbose >= 2) {
avrdude_message("%s: %s: Valid pins for this function are: %s\n",
avrdude_message(MSG_NOTICE2, "%s: %s: Valid pins for this function are: %s\n",
progname, avr_pin_name(pinname), pinmask_to_str(valid_pins->mask));
}
}
is_ok = false;
}
if(inverse) {
if(output) {
avrdude_message("%s: %s: Following pins are not usable as inverse pins for this function: %s\n",
avrdude_message(MSG_INFO, "%s: %s: Following pins are not usable as inverse pins for this function: %s\n",
progname, avr_pin_name(pinname), pinmask_to_str(inverse_used));
if(verbose >= 2) {
avrdude_message("%s: %s: Valid inverse pins for this function are: %s\n",
avrdude_message(MSG_NOTICE2, "%s: %s: Valid inverse pins for this function are: %s\n",
progname, avr_pin_name(pinname), pinmask_to_str(valid_pins->inverse));
}
}
is_ok = false;
}
if(used) {
if(output) {
avrdude_message("%s: %s: Following pins are set for other functions too: %s\n",
avrdude_message(MSG_INFO, "%s: %s: Following pins are set for other functions too: %s\n",
progname, avr_pin_name(pinname), pinmask_to_str(already_used));
is_ok = false;
}
}
if(!mandatory_used && is_mandatory && !invalid) {
if(output) {
avrdude_message("%s: %s: Mandatory pin is not defined.\n",
avrdude_message(MSG_INFO, "%s: %s: Mandatory pin is not defined.\n",
progname, avr_pin_name(pinname));
}
is_ok = false;
}
if(!is_ok) {
rv = -1;
} else if(output && verbose >= 3) {
avrdude_message("%s: %s: Pin is ok.\n",
} else if(output) {
avrdude_message(MSG_DEBUG, "%s: %s: Pin is ok.\n",
progname, avr_pin_name(pinname));
}
}

4
ppi.c
View File

@ -68,7 +68,7 @@ static int ppi_shadow_access(union filedescriptor *fdp, int reg,
shadow_num = 2;
break;
default:
avrdude_message("%s: avr_set(): invalid register=%d\n",
avrdude_message(MSG_INFO, "%s: avr_set(): invalid register=%d\n",
progname, reg);
return -1;
break;
@ -205,7 +205,7 @@ void ppi_open(char * port, union filedescriptor *fdp)
fd = open(port, O_RDWR);
if (fd < 0) {
avrdude_message("%s: can't open device \"%s\": %s\n",
avrdude_message(MSG_INFO, "%s: can't open device \"%s\": %s\n",
progname, port, strerror(errno));
fdp->ifd = -1;
return;

View File

@ -92,7 +92,7 @@ void ppi_open(char *port, union filedescriptor *fdp)
if(fd < 0)
{
avrdude_message("%s: can't open device \"giveio\"\n\n", progname);
avrdude_message(MSG_INFO, "%s: can't open device \"giveio\"\n\n", progname);
fdp->ifd = -1;
return;
}
@ -120,14 +120,14 @@ void ppi_open(char *port, union filedescriptor *fdp)
fd = strtol(port, &cp, 0);
if(*port == '\0' || *cp != '\0')
{
avrdude_message("%s: port name \"%s\" is neither lpt1/2/3 nor valid number\n",
avrdude_message(MSG_INFO, "%s: port name \"%s\" is neither lpt1/2/3 nor valid number\n",
progname, port);
fd = -1;
}
}
if(fd < 0)
{
avrdude_message("%s: can't open device \"%s\"\n\n", progname, port);
avrdude_message(MSG_INFO, "%s: can't open device \"%s\"\n\n", progname, port);
fdp->ifd = -1;
return;
}
@ -361,7 +361,7 @@ int gettimeofday(struct timeval *tv, struct timezone *unused){
unsigned long dt; \
dt = (unsigned long)((stop.QuadPart - start.QuadPart) * 1000 * 1000 \
/ freq.QuadPart); \
avrdude_message(\
avrdude_message(MSG_INFO, \
"hpt:%i usleep usec:%lu sleep msec:%lu timed usec:%lu\n", \
has_highperf, us, ((us + 999) / 1000), dt); \
} while (0)

View File

@ -33,7 +33,7 @@
* before giving up
*/
int safemode_writefuse (unsigned char fuse, char * fusename, PROGRAMMER * pgm,
AVRPART * p, int tries, int verbose)
AVRPART * p, int tries)
{
AVRMEM * m;
unsigned char fuseread;
@ -56,10 +56,8 @@ int safemode_writefuse (unsigned char fuse, char * fusename, PROGRAMMER * pgm,
}
/* Report information to user if needed */
if (verbose > 0) {
avrdude_message("%s: safemode: Wrote %s to %x, read as %x. %d attempts left\n",
avrdude_message(MSG_NOTICE, "%s: safemode: Wrote %s to %x, read as %x. %d attempts left\n",
progname, fusename, fuse, fuseread, tries-1);
}
/* If fuse wrote OK, no need to keep going */
if (fuse == fuseread) {
@ -78,7 +76,7 @@ int safemode_writefuse (unsigned char fuse, char * fusename, PROGRAMMER * pgm,
*/
int safemode_readfuses (unsigned char * lfuse, unsigned char * hfuse,
unsigned char * efuse, unsigned char * fuse,
PROGRAMMER * pgm, AVRPART * p, int verbose)
PROGRAMMER * pgm, AVRPART * p)
{
unsigned char value;
@ -106,27 +104,18 @@ int safemode_readfuses (unsigned char * lfuse, unsigned char * hfuse,
{
allowfuseread = 0;
}
if (verbose > 2)
{
avrdude_message("%s: safemode read 1, fuse value: %x\n",progname, safemode_fuse);
}
avrdude_message(MSG_DEBUG, "%s: safemode read 1, fuse value: %x\n",progname, safemode_fuse);
if(pgm->read_byte(pgm, p, m, 0, &value) != 0)
{
allowfuseread = 0;
}
if (verbose > 2)
{
avrdude_message("%s: safemode read 2, fuse value: %x\n",progname, value);
}
avrdude_message(MSG_DEBUG, "%s: safemode read 2, fuse value: %x\n",progname, value);
if (value == safemode_fuse) {
if (pgm->read_byte(pgm, p, m, 0, &value) != 0)
{
allowfuseread = 0;
}
if (verbose > 2)
{
avrdude_message("%s: safemode read 3, fuse value: %x\n",progname, value);
}
avrdude_message(MSG_DEBUG, "%s: safemode read 3, fuse value: %x\n",progname, value);
if (value == safemode_fuse)
{
fusegood = 1; /* Fuse read OK three times */
@ -141,12 +130,12 @@ int safemode_readfuses (unsigned char * lfuse, unsigned char * hfuse,
}
if (fusegood == 0) {
avrdude_message("%s: safemode: Verify error - unable to read fuse properly. "
avrdude_message(MSG_INFO, "%s: safemode: Verify error - unable to read fuse properly. "
"Programmer may not be reliable.\n", progname);
return -1;
}
else if ((fusegood == 1) && (verbose > 0)) {
avrdude_message("%s: safemode: fuse reads as %X\n", progname, safemode_fuse);
else if ((fusegood == 1)) {
avrdude_message(MSG_NOTICE, "%s: safemode: fuse reads as %X\n", progname, safemode_fuse);
}
@ -160,27 +149,18 @@ int safemode_readfuses (unsigned char * lfuse, unsigned char * hfuse,
{
allowfuseread = 0;
}
if (verbose > 2)
{
avrdude_message("%s: safemode read 1, lfuse value: %x\n",progname, safemode_lfuse);
}
avrdude_message(MSG_DEBUG, "%s: safemode read 1, lfuse value: %x\n",progname, safemode_lfuse);
if (pgm->read_byte(pgm, p, m, 0, &value) != 0)
{
allowfuseread = 0;
}
if (verbose > 2)
{
avrdude_message("%s: safemode read 2, lfuse value: %x\n",progname, value);
}
avrdude_message(MSG_DEBUG, "%s: safemode read 2, lfuse value: %x\n",progname, value);
if (value == safemode_lfuse) {
if (pgm->read_byte(pgm, p, m, 0, &value) != 0)
{
allowfuseread = 0;
}
if (verbose > 2)
{
avrdude_message("%s: safemode read 3, lfuse value: %x\n",progname, value);
}
avrdude_message(MSG_DEBUG, "%s: safemode read 3, lfuse value: %x\n",progname, value);
if (value == safemode_lfuse){
fusegood = 1; /* Fuse read OK three times */
}
@ -195,12 +175,12 @@ int safemode_readfuses (unsigned char * lfuse, unsigned char * hfuse,
if (fusegood == 0) {
avrdude_message("%s: safemode: Verify error - unable to read lfuse properly. "
avrdude_message(MSG_INFO, "%s: safemode: Verify error - unable to read lfuse properly. "
"Programmer may not be reliable.\n", progname);
return -1;
}
else if ((fusegood == 1) && (verbose > 0)) {
avrdude_message("%s: safemode: lfuse reads as %X\n", progname, safemode_lfuse);
else if (fusegood == 1) {
avrdude_message(MSG_DEBUG, "%s: safemode: lfuse reads as %X\n", progname, safemode_lfuse);
}
/* Read hfuse three times */
@ -213,27 +193,18 @@ int safemode_readfuses (unsigned char * lfuse, unsigned char * hfuse,
{
allowfuseread = 0;
}
if (verbose > 2)
{
avrdude_message("%s: safemode read 1, hfuse value: %x\n",progname, safemode_hfuse);
}
avrdude_message(MSG_DEBUG, "%s: safemode read 1, hfuse value: %x\n",progname, safemode_hfuse);
if (pgm->read_byte(pgm, p, m, 0, &value) != 0)
{
allowfuseread = 0;
}
if (verbose > 2)
{
avrdude_message("%s: safemode read 2, hfuse value: %x\n",progname, value);
}
avrdude_message(MSG_DEBUG, "%s: safemode read 2, hfuse value: %x\n",progname, value);
if (value == safemode_hfuse) {
if (pgm->read_byte(pgm, p, m, 0, &value) != 0)
{
allowfuseread = 0;
}
if (verbose > 2)
{
avrdude_message("%s: safemode read 3, hfuse value: %x\n",progname, value);
}
avrdude_message(MSG_DEBUG, "%s: safemode read 3, hfuse value: %x\n",progname, value);
if (value == safemode_hfuse){
fusegood = 1; /* Fuse read OK three times */
}
@ -247,12 +218,12 @@ int safemode_readfuses (unsigned char * lfuse, unsigned char * hfuse,
}
if (fusegood == 0) {
avrdude_message("%s: safemode: Verify error - unable to read hfuse properly. "
avrdude_message(MSG_INFO, "%s: safemode: Verify error - unable to read hfuse properly. "
"Programmer may not be reliable.\n", progname);
return -2;
}
else if ((fusegood == 1) && (verbose > 0)){
avrdude_message("%s: safemode: hfuse reads as %X\n", progname, safemode_hfuse);
else if (fusegood == 1){
avrdude_message(MSG_NOTICE, "%s: safemode: hfuse reads as %X\n", progname, safemode_hfuse);
}
/* Read efuse three times */
@ -265,27 +236,18 @@ int safemode_readfuses (unsigned char * lfuse, unsigned char * hfuse,
{
allowfuseread = 0;
}
if (verbose > 2)
{
avrdude_message("%s: safemode read 1, efuse value: %x\n",progname, safemode_efuse);
}
avrdude_message(MSG_DEBUG, "%s: safemode read 1, efuse value: %x\n",progname, safemode_efuse);
if (pgm->read_byte(pgm, p, m, 0, &value) != 0)
{
allowfuseread = 0;
}
if (verbose > 2)
{
avrdude_message("%s: safemode read 2, efuse value: %x\n",progname, value);
}
avrdude_message(MSG_DEBUG, "%s: safemode read 2, efuse value: %x\n",progname, value);
if (value == safemode_efuse) {
if (pgm->read_byte(pgm, p, m, 0, &value) != 0)
{
allowfuseread = 0;
}
if (verbose > 2)
{
avrdude_message("%s: safemode read 3, efuse value: %x\n",progname, value);
}
avrdude_message(MSG_DEBUG, "%s: safemode read 3, efuse value: %x\n",progname, value);
if (value == safemode_efuse){
fusegood = 1; /* Fuse read OK three times */
}
@ -299,12 +261,12 @@ int safemode_readfuses (unsigned char * lfuse, unsigned char * hfuse,
}
if (fusegood == 0) {
avrdude_message("%s: safemode: Verify error - unable to read efuse properly. "
avrdude_message(MSG_INFO, "%s: safemode: Verify error - unable to read efuse properly. "
"Programmer may not be reliable.\n", progname);
return -3;
}
else if ((fusegood == 1) && (verbose > 0)) {
avrdude_message("%s: safemode: efuse reads as %X\n", progname, safemode_efuse);
else if (fusegood == 1) {
avrdude_message(MSG_NOTICE, "%s: safemode: efuse reads as %X\n", progname, safemode_efuse);
}
*lfuse = safemode_lfuse;

View File

@ -313,7 +313,7 @@ static int usbOpenDevice(union filedescriptor *fdp, int vendor, char *vendorName
handle = usb_open(dev); /* we need to open the device in order to query strings */
if(!handle){
errorCode = USB_ERROR_ACCESS;
avrdude_message("Warning: cannot open USB device: %s\n",
avrdude_message(MSG_INFO, "Warning: cannot open USB device: %s\n",
usb_strerror());
continue;
}
@ -325,21 +325,21 @@ static int usbOpenDevice(union filedescriptor *fdp, int vendor, char *vendorName
0x0409, string, sizeof(string));
if(len < 0){
errorCode = USB_ERROR_IO;
avrdude_message("Warning: cannot query manufacturer for device: %s\n",
avrdude_message(MSG_INFO, "Warning: cannot query manufacturer for device: %s\n",
usb_strerror());
}else{
errorCode = USB_ERROR_NOTFOUND;
/* avrdude_message("seen device from vendor ->%s<-\n", string); */
/* avrdude_message(MSG_INFO, "seen device from vendor ->%s<-\n", string); */
if(strcmp(string, vendorName) == 0){
len = usbGetStringAscii(handle, dev->descriptor.iProduct,
0x0409, string, sizeof(string));
if(len < 0){
errorCode = USB_ERROR_IO;
avrdude_message("Warning: cannot query product for device: %s\n",
avrdude_message(MSG_INFO, "Warning: cannot query product for device: %s\n",
usb_strerror());
}else{
errorCode = USB_ERROR_NOTFOUND;
/* avrdude_message("seen product ->%s<-\n", string); */
/* avrdude_message(MSG_INFO, "seen product ->%s<-\n", string); */
if(strcmp(string, productName) == 0)
break;
}
@ -355,7 +355,7 @@ static int usbOpenDevice(union filedescriptor *fdp, int vendor, char *vendorName
if(handle != NULL){
int rval, retries = 3;
if(usb_set_configuration(handle, 1)){
avrdude_message("Warning: could not set configuration: %s\n",
avrdude_message(MSG_INFO, "Warning: could not set configuration: %s\n",
usb_strerror());
}
/* now try to claim the interface and detach the kernel HID driver on
@ -364,13 +364,13 @@ static int usbOpenDevice(union filedescriptor *fdp, int vendor, char *vendorName
while((rval = usb_claim_interface(handle, 0)) != 0 && retries-- > 0){
#ifdef LIBUSB_HAS_DETACH_KERNEL_DRIVER_NP
if(usb_detach_kernel_driver_np(handle, 0) < 0){
avrdude_message("Warning: could not detach kernel HID driver: %s\n",
avrdude_message(MSG_INFO, "Warning: could not detach kernel HID driver: %s\n",
usb_strerror());
}
#endif
}
if(rval != 0)
avrdude_message("Warning: could not claim interface\n");
avrdude_message(MSG_INFO, "Warning: could not claim interface\n");
/* Continue anyway, even if we could not claim the interface. Control transfers
* should still work.
*/
@ -403,7 +403,7 @@ static int usbSetReport(union filedescriptor *fdp, int reportType, char *buffer,
reportType << 8 | buffer[0], 0, buffer, len, 5000);
if(bytesSent != len){
if(bytesSent < 0)
avrdude_message("Error sending message: %s\n", usb_strerror());
avrdude_message(MSG_INFO, "Error sending message: %s\n", usb_strerror());
return USB_ERROR_IO;
}
return 0;
@ -424,7 +424,7 @@ static int usbGetReport(union filedescriptor *fdp, int reportType, int reportNum
USB_RECIP_INTERFACE | USB_ENDPOINT_IN, USBRQ_HID_GET_REPORT,
reportType << 8 | reportNumber, 0, buffer, maxLen, 5000);
if(bytesReceived < 0){
avrdude_message("Error sending message: %s\n", usb_strerror());
avrdude_message(MSG_INFO, "Error sending message: %s\n", usb_strerror());
return USB_ERROR_IO;
}
*len = bytesReceived;
@ -448,11 +448,11 @@ static void dumpBlock(char *prefix, unsigned char *buf, int len)
int i;
if(len <= 8){ /* more compact format for short blocks */
avrdude_message("%s: %d bytes: ", prefix, len);
avrdude_message(MSG_INFO, "%s: %d bytes: ", prefix, len);
for(i = 0; i < len; i++){
avrdude_message("%02x ", buf[i]);
avrdude_message(MSG_INFO, "%02x ", buf[i]);
}
avrdude_message(" \"");
avrdude_message(MSG_INFO, " \"");
for(i = 0; i < len; i++){
if(buf[i] >= 0x20 && buf[i] < 0x7f){
fputc(buf[i], stderr);
@ -460,20 +460,20 @@ static void dumpBlock(char *prefix, unsigned char *buf, int len)
fputc('.', stderr);
}
}
avrdude_message("\"\n");
avrdude_message(MSG_INFO, "\"\n");
}else{
avrdude_message("%s: %d bytes:\n", prefix, len);
avrdude_message(MSG_INFO, "%s: %d bytes:\n", prefix, len);
while(len > 0){
for(i = 0; i < 16; i++){
if(i < len){
avrdude_message("%02x ", buf[i]);
avrdude_message(MSG_INFO, "%02x ", buf[i]);
}else{
avrdude_message(" ");
avrdude_message(MSG_INFO, " ");
}
if(i == 7)
fputc(' ', stderr);
}
avrdude_message(" \"");
avrdude_message(MSG_INFO, " \"");
for(i = 0; i < 16; i++){
if(i < len){
if(buf[i] >= 0x20 && buf[i] < 0x7f){
@ -483,7 +483,7 @@ static void dumpBlock(char *prefix, unsigned char *buf, int len)
}
}
}
avrdude_message("\"\n");
avrdude_message(MSG_INFO, "\"\n");
buf += 16;
len -= 16;
}
@ -516,7 +516,7 @@ static int avrdoper_open(char *port, union pinfo pinfo, union filedescriptor *fd
rval = usbOpenDevice(fdp, USB_VENDOR_ID, vname, USB_PRODUCT_ID, devname, 1);
if(rval != 0){
avrdude_message("%s: avrdoper_open(): %s\n", progname, usbErrorText(rval));
avrdude_message(MSG_INFO, "%s: avrdoper_open(): %s\n", progname, usbErrorText(rval));
return -1;
}
return 0;
@ -554,12 +554,11 @@ static int avrdoper_send(union filedescriptor *fdp, unsigned char *buf, size_t b
buffer[0] = lenIndex + 1; /* report ID */
buffer[1] = thisLen;
memcpy(buffer + 2, buf, thisLen);
if(verbose > 3)
avrdude_message("Sending %d bytes data chunk\n", thisLen);
avrdude_message(MSG_TRACE, "Sending %d bytes data chunk\n", thisLen);
rval = usbSetReport(fdp, USB_HID_REPORT_TYPE_FEATURE, (char *)buffer,
reportDataSizes[lenIndex] + 2);
if(rval != 0){
avrdude_message("%s: avrdoper_send(): %s\n", progname, usbErrorText(rval));
avrdude_message(MSG_INFO, "%s: avrdoper_send(): %s\n", progname, usbErrorText(rval));
return -1;
}
buflen -= thisLen;
@ -585,17 +584,16 @@ static int avrdoperFillBuffer(union filedescriptor *fdp)
usbErr = usbGetReport(fdp, USB_HID_REPORT_TYPE_FEATURE, lenIndex + 1,
(char *)buffer, &len);
if(usbErr != 0){
avrdude_message("%s: avrdoperFillBuffer(): %s\n", progname, usbErrorText(usbErr));
avrdude_message(MSG_INFO, "%s: avrdoperFillBuffer(): %s\n", progname, usbErrorText(usbErr));
return -1;
}
if(verbose > 3)
avrdude_message("Received %d bytes data chunk of total %d\n", len - 2, buffer[1]);
avrdude_message(MSG_TRACE, "Received %d bytes data chunk of total %d\n", len - 2, buffer[1]);
len -= 2; /* compensate for report ID and length byte */
bytesPending = buffer[1] - len; /* amount still buffered */
if(len > buffer[1]) /* cut away padding */
len = buffer[1];
if(avrdoperRxLength + len > sizeof(avrdoperRxBuffer)){
avrdude_message("%s: avrdoperFillBuffer(): internal error: buffer overflow\n",
avrdude_message(MSG_INFO, "%s: avrdoperFillBuffer(): internal error: buffer overflow\n",
progname);
return -1;
}
@ -643,7 +641,7 @@ static int avrdoper_drain(union filedescriptor *fdp, int display)
static int avrdoper_set_dtr_rts(union filedescriptor *fdp, int is_on)
{
avrdude_message("%s: AVR-Doper doesn't support DTR/RTS setting\n", progname);
avrdude_message(MSG_INFO, "%s: AVR-Doper doesn't support DTR/RTS setting\n", progname);
return -1;
}

View File

@ -90,8 +90,7 @@ static speed_t serial_baud_lookup(long baud)
* If a non-standard BAUD rate is used, issue
* a warning (if we are verbose) and return the raw rate
*/
if (verbose > 0)
avrdude_message("%s: serial_baud_lookup(): Using non-standard baud rate: %ld",
avrdude_message(MSG_NOTICE, "%s: serial_baud_lookup(): Using non-standard baud rate: %ld",
progname, baud);
return baud;
@ -111,7 +110,7 @@ static int ser_setspeed(union filedescriptor *fd, long baud)
*/
rc = tcgetattr(fd->ifd, &termios);
if (rc < 0) {
avrdude_message("%s: ser_setspeed(): tcgetattr() failed",
avrdude_message(MSG_INFO, "%s: ser_setspeed(): tcgetattr() failed",
progname);
return -errno;
}
@ -135,7 +134,7 @@ static int ser_setspeed(union filedescriptor *fd, long baud)
rc = tcsetattr(fd->ifd, TCSANOW, &termios);
if (rc < 0) {
avrdude_message("%s: ser_setspeed(): tcsetattr() failed\n",
avrdude_message(MSG_INFO, "%s: ser_setspeed(): tcsetattr() failed\n",
progname);
return -errno;
}
@ -167,13 +166,13 @@ net_open(const char *port, union filedescriptor *fdp)
struct hostent *hp;
if ((hstr = strdup(port)) == NULL) {
avrdude_message("%s: net_open(): Out of memory!\n",
avrdude_message(MSG_INFO, "%s: net_open(): Out of memory!\n",
progname);
return -1;
}
if (((pstr = strchr(hstr, ':')) == NULL) || (pstr == hstr)) {
avrdude_message("%s: net_open(): Mangled host:port string \"%s\"\n",
avrdude_message(MSG_INFO, "%s: net_open(): Mangled host:port string \"%s\"\n",
progname, hstr);
free(hstr);
return -1;
@ -187,14 +186,14 @@ net_open(const char *port, union filedescriptor *fdp)
pnum = strtoul(pstr, &end, 10);
if ((*pstr == '\0') || (*end != '\0') || (pnum == 0) || (pnum > 65535)) {
avrdude_message("%s: net_open(): Bad port number \"%s\"\n",
avrdude_message(MSG_INFO, "%s: net_open(): Bad port number \"%s\"\n",
progname, pstr);
free(hstr);
return -1;
}
if ((hp = gethostbyname(hstr)) == NULL) {
avrdude_message("%s: net_open(): unknown host \"%s\"\n",
avrdude_message(MSG_INFO, "%s: net_open(): unknown host \"%s\"\n",
progname, hstr);
free(hstr);
return -1;
@ -203,7 +202,7 @@ net_open(const char *port, union filedescriptor *fdp)
free(hstr);
if ((fd = socket(PF_INET, SOCK_STREAM, 0)) < 0) {
avrdude_message("%s: net_open(): Cannot open socket: %s\n",
avrdude_message(MSG_INFO, "%s: net_open(): Cannot open socket: %s\n",
progname, strerror(errno));
return -1;
}
@ -214,7 +213,7 @@ net_open(const char *port, union filedescriptor *fdp)
memcpy(&(sockaddr.sin_addr.s_addr), hp->h_addr, sizeof(struct in_addr));
if (connect(fd, (struct sockaddr *)&sockaddr, sizeof(sockaddr))) {
avrdude_message("%s: net_open(): Connect failed: %s\n",
avrdude_message(MSG_INFO, "%s: net_open(): Connect failed: %s\n",
progname, strerror(errno));
return -1;
}
@ -271,7 +270,7 @@ static int ser_open(char * port, union pinfo pinfo, union filedescriptor *fdp)
*/
fd = open(port, O_RDWR | O_NOCTTY | O_NONBLOCK);
if (fd < 0) {
avrdude_message("%s: ser_open(): can't open device \"%s\": %s\n",
avrdude_message(MSG_INFO, "%s: ser_open(): can't open device \"%s\": %s\n",
progname, port, strerror(errno));
return -1;
}
@ -283,7 +282,7 @@ static int ser_open(char * port, union pinfo pinfo, union filedescriptor *fdp)
*/
rc = ser_setspeed(fdp, pinfo.baud);
if (rc) {
avrdude_message("%s: ser_open(): can't set attributes for device \"%s\": %s\n",
avrdude_message(MSG_INFO, "%s: ser_open(): can't set attributes for device \"%s\": %s\n",
progname, port, strerror(-rc));
close(fd);
return -1;
@ -300,7 +299,7 @@ static void ser_close(union filedescriptor *fd)
if (saved_original_termios) {
int rc = tcsetattr(fd->ifd, TCSANOW | TCSADRAIN, &original_termios);
if (rc) {
avrdude_message("%s: ser_close(): can't reset attributes for device: %s\n",
avrdude_message(MSG_INFO, "%s: ser_close(): can't reset attributes for device: %s\n",
progname, strerror(errno));
}
saved_original_termios = 0;
@ -321,29 +320,29 @@ static int ser_send(union filedescriptor *fd, unsigned char * buf, size_t buflen
if (verbose > 3)
{
avrdude_message("%s: Send: ", progname);
avrdude_message(MSG_TRACE, "%s: Send: ", progname);
while (buflen) {
unsigned char c = *buf;
if (isprint(c)) {
avrdude_message("%c ", c);
avrdude_message(MSG_TRACE, "%c ", c);
}
else {
avrdude_message(". ");
avrdude_message(MSG_TRACE, ". ");
}
avrdude_message("[%02x] ", c);
avrdude_message(MSG_TRACE, "[%02x] ", c);
buf++;
buflen--;
}
avrdude_message("\n");
avrdude_message(MSG_TRACE, "\n");
}
while (len) {
rc = write(fd->ifd, p, (len > 1024) ? 1024 : len);
if (rc < 0) {
avrdude_message("%s: ser_send(): write error: %s\n",
avrdude_message(MSG_INFO, "%s: ser_send(): write error: %s\n",
progname, strerror(errno));
return -1;
}
@ -375,19 +374,18 @@ static int ser_recv(union filedescriptor *fd, unsigned char * buf, size_t buflen
nfds = select(fd->ifd + 1, &rfds, NULL, NULL, &to2);
if (nfds == 0) {
if (verbose > 1)
avrdude_message("%s: ser_recv(): programmer is not responding\n",
avrdude_message(MSG_NOTICE2, "%s: ser_recv(): programmer is not responding\n",
progname);
return -1;
}
else if (nfds == -1) {
if (errno == EINTR || errno == EAGAIN) {
avrdude_message("%s: ser_recv(): programmer is not responding,reselecting\n",
avrdude_message(MSG_INFO, "%s: ser_recv(): programmer is not responding,reselecting\n",
progname);
goto reselect;
}
else {
avrdude_message("%s: ser_recv(): select(): %s\n",
avrdude_message(MSG_INFO, "%s: ser_recv(): select(): %s\n",
progname, strerror(errno));
return -1;
}
@ -395,7 +393,7 @@ static int ser_recv(union filedescriptor *fd, unsigned char * buf, size_t buflen
rc = read(fd->ifd, p, (buflen - len > 1024) ? 1024 : buflen - len);
if (rc < 0) {
avrdude_message("%s: ser_recv(): read error: %s\n",
avrdude_message(MSG_INFO, "%s: ser_recv(): read error: %s\n",
progname, strerror(errno));
return -1;
}
@ -407,22 +405,22 @@ static int ser_recv(union filedescriptor *fd, unsigned char * buf, size_t buflen
if (verbose > 3)
{
avrdude_message("%s: Recv: ", progname);
avrdude_message(MSG_TRACE, "%s: Recv: ", progname);
while (len) {
unsigned char c = *p;
if (isprint(c)) {
avrdude_message("%c ", c);
avrdude_message(MSG_TRACE, "%c ", c);
}
else {
avrdude_message(". ");
avrdude_message(MSG_TRACE, ". ");
}
avrdude_message("[%02x] ", c);
avrdude_message(MSG_TRACE, "[%02x] ", c);
p++;
len--;
}
avrdude_message("\n");
avrdude_message(MSG_TRACE, "\n");
}
return 0;
@ -441,7 +439,7 @@ static int ser_drain(union filedescriptor *fd, int display)
timeout.tv_usec = 250000;
if (display) {
avrdude_message("drain>");
avrdude_message(MSG_INFO, "drain>");
}
while (1) {
@ -452,7 +450,7 @@ static int ser_drain(union filedescriptor *fd, int display)
nfds = select(fd->ifd + 1, &rfds, NULL, NULL, &timeout);
if (nfds == 0) {
if (display) {
avrdude_message("<drain\n");
avrdude_message(MSG_INFO, "<drain\n");
}
break;
@ -462,7 +460,7 @@ static int ser_drain(union filedescriptor *fd, int display)
goto reselect;
}
else {
avrdude_message("%s: ser_drain(): select(): %s\n",
avrdude_message(MSG_INFO, "%s: ser_drain(): select(): %s\n",
progname, strerror(errno));
return -1;
}
@ -470,12 +468,12 @@ static int ser_drain(union filedescriptor *fd, int display)
rc = read(fd->ifd, &buf, 1);
if (rc < 0) {
avrdude_message("%s: ser_drain(): read error: %s\n",
avrdude_message(MSG_INFO, "%s: ser_drain(): read error: %s\n",
progname, strerror(errno));
return -1;
}
if (display) {
avrdude_message("%02x ", buf);
avrdude_message(MSG_INFO, "%02x ", buf);
}
}

View File

@ -69,8 +69,7 @@ static DWORD serial_baud_lookup(long baud)
* If a non-standard BAUD rate is used, issue
* a warning (if we are verbose) and return the raw rate
*/
if (verbose > 0)
avrdude_message("%s: serial_baud_lookup(): Using non-standard baud rate: %ld",
avrdude_message(MSG_NOTICE, "%s: serial_baud_lookup(): Using non-standard baud rate: %ld",
progname, baud);
return baud;
@ -123,7 +122,7 @@ static int ser_open(char * port, union pinfo pinfo, union filedescriptor *fdp)
* This is curently not implemented for Win32.
*/
if (strncmp(port, "net:", strlen("net:")) == 0) {
avrdude_message("%s: ser_open(): network connects are currently not"
avrdude_message(MSG_INFO, "%s: ser_open(): network connects are currently not"
"implemented for Win32 environments\n",
progname);
return -1;
@ -135,7 +134,7 @@ static int ser_open(char * port, union pinfo pinfo, union filedescriptor *fdp)
newname = malloc(strlen("\\\\.\\") + strlen(port) + 1);
if (newname == 0) {
avrdude_message("%s: ser_open(): out of memory\n",
avrdude_message(MSG_INFO, "%s: ser_open(): out of memory\n",
progname);
exit(1);
}
@ -159,7 +158,7 @@ static int ser_open(char * port, union pinfo pinfo, union filedescriptor *fdp)
(LPTSTR) &lpMsgBuf,
0,
NULL);
avrdude_message("%s: ser_open(): can't open device \"%s\": %s\n",
avrdude_message(MSG_INFO, "%s: ser_open(): can't open device \"%s\": %s\n",
progname, port, (char*)lpMsgBuf);
LocalFree( lpMsgBuf );
return -1;
@ -168,7 +167,7 @@ static int ser_open(char * port, union pinfo pinfo, union filedescriptor *fdp)
if (!SetupComm(hComPort, W32SERBUFSIZE, W32SERBUFSIZE))
{
CloseHandle(hComPort);
avrdude_message("%s: ser_open(): can't set buffers for \"%s\"\n",
avrdude_message(MSG_INFO, "%s: ser_open(): can't set buffers for \"%s\"\n",
progname, port);
return -1;
}
@ -177,7 +176,7 @@ static int ser_open(char * port, union pinfo pinfo, union filedescriptor *fdp)
if (ser_setspeed(fdp, pinfo.baud) != 0)
{
CloseHandle(hComPort);
avrdude_message("%s: ser_open(): can't set com-state for \"%s\"\n",
avrdude_message(MSG_INFO, "%s: ser_open(): can't set com-state for \"%s\"\n",
progname, port);
return -1;
}
@ -185,7 +184,7 @@ static int ser_open(char * port, union pinfo pinfo, union filedescriptor *fdp)
if (!serial_w32SetTimeOut(hComPort,0))
{
CloseHandle(hComPort);
avrdude_message("%s: ser_open(): can't set initial timeout for \"%s\"\n",
avrdude_message(MSG_INFO, "%s: ser_open(): can't set initial timeout for \"%s\"\n",
progname, port);
return -1;
}
@ -231,7 +230,7 @@ static int ser_send(union filedescriptor *fd, unsigned char * buf, size_t buflen
HANDLE hComPort=(HANDLE)fd->pfd;
if (hComPort == INVALID_HANDLE_VALUE) {
avrdude_message("%s: ser_send(): port not open\n",
avrdude_message(MSG_INFO, "%s: ser_send(): port not open\n",
progname);
return -1;
}
@ -241,33 +240,33 @@ static int ser_send(union filedescriptor *fd, unsigned char * buf, size_t buflen
if (verbose > 3)
{
avrdude_message("%s: Send: ", progname);
avrdude_message(MSG_TRACE, "%s: Send: ", progname);
while (len) {
c = *b;
if (isprint(c)) {
avrdude_message("%c ", c);
avrdude_message(MSG_TRACE, "%c ", c);
}
else {
avrdude_message(". ");
avrdude_message(MSG_TRACE, ". ");
}
avrdude_message("[%02x] ", c);
avrdude_message(MSG_TRACE, "[%02x] ", c);
b++;
len--;
}
avrdude_message("\n");
avrdude_message(MSG_INFO, "\n");
}
serial_w32SetTimeOut(hComPort,500);
if (!WriteFile (hComPort, buf, buflen, &written, NULL)) {
avrdude_message("%s: ser_send(): write error: %s\n",
avrdude_message(MSG_INFO, "%s: ser_send(): write error: %s\n",
progname, "sorry no info avail"); // TODO
return -1;
}
if (written != buflen) {
avrdude_message("%s: ser_send(): size/send mismatch\n",
avrdude_message(MSG_INFO, "%s: ser_send(): size/send mismatch\n",
progname);
return -1;
}
@ -285,7 +284,7 @@ static int ser_recv(union filedescriptor *fd, unsigned char * buf, size_t buflen
HANDLE hComPort=(HANDLE)fd->pfd;
if (hComPort == INVALID_HANDLE_VALUE) {
avrdude_message("%s: ser_read(): port not open\n",
avrdude_message(MSG_INFO, "%s: ser_read(): port not open\n",
progname);
return -1;
}
@ -304,7 +303,7 @@ static int ser_recv(union filedescriptor *fd, unsigned char * buf, size_t buflen
(LPTSTR) &lpMsgBuf,
0,
NULL );
avrdude_message("%s: ser_recv(): read error: %s\n",
avrdude_message(MSG_INFO, "%s: ser_recv(): read error: %s\n",
progname, (char*)lpMsgBuf);
LocalFree( lpMsgBuf );
return -1;
@ -312,8 +311,7 @@ static int ser_recv(union filedescriptor *fd, unsigned char * buf, size_t buflen
/* time out detected */
if (read == 0) {
if (verbose > 1)
avrdude_message("%s: ser_recv(): programmer is not responding\n",
avrdude_message(MSG_NOTICE2, "%s: ser_recv(): programmer is not responding\n",
progname);
return -1;
}
@ -322,22 +320,22 @@ static int ser_recv(union filedescriptor *fd, unsigned char * buf, size_t buflen
if (verbose > 3)
{
avrdude_message("%s: Recv: ", progname);
avrdude_message(MSG_TRACE, "%s: Recv: ", progname);
while (read) {
c = *p;
if (isprint(c)) {
avrdude_message("%c ", c);
avrdude_message(MSG_TRACE, "%c ", c);
}
else {
avrdude_message(". ");
avrdude_message(MSG_TRACE, ". ");
}
avrdude_message("[%02x] ", c);
avrdude_message(MSG_TRACE, "[%02x] ", c);
p++;
read--;
}
avrdude_message("\n");
avrdude_message(MSG_INFO, "\n");
}
return 0;
}
@ -353,7 +351,7 @@ static int ser_drain(union filedescriptor *fd, int display)
HANDLE hComPort=(HANDLE)fd->pfd;
if (hComPort == INVALID_HANDLE_VALUE) {
avrdude_message("%s: ser_drain(): port not open\n",
avrdude_message(MSG_INFO, "%s: ser_drain(): port not open\n",
progname);
return -1;
}
@ -361,7 +359,7 @@ static int ser_drain(union filedescriptor *fd, int display)
serial_w32SetTimeOut(hComPort,250);
if (display) {
avrdude_message("drain>");
avrdude_message(MSG_INFO, "drain>");
}
while (1) {
@ -378,17 +376,17 @@ static int ser_drain(union filedescriptor *fd, int display)
(LPTSTR) &lpMsgBuf,
0,
NULL );
avrdude_message("%s: ser_drain(): read error: %s\n",
avrdude_message(MSG_INFO, "%s: ser_drain(): read error: %s\n",
progname, (char*)lpMsgBuf);
LocalFree( lpMsgBuf );
return -1;
}
if (read) { // data avail
if (display) avrdude_message("%02x ", buf[0]);
if (display) avrdude_message(MSG_INFO, "%02x ", buf[0]);
}
else { // no more data
if (display) avrdude_message("<drain\n");
if (display) avrdude_message(MSG_INFO, "<drain\n");
break;
}
} // while

View File

@ -238,7 +238,7 @@ static int serbb_open(PROGRAMMER *pgm, char *port)
r = tcgetattr(pgm->fd.ifd, &mode);
if (r < 0) {
avrdude_message("%s: ", port);
avrdude_message(MSG_INFO, "%s: ", port);
perror("tcgetattr");
return(-1);
}
@ -252,7 +252,7 @@ static int serbb_open(PROGRAMMER *pgm, char *port)
r = tcsetattr(pgm->fd.ifd, TCSANOW, &mode);
if (r < 0) {
avrdude_message("%s: ", port);
avrdude_message(MSG_INFO, "%s: ", port);
perror("tcsetattr");
return(-1);
}
@ -261,14 +261,14 @@ static int serbb_open(PROGRAMMER *pgm, char *port)
flags = fcntl(pgm->fd.ifd, F_GETFL, 0);
if (flags == -1)
{
avrdude_message("%s: Can not get flags: %s\n",
avrdude_message(MSG_INFO, "%s: Can not get flags: %s\n",
progname, strerror(errno));
return(-1);
}
flags &= ~O_NONBLOCK;
if (fcntl(pgm->fd.ifd, F_SETFL, flags) == -1)
{
avrdude_message("%s: Can not clear nonblock flag: %s\n",
avrdude_message(MSG_INFO, "%s: Can not clear nonblock flag: %s\n",
progname, strerror(errno));
return(-1);
}

View File

@ -97,13 +97,11 @@ static int serbb_setpin(PROGRAMMER * pgm, int pinfunc, int value)
break;
default:
if (verbose)
avrdude_message("%s: serbb_setpin(): unknown pin %d\n",
avrdude_message(MSG_NOTICE, "%s: serbb_setpin(): unknown pin %d\n",
progname, pin + 1);
return -1;
}
if (verbose > 4)
avrdude_message("%s: serbb_setpin(): EscapeCommFunction(%s)\n",
avrdude_message(MSG_TRACE2, "%s: serbb_setpin(): EscapeCommFunction(%s)\n",
progname, name);
if (!EscapeCommFunction(hComPort, dwFunc))
{
@ -117,7 +115,7 @@ static int serbb_setpin(PROGRAMMER * pgm, int pinfunc, int value)
(LPTSTR) &lpMsgBuf,
0,
NULL);
avrdude_message("%s: serbb_setpin(): SetCommState() failed: %s\n",
avrdude_message(MSG_INFO, "%s: serbb_setpin(): SetCommState() failed: %s\n",
progname, (char *)lpMsgBuf);
CloseHandle(hComPort);
LocalFree(lpMsgBuf);
@ -163,14 +161,13 @@ static int serbb_getpin(PROGRAMMER * pgm, int pinfunc)
(LPTSTR) &lpMsgBuf,
0,
NULL);
avrdude_message("%s: serbb_setpin(): GetCommModemStatus() failed: %s\n",
avrdude_message(MSG_INFO, "%s: serbb_setpin(): GetCommModemStatus() failed: %s\n",
progname, (char *)lpMsgBuf);
CloseHandle(hComPort);
LocalFree(lpMsgBuf);
return -1;
}
if (verbose > 4)
avrdude_message("%s: serbb_getpin(): GetCommState() => 0x%lx\n",
avrdude_message(MSG_TRACE2, "%s: serbb_getpin(): GetCommState() => 0x%lx\n",
progname, modemstate);
switch (pin)
{
@ -206,13 +203,11 @@ static int serbb_getpin(PROGRAMMER * pgm, int pinfunc)
name = "RTS";
break;
default:
if (verbose)
avrdude_message("%s: serbb_getpin(): unknown pin %d\n",
avrdude_message(MSG_NOTICE, "%s: serbb_getpin(): unknown pin %d\n",
progname, pin + 1);
return -1;
}
if (verbose > 4)
avrdude_message("%s: serbb_getpin(): return cached state for %s\n",
avrdude_message(MSG_TRACE2, "%s: serbb_getpin(): return cached state for %s\n",
progname, name);
if (invert)
rv = !rv;
@ -281,7 +276,7 @@ static int serbb_open(PROGRAMMER *pgm, char *port)
(LPTSTR) &lpMsgBuf,
0,
NULL);
avrdude_message("%s: ser_open(): can't open device \"%s\": %s\n",
avrdude_message(MSG_INFO, "%s: ser_open(): can't open device \"%s\": %s\n",
progname, port, (char*)lpMsgBuf);
LocalFree(lpMsgBuf);
return -1;
@ -290,7 +285,7 @@ static int serbb_open(PROGRAMMER *pgm, char *port)
if (!SetupComm(hComPort, W32SERBUFSIZE, W32SERBUFSIZE))
{
CloseHandle(hComPort);
avrdude_message("%s: ser_open(): can't set buffers for \"%s\"\n",
avrdude_message(MSG_INFO, "%s: ser_open(): can't set buffers for \"%s\"\n",
progname, port);
return -1;
}
@ -309,12 +304,11 @@ static int serbb_open(PROGRAMMER *pgm, char *port)
if (!SetCommState(hComPort, &dcb))
{
CloseHandle(hComPort);
avrdude_message("%s: ser_open(): can't set com-state for \"%s\"\n",
avrdude_message(MSG_INFO, "%s: ser_open(): can't set com-state for \"%s\"\n",
progname, port);
return -1;
}
if (verbose > 2)
avrdude_message("%s: ser_open(): opened comm port \"%s\", handle 0x%x\n",
avrdude_message(MSG_DEBUG, "%s: ser_open(): opened comm port \"%s\", handle 0x%x\n",
progname, port, (int)hComPort);
pgm->fd.pfd = (void *)hComPort;
@ -332,8 +326,7 @@ static void serbb_close(PROGRAMMER *pgm)
pgm->setpin(pgm, PIN_AVR_RESET, 1);
CloseHandle (hComPort);
}
if (verbose > 2)
avrdude_message("%s: ser_close(): closed comm port handle 0x%x\n",
avrdude_message(MSG_DEBUG, "%s: ser_close(): closed comm port handle 0x%x\n",
progname, (int)hComPort);
hComPort = INVALID_HANDLE_VALUE;

139
stk500.c
View File

@ -71,7 +71,7 @@ static int stk500_recv(PROGRAMMER * pgm, unsigned char * buf, size_t len)
rv = serial_recv(&pgm->fd, buf, len);
if (rv < 0) {
avrdude_message("%s: stk500_recv(): programmer is not responding\n",
avrdude_message(MSG_INFO, "%s: stk500_recv(): programmer is not responding\n",
progname);
return -1;
}
@ -110,7 +110,7 @@ int stk500_getsync(PROGRAMMER * pgm)
if (resp[0] == Resp_STK_INSYNC){
break;
}
avrdude_message("%s: stk500_getsync() attempt %d of %d: not in sync: resp=0x%02x\n",
avrdude_message(MSG_INFO, "%s: stk500_getsync() attempt %d of %d: not in sync: resp=0x%02x\n",
progname, attempt + 1, MAX_SYNC_ATTEMPTS, resp[0]);
}
if (attempt == MAX_SYNC_ATTEMPTS) {
@ -121,7 +121,7 @@ int stk500_getsync(PROGRAMMER * pgm)
if (stk500_recv(pgm, resp, 1) < 0)
return -1;
if (resp[0] != Resp_STK_OK) {
avrdude_message("%s: stk500_getsync(): can't communicate with device: "
avrdude_message(MSG_INFO, "%s: stk500_getsync(): can't communicate with device: "
"resp=0x%02x\n",
progname, resp[0]);
return -1;
@ -152,7 +152,7 @@ static int stk500_cmd(PROGRAMMER * pgm, const unsigned char *cmd,
if (stk500_recv(pgm, buf, 1) < 0)
return -1;
if (buf[0] != Resp_STK_INSYNC) {
avrdude_message("%s: stk500_cmd(): programmer is out of sync\n", progname);
avrdude_message(MSG_INFO, "%s: stk500_cmd(): programmer is out of sync\n", progname);
return -1;
}
@ -165,7 +165,7 @@ static int stk500_cmd(PROGRAMMER * pgm, const unsigned char *cmd,
if (stk500_recv(pgm, buf, 1) < 0)
return -1;
if (buf[0] != Resp_STK_OK) {
avrdude_message("%s: stk500_cmd(): protocol error\n", progname);
avrdude_message(MSG_INFO, "%s: stk500_cmd(): protocol error\n", progname);
return -1;
}
@ -183,14 +183,14 @@ static int stk500_chip_erase(PROGRAMMER * pgm, AVRPART * p)
unsigned char res[4];
if (pgm->cmd == NULL) {
avrdude_message("%s: Error: %s programmer uses stk500_chip_erase() but does not\n"
avrdude_message(MSG_INFO, "%s: Error: %s programmer uses stk500_chip_erase() but does not\n"
"provide a cmd() method.\n",
progname, pgm->type);
return -1;
}
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;
}
@ -229,7 +229,7 @@ static int stk500_program_enable(PROGRAMMER * pgm, AVRPART * p)
return -1;
if (buf[0] == Resp_STK_NOSYNC) {
if (tries > 33) {
avrdude_message("%s: stk500_program_enable(): can't get into sync\n",
avrdude_message(MSG_INFO, "%s: stk500_program_enable(): can't get into sync\n",
progname);
return -1;
}
@ -238,7 +238,7 @@ static int stk500_program_enable(PROGRAMMER * pgm, AVRPART * p)
goto retry;
}
else if (buf[0] != Resp_STK_INSYNC) {
avrdude_message("%s: stk500_program_enable(): protocol error, "
avrdude_message(MSG_INFO, "%s: stk500_program_enable(): protocol error, "
"expect=0x%02x, resp=0x%02x\n",
progname, Resp_STK_INSYNC, buf[0]);
return -1;
@ -250,20 +250,20 @@ static int stk500_program_enable(PROGRAMMER * pgm, AVRPART * p)
return 0;
}
else if (buf[0] == Resp_STK_NODEVICE) {
avrdude_message("%s: stk500_program_enable(): no device\n",
avrdude_message(MSG_INFO, "%s: stk500_program_enable(): no device\n",
progname);
return -1;
}
if(buf[0] == Resp_STK_FAILED)
{
avrdude_message("%s: stk500_program_enable(): failed to enter programming mode\n",
avrdude_message(MSG_INFO, "%s: stk500_program_enable(): failed to enter programming mode\n",
progname);
return -1;
}
avrdude_message("%s: stk500_program_enable(): unknown response=0x%02x\n",
avrdude_message(MSG_INFO, "%s: stk500_program_enable(): unknown response=0x%02x\n",
progname, buf[0]);
return -1;
@ -294,7 +294,7 @@ static int stk500_set_extended_parms(PROGRAMMER * pgm, int n,
return -1;
if (buf[0] == Resp_STK_NOSYNC) {
if (tries > 33) {
avrdude_message("%s: stk500_set_extended_parms(): can't get into sync\n",
avrdude_message(MSG_INFO, "%s: stk500_set_extended_parms(): can't get into sync\n",
progname);
return -1;
}
@ -303,7 +303,7 @@ static int stk500_set_extended_parms(PROGRAMMER * pgm, int n,
goto retry;
}
else if (buf[0] != Resp_STK_INSYNC) {
avrdude_message("%s: stk500_set_extended_parms(): protocol error, "
avrdude_message(MSG_INFO, "%s: stk500_set_extended_parms(): protocol error, "
"expect=0x%02x, resp=0x%02x\n",
progname, Resp_STK_INSYNC, buf[0]);
return -1;
@ -315,21 +315,21 @@ static int stk500_set_extended_parms(PROGRAMMER * pgm, int n,
return 0;
}
else if (buf[0] == Resp_STK_NODEVICE) {
avrdude_message("%s: stk500_set_extended_parms(): no device\n",
avrdude_message(MSG_INFO, "%s: stk500_set_extended_parms(): no device\n",
progname);
return -1;
}
if(buf[0] == Resp_STK_FAILED)
{
avrdude_message("%s: stk500_set_extended_parms(): failed to set extended "
avrdude_message(MSG_INFO, "%s: stk500_set_extended_parms(): failed to set extended "
"device programming parameters\n",
progname);
return -1;
}
avrdude_message("%s: stk500_set_extended_parms(): unknown response=0x%02x\n",
avrdude_message(MSG_INFO, "%s: stk500_set_extended_parms(): unknown response=0x%02x\n",
progname, buf[0]);
return -1;
@ -364,7 +364,7 @@ static int mib510_isp(PROGRAMMER * pgm, unsigned char cmd)
return -1;
if (buf[0] == Resp_STK_NOSYNC) {
if (tries > 33) {
avrdude_message("%s: mib510_isp(): can't get into sync\n",
avrdude_message(MSG_INFO, "%s: mib510_isp(): can't get into sync\n",
progname);
return -1;
}
@ -373,7 +373,7 @@ static int mib510_isp(PROGRAMMER * pgm, unsigned char cmd)
goto retry;
}
else if (buf[0] != Resp_STK_INSYNC) {
avrdude_message("%s: mib510_isp(): protocol error, "
avrdude_message(MSG_INFO, "%s: mib510_isp(): protocol error, "
"expect=0x%02x, resp=0x%02x\n",
progname, Resp_STK_INSYNC, buf[0]);
return -1;
@ -385,20 +385,20 @@ static int mib510_isp(PROGRAMMER * pgm, unsigned char cmd)
return 0;
}
else if (buf[0] == Resp_STK_NODEVICE) {
avrdude_message("%s: mib510_isp(): no device\n",
avrdude_message(MSG_INFO, "%s: mib510_isp(): no device\n",
progname);
return -1;
}
if (buf[0] == Resp_STK_FAILED)
{
avrdude_message("%s: mib510_isp(): command %d failed\n",
avrdude_message(MSG_INFO, "%s: mib510_isp(): command %d failed\n",
progname, cmd);
return -1;
}
avrdude_message("%s: mib510_isp(): unknown response=0x%02x\n",
avrdude_message(MSG_INFO, "%s: mib510_isp(): unknown response=0x%02x\n",
progname, buf[0]);
return -1;
@ -459,7 +459,7 @@ static int stk500_initialize(PROGRAMMER * pgm, AVRPART * p)
}
#if 0
avrdude_message("%s: stk500_initialize(): n_extparms = %d\n",
avrdude_message(MSG_INFO, "%s: stk500_initialize(): n_extparms = %d\n",
progname, n_extparms);
#endif
@ -533,7 +533,7 @@ static int stk500_initialize(PROGRAMMER * pgm, AVRPART * p)
if (stk500_recv(pgm, buf, 1) < 0)
return -1;
if (buf[0] == Resp_STK_NOSYNC) {
avrdude_message("%s: stk500_initialize(): programmer not in sync, resp=0x%02x\n",
avrdude_message(MSG_INFO, "%s: stk500_initialize(): programmer not in sync, resp=0x%02x\n",
progname, buf[0]);
if (tries > 33)
return -1;
@ -542,7 +542,7 @@ static int stk500_initialize(PROGRAMMER * pgm, AVRPART * p)
goto retry;
}
else if (buf[0] != Resp_STK_INSYNC) {
avrdude_message("%s: stk500_initialize(): (a) protocol error, "
avrdude_message(MSG_INFO, "%s: stk500_initialize(): (a) protocol error, "
"expect=0x%02x, resp=0x%02x\n",
progname, Resp_STK_INSYNC, buf[0]);
return -1;
@ -551,7 +551,7 @@ static int stk500_initialize(PROGRAMMER * pgm, AVRPART * p)
if (stk500_recv(pgm, buf, 1) < 0)
return -1;
if (buf[0] != Resp_STK_OK) {
avrdude_message("%s: stk500_initialize(): (b) protocol error, "
avrdude_message(MSG_INFO, "%s: stk500_initialize(): (b) protocol error, "
"expect=0x%02x, resp=0x%02x\n",
progname, Resp_STK_OK, buf[0]);
return -1;
@ -559,8 +559,7 @@ static int stk500_initialize(PROGRAMMER * pgm, AVRPART * p)
if (n_extparms) {
if ((p->pagel == 0) || (p->bs2 == 0)) {
if (verbose > 1)
avrdude_message("%s: PAGEL and BS2 signals not defined in the configuration "
avrdude_message(MSG_NOTICE2, "%s: PAGEL and BS2 signals not defined in the configuration "
"file for part %s, using dummy values\n",
progname, p->desc);
buf[2] = 0xD7; /* they look somehow possible, */
@ -590,7 +589,7 @@ static int stk500_initialize(PROGRAMMER * pgm, AVRPART * p)
rc = stk500_set_extended_parms(pgm, n_extparms+1, buf);
if (rc) {
avrdude_message("%s: stk500_initialize(): failed\n", progname);
avrdude_message(MSG_INFO, "%s: stk500_initialize(): failed\n", progname);
return -1;
}
}
@ -616,7 +615,7 @@ static void stk500_disable(PROGRAMMER * pgm)
return;
if (buf[0] == Resp_STK_NOSYNC) {
if (tries > 33) {
avrdude_message("%s: stk500_disable(): can't get into sync\n",
avrdude_message(MSG_INFO, "%s: stk500_disable(): can't get into sync\n",
progname);
return;
}
@ -625,7 +624,7 @@ static void stk500_disable(PROGRAMMER * pgm)
goto retry;
}
else if (buf[0] != Resp_STK_INSYNC) {
avrdude_message("%s: stk500_disable(): protocol error, expect=0x%02x, "
avrdude_message(MSG_INFO, "%s: stk500_disable(): protocol error, expect=0x%02x, "
"resp=0x%02x\n",
progname, Resp_STK_INSYNC, buf[0]);
return;
@ -637,12 +636,12 @@ static void stk500_disable(PROGRAMMER * pgm)
return;
}
else if (buf[0] == Resp_STK_NODEVICE) {
avrdude_message("%s: stk500_disable(): no device\n",
avrdude_message(MSG_INFO, "%s: stk500_disable(): no device\n",
progname);
return;
}
avrdude_message("%s: stk500_disable(): unknown response=0x%02x\n",
avrdude_message(MSG_INFO, "%s: stk500_disable(): unknown response=0x%02x\n",
progname, buf[0]);
return;
@ -727,7 +726,7 @@ static int stk500_loadaddr(PROGRAMMER * pgm, AVRMEM * mem, unsigned int addr)
return -1;
if (buf[0] == Resp_STK_NOSYNC) {
if (tries > 33) {
avrdude_message("%s: stk500_loadaddr(): can't get into sync\n",
avrdude_message(MSG_INFO, "%s: stk500_loadaddr(): can't get into sync\n",
progname);
return -1;
}
@ -736,7 +735,7 @@ static int stk500_loadaddr(PROGRAMMER * pgm, AVRMEM * mem, unsigned int addr)
goto retry;
}
else if (buf[0] != Resp_STK_INSYNC) {
avrdude_message("%s: stk500_loadaddr(): (a) protocol error, "
avrdude_message(MSG_INFO, "%s: stk500_loadaddr(): (a) protocol error, "
"expect=0x%02x, resp=0x%02x\n",
progname, Resp_STK_INSYNC, buf[0]);
return -1;
@ -748,7 +747,7 @@ static int stk500_loadaddr(PROGRAMMER * pgm, AVRMEM * mem, unsigned int addr)
return 0;
}
avrdude_message("%s: loadaddr(): (b) protocol error, "
avrdude_message(MSG_INFO, "%s: loadaddr(): (b) protocol error, "
"expect=0x%02x, resp=0x%02x\n",
progname, Resp_STK_INSYNC, buf[0]);
@ -785,7 +784,7 @@ static int stk500_paged_write(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m,
n = addr + n_bytes;
#if 0
avrdude_message("n_bytes = %d\n"
avrdude_message(MSG_INFO, "n_bytes = %d\n"
"n = %u\n"
"a_div = %d\n"
"page_size = %d\n",
@ -823,7 +822,7 @@ static int stk500_paged_write(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m,
return -1;
if (buf[0] == Resp_STK_NOSYNC) {
if (tries > 33) {
avrdude_message("\n%s: stk500_paged_write(): can't get into sync\n",
avrdude_message(MSG_INFO, "\n%s: stk500_paged_write(): can't get into sync\n",
progname);
return -3;
}
@ -832,7 +831,7 @@ static int stk500_paged_write(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m,
goto retry;
}
else if (buf[0] != Resp_STK_INSYNC) {
avrdude_message("\n%s: stk500_paged_write(): (a) protocol error, "
avrdude_message(MSG_INFO, "\n%s: stk500_paged_write(): (a) protocol error, "
"expect=0x%02x, resp=0x%02x\n",
progname, Resp_STK_INSYNC, buf[0]);
return -4;
@ -841,7 +840,7 @@ static int stk500_paged_write(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m,
if (stk500_recv(pgm, buf, 1) < 0)
return -1;
if (buf[0] != Resp_STK_OK) {
avrdude_message("\n%s: stk500_paged_write(): (a) protocol error, "
avrdude_message(MSG_INFO, "\n%s: stk500_paged_write(): (a) protocol error, "
"expect=0x%02x, resp=0x%02x\n",
progname, Resp_STK_INSYNC, buf[0]);
return -5;
@ -904,7 +903,7 @@ static int stk500_paged_load(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m,
return -1;
if (buf[0] == Resp_STK_NOSYNC) {
if (tries > 33) {
avrdude_message("\n%s: stk500_paged_load(): can't get into sync\n",
avrdude_message(MSG_INFO, "\n%s: stk500_paged_load(): can't get into sync\n",
progname);
return -3;
}
@ -913,7 +912,7 @@ static int stk500_paged_load(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m,
goto retry;
}
else if (buf[0] != Resp_STK_INSYNC) {
avrdude_message("\n%s: stk500_paged_load(): (a) protocol error, "
avrdude_message(MSG_INFO, "\n%s: stk500_paged_load(): (a) protocol error, "
"expect=0x%02x, resp=0x%02x\n",
progname, Resp_STK_INSYNC, buf[0]);
return -4;
@ -927,7 +926,7 @@ static int stk500_paged_load(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m,
if(strcmp(ldata(lfirst(pgm->id)), "mib510") == 0) {
if (buf[0] != Resp_STK_INSYNC) {
avrdude_message("\n%s: stk500_paged_load(): (a) protocol error, "
avrdude_message(MSG_INFO, "\n%s: stk500_paged_load(): (a) protocol error, "
"expect=0x%02x, resp=0x%02x\n",
progname, Resp_STK_INSYNC, buf[0]);
return -5;
@ -935,7 +934,7 @@ static int stk500_paged_load(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m,
}
else {
if (buf[0] != Resp_STK_OK) {
avrdude_message("\n%s: stk500_paged_load(): (a) protocol error, "
avrdude_message(MSG_INFO, "\n%s: stk500_paged_load(): (a) protocol error, "
"expect=0x%02x, resp=0x%02x\n",
progname, Resp_STK_OK, buf[0]);
return -5;
@ -954,13 +953,13 @@ static int stk500_set_vtarget(PROGRAMMER * pgm, double v)
utarg = (unsigned)((v + 0.049) * 10);
if (stk500_getparm(pgm, Parm_STK_VADJUST, &uaref) != 0) {
avrdude_message("%s: stk500_set_vtarget(): cannot obtain V[aref]\n",
avrdude_message(MSG_INFO, "%s: stk500_set_vtarget(): cannot obtain V[aref]\n",
progname);
return -1;
}
if (uaref > utarg) {
avrdude_message("%s: stk500_set_vtarget(): reducing V[aref] from %.1f to %.1f\n",
avrdude_message(MSG_INFO, "%s: stk500_set_vtarget(): reducing V[aref] from %.1f to %.1f\n",
progname, uaref / 10.0, v);
if (stk500_setparm(pgm, Parm_STK_VADJUST, utarg)
!= 0)
@ -978,13 +977,13 @@ static int stk500_set_varef(PROGRAMMER * pgm, unsigned int chan /* unused */,
uaref = (unsigned)((v + 0.049) * 10);
if (stk500_getparm(pgm, Parm_STK_VTARGET, &utarg) != 0) {
avrdude_message("%s: stk500_set_varef(): cannot obtain V[target]\n",
avrdude_message(MSG_INFO, "%s: stk500_set_varef(): cannot obtain V[target]\n",
progname);
return -1;
}
if (uaref > utarg) {
avrdude_message("%s: stk500_set_varef(): V[aref] must not be greater than "
avrdude_message(MSG_INFO, "%s: stk500_set_varef(): V[aref] must not be greater than "
"V[target] = %.1f\n",
progname, utarg / 10.0);
return -1;
@ -1013,7 +1012,7 @@ static int stk500_set_fosc(PROGRAMMER * pgm, double v)
unit = "kHz";
} else
unit = "Hz";
avrdude_message("%s: stk500_set_fosc(): f = %.3f %s too high, using %.3f MHz\n",
avrdude_message(MSG_INFO, "%s: stk500_set_fosc(): f = %.3f %s too high, using %.3f MHz\n",
progname, v, unit, STK500_XTAL / 2e6);
fosc = STK500_XTAL / 2;
} else
@ -1028,7 +1027,7 @@ static int stk500_set_fosc(PROGRAMMER * pgm, double v)
}
}
if (idx == sizeof(ps) / sizeof(ps[0])) {
avrdude_message("%s: stk500_set_fosc(): f = %u Hz too low, %u Hz min\n",
avrdude_message(MSG_INFO, "%s: stk500_set_fosc(): f = %u Hz too low, %u Hz min\n",
progname, fosc, STK500_XTAL / (256 * 1024 * 2));
return -1;
}
@ -1060,11 +1059,11 @@ static int stk500_set_sck_period(PROGRAMMER * pgm, double v)
if (v < min) {
dur = 1;
avrdude_message("%s: stk500_set_sck_period(): p = %.1f us too small, using %.1f us\n",
avrdude_message(MSG_INFO, "%s: stk500_set_sck_period(): p = %.1f us too small, using %.1f us\n",
progname, v / 1e-6, dur * min / 1e-6);
} else if (v > max) {
dur = 255;
avrdude_message("%s: stk500_set_sck_period(): p = %.1f us too large, using %.1f us\n",
avrdude_message(MSG_INFO, "%s: stk500_set_sck_period(): p = %.1f us too large, using %.1f us\n",
progname, v / 1e-6, dur * min / 1e-6);
}
@ -1090,7 +1089,7 @@ static int stk500_getparm(PROGRAMMER * pgm, unsigned parm, unsigned * value)
return -1;
if (buf[0] == Resp_STK_NOSYNC) {
if (tries > 33) {
avrdude_message("\n%s: stk500_getparm(): can't get into sync\n",
avrdude_message(MSG_INFO, "\n%s: stk500_getparm(): can't get into sync\n",
progname);
return -1;
}
@ -1099,7 +1098,7 @@ static int stk500_getparm(PROGRAMMER * pgm, unsigned parm, unsigned * value)
goto retry;
}
else if (buf[0] != Resp_STK_INSYNC) {
avrdude_message("\n%s: stk500_getparm(): (a) protocol error, "
avrdude_message(MSG_INFO, "\n%s: stk500_getparm(): (a) protocol error, "
"expect=0x%02x, resp=0x%02x\n",
progname, Resp_STK_INSYNC, buf[0]);
return -2;
@ -1112,12 +1111,12 @@ static int stk500_getparm(PROGRAMMER * pgm, unsigned parm, unsigned * value)
if (stk500_recv(pgm, buf, 1) < 0)
return -1;
if (buf[0] == Resp_STK_FAILED) {
avrdude_message("\n%s: stk500_getparm(): parameter 0x%02x failed\n",
avrdude_message(MSG_INFO, "\n%s: stk500_getparm(): parameter 0x%02x failed\n",
progname, v);
return -3;
}
else if (buf[0] != Resp_STK_OK) {
avrdude_message("\n%s: stk500_getparm(): (a) protocol error, "
avrdude_message(MSG_INFO, "\n%s: stk500_getparm(): (a) protocol error, "
"expect=0x%02x, resp=0x%02x\n",
progname, Resp_STK_INSYNC, buf[0]);
return -3;
@ -1147,7 +1146,7 @@ static int stk500_setparm(PROGRAMMER * pgm, unsigned parm, unsigned value)
return -1;
if (buf[0] == Resp_STK_NOSYNC) {
if (tries > 33) {
avrdude_message("\n%s: stk500_setparm(): can't get into sync\n",
avrdude_message(MSG_INFO, "\n%s: stk500_setparm(): can't get into sync\n",
progname);
return -1;
}
@ -1156,7 +1155,7 @@ static int stk500_setparm(PROGRAMMER * pgm, unsigned parm, unsigned value)
goto retry;
}
else if (buf[0] != Resp_STK_INSYNC) {
avrdude_message("\n%s: stk500_setparm(): (a) protocol error, "
avrdude_message(MSG_INFO, "\n%s: stk500_setparm(): (a) protocol error, "
"expect=0x%02x, resp=0x%02x\n",
progname, Resp_STK_INSYNC, buf[0]);
return -2;
@ -1171,12 +1170,12 @@ static int stk500_setparm(PROGRAMMER * pgm, unsigned parm, unsigned value)
if (stk500_recv(pgm, buf, 1) < 0)
return -1;
if (buf[0] == Resp_STK_FAILED) {
avrdude_message("\n%s: stk500_setparm(): parameter 0x%02x failed\n",
avrdude_message(MSG_INFO, "\n%s: stk500_setparm(): parameter 0x%02x failed\n",
progname, parm);
return -3;
}
else {
avrdude_message("\n%s: stk500_setparm(): (a) protocol error, "
avrdude_message(MSG_INFO, "\n%s: stk500_setparm(): (a) protocol error, "
"expect=0x%02x, resp=0x%02x\n",
progname, Resp_STK_INSYNC, buf[0]);
return -3;
@ -1193,8 +1192,8 @@ static void stk500_display(PROGRAMMER * pgm, const char * p)
stk500_getparm(pgm, Parm_STK_SW_MINOR, &min);
stk500_getparm(pgm, Param_STK500_TOPCARD_DETECT, &topcard);
avrdude_message("%sHardware Version: %d\n", p, hdw);
avrdude_message("%sFirmware Version: %d.%d\n", p, maj, min);
avrdude_message(MSG_INFO, "%sHardware Version: %d\n", p, hdw);
avrdude_message(MSG_INFO, "%sFirmware Version: %d.%d\n", p, maj, min);
if (topcard < 3) {
const char *n = "Unknown";
@ -1207,7 +1206,7 @@ static void stk500_display(PROGRAMMER * pgm, const char * p)
n = "STK501";
break;
}
avrdude_message("%sTopcard : %s\n", p, n);
avrdude_message(MSG_INFO, "%sTopcard : %s\n", p, n);
}
stk500_print_parms1(pgm, p);
@ -1225,11 +1224,11 @@ static void stk500_print_parms1(PROGRAMMER * pgm, const char * p)
stk500_getparm(pgm, Parm_STK_OSC_CMATCH, &osc_cmatch);
stk500_getparm(pgm, Parm_STK_SCK_DURATION, &sck_duration);
avrdude_message("%sVtarget : %.1f V\n", p, vtarget / 10.0);
avrdude_message("%sVaref : %.1f V\n", p, vadjust / 10.0);
avrdude_message("%sOscillator : ", p);
avrdude_message(MSG_INFO, "%sVtarget : %.1f V\n", p, vtarget / 10.0);
avrdude_message(MSG_INFO, "%sVaref : %.1f V\n", p, vadjust / 10.0);
avrdude_message(MSG_INFO, "%sOscillator : ", p);
if (osc_pscale == 0)
avrdude_message("Off\n");
avrdude_message(MSG_INFO, "Off\n");
else {
int prescale = 1;
double f = STK500_XTAL / 2;
@ -1253,9 +1252,9 @@ static void stk500_print_parms1(PROGRAMMER * pgm, const char * p)
unit = "kHz";
} else
unit = "Hz";
avrdude_message("%.3f %s\n", f, unit);
avrdude_message(MSG_INFO, "%.3f %s\n", f, unit);
}
avrdude_message("%sSCK period : %.1f us\n", p,
avrdude_message(MSG_INFO, "%sSCK period : %.1f us\n", p,
sck_duration * 8.0e6 / STK500_XTAL + 0.05);
return;
@ -1270,7 +1269,7 @@ static void stk500_print_parms(PROGRAMMER * pgm)
static void stk500_setup(PROGRAMMER * pgm)
{
if ((pgm->cookie = malloc(sizeof(struct pdata))) == 0) {
avrdude_message("%s: stk500_setup(): Out of memory allocating private data\n",
avrdude_message(MSG_INFO, "%s: stk500_setup(): Out of memory allocating private data\n",
progname);
return;
}

View File

@ -43,7 +43,7 @@ static int stk500generic_open(PROGRAMMER * pgm, char * port)
stk500_initpgm(pgm);
if (pgm->open(pgm, port) >= 0)
{
avrdude_message("%s: successfully opened stk500v1 device -- please use -c stk500v1\n",
avrdude_message(MSG_INFO, "%s: successfully opened stk500v1 device -- please use -c stk500v1\n",
progname);
return 0;
}
@ -53,12 +53,12 @@ static int stk500generic_open(PROGRAMMER * pgm, char * port)
stk500v2_initpgm(pgm);
if (pgm->open(pgm, port) >= 0)
{
avrdude_message("%s: successfully opened stk500v2 device -- please use -c stk500v2\n",
avrdude_message(MSG_INFO, "%s: successfully opened stk500v2 device -- please use -c stk500v2\n",
progname);
return 0;
}
avrdude_message("%s: cannot open either stk500v1 or stk500v2 programmer\n",
avrdude_message(MSG_INFO, "%s: cannot open either stk500v1 or stk500v2 programmer\n",
progname);
return -1;
}

File diff suppressed because it is too large Load Diff

108
term.c
View File

@ -243,7 +243,7 @@ static int cmd_dump(PROGRAMMER * pgm, struct avrpart * p,
int rc;
if (!((argc == 2) || (argc == 4))) {
avrdude_message("Usage: dump <memtype> [<addr> <len>]\n");
avrdude_message(MSG_INFO, "Usage: dump <memtype> [<addr> <len>]\n");
return -1;
}
@ -258,7 +258,7 @@ static int cmd_dump(PROGRAMMER * pgm, struct avrpart * p,
mem = avr_locate_mem(p, memtype);
if (mem == NULL) {
avrdude_message("\"%s\" memory type not defined for part \"%s\"\n",
avrdude_message(MSG_INFO, "\"%s\" memory type not defined for part \"%s\"\n",
memtype, p->desc);
return -1;
}
@ -266,14 +266,14 @@ static int cmd_dump(PROGRAMMER * pgm, struct avrpart * p,
if (argc == 4) {
addr = strtoul(argv[2], &e, 0);
if (*e || (e == argv[2])) {
avrdude_message("%s (dump): can't parse address \"%s\"\n",
avrdude_message(MSG_INFO, "%s (dump): can't parse address \"%s\"\n",
progname, argv[2]);
return -1;
}
len = strtol(argv[3], &e, 0);
if (*e || (e == argv[3])) {
avrdude_message("%s (dump): can't parse length \"%s\"\n",
avrdude_message(MSG_INFO, "%s (dump): can't parse length \"%s\"\n",
progname, argv[3]);
return -1;
}
@ -287,7 +287,7 @@ static int cmd_dump(PROGRAMMER * pgm, struct avrpart * p,
addr = 0;
}
else {
avrdude_message("%s (dump): address 0x%05lx is out of range for %s memory\n",
avrdude_message(MSG_INFO, "%s (dump): address 0x%05lx is out of range for %s memory\n",
progname, addr, mem->desc);
return -1;
}
@ -299,17 +299,17 @@ static int cmd_dump(PROGRAMMER * pgm, struct avrpart * p,
buf = malloc(len);
if (buf == NULL) {
avrdude_message("%s (dump): out of memory\n", progname);
avrdude_message(MSG_INFO, "%s (dump): out of memory\n", progname);
return -1;
}
for (i=0; i<len; i++) {
rc = pgm->read_byte(pgm, p, mem, addr+i, &buf[i]);
if (rc != 0) {
avrdude_message("error reading %s address 0x%05lx of part %s\n",
avrdude_message(MSG_INFO, "error reading %s address 0x%05lx of part %s\n",
mem->desc, addr+i, p->desc);
if (rc == -1)
avrdude_message("read operation not supported on memory type \"%s\"\n",
avrdude_message(MSG_INFO, "read operation not supported on memory type \"%s\"\n",
mem->desc);
return -1;
}
@ -341,7 +341,7 @@ static int cmd_write(PROGRAMMER * pgm, struct avrpart * p,
AVRMEM * mem;
if (argc < 4) {
avrdude_message("Usage: write <memtype> <addr> <byte1> "
avrdude_message(MSG_INFO, "Usage: write <memtype> <addr> <byte1> "
"<byte2> ... byteN>\n");
return -1;
}
@ -350,7 +350,7 @@ static int cmd_write(PROGRAMMER * pgm, struct avrpart * p,
mem = avr_locate_mem(p, memtype);
if (mem == NULL) {
avrdude_message("\"%s\" memory type not defined for part \"%s\"\n",
avrdude_message(MSG_INFO, "\"%s\" memory type not defined for part \"%s\"\n",
memtype, p->desc);
return -1;
}
@ -359,13 +359,13 @@ static int cmd_write(PROGRAMMER * pgm, struct avrpart * p,
addr = strtoul(argv[2], &e, 0);
if (*e || (e == argv[2])) {
avrdude_message("%s (write): can't parse address \"%s\"\n",
avrdude_message(MSG_INFO, "%s (write): can't parse address \"%s\"\n",
progname, argv[2]);
return -1;
}
if (addr > maxsize) {
avrdude_message("%s (write): address 0x%05lx is out of range for %s memory\n",
avrdude_message(MSG_INFO, "%s (write): address 0x%05lx is out of range for %s memory\n",
progname, addr, memtype);
return -1;
}
@ -374,7 +374,7 @@ static int cmd_write(PROGRAMMER * pgm, struct avrpart * p,
len = argc - 3;
if ((addr + len) > maxsize) {
avrdude_message("%s (write): selected address and # bytes exceed "
avrdude_message(MSG_INFO, "%s (write): selected address and # bytes exceed "
"range for %s memory\n",
progname, memtype);
return -1;
@ -382,14 +382,14 @@ static int cmd_write(PROGRAMMER * pgm, struct avrpart * p,
buf = malloc(len);
if (buf == NULL) {
avrdude_message("%s (write): out of memory\n", progname);
avrdude_message(MSG_INFO, "%s (write): out of memory\n", progname);
return -1;
}
for (i=3; i<argc; i++) {
buf[i-3] = strtoul(argv[i], &e, 0);
if (*e || (e == argv[i])) {
avrdude_message("%s (write): can't parse byte \"%s\"\n",
avrdude_message(MSG_INFO, "%s (write): can't parse byte \"%s\"\n",
progname, argv[i]);
free(buf);
return -1;
@ -401,17 +401,17 @@ static int cmd_write(PROGRAMMER * pgm, struct avrpart * p,
rc = avr_write_byte(pgm, p, mem, addr+i, buf[i]);
if (rc) {
avrdude_message("%s (write): error writing 0x%02x at 0x%05lx, rc=%d\n",
avrdude_message(MSG_INFO, "%s (write): error writing 0x%02x at 0x%05lx, rc=%d\n",
progname, buf[i], addr+i, rc);
if (rc == -1)
avrdude_message("write operation not supported on memory type \"%s\"\n",
avrdude_message(MSG_INFO, "write operation not supported on memory type \"%s\"\n",
mem->desc);
werror = 1;
}
rc = pgm->read_byte(pgm, p, mem, addr+i, &b);
if (b != buf[i]) {
avrdude_message("%s (write): error writing 0x%02x at 0x%05lx cell=0x%02x\n",
avrdude_message(MSG_INFO, "%s (write): error writing 0x%02x at 0x%05lx cell=0x%02x\n",
progname, buf[i], addr+i, b);
werror = 1;
}
@ -438,20 +438,20 @@ static int cmd_send(PROGRAMMER * pgm, struct avrpart * p,
int len;
if (pgm->cmd == NULL) {
avrdude_message("The %s programmer does not support direct ISP commands.\n",
avrdude_message(MSG_INFO, "The %s programmer does not support direct ISP commands.\n",
pgm->type);
return -1;
}
if (spi_mode && (pgm->spi == NULL)) {
avrdude_message("The %s programmer does not support direct SPI transfers.\n",
avrdude_message(MSG_INFO, "The %s programmer does not support direct SPI transfers.\n",
pgm->type);
return -1;
}
if ((argc > 5) || ((argc < 5) && (!spi_mode))) {
avrdude_message(spi_mode?
avrdude_message(MSG_INFO, spi_mode?
"Usage: send <byte1> [<byte2> [<byte3> [<byte4>]]]\n":
"Usage: send <byte1> <byte2> <byte3> <byte4>\n");
return -1;
@ -464,7 +464,7 @@ static int cmd_send(PROGRAMMER * pgm, struct avrpart * p,
for (i=1; i<argc; i++) {
cmd[i-1] = strtoul(argv[i], &e, 0);
if (*e || (e == argv[i])) {
avrdude_message("%s (send): can't parse byte \"%s\"\n",
avrdude_message(MSG_INFO, "%s (send): can't parse byte \"%s\"\n",
progname, argv[i]);
return -1;
}
@ -480,10 +480,10 @@ static int cmd_send(PROGRAMMER * pgm, struct avrpart * p,
/*
* display results
*/
avrdude_message("results:");
avrdude_message(MSG_INFO, "results:");
for (i=0; i<len; i++)
avrdude_message(" %02x", res[i]);
avrdude_message("\n");
avrdude_message(MSG_INFO, " %02x", res[i]);
avrdude_message(MSG_INFO, "\n");
fprintf(stdout, "\n");
@ -494,7 +494,7 @@ static int cmd_send(PROGRAMMER * pgm, struct avrpart * p,
static int cmd_erase(PROGRAMMER * pgm, struct avrpart * p,
int argc, char * argv[])
{
avrdude_message("%s: erasing chip\n", progname);
avrdude_message(MSG_INFO, "%s: erasing chip\n", progname);
pgm->chip_erase(pgm, p);
return 0;
}
@ -520,13 +520,13 @@ static int cmd_sig(PROGRAMMER * pgm, struct avrpart * p,
rc = avr_signature(pgm, p);
if (rc != 0) {
avrdude_message("error reading signature data, rc=%d\n",
avrdude_message(MSG_INFO, "error reading signature data, rc=%d\n",
rc);
}
m = avr_locate_mem(p, "signature");
if (m == NULL) {
avrdude_message("signature data not defined for device \"%s\"\n",
avrdude_message(MSG_INFO, "signature data not defined for device \"%s\"\n",
p->desc);
}
else {
@ -551,7 +551,7 @@ static int cmd_parms(PROGRAMMER * pgm, struct avrpart * p,
int argc, char * argv[])
{
if (pgm->print_parms == NULL) {
avrdude_message("%s (parms): the %s programmer does not support "
avrdude_message(MSG_INFO, "%s (parms): the %s programmer does not support "
"adjustable parameters\n",
progname, pgm->type);
return -1;
@ -570,22 +570,22 @@ static int cmd_vtarg(PROGRAMMER * pgm, struct avrpart * p,
char *endp;
if (argc != 2) {
avrdude_message("Usage: vtarg <value>\n");
avrdude_message(MSG_INFO, "Usage: vtarg <value>\n");
return -1;
}
v = strtod(argv[1], &endp);
if (endp == argv[1]) {
avrdude_message("%s (vtarg): can't parse voltage \"%s\"\n",
avrdude_message(MSG_INFO, "%s (vtarg): can't parse voltage \"%s\"\n",
progname, argv[1]);
return -1;
}
if (pgm->set_vtarget == NULL) {
avrdude_message("%s (vtarg): the %s programmer cannot set V[target]\n",
avrdude_message(MSG_INFO, "%s (vtarg): the %s programmer cannot set V[target]\n",
progname, pgm->type);
return -2;
}
if ((rc = pgm->set_vtarget(pgm, v)) != 0) {
avrdude_message("%s (vtarg): failed to set V[target] (rc = %d)\n",
avrdude_message(MSG_INFO, "%s (vtarg): failed to set V[target] (rc = %d)\n",
progname, rc);
return -3;
}
@ -601,7 +601,7 @@ static int cmd_fosc(PROGRAMMER * pgm, struct avrpart * p,
char *endp;
if (argc != 2) {
avrdude_message("Usage: fosc <value>[M|k] | off\n");
avrdude_message(MSG_INFO, "Usage: fosc <value>[M|k] | off\n");
return -1;
}
v = strtod(argv[1], &endp);
@ -609,7 +609,7 @@ static int cmd_fosc(PROGRAMMER * pgm, struct avrpart * p,
if (strcmp(argv[1], "off") == 0)
v = 0.0;
else {
avrdude_message("%s (fosc): can't parse frequency \"%s\"\n",
avrdude_message(MSG_INFO, "%s (fosc): can't parse frequency \"%s\"\n",
progname, argv[1]);
return -1;
}
@ -619,12 +619,12 @@ static int cmd_fosc(PROGRAMMER * pgm, struct avrpart * p,
else if (*endp == 'k' || *endp == 'K')
v *= 1e3;
if (pgm->set_fosc == NULL) {
avrdude_message("%s (fosc): the %s programmer cannot set oscillator frequency\n",
avrdude_message(MSG_INFO, "%s (fosc): the %s programmer cannot set oscillator frequency\n",
progname, pgm->type);
return -2;
}
if ((rc = pgm->set_fosc(pgm, v)) != 0) {
avrdude_message("%s (fosc): failed to set oscillator_frequency (rc = %d)\n",
avrdude_message(MSG_INFO, "%s (fosc): failed to set oscillator_frequency (rc = %d)\n",
progname, rc);
return -3;
}
@ -640,23 +640,23 @@ static int cmd_sck(PROGRAMMER * pgm, struct avrpart * p,
char *endp;
if (argc != 2) {
avrdude_message("Usage: sck <value>\n");
avrdude_message(MSG_INFO, "Usage: sck <value>\n");
return -1;
}
v = strtod(argv[1], &endp);
if (endp == argv[1]) {
avrdude_message("%s (sck): can't parse period \"%s\"\n",
avrdude_message(MSG_INFO, "%s (sck): can't parse period \"%s\"\n",
progname, argv[1]);
return -1;
}
v *= 1e-6; /* Convert from microseconds to seconds. */
if (pgm->set_sck_period == NULL) {
avrdude_message("%s (sck): the %s programmer cannot set SCK period\n",
avrdude_message(MSG_INFO, "%s (sck): the %s programmer cannot set SCK period\n",
progname, pgm->type);
return -2;
}
if ((rc = pgm->set_sck_period(pgm, v)) != 0) {
avrdude_message("%s (sck): failed to set SCK period (rc = %d)\n",
avrdude_message(MSG_INFO, "%s (sck): failed to set SCK period (rc = %d)\n",
progname, rc);
return -3;
}
@ -673,38 +673,38 @@ static int cmd_varef(PROGRAMMER * pgm, struct avrpart * p,
char *endp;
if (argc != 2 && argc != 3) {
avrdude_message("Usage: varef [channel] <value>\n");
avrdude_message(MSG_INFO, "Usage: varef [channel] <value>\n");
return -1;
}
if (argc == 2) {
chan = 0;
v = strtod(argv[1], &endp);
if (endp == argv[1]) {
avrdude_message("%s (varef): can't parse voltage \"%s\"\n",
avrdude_message(MSG_INFO, "%s (varef): can't parse voltage \"%s\"\n",
progname, argv[1]);
return -1;
}
} else {
chan = strtoul(argv[1], &endp, 10);
if (endp == argv[1]) {
avrdude_message("%s (varef): can't parse channel \"%s\"\n",
avrdude_message(MSG_INFO, "%s (varef): can't parse channel \"%s\"\n",
progname, argv[1]);
return -1;
}
v = strtod(argv[2], &endp);
if (endp == argv[2]) {
avrdude_message("%s (varef): can't parse voltage \"%s\"\n",
avrdude_message(MSG_INFO, "%s (varef): can't parse voltage \"%s\"\n",
progname, argv[2]);
return -1;
}
}
if (pgm->set_varef == NULL) {
avrdude_message("%s (varef): the %s programmer cannot set V[aref]\n",
avrdude_message(MSG_INFO, "%s (varef): the %s programmer cannot set V[aref]\n",
progname, pgm->type);
return -2;
}
if ((rc = pgm->set_varef(pgm, chan, v)) != 0) {
avrdude_message("%s (varef): failed to set V[aref] (rc = %d)\n",
avrdude_message(MSG_INFO, "%s (varef): failed to set V[aref] (rc = %d)\n",
progname, rc);
return -3;
}
@ -754,26 +754,26 @@ static int cmd_verbose(PROGRAMMER * pgm, struct avrpart * p,
char *endp;
if (argc != 1 && argc != 2) {
avrdude_message("Usage: verbose [<value>]\n");
avrdude_message(MSG_INFO, "Usage: verbose [<value>]\n");
return -1;
}
if (argc == 1) {
avrdude_message("Verbosity level: %d\n", verbose);
avrdude_message(MSG_INFO, "Verbosity level: %d\n", verbose);
return 0;
}
nverb = strtol(argv[1], &endp, 0);
if (endp == argv[2]) {
avrdude_message("%s: can't parse verbosity level \"%s\"\n",
avrdude_message(MSG_INFO, "%s: can't parse verbosity level \"%s\"\n",
progname, argv[2]);
return -1;
}
if (nverb < 0) {
avrdude_message("%s: verbosity level must be positive: %d\n",
avrdude_message(MSG_INFO, "%s: verbosity level must be positive: %d\n",
progname, nverb);
return -1;
}
verbose = nverb;
avrdude_message("New verbosity level: %d\n", verbose);
avrdude_message(MSG_INFO, "New verbosity level: %d\n", verbose);
return 0;
}
@ -870,7 +870,7 @@ static int do_cmd(PROGRAMMER * pgm, struct avrpart * p,
}
else if (strncasecmp(argv[0], cmd[i].name, len)==0) {
if (hold != -1) {
avrdude_message("%s: command \"%s\" is ambiguous\n",
avrdude_message(MSG_INFO, "%s: command \"%s\" is ambiguous\n",
progname, argv[0]);
return -1;
}
@ -881,7 +881,7 @@ static int do_cmd(PROGRAMMER * pgm, struct avrpart * p,
if (hold != -1)
return cmd[hold].func(pgm, p, argc, argv);
avrdude_message("%s: invalid command \"%s\"\n",
avrdude_message(MSG_INFO, "%s: invalid command \"%s\"\n",
progname, argv[0]);
return -1;

View File

@ -38,7 +38,7 @@ UPDATE * parse_op(char * s)
upd = (UPDATE *)malloc(sizeof(UPDATE));
if (upd == NULL) {
avrdude_message("%s: out of memory\n", progname);
avrdude_message(MSG_INFO, "%s: out of memory\n", progname);
exit(1);
}
@ -53,7 +53,7 @@ UPDATE * parse_op(char * s)
upd->op = DEVICE_WRITE;
upd->filename = (char *)malloc(strlen(buf) + 1);
if (upd->filename == NULL) {
avrdude_message("%s: out of memory\n", progname);
avrdude_message(MSG_INFO, "%s: out of memory\n", progname);
exit(1);
}
strcpy(upd->filename, buf);
@ -63,7 +63,7 @@ UPDATE * parse_op(char * s)
upd->memtype = (char *)malloc(strlen(buf)+1);
if (upd->memtype == NULL) {
avrdude_message("%s: out of memory\n", progname);
avrdude_message(MSG_INFO, "%s: out of memory\n", progname);
exit(1);
}
strcpy(upd->memtype, buf);
@ -79,9 +79,9 @@ UPDATE * parse_op(char * s)
upd->op = DEVICE_VERIFY;
}
else {
avrdude_message("%s: invalid I/O mode '%c' in update specification\n",
avrdude_message(MSG_INFO, "%s: invalid I/O mode '%c' in update specification\n",
progname, *p);
avrdude_message(" allowed values are:\n"
avrdude_message(MSG_INFO, " allowed values are:\n"
" r = read device\n"
" w = write device\n"
" v = verify device\n");
@ -93,7 +93,7 @@ UPDATE * parse_op(char * s)
p++;
if (*p != ':') {
avrdude_message("%s: invalid update specification\n", progname);
avrdude_message(MSG_INFO, "%s: invalid update specification\n", progname);
free(upd->memtype);
free(upd);
return NULL;
@ -135,7 +135,7 @@ UPDATE * parse_op(char * s)
case 'h': upd->format = FMT_HEX; break;
case 'o': upd->format = FMT_OCT; break;
default:
avrdude_message("%s: invalid file format '%s' in update specifier\n",
avrdude_message(MSG_INFO, "%s: invalid file format '%s' in update specifier\n",
progname, p);
free(upd->memtype);
free(upd);
@ -144,7 +144,7 @@ UPDATE * parse_op(char * s)
}
if (upd->filename == NULL) {
avrdude_message("%s: out of memory\n", progname);
avrdude_message(MSG_INFO, "%s: out of memory\n", progname);
free(upd->memtype);
free(upd);
return NULL;
@ -161,7 +161,7 @@ UPDATE * dup_update(UPDATE * upd)
u = (UPDATE *)malloc(sizeof(UPDATE));
if (u == NULL) {
avrdude_message("%s: out of memory\n", progname);
avrdude_message(MSG_INFO, "%s: out of memory\n", progname);
exit(1);
}
@ -182,7 +182,7 @@ UPDATE * new_update(int op, char * memtype, int filefmt, char * filename)
u = (UPDATE *)malloc(sizeof(UPDATE));
if (u == NULL) {
avrdude_message("%s: out of memory\n", progname);
avrdude_message(MSG_INFO, "%s: out of memory\n", progname);
exit(1);
}
@ -219,7 +219,7 @@ int do_op(PROGRAMMER * pgm, struct avrpart * p, UPDATE * upd, enum updateflags f
mem = avr_locate_mem(p, upd->memtype);
if (mem == NULL) {
avrdude_message("\"%s\" memory type not defined for part \"%s\"\n",
avrdude_message(MSG_INFO, "\"%s\" memory type not defined for part \"%s\"\n",
upd->memtype, p->desc);
return -1;
}
@ -229,13 +229,13 @@ int do_op(PROGRAMMER * pgm, struct avrpart * p, UPDATE * upd, enum updateflags f
* read out the specified device memory and write it to a file
*/
if (quell_progress < 2) {
avrdude_message("%s: reading %s memory:\n",
avrdude_message(MSG_INFO, "%s: reading %s memory:\n",
progname, mem->desc);
}
report_progress(0,1,"Reading");
rc = avr_read(pgm, p, upd->memtype, 0);
if (rc < 0) {
avrdude_message("%s: failed to read all of %s memory, rc=%d\n",
avrdude_message(MSG_INFO, "%s: failed to read all of %s memory, rc=%d\n",
progname, mem->desc, rc);
return -1;
}
@ -243,13 +243,13 @@ int do_op(PROGRAMMER * pgm, struct avrpart * p, UPDATE * upd, enum updateflags f
size = rc;
if (quell_progress < 2) {
avrdude_message("%s: writing output file \"%s\"\n",
avrdude_message(MSG_INFO, "%s: writing output file \"%s\"\n",
progname,
strcmp(upd->filename, "-")==0 ? "<stdout>" : upd->filename);
}
rc = fileio(FIO_WRITE, upd->filename, upd->format, p, upd->memtype, size);
if (rc < 0) {
avrdude_message("%s: write to file '%s' failed\n",
avrdude_message(MSG_INFO, "%s: write to file '%s' failed\n",
progname, upd->filename);
return -1;
}
@ -260,13 +260,13 @@ int do_op(PROGRAMMER * pgm, struct avrpart * p, UPDATE * upd, enum updateflags f
* read the data from the specified file
*/
if (quell_progress < 2) {
avrdude_message("%s: reading input file \"%s\"\n",
avrdude_message(MSG_INFO, "%s: reading input file \"%s\"\n",
progname,
strcmp(upd->filename, "-")==0 ? "<stdin>" : upd->filename);
}
rc = fileio(FIO_READ, upd->filename, upd->format, p, upd->memtype, -1);
if (rc < 0) {
avrdude_message("%s: read from file '%s' failed\n",
avrdude_message(MSG_INFO, "%s: read from file '%s' failed\n",
progname, upd->filename);
return -1;
}
@ -276,7 +276,7 @@ int do_op(PROGRAMMER * pgm, struct avrpart * p, UPDATE * upd, enum updateflags f
* write the buffer contents to the selected memory type
*/
if (quell_progress < 2) {
avrdude_message("%s: writing %s (%d bytes):\n",
avrdude_message(MSG_INFO, "%s: writing %s (%d bytes):\n",
progname, mem->desc, size);
}
@ -294,7 +294,7 @@ int do_op(PROGRAMMER * pgm, struct avrpart * p, UPDATE * upd, enum updateflags f
}
if (rc < 0) {
avrdude_message("%s: failed to write %s memory, rc=%d\n",
avrdude_message(MSG_INFO, "%s: failed to write %s memory, rc=%d\n",
progname, mem->desc, rc);
return -1;
}
@ -302,7 +302,7 @@ int do_op(PROGRAMMER * pgm, struct avrpart * p, UPDATE * upd, enum updateflags f
vsize = rc;
if (quell_progress < 2) {
avrdude_message("%s: %d bytes of %s written\n", progname,
avrdude_message(MSG_INFO, "%s: %d bytes of %s written\n", progname,
vsize, mem->desc);
}
@ -315,32 +315,32 @@ int do_op(PROGRAMMER * pgm, struct avrpart * p, UPDATE * upd, enum updateflags f
pgm->vfy_led(pgm, ON);
if (quell_progress < 2) {
avrdude_message("%s: verifying %s memory against %s:\n",
avrdude_message(MSG_INFO, "%s: verifying %s memory against %s:\n",
progname, mem->desc, upd->filename);
avrdude_message("%s: load data %s data from input file %s:\n",
avrdude_message(MSG_INFO, "%s: load data %s data from input file %s:\n",
progname, mem->desc, upd->filename);
}
rc = fileio(FIO_READ, upd->filename, upd->format, p, upd->memtype, -1);
if (rc < 0) {
avrdude_message("%s: read from file '%s' failed\n",
avrdude_message(MSG_INFO, "%s: read from file '%s' failed\n",
progname, upd->filename);
return -1;
}
v = avr_dup_part(p);
size = rc;
if (quell_progress < 2) {
avrdude_message("%s: input file %s contains %d bytes\n",
avrdude_message(MSG_INFO, "%s: input file %s contains %d bytes\n",
progname, upd->filename, size);
avrdude_message("%s: reading on-chip %s data:\n",
avrdude_message(MSG_INFO, "%s: reading on-chip %s data:\n",
progname, mem->desc);
}
report_progress (0,1,"Reading");
rc = avr_read(pgm, p, upd->memtype, v);
if (rc < 0) {
avrdude_message("%s: failed to read all of %s memory, rc=%d\n",
avrdude_message(MSG_INFO, "%s: failed to read all of %s memory, rc=%d\n",
progname, mem->desc, rc);
pgm->err_led(pgm, ON);
return -1;
@ -350,25 +350,25 @@ int do_op(PROGRAMMER * pgm, struct avrpart * p, UPDATE * upd, enum updateflags f
if (quell_progress < 2) {
avrdude_message("%s: verifying ...\n", progname);
avrdude_message(MSG_INFO, "%s: verifying ...\n", progname);
}
rc = avr_verify(p, v, upd->memtype, size);
if (rc < 0) {
avrdude_message("%s: verification error; content mismatch\n",
avrdude_message(MSG_INFO, "%s: verification error; content mismatch\n",
progname);
pgm->err_led(pgm, ON);
return -1;
}
if (quell_progress < 2) {
avrdude_message("%s: %d bytes of %s verified\n",
avrdude_message(MSG_INFO, "%s: %d bytes of %s verified\n",
progname, rc, mem->desc);
}
pgm->vfy_led(pgm, OFF);
}
else {
avrdude_message("%s: invalid update operation (%d) requested\n",
avrdude_message(MSG_INFO, "%s: invalid update operation (%d) requested\n",
progname, upd->op);
return -1;
}

View File

@ -98,7 +98,7 @@ static int usbdev_open(char * port, union pinfo pinfo, union filedescriptor *fd)
if (strlen(serno) > 12)
{
avrdude_message("%s: usbdev_open(): invalid serial number \"%s\"\n",
avrdude_message(MSG_INFO, "%s: usbdev_open(): invalid serial number \"%s\"\n",
progname, serno);
return -1;
}
@ -127,7 +127,7 @@ static int usbdev_open(char * port, union pinfo pinfo, union filedescriptor *fd)
dev->descriptor.iSerialNumber,
string, sizeof(string)) < 0)
{
avrdude_message("%s: usb_open(): cannot read serial number \"%s\"\n",
avrdude_message(MSG_INFO, "%s: usb_open(): cannot read serial number \"%s\"\n",
progname, usb_strerror());
/*
* On some systems, libusb appears to have
@ -146,7 +146,7 @@ static int usbdev_open(char * port, union pinfo pinfo, union filedescriptor *fd)
dev->descriptor.iProduct,
product, sizeof(product)) < 0)
{
avrdude_message("%s: usb_open(): cannot read product name \"%s\"\n",
avrdude_message(MSG_INFO, "%s: usb_open(): cannot read product name \"%s\"\n",
progname, usb_strerror());
strcpy(product, "[unnamed product]");
}
@ -166,8 +166,7 @@ static int usbdev_open(char * port, union pinfo pinfo, union filedescriptor *fd)
fd->usb.eep = 0;
}
if (verbose)
avrdude_message("%s: usbdev_open(): Found %s, serno: %s\n",
avrdude_message(MSG_NOTICE, "%s: usbdev_open(): Found %s, serno: %s\n",
progname, product, string);
if (serno != NULL)
{
@ -179,8 +178,7 @@ static int usbdev_open(char * port, union pinfo pinfo, union filedescriptor *fd)
x = strlen(string) - strlen(serno);
if (strcasecmp(string + x, serno) != 0)
{
if (verbose > 2)
avrdude_message("%s: usbdev_open(): serial number doesn't match\n",
avrdude_message(MSG_DEBUG, "%s: usbdev_open(): serial number doesn't match\n",
progname);
usb_close(udev);
continue;
@ -189,14 +187,14 @@ static int usbdev_open(char * port, union pinfo pinfo, union filedescriptor *fd)
if (dev->config == NULL)
{
avrdude_message("%s: usbdev_open(): USB device has no configuration\n",
avrdude_message(MSG_INFO, "%s: usbdev_open(): USB device has no configuration\n",
progname);
goto trynext;
}
if (usb_set_configuration(udev, dev->config[0].bConfigurationValue))
{
avrdude_message("%s: usbdev_open(): WARNING: failed to set configuration %d: %s\n",
avrdude_message(MSG_INFO, "%s: usbdev_open(): WARNING: failed to set configuration %d: %s\n",
progname, dev->config[0].bConfigurationValue,
usb_strerror());
/* let's hope it has already been configured */
@ -217,7 +215,7 @@ static int usbdev_open(char * port, union pinfo pinfo, union filedescriptor *fd)
#endif
if (usb_claim_interface(udev, usb_interface))
{
avrdude_message("%s: usbdev_open(): error claiming interface %d: %s\n",
avrdude_message(MSG_INFO, "%s: usbdev_open(): error claiming interface %d: %s\n",
progname, usb_interface, usb_strerror());
}
else
@ -235,7 +233,7 @@ static int usbdev_open(char * port, union pinfo pinfo, union filedescriptor *fd)
}
if (iface == dev->config[0].bNumInterfaces)
{
avrdude_message("%s: usbdev_open(): no usable interface found\n",
avrdude_message(MSG_INFO, "%s: usbdev_open(): no usable interface found\n",
progname);
goto trynext;
}
@ -251,18 +249,15 @@ static int usbdev_open(char * port, union pinfo pinfo, union filedescriptor *fd)
if ((possible_ep & USB_ENDPOINT_DIR_MASK) != 0)
{
if (verbose > 1)
{
avrdude_message("%s: usbdev_open(): using read endpoint 0x%02x\n",
avrdude_message(MSG_NOTICE2, "%s: usbdev_open(): using read endpoint 0x%02x\n",
progname, possible_ep);
}
fd->usb.rep = possible_ep;
break;
}
}
if (fd->usb.rep == 0)
{
avrdude_message("%s: usbdev_open(): cannot find a read endpoint, using 0x%02x\n",
avrdude_message(MSG_INFO, "%s: usbdev_open(): cannot find a read endpoint, using 0x%02x\n",
progname, USBDEV_BULK_EP_READ_MKII);
fd->usb.rep = USBDEV_BULK_EP_READ_MKII;
}
@ -273,8 +268,7 @@ static int usbdev_open(char * port, union pinfo pinfo, union filedescriptor *fd)
dev->config[0].interface[iface].altsetting[0].endpoint[i].bEndpointAddress == fd->usb.wep) &&
dev->config[0].interface[iface].altsetting[0].endpoint[i].wMaxPacketSize < fd->usb.max_xfer)
{
if (verbose != 0)
avrdude_message("%s: max packet size expected %d, but found %d due to EP 0x%02x's wMaxPacketSize\n",
avrdude_message(MSG_NOTICE, "%s: max packet size expected %d, but found %d due to EP 0x%02x's wMaxPacketSize\n",
progname,
fd->usb.max_xfer,
dev->config[0].interface[iface].altsetting[0].endpoint[i].wMaxPacketSize,
@ -285,21 +279,21 @@ static int usbdev_open(char * port, union pinfo pinfo, union filedescriptor *fd)
if (pinfo.usbinfo.flags & PINFO_FL_USEHID)
{
if (usb_control_msg(udev, 0x21, 0x0a /* SET_IDLE */, 0, 0, NULL, 0, 100) < 0)
avrdude_message("%s: usbdev_open(): SET_IDLE failed\n", progname);
avrdude_message(MSG_INFO, "%s: usbdev_open(): SET_IDLE failed\n", progname);
}
return 0;
trynext:
usb_close(udev);
}
else
avrdude_message("%s: usbdev_open(): cannot open device: %s\n",
avrdude_message(MSG_INFO, "%s: usbdev_open(): cannot open device: %s\n",
progname, usb_strerror());
}
}
}
if ((pinfo.usbinfo.flags & PINFO_FL_SILENT) == 0 || verbose > 0)
avrdude_message("%s: usbdev_open(): did not find any%s USB device \"%s\" (0x%04x:0x%04x)\n",
if ((pinfo.usbinfo.flags & PINFO_FL_SILENT) == 0)
avrdude_message(MSG_NOTICE, "%s: usbdev_open(): did not find any%s USB device \"%s\" (0x%04x:0x%04x)\n",
progname, serno? " (matching)": "", port,
(unsigned)pinfo.usbinfo.vid, (unsigned)pinfo.usbinfo.pid);
return -1;
@ -353,7 +347,7 @@ static int usbdev_send(union filedescriptor *fd, unsigned char *bp, size_t mlen)
rv = usb_bulk_write(udev, fd->usb.wep, (char *)bp, tx_size, 10000);
if (rv != tx_size)
{
avrdude_message("%s: usbdev_send(): wrote %d out of %d bytes, err = %s\n",
avrdude_message(MSG_INFO, "%s: usbdev_send(): wrote %d out of %d bytes, err = %s\n",
progname, rv, tx_size, usb_strerror());
return -1;
}
@ -363,22 +357,22 @@ static int usbdev_send(union filedescriptor *fd, unsigned char *bp, size_t mlen)
if (verbose > 3)
{
avrdude_message("%s: Sent: ", progname);
avrdude_message(MSG_TRACE, "%s: Sent: ", progname);
while (i) {
unsigned char c = *p;
if (isprint(c)) {
avrdude_message("%c ", c);
avrdude_message(MSG_TRACE, "%c ", c);
}
else {
avrdude_message(". ");
avrdude_message(MSG_TRACE, ". ");
}
avrdude_message("[%02x] ", c);
avrdude_message(MSG_TRACE, "[%02x] ", c);
p++;
i--;
}
avrdude_message("\n");
avrdude_message(MSG_TRACE, "\n");
}
return 0;
}
@ -402,8 +396,7 @@ usb_fill_buf(usb_dev_handle *udev, int maxsize, int ep, int use_interrupt_xfer)
rv = usb_bulk_read(udev, ep, usbbuf, maxsize, 10000);
if (rv < 0)
{
if (verbose > 1)
avrdude_message("%s: usb_fill_buf(): usb_%s_read() error %s\n",
avrdude_message(MSG_NOTICE2, "%s: usb_fill_buf(): usb_%s_read() error %s\n",
progname, (use_interrupt_xfer? "interrupt": "bulk"),
usb_strerror());
return -1;
@ -440,22 +433,22 @@ static int usbdev_recv(union filedescriptor *fd, unsigned char *buf, size_t nbyt
if (verbose > 4)
{
avrdude_message("%s: Recv: ", progname);
avrdude_message(MSG_TRACE2, "%s: Recv: ", progname);
while (i) {
unsigned char c = *p;
if (isprint(c)) {
avrdude_message("%c ", c);
avrdude_message(MSG_TRACE2, "%c ", c);
}
else {
avrdude_message(". ");
avrdude_message(MSG_TRACE2, ". ");
}
avrdude_message("[%02x] ", c);
avrdude_message(MSG_TRACE2, "[%02x] ", c);
p++;
i--;
}
avrdude_message("\n");
avrdude_message(MSG_TRACE2, "\n");
}
return 0;
@ -494,7 +487,7 @@ static int usbdev_recv_frame(union filedescriptor *fd, unsigned char *buf, size_
}
else if (rv > 0)
{
avrdude_message("Short event len = %d, ignored.\n", rv);
avrdude_message(MSG_INFO, "Short event len = %d, ignored.\n", rv);
/* fallthrough */
}
}
@ -510,8 +503,7 @@ static int usbdev_recv_frame(union filedescriptor *fd, unsigned char *buf, size_
fd->usb.max_xfer, 10000);
if (rv < 0)
{
if (verbose > 1)
avrdude_message("%s: usbdev_recv_frame(): usb_%s_read(): %s\n",
avrdude_message(MSG_NOTICE2, "%s: usbdev_recv_frame(): usb_%s_read(): %s\n",
progname, (fd->usb.use_interrupt_xfer? "interrupt": "bulk"),
usb_strerror());
return -1;
@ -535,22 +527,22 @@ static int usbdev_recv_frame(union filedescriptor *fd, unsigned char *buf, size_
if (verbose > 3)
{
i = n & USB_RECV_LENGTH_MASK;
avrdude_message("%s: Recv: ", progname);
avrdude_message(MSG_TRACE, "%s: Recv: ", progname);
while (i) {
unsigned char c = *p;
if (isprint(c)) {
avrdude_message("%c ", c);
avrdude_message(MSG_TRACE, "%c ", c);
}
else {
avrdude_message(". ");
avrdude_message(MSG_TRACE, ". ");
}
avrdude_message("[%02x] ", c);
avrdude_message(MSG_TRACE, "[%02x] ", c);
p++;
i--;
}
avrdude_message("\n");
avrdude_message(MSG_TRACE, "\n");
}
return n;
}
@ -568,8 +560,8 @@ static int usbdev_drain(union filedescriptor *fd, int display)
rv = usb_interrupt_read(udev, fd->usb.rep, usbbuf, fd->usb.max_xfer, 100);
else
rv = usb_bulk_read(udev, fd->usb.rep, usbbuf, fd->usb.max_xfer, 100);
if (rv > 0 && verbose >= 4)
avrdude_message("%s: usbdev_drain(): flushed %d characters\n",
if (rv > 0)
avrdude_message(MSG_TRACE, "%s: usbdev_drain(): flushed %d characters\n",
progname, rv);
} while (rv > 0);

156
usbasp.c
View File

@ -180,7 +180,7 @@ static int usbasp_tpi_write_byte(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m, unsi
static void usbasp_setup(PROGRAMMER * pgm)
{
if ((pgm->cookie = malloc(sizeof(struct pdata))) == 0) {
avrdude_message("%s: usbasp_setup(): Out of memory allocating private data\n",
avrdude_message(MSG_INFO, "%s: usbasp_setup(): Out of memory allocating private data\n",
progname);
exit(1);
}
@ -229,15 +229,15 @@ static int usbasp_transmit(PROGRAMMER * pgm,
int nbytes;
if (verbose > 3) {
avrdude_message("%s: usbasp_transmit(\"%s\", 0x%02x, 0x%02x, 0x%02x, 0x%02x)\n",
avrdude_message(MSG_TRACE, "%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;
avrdude_message("%s => ", progbuf);
avrdude_message(MSG_TRACE, "%s => ", progbuf);
for (i = 0; i < buffersize; i++)
avrdude_message("[%02x] ", buffer[i]);
avrdude_message("\n");
avrdude_message(MSG_TRACE, "[%02x] ", buffer[i]);
avrdude_message(MSG_TRACE, "\n");
}
}
@ -251,7 +251,7 @@ static int usbasp_transmit(PROGRAMMER * pgm,
buffersize & 0xffff,
5000);
if(nbytes < 0){
avrdude_message("%s: error: usbasp_transmit: %s\n", progname, strerror(libusb_to_errno(nbytes)));
avrdude_message(MSG_INFO, "%s: error: usbasp_transmit: %s\n", progname, strerror(libusb_to_errno(nbytes)));
return -1;
}
#else
@ -263,17 +263,17 @@ static int usbasp_transmit(PROGRAMMER * pgm,
(char *)buffer, buffersize,
5000);
if(nbytes < 0){
avrdude_message("%s: error: usbasp_transmit: %s\n", progname, usb_strerror());
avrdude_message(MSG_INFO, "%s: error: usbasp_transmit: %s\n", progname, usb_strerror());
return -1;
}
#endif
if (verbose > 3 && receive && nbytes > 0) {
int i;
avrdude_message("%s<= ", progbuf);
avrdude_message(MSG_TRACE, "%s<= ", progbuf);
for (i = 0; i < nbytes; i++)
avrdude_message("[%02x] ", buffer[i]);
avrdude_message("\n");
avrdude_message(MSG_TRACE, "[%02x] ", buffer[i]);
avrdude_message(MSG_TRACE, "\n");
}
return nbytes;
@ -314,7 +314,7 @@ static int usbOpenDevice(libusb_device_handle **device, int vendor,
r = libusb_open(dev, &handle);
if (!handle) {
errorCode = USB_ERROR_ACCESS;
avrdude_message("%s: Warning: cannot open USB device: %s\n",
avrdude_message(MSG_INFO, "%s: Warning: cannot open USB device: %s\n",
progname, strerror(libusb_to_errno(r)));
continue;
}
@ -325,12 +325,11 @@ static int usbOpenDevice(libusb_device_handle **device, int vendor,
if (r < 0) {
if ((vendorName != NULL) && (vendorName[0] != 0)) {
errorCode = USB_ERROR_IO;
avrdude_message("%s: Warning: cannot query manufacturer for device: %s\n",
avrdude_message(MSG_INFO, "%s: Warning: cannot query manufacturer for device: %s\n",
progname, strerror(libusb_to_errno(r)));
}
} else {
if (verbose > 1)
avrdude_message("%s: seen device from vendor ->%s<-\n",
avrdude_message(MSG_NOTICE2, "%s: seen device from vendor ->%s<-\n",
progname, string);
if ((vendorName != NULL) && (vendorName[0] != 0) && (strcmp(string, vendorName) != 0))
errorCode = USB_ERROR_NOTFOUND;
@ -340,12 +339,11 @@ static int usbOpenDevice(libusb_device_handle **device, int vendor,
if (r < 0) {
if ((productName != NULL) && (productName[0] != 0)) {
errorCode = USB_ERROR_IO;
avrdude_message("%s: Warning: cannot query product for device: %s\n",
avrdude_message(MSG_INFO, "%s: Warning: cannot query product for device: %s\n",
progname, strerror(libusb_to_errno(r)));
}
} else {
if (verbose > 1)
avrdude_message("%s: seen product ->%s<-\n",
avrdude_message(MSG_NOTICE2, "%s: seen product ->%s<-\n",
progname, string);
if((productName != NULL) && (productName[0] != 0) && (strcmp(string, productName) != 0))
errorCode = USB_ERROR_NOTFOUND;
@ -389,7 +387,7 @@ static int didUsbInit = 0;
handle = usb_open(dev);
if(!handle){
errorCode = USB_ERROR_ACCESS;
avrdude_message("%s: Warning: cannot open USB device: %s\n",
avrdude_message(MSG_INFO, "%s: Warning: cannot open USB device: %s\n",
progname, usb_strerror());
continue;
}
@ -401,12 +399,11 @@ static int didUsbInit = 0;
if(len < 0){
if ((vendorName != NULL) && (vendorName[0] != 0)) {
errorCode = USB_ERROR_IO;
avrdude_message("%s: Warning: cannot query manufacturer for device: %s\n",
avrdude_message(MSG_INFO, "%s: Warning: cannot query manufacturer for device: %s\n",
progname, usb_strerror());
}
} else {
if (verbose > 1)
avrdude_message("%s: seen device from vendor ->%s<-\n",
avrdude_message(MSG_NOTICE2, "%s: seen device from vendor ->%s<-\n",
progname, string);
if((vendorName != NULL) && (vendorName[0] != 0) && (strcmp(string, vendorName) != 0))
errorCode = USB_ERROR_NOTFOUND;
@ -417,12 +414,11 @@ static int didUsbInit = 0;
if(len < 0){
if ((productName != NULL) && (productName[0] != 0)) {
errorCode = USB_ERROR_IO;
avrdude_message("%s: Warning: cannot query product for device: %s\n",
avrdude_message(MSG_INFO, "%s: Warning: cannot query product for device: %s\n",
progname, usb_strerror());
}
} else {
if (verbose > 1)
avrdude_message("%s: seen product ->%s<-\n",
avrdude_message(MSG_NOTICE2, "%s: seen product ->%s<-\n",
progname, string);
if((productName != NULL) && (productName[0] != 0) && (strcmp(string, productName) != 0))
errorCode = USB_ERROR_NOTFOUND;
@ -448,8 +444,7 @@ static int didUsbInit = 0;
/* Interface - prog. */
static int usbasp_open(PROGRAMMER * pgm, char * port)
{
if (verbose > 2)
avrdude_message("%s: usbasp_open(\"%s\")\n",
avrdude_message(MSG_DEBUG, "%s: usbasp_open(\"%s\")\n",
progname, port);
/* usb_init will be done in usbOpenDevice */
@ -458,7 +453,7 @@ static int usbasp_open(PROGRAMMER * pgm, char * port)
if (usbpid) {
pid = *(int *)(ldata(usbpid));
if (lnext(usbpid))
avrdude_message("%s: Warning: using PID 0x%04x, ignoring remaining PIDs in list\n",
avrdude_message(MSG_INFO, "%s: Warning: using PID 0x%04x, ignoring remaining PIDs in list\n",
progname, pid);
} else {
pid = USBASP_SHARED_PID;
@ -469,12 +464,12 @@ static int usbasp_open(PROGRAMMER * pgm, char * port)
if(strcasecmp(ldata(lfirst(pgm->id)), "usbasp") == 0) {
/* for id usbasp autodetect some variants */
if(strcasecmp(port, "nibobee") == 0) {
avrdude_message("%s: warning: Using \"-C usbasp -P nibobee\" is deprecated,"
avrdude_message(MSG_INFO, "%s: warning: Using \"-C usbasp -P nibobee\" is deprecated,"
"use \"-C nibobee\" instead.\n",
progname);
if (usbOpenDevice(&PDATA(pgm)->usbhandle, USBASP_NIBOBEE_VID, "www.nicai-systems.com",
USBASP_NIBOBEE_PID, "NIBObee") != 0) {
avrdude_message("%s: error: could not find USB device "
avrdude_message(MSG_INFO, "%s: error: could not find USB device "
"\"NIBObee\" with vid=0x%x pid=0x%x\n",
progname, USBASP_NIBOBEE_VID, USBASP_NIBOBEE_PID);
return -1;
@ -485,7 +480,7 @@ static int usbasp_open(PROGRAMMER * pgm, char * port)
if (usbOpenDevice(&PDATA(pgm)->usbhandle, USBASP_OLD_VID, "www.fischl.de",
USBASP_OLD_PID, "USBasp") == 0) {
/* found USBasp with old IDs */
avrdude_message("%s: Warning: Found USB device \"USBasp\" with "
avrdude_message(MSG_INFO, "%s: Warning: Found USB device \"USBasp\" with "
"old VID/PID! Please update firmware of USBasp!\n",
progname);
return 0;
@ -494,15 +489,15 @@ static int usbasp_open(PROGRAMMER * pgm, char * port)
/* no alternative found => fall through to generic error message */
}
avrdude_message("%s: error: could not find USB device with vid=0x%x pid=0x%x",
avrdude_message(MSG_INFO, "%s: error: could not find USB device with vid=0x%x pid=0x%x",
progname, vid, pid);
if (pgm->usbvendor[0] != 0) {
avrdude_message(" vendor='%s'", pgm->usbvendor);
avrdude_message(MSG_INFO, " vendor='%s'", pgm->usbvendor);
}
if (pgm->usbproduct[0] != 0) {
avrdude_message(" product='%s'", pgm->usbproduct);
avrdude_message(MSG_INFO, " product='%s'", pgm->usbproduct);
}
avrdude_message("\n");
avrdude_message(MSG_INFO, "\n");
return -1;
}
@ -511,8 +506,7 @@ static int usbasp_open(PROGRAMMER * pgm, char * port)
static void usbasp_close(PROGRAMMER * pgm)
{
if (verbose > 2)
avrdude_message("%s: usbasp_close()\n", progname);
avrdude_message(MSG_DEBUG, "%s: usbasp_close()\n", progname);
if (PDATA(pgm)->usbhandle!=NULL) {
unsigned char temp[4];
@ -566,8 +560,7 @@ static int usbasp_initialize(PROGRAMMER * pgm, AVRPART * p)
unsigned char res[4];
IMPORT_PDATA(pgm);
if (verbose > 2)
avrdude_message("%s: usbasp_initialize()\n", progname);
avrdude_message(MSG_DEBUG, "%s: usbasp_initialize()\n", progname);
/* get capabilities */
memset(temp, 0, sizeof(temp));
@ -631,8 +624,7 @@ static int usbasp_initialize(PROGRAMMER * pgm, AVRPART * p)
static int usbasp_spi_cmd(PROGRAMMER * pgm, const unsigned char *cmd,
unsigned char *res)
{
if (verbose > 2)
avrdude_message("%s: usbasp_cpi_cmd(0x%02x, 0x%02x, 0x%02x, 0x%02x)%s",
avrdude_message(MSG_DEBUG, "%s: usbasp_cpi_cmd(0x%02x, 0x%02x, 0x%02x, 0x%02x)%s",
progname, cmd[0], cmd[1], cmd[2], cmd[3],
verbose > 3? "...\n": "");
@ -643,16 +635,13 @@ static int usbasp_spi_cmd(PROGRAMMER * pgm, const unsigned char *cmd,
if (verbose == 3)
putc('\n', stderr);
avrdude_message("%s: error: wrong responds size\n",
avrdude_message(MSG_INFO, "%s: error: wrong responds size\n",
progname);
return -1;
}
if (verbose > 2) {
if (verbose > 3)
avrdude_message("%s: usbasp_cpi_cmd()", progname);
avrdude_message(" => 0x%02x, 0x%02x, 0x%02x, 0x%02x\n",
res[0], res[1], res[2], res[3]);
}
avrdude_message(MSG_TRACE, "%s: usbasp_cpi_cmd()", progname);
avrdude_message(MSG_DEBUG, " => 0x%02x, 0x%02x, 0x%02x, 0x%02x\n",
res[0], res[1], res[2], res[3]);
return 0;
}
@ -666,15 +655,14 @@ static int usbasp_spi_program_enable(PROGRAMMER * pgm, AVRPART * p)
cmd[0] = 0;
if (verbose > 2)
avrdude_message("%s: usbasp_program_enable()\n",
avrdude_message(MSG_DEBUG, "%s: usbasp_program_enable()\n",
progname);
int nbytes =
usbasp_transmit(pgm, 1, USBASP_FUNC_ENABLEPROG, cmd, res, sizeof(res));
if ((nbytes != 1) | (res[0] != 0)) {
avrdude_message("%s: error: program enable: target doesn't answer. %x \n",
avrdude_message(MSG_INFO, "%s: error: program enable: target doesn't answer. %x \n",
progname, res[0]);
return -1;
}
@ -687,12 +675,11 @@ static int usbasp_spi_chip_erase(PROGRAMMER * pgm, AVRPART * p)
unsigned char cmd[4];
unsigned char res[4];
if (verbose > 2)
avrdude_message("%s: usbasp_chip_erase()\n",
avrdude_message(MSG_DEBUG, "%s: usbasp_chip_erase()\n",
progname);
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;
}
@ -718,8 +705,7 @@ static int usbasp_spi_paged_load(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m,
unsigned char *buffer = m->buf + address;
int function;
if (verbose > 2)
avrdude_message("%s: usbasp_program_paged_load(\"%s\", 0x%x, %d)\n",
avrdude_message(MSG_DEBUG, "%s: usbasp_program_paged_load(\"%s\", 0x%x, %d)\n",
progname, m->desc, address, n_bytes);
if (strcmp(m->desc, "flash") == 0) {
@ -763,7 +749,7 @@ static int usbasp_spi_paged_load(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m,
n = usbasp_transmit(pgm, 1, function, cmd, buffer, blocksize);
if (n != blocksize) {
avrdude_message("%s: error: wrong reading bytes %x\n",
avrdude_message(MSG_INFO, "%s: error: wrong reading bytes %x\n",
progname, n);
return -3;
}
@ -787,8 +773,7 @@ static int usbasp_spi_paged_write(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m,
unsigned char blockflags = USBASP_BLOCKFLAG_FIRST;
int function;
if (verbose > 2)
avrdude_message("%s: usbasp_program_paged_write(\"%s\", 0x%x, %d)\n",
avrdude_message(MSG_DEBUG, "%s: usbasp_program_paged_write(\"%s\", 0x%x, %d)\n",
progname, m->desc, address, n_bytes);
if (strcmp(m->desc, "flash") == 0) {
@ -837,7 +822,7 @@ static int usbasp_spi_paged_write(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m,
n = usbasp_transmit(pgm, 0, function, cmd, buffer, blocksize);
if (n != blocksize) {
avrdude_message("%s: error: wrong count at writing %x\n",
avrdude_message(MSG_INFO, "%s: error: wrong count at writing %x\n",
progname, n);
return -3;
}
@ -876,8 +861,7 @@ static int usbasp_spi_set_sck_period(PROGRAMMER *pgm, double sckperiod)
unsigned char res[4];
unsigned char cmd[4];
if (verbose > 2)
avrdude_message("%s: usbasp_spi_set_sck_period(%g)\n",
avrdude_message(MSG_DEBUG, "%s: usbasp_spi_set_sck_period(%g)\n",
progname, sckperiod);
memset(cmd, 0, sizeof(cmd));
@ -889,16 +873,14 @@ static int usbasp_spi_set_sck_period(PROGRAMMER *pgm, double sckperiod)
if (sckperiod == 0) {
/* auto sck set */
if (verbose >= 1)
avrdude_message("%s: auto set sck period (because given equals null)\n", progname);
avrdude_message(MSG_NOTICE, "%s: auto set sck period (because given equals null)\n", progname);
} else {
int sckfreq = 1 / sckperiod; /* sck in Hz */
int usefreq = 0;
if (verbose >= 2)
avrdude_message("%s: try to set SCK period to %g s (= %i Hz)\n", progname, sckperiod, sckfreq);
avrdude_message(MSG_NOTICE2, "%s: try to set SCK period to %g s (= %i Hz)\n", progname, sckperiod, sckfreq);
if (sckfreq >= usbaspSCKoptions[0].frequency) {
clockoption = usbaspSCKoptions[0].id;
@ -919,7 +901,7 @@ static int usbasp_spi_set_sck_period(PROGRAMMER *pgm, double sckperiod)
/* save used sck frequency */
PDATA(pgm)->sckfreq_hz = usefreq;
avrdude_message("%s: set SCK frequency to %i Hz\n", progname, usefreq);
avrdude_message(MSG_INFO, "%s: set SCK frequency to %i Hz\n", progname, usefreq);
}
cmd[0] = clockoption;
@ -928,7 +910,7 @@ static int usbasp_spi_set_sck_period(PROGRAMMER *pgm, double sckperiod)
usbasp_transmit(pgm, 1, USBASP_FUNC_SETISPSCK, cmd, res, sizeof(res));
if ((nbytes != 1) | (res[0] != 0)) {
avrdude_message("%s: warning: cannot set sck period. please check for usbasp firmware update.\n",
avrdude_message(MSG_INFO, "%s: warning: cannot set sck period. please check for usbasp firmware update.\n",
progname);
return -1;
}
@ -955,7 +937,7 @@ static int usbasp_tpi_recv_byte(PROGRAMMER * pgm)
if(usbasp_transmit(pgm, 1, USBASP_FUNC_TPI_RAWREAD, temp, temp, sizeof(temp)) != 1)
{
avrdude_message("%s: error: wrong responds size\n", progname);
avrdude_message(MSG_INFO, "%s: error: wrong responds size\n", progname);
return -1;
}
@ -967,8 +949,7 @@ static int usbasp_tpi_nvm_waitbusy(PROGRAMMER * pgm)
{
int retry;
if (verbose > 2)
avrdude_message("%s: usbasp_tpi_nvm_waitbusy() ...", progname);
avrdude_message(MSG_DEBUG, "%s: usbasp_tpi_nvm_waitbusy() ...", progname);
for(retry=50; retry>0; retry--)
{
@ -976,21 +957,19 @@ static int usbasp_tpi_nvm_waitbusy(PROGRAMMER * pgm)
if(usbasp_tpi_recv_byte(pgm) & NVMCSR_BSY)
continue;
if (verbose > 2)
avrdude_message(" ready\n");
avrdude_message(MSG_DEBUG, " ready\n");
return 0;
}
if (verbose > 2)
avrdude_message(" failure\n");
avrdude_message(MSG_DEBUG, " failure\n");
return -1;
}
static int usbasp_tpi_cmd(PROGRAMMER * pgm, const unsigned char *cmd, unsigned char *res)
{
avrdude_message("%s: error: spi_cmd used in TPI mode: not allowed\n", progname);
avrdude_message(MSG_INFO, "%s: error: spi_cmd used in TPI mode: not allowed\n", progname);
return -1;
}
@ -998,8 +977,7 @@ static int usbasp_tpi_program_enable(PROGRAMMER * pgm, AVRPART * p)
{
int retry;
if (verbose > 2)
avrdude_message("%s: usbasp_tpi_program_enable()\n", progname);
avrdude_message(MSG_DEBUG, "%s: usbasp_tpi_program_enable()\n", progname);
/* change guard time */
usbasp_tpi_send_byte(pgm, TPI_OP_SSTCS(TPIPCR));
@ -1029,7 +1007,7 @@ static int usbasp_tpi_program_enable(PROGRAMMER * pgm, AVRPART * p)
}
if(retry >= 10)
{
avrdude_message("%s: error: program enable: target doesn't answer.\n", progname);
avrdude_message(MSG_INFO, "%s: error: program enable: target doesn't answer.\n", progname);
return -1;
}
@ -1038,8 +1016,7 @@ static int usbasp_tpi_program_enable(PROGRAMMER * pgm, AVRPART * p)
static int usbasp_tpi_chip_erase(PROGRAMMER * pgm, AVRPART * p)
{
if (verbose > 2)
avrdude_message("%s: usbasp_tpi_chip_erase()\n", progname);
avrdude_message(MSG_DEBUG, "%s: usbasp_tpi_chip_erase()\n", progname);
/* Set PR to flash */
usbasp_tpi_send_byte(pgm, TPI_OP_SSTPR(0));
@ -1070,8 +1047,7 @@ static int usbasp_tpi_paged_load(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m,
uint16_t pr;
if (verbose > 2)
avrdude_message("%s: usbasp_tpi_paged_load(\"%s\", 0x%0x, %d)\n",
avrdude_message(MSG_DEBUG, "%s: usbasp_tpi_paged_load(\"%s\", 0x%0x, %d)\n",
progname, m->desc, addr, n_bytes);
dptr = addr + m->buf;
@ -1092,7 +1068,7 @@ static int usbasp_tpi_paged_load(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m,
n = usbasp_transmit(pgm, 1, USBASP_FUNC_TPI_READBLOCK, cmd, dptr, clen);
if(n != clen)
{
avrdude_message("%s: error: wrong reading bytes %x\n", progname, n);
avrdude_message(MSG_INFO, "%s: error: wrong reading bytes %x\n", progname, n);
return -3;
}
@ -1114,8 +1090,7 @@ static int usbasp_tpi_paged_write(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m,
uint16_t pr;
if (verbose > 2)
avrdude_message("%s: usbasp_tpi_paged_write(\"%s\", 0x%0x, %d)\n",
avrdude_message(MSG_DEBUG, "%s: usbasp_tpi_paged_write(\"%s\", 0x%0x, %d)\n",
progname, m->desc, addr, n_bytes);
sptr = addr + m->buf;
@ -1142,7 +1117,7 @@ static int usbasp_tpi_paged_write(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m,
n = usbasp_transmit(pgm, 0, USBASP_FUNC_TPI_WRITEBLOCK, cmd, sptr, clen);
if(n != clen)
{
avrdude_message("%s: error: wrong count at writing %x\n", progname, n);
avrdude_message(MSG_INFO, "%s: error: wrong count at writing %x\n", progname, n);
return -3;
}
@ -1165,8 +1140,7 @@ static int usbasp_tpi_read_byte(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m, unsig
uint16_t pr;
if (verbose > 2)
avrdude_message("%s: usbasp_tpi_read_byte(\"%s\", 0x%0lx)\n",
avrdude_message(MSG_DEBUG, "%s: usbasp_tpi_read_byte(\"%s\", 0x%0lx)\n",
progname, m->desc, addr);
pr = m->offset + addr;
@ -1179,7 +1153,7 @@ static int usbasp_tpi_read_byte(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m, unsig
n = usbasp_transmit(pgm, 1, USBASP_FUNC_TPI_READBLOCK, cmd, value, 1);
if(n != 1)
{
avrdude_message("%s: error: wrong reading bytes %x\n", progname, n);
avrdude_message(MSG_INFO, "%s: error: wrong reading bytes %x\n", progname, n);
return -3;
}
return 0;
@ -1187,7 +1161,7 @@ static int usbasp_tpi_read_byte(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m, unsig
static int usbasp_tpi_write_byte(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m, unsigned long addr, unsigned char data)
{
avrdude_message("%s: error: usbasp_write_byte in TPI mode: all writes have to be done at page level\n", progname);
avrdude_message(MSG_INFO, "%s: error: usbasp_write_byte in TPI mode: all writes have to be done at page level\n", progname);
return -1;
}
@ -1229,7 +1203,7 @@ void usbasp_initpgm(PROGRAMMER * pgm)
static int usbasp_nousb_open (struct programmer_t *pgm, char * name)
{
avrdude_message("%s: error: no usb support. please compile again with libusb installed.\n",
avrdude_message(MSG_INFO, "%s: error: no usb support. please compile again with libusb installed.\n",
progname);
return -1;

View File

@ -75,7 +75,7 @@ struct pdata
static void usbtiny_setup(PROGRAMMER * pgm)
{
if ((pgm->cookie = malloc(sizeof(struct pdata))) == 0) {
avrdude_message("%s: usbtiny_setup(): Out of memory allocating private data\n",
avrdude_message(MSG_INFO, "%s: usbtiny_setup(): Out of memory allocating private data\n",
progname);
exit(1);
}
@ -99,7 +99,7 @@ static int usb_control (PROGRAMMER * pgm,
NULL, 0, // no data buffer in control messge
USB_TIMEOUT ); // default timeout
if(nbytes < 0){
avrdude_message("\n%s: error: usbtiny_transmit: %s\n", progname, usb_strerror());
avrdude_message(MSG_INFO, "\n%s: error: usbtiny_transmit: %s\n", progname, usb_strerror());
return -1;
}
@ -131,7 +131,7 @@ static int usb_in (PROGRAMMER * pgm,
}
PDATA(pgm)->retries++;
}
avrdude_message("\n%s: error: usbtiny_receive: %s (expected %d, got %d)\n",
avrdude_message(MSG_INFO, "\n%s: error: usbtiny_receive: %s (expected %d, got %d)\n",
progname, usb_strerror(), buflen, nbytes);
return -1;
}
@ -140,7 +140,7 @@ static int usb_in (PROGRAMMER * pgm,
static void check_retries (PROGRAMMER * pgm, const char* operation)
{
if (PDATA(pgm)->retries > 0 && quell_progress < 2) {
avrdude_message("%s: %d retries during %s\n", progname,
avrdude_message(MSG_INFO, "%s: %d retries during %s\n", progname,
PDATA(pgm)->retries, operation);
}
PDATA(pgm)->retries = 0;
@ -165,7 +165,7 @@ static int usb_out (PROGRAMMER * pgm,
(char *)buffer, buflen,
timeout);
if (nbytes != buflen) {
avrdude_message("\n%s: error: usbtiny_send: %s (expected %d, got %d)\n",
avrdude_message(MSG_INFO, "\n%s: error: usbtiny_send: %s (expected %d, got %d)\n",
progname, usb_strerror(), buflen, nbytes);
return -1;
}
@ -184,7 +184,7 @@ static int usbtiny_avr_op (PROGRAMMER * pgm, AVRPART * p,
unsigned char cmd[4];
if (p->op[op] == NULL) {
avrdude_message("Operation %d not defined for this chip!\n", op );
avrdude_message(MSG_INFO, "Operation %d not defined for this chip!\n", op );
return -1;
}
memset(cmd, 0, sizeof(cmd));
@ -234,7 +234,7 @@ static int usbtiny_open(PROGRAMMER* pgm, char* name)
if (usbpid) {
pid = *(int *)(ldata(usbpid));
if (lnext(usbpid))
avrdude_message("%s: Warning: using PID 0x%04x, ignoring remaining PIDs in list\n",
avrdude_message(MSG_INFO, "%s: Warning: using PID 0x%04x, ignoring remaining PIDs in list\n",
progname, pid);
} else {
pid = USBTINY_PRODUCT_DEFAULT;
@ -246,8 +246,7 @@ static int usbtiny_open(PROGRAMMER* pgm, char* name)
for ( dev = bus->devices; dev; dev = dev->next ) {
if (dev->descriptor.idVendor == vid
&& dev->descriptor.idProduct == pid ) { // found match?
if(verbose)
avrdude_message("%s: usbdev_open(): Found USBtinyISP, bus:device: %s:%s\n",
avrdude_message(MSG_NOTICE, "%s: usbdev_open(): Found USBtinyISP, bus:device: %s:%s\n",
progname, bus->dirname, dev->filename);
// if -P was given, match device by device name and bus name
if(name != NULL &&
@ -259,7 +258,7 @@ static int usbtiny_open(PROGRAMMER* pgm, char* name)
// wrong permissions or something?
if (!PDATA(pgm)->usb_handle) {
avrdude_message("%s: Warning: cannot open USB device: %s\n",
avrdude_message(MSG_INFO, "%s: Warning: cannot open USB device: %s\n",
progname, usb_strerror());
continue;
}
@ -268,12 +267,12 @@ static int usbtiny_open(PROGRAMMER* pgm, char* name)
}
if(NULL != name && NULL == dev_name) {
avrdude_message("%s: Error: Invalid -P value: '%s'\n", progname, name);
avrdude_message("%sUse -P usb:bus:device\n", progbuf);
avrdude_message(MSG_INFO, "%s: Error: Invalid -P value: '%s'\n", progname, name);
avrdude_message(MSG_INFO, "%sUse -P usb:bus:device\n", progbuf);
return -1;
}
if (!PDATA(pgm)->usb_handle) {
avrdude_message("%s: Error: Could not find USBtiny device (0x%x/0x%x)\n",
avrdude_message(MSG_INFO, "%s: Error: Could not find USBtiny device (0x%x/0x%x)\n",
progname, vid, pid );
return -1;
}
@ -318,10 +317,8 @@ static int usbtiny_set_sck_period (PROGRAMMER *pgm, double v)
if (PDATA(pgm)->sck_period > SCK_MAX)
PDATA(pgm)->sck_period = SCK_MAX;
if (verbose) {
avrdude_message("%s: Setting SCK period to %d usec\n", progname,
avrdude_message(MSG_NOTICE, "%s: Setting SCK period to %d usec\n", progname,
PDATA(pgm)->sck_period );
}
// send the command to the usbtiny device.
// MEME: for at90's fix resetstate?
@ -345,10 +342,8 @@ static int usbtiny_initialize (PROGRAMMER *pgm, AVRPART *p )
} else {
// -B option not specified: use default
PDATA(pgm)->sck_period = SCK_DEFAULT;
if (verbose) {
avrdude_message("%s: Using SCK period of %d usec\n",
avrdude_message(MSG_NOTICE, "%s: Using SCK period of %d usec\n",
progname, PDATA(pgm)->sck_period );
}
if (usb_control(pgm, USBTINY_POWERUP,
PDATA(pgm)->sck_period, RESET_LOW ) < 0)
return -1;
@ -400,12 +395,10 @@ static int usbtiny_cmd(PROGRAMMER * pgm, const unsigned char *cmd, unsigned char
if (nbytes < 0)
return -1;
check_retries(pgm, "SPI command");
if (verbose > 1) {
// print out the data we sent and received
avrdude_message("CMD: [%02x %02x %02x %02x] [%02x %02x %02x %02x]\n",
// print out the data we sent and received
avrdude_message(MSG_NOTICE2, "CMD: [%02x %02x %02x %02x] [%02x %02x %02x %02x]\n",
cmd[0], cmd[1], cmd[2], cmd[3],
res[0], res[1], res[2], res[3] );
}
return ((nbytes == 4) && // should have read 4 bytes
res[2] == cmd[1]); // AVR's do a delayed-echo thing
}
@ -416,7 +409,7 @@ static int usbtiny_chip_erase(PROGRAMMER * pgm, AVRPART * p)
unsigned char res[4];
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;
}
@ -577,7 +570,7 @@ void usbtiny_initpgm ( PROGRAMMER* pgm )
static int usbtiny_nousb_open(struct programmer_t *pgm, char * name)
{
avrdude_message("%s: error: no usb support. Please compile again with libusb installed.\n",
avrdude_message(MSG_INFO, "%s: error: no usb support. Please compile again with libusb installed.\n",
progname);
return -1;

View File

@ -85,7 +85,7 @@ static void wiring_setup(PROGRAMMER * pgm)
* Now prepare our data
*/
if ((mycookie = malloc(sizeof(struct wiringpdata))) == 0) {
avrdude_message("%s: wiring_setup(): Out of memory allocating private data\n",
avrdude_message(MSG_INFO, "%s: wiring_setup(): Out of memory allocating private data\n",
progname);
exit(1);
}
@ -123,21 +123,19 @@ static int wiring_parseextparms(PROGRAMMER * pgm, LISTID extparms)
int newsnooze;
if (sscanf(extended_param, "snooze=%i", &newsnooze) != 1 ||
newsnooze < 0) {
avrdude_message("%s: wiring_parseextparms(): invalid snooze time '%s'\n",
avrdude_message(MSG_INFO, "%s: wiring_parseextparms(): invalid snooze time '%s'\n",
progname, extended_param);
rv = -1;
continue;
}
if (verbose >= 2) {
avrdude_message("%s: wiring_parseextparms(): snooze time set to %d ms\n",
progname, newsnooze);
}
avrdude_message(MSG_NOTICE2, "%s: wiring_parseextparms(): snooze time set to %d ms\n",
progname, newsnooze);
WIRINGPDATA(mycookie)->snoozetime = newsnooze;
continue;
}
avrdude_message("%s: wiring_parseextparms(): invalid extended parameter '%s'\n",
avrdude_message(MSG_INFO, "%s: wiring_parseextparms(): invalid extended parameter '%s'\n",
progname, extended_param);
rv = -1;
}
@ -160,27 +158,20 @@ static int wiring_open(PROGRAMMER * pgm, char * port)
if (WIRINGPDATA(mycookie)->snoozetime > 0) {
timetosnooze = WIRINGPDATA(mycookie)->snoozetime;
if (verbose >= 2) {
avrdude_message("%s: wiring_open(): snoozing for %d ms\n",
progname, timetosnooze);
}
avrdude_message(MSG_NOTICE2, "%s: wiring_open(): snoozing for %d ms\n",
progname, timetosnooze);
while (timetosnooze--)
usleep(1000);
if (verbose >= 2) {
avrdude_message("%s: wiring_open(): done snoozing\n",
progname);
}
avrdude_message(MSG_NOTICE2, "%s: wiring_open(): done snoozing\n",
progname);
} else {
/* Perform Wiring programming mode RESET. */
/* This effectively *releases* both DTR and RTS. */
/* i.e. both DTR and RTS rise to a HIGH logic level */
/* since they are active LOW signals. */
if (verbose >= 2) {
avrdude_message("%s: wiring_open(): releasing DTR/RTS\n",
progname);
}
avrdude_message(MSG_NOTICE2, "%s: wiring_open(): releasing DTR/RTS\n",
progname);
serial_set_dtr_rts(&pgm->fd, 0);
usleep(50*1000);
@ -188,10 +179,8 @@ static int wiring_open(PROGRAMMER * pgm, char * port)
/* After releasing for 50 milliseconds, DTR and RTS */
/* are asserted (i.e. logic LOW) again. */
if (verbose >= 2) {
avrdude_message("%s: wiring_open(): asserting DTR/RTS\n",
progname);
}
avrdude_message(MSG_NOTICE2, "%s: wiring_open(): asserting DTR/RTS\n",
progname);
serial_set_dtr_rts(&pgm->fd, 1);
usleep(50*1000);