Exchange of fprintf(stderr, ...) with avrdude_message(...).
This change was made for the shared library, since library functions should not write to std-streams directly. Instead avrdude_message() has to be implemented by the library user. For the avrdude application this function is implemented in main.c. git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@1305 81a1dc3b-b13d-400b-aceb-764788c761c2
This commit is contained in:
parent
52dd5cc7ac
commit
eb5fcb581f
18
arduino.c
18
arduino.c
|
@ -46,7 +46,7 @@ static int arduino_read_sig_bytes(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m)
|
|||
/* Signature byte reads are always 3 bytes. */
|
||||
|
||||
if (m->size < 3) {
|
||||
fprintf(stderr, "%s: memsize too small for sig byte read", progname);
|
||||
avrdude_message("%s: memsize too small for sig byte read", progname);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -58,21 +58,19 @@ 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) {
|
||||
fprintf(stderr, "%s: stk500_cmd(): programmer is out of sync\n",
|
||||
avrdude_message("%s: stk500_cmd(): programmer is out of sync\n",
|
||||
progname);
|
||||
return -1;
|
||||
} else if (buf[0] != Resp_STK_INSYNC) {
|
||||
fprintf(stderr,
|
||||
"\n%s: arduino_read_sig_bytes(): (a) protocol error, "
|
||||
"expect=0x%02x, resp=0x%02x\n",
|
||||
progname, Resp_STK_INSYNC, buf[0]);
|
||||
avrdude_message("\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) {
|
||||
fprintf(stderr,
|
||||
"\n%s: arduino_read_sig_bytes(): (a) protocol error, "
|
||||
"expect=0x%02x, resp=0x%02x\n",
|
||||
progname, Resp_STK_OK, buf[4]);
|
||||
avrdude_message("\n%s: arduino_read_sig_bytes(): (a) protocol error, "
|
||||
"expect=0x%02x, resp=0x%02x\n",
|
||||
progname, Resp_STK_OK, buf[4]);
|
||||
return -3;
|
||||
}
|
||||
|
||||
|
|
173
avr.c
173
avr.c
|
@ -65,7 +65,7 @@ int avr_tpi_chip_erase(PROGRAMMER * pgm, AVRPART * p)
|
|||
/* Set Pointer Register */
|
||||
mem = avr_locate_mem(p, "flash");
|
||||
if (mem == NULL) {
|
||||
fprintf(stderr, "No flash memory to erase for part %s\n",
|
||||
avrdude_message("No flash memory to erase for part %s\n",
|
||||
p->desc);
|
||||
return -1;
|
||||
}
|
||||
|
@ -97,7 +97,7 @@ int avr_tpi_chip_erase(PROGRAMMER * pgm, AVRPART * p)
|
|||
|
||||
return 0;
|
||||
} else {
|
||||
fprintf(stderr, "%s called for a part that has no TPI\n", __func__);
|
||||
avrdude_message("%s called for a part that has no TPI\n", __func__);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
@ -122,7 +122,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) {
|
||||
fprintf(stderr, "TPIIR not correct\n");
|
||||
avrdude_message("TPIIR not correct\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -142,12 +142,12 @@ int avr_tpi_program_enable(PROGRAMMER * pgm, AVRPART * p, unsigned char guard_ti
|
|||
return 0;
|
||||
}
|
||||
|
||||
fprintf(stderr, "Error enabling TPI external programming mode:");
|
||||
fprintf(stderr, "Target does not reply\n");
|
||||
avrdude_message("Error enabling TPI external programming mode:");
|
||||
avrdude_message("Target does not reply\n");
|
||||
return -1;
|
||||
|
||||
} else {
|
||||
fprintf(stderr, "%s called for a part that has no TPI\n", __func__);
|
||||
avrdude_message("%s called for a part that has no TPI\n", __func__);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
@ -192,10 +192,9 @@ int avr_read_byte_default(PROGRAMMER * pgm, AVRPART * p, AVRMEM * mem,
|
|||
OPCODE * readop, * lext;
|
||||
|
||||
if (pgm->cmd == NULL) {
|
||||
fprintf(stderr,
|
||||
"%s: Error: %s programmer uses avr_read_byte_default() but does not\n"
|
||||
"provide a cmd() method.\n",
|
||||
progname, pgm->type);
|
||||
avrdude_message("%s: Error: %s programmer uses avr_read_byte_default() but does not\n"
|
||||
"provide a cmd() method.\n",
|
||||
progname, pgm->type);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -204,7 +203,7 @@ int avr_read_byte_default(PROGRAMMER * pgm, AVRPART * p, AVRMEM * mem,
|
|||
|
||||
if (p->flags & AVRPART_HAS_TPI) {
|
||||
if (pgm->cmd_tpi == NULL) {
|
||||
fprintf(stderr, "%s: Error: %s programmer does not support TPI\n",
|
||||
avrdude_message("%s: Error: %s programmer does not support TPI\n",
|
||||
progname, pgm->type);
|
||||
return -1;
|
||||
}
|
||||
|
@ -239,9 +238,8 @@ int avr_read_byte_default(PROGRAMMER * pgm, AVRPART * p, AVRMEM * mem,
|
|||
|
||||
if (readop == NULL) {
|
||||
#if DEBUG
|
||||
fprintf(stderr,
|
||||
"avr_read_byte(): operation not supported on memory type \"%s\"\n",
|
||||
mem->desc);
|
||||
avrdude_message("avr_read_byte(): operation not supported on memory type \"%s\"\n",
|
||||
mem->desc);
|
||||
#endif
|
||||
return -1;
|
||||
}
|
||||
|
@ -325,7 +323,7 @@ int avr_read(PROGRAMMER * pgm, AVRPART * p, char * memtype,
|
|||
if (v != NULL)
|
||||
vmem = avr_locate_mem(v, memtype);
|
||||
if (mem == NULL) {
|
||||
fprintf(stderr, "No \"%s\" memory for part %s\n",
|
||||
avrdude_message("No \"%s\" memory for part %s\n",
|
||||
memtype, p->desc);
|
||||
return -1;
|
||||
}
|
||||
|
@ -358,7 +356,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) {
|
||||
fprintf(stderr, "avr_read(): error reading address 0x%04lx\n", i);
|
||||
avrdude_message("avr_read(): error reading address 0x%04lx\n", i);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
@ -415,9 +413,8 @@ int avr_read(PROGRAMMER * pgm, AVRPART * p, char * memtype,
|
|||
/* paged load failed, fall back to byte-at-a-time read below */
|
||||
failure = 1;
|
||||
} else if (verbose >= 3) {
|
||||
fprintf(stderr,
|
||||
"%s: avr_read(): skipping page %u: no interesting data\n",
|
||||
progname, pageaddr / mem->page_size);
|
||||
avrdude_message("%s: avr_read(): skipping page %u: no interesting data\n",
|
||||
progname, pageaddr / mem->page_size);
|
||||
}
|
||||
nread++;
|
||||
report_progress(nread, npages, NULL);
|
||||
|
@ -446,11 +443,10 @@ int avr_read(PROGRAMMER * pgm, AVRPART * p, char * memtype,
|
|||
{
|
||||
rc = pgm->read_byte(pgm, p, mem, i, mem->buf + i);
|
||||
if (rc != 0) {
|
||||
fprintf(stderr, "avr_read(): error reading address 0x%04lx\n", i);
|
||||
if (rc == -1)
|
||||
fprintf(stderr,
|
||||
" read operation not supported for memory \"%s\"\n",
|
||||
memtype);
|
||||
avrdude_message("avr_read(): error reading address 0x%04lx\n", i);
|
||||
if (rc == -1)
|
||||
avrdude_message(" read operation not supported for memory \"%s\"\n",
|
||||
memtype);
|
||||
return -2;
|
||||
}
|
||||
}
|
||||
|
@ -478,18 +474,16 @@ int avr_write_page(PROGRAMMER * pgm, AVRPART * p, AVRMEM * mem,
|
|||
OPCODE * wp, * lext;
|
||||
|
||||
if (pgm->cmd == NULL) {
|
||||
fprintf(stderr,
|
||||
"%s: Error: %s programmer uses avr_write_page() but does not\n"
|
||||
"provide a cmd() method.\n",
|
||||
progname, pgm->type);
|
||||
avrdude_message("%s: Error: %s programmer uses avr_write_page() but does not\n"
|
||||
"provide a cmd() method.\n",
|
||||
progname, pgm->type);
|
||||
return -1;
|
||||
}
|
||||
|
||||
wp = mem->op[AVR_OP_WRITEPAGE];
|
||||
if (wp == NULL) {
|
||||
fprintf(stderr,
|
||||
"avr_write_page(): memory \"%s\" not configured for page writes\n",
|
||||
mem->desc);
|
||||
avrdude_message("avr_write_page(): memory \"%s\" not configured for page writes\n",
|
||||
mem->desc);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -550,25 +544,24 @@ int avr_write_byte_default(PROGRAMMER * pgm, AVRPART * p, AVRMEM * mem,
|
|||
struct timeval tv;
|
||||
|
||||
if (pgm->cmd == NULL) {
|
||||
fprintf(stderr,
|
||||
"%s: Error: %s programmer uses avr_write_byte_default() but does not\n"
|
||||
"provide a cmd() method.\n",
|
||||
progname, pgm->type);
|
||||
avrdude_message("%s: Error: %s programmer uses avr_write_byte_default() but does not\n"
|
||||
"provide a cmd() method.\n",
|
||||
progname, pgm->type);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (p->flags & AVRPART_HAS_TPI) {
|
||||
if (pgm->cmd_tpi == NULL) {
|
||||
fprintf(stderr, "%s: Error: %s programmer does not support TPI\n",
|
||||
avrdude_message("%s: Error: %s programmer does not support TPI\n",
|
||||
progname, pgm->type);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (strcmp(mem->desc, "flash") == 0) {
|
||||
fprintf(stderr, "Writing a byte to flash is not supported for %s\n", p->desc);
|
||||
avrdude_message("Writing a byte to flash is not supported for %s\n", p->desc);
|
||||
return -1;
|
||||
} else if ((mem->offset + addr) & 1) {
|
||||
fprintf(stderr, "Writing a byte to an odd location is not supported for %s\n", p->desc);
|
||||
avrdude_message("Writing a byte to an odd location is not supported for %s\n", p->desc);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -656,9 +649,8 @@ int avr_write_byte_default(PROGRAMMER * pgm, AVRPART * p, AVRMEM * mem,
|
|||
|
||||
if (writeop == NULL) {
|
||||
#if DEBUG
|
||||
fprintf(stderr,
|
||||
"avr_write_byte(): write not supported for memory type \"%s\"\n",
|
||||
mem->desc);
|
||||
avrdude_message("avr_write_byte(): write not supported for memory type \"%s\"\n",
|
||||
mem->desc);
|
||||
#endif
|
||||
return -1;
|
||||
}
|
||||
|
@ -750,27 +742,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);
|
||||
fprintf(stderr,
|
||||
"%s: this device must be powered off and back on to continue\n",
|
||||
progname);
|
||||
avrdude_message("%s: this device must be powered off and back on to continue\n",
|
||||
progname);
|
||||
if (pgm->pinno[PPI_AVR_VCC]) {
|
||||
fprintf(stderr, "%s: attempting to do this now ...\n", progname);
|
||||
avrdude_message("%s: attempting to do this now ...\n", progname);
|
||||
pgm->powerdown(pgm);
|
||||
usleep(250000);
|
||||
rc = pgm->initialize(pgm, p);
|
||||
if (rc < 0) {
|
||||
fprintf(stderr, "%s: initialization failed, rc=%d\n", progname, rc);
|
||||
fprintf(stderr,
|
||||
"%s: can't re-initialize device after programming the "
|
||||
"%s bits\n", progname, mem->desc);
|
||||
fprintf(stderr,
|
||||
"%s: you must manually power-down the device and restart\n"
|
||||
"%s: %s to continue.\n",
|
||||
progname, progname, progname);
|
||||
avrdude_message("%s: initialization failed, rc=%d\n", progname, rc);
|
||||
avrdude_message("%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"
|
||||
"%s: %s to continue.\n",
|
||||
progname, progname, progname);
|
||||
return -3;
|
||||
}
|
||||
|
||||
fprintf(stderr, "%s: device was successfully re-initialized\n",
|
||||
avrdude_message("%s: device was successfully re-initialized\n",
|
||||
progname);
|
||||
return 0;
|
||||
}
|
||||
|
@ -852,7 +841,7 @@ int avr_write(PROGRAMMER * pgm, AVRPART * p, char * memtype, int size,
|
|||
|
||||
m = avr_locate_mem(p, memtype);
|
||||
if (m == NULL) {
|
||||
fprintf(stderr, "No \"%s\" memory for part %s\n",
|
||||
avrdude_message("No \"%s\" memory for part %s\n",
|
||||
memtype, p->desc);
|
||||
return -1;
|
||||
}
|
||||
|
@ -866,12 +855,11 @@ int avr_write(PROGRAMMER * pgm, AVRPART * p, char * memtype, int size,
|
|||
wsize = size;
|
||||
}
|
||||
else if (size > wsize) {
|
||||
fprintf(stderr,
|
||||
"%s: WARNING: %d bytes requested, but memory region is only %d"
|
||||
"bytes\n"
|
||||
"%sOnly %d bytes will actually be written\n",
|
||||
progname, size, wsize,
|
||||
progbuf, wsize);
|
||||
avrdude_message("%s: WARNING: %d bytes requested, but memory region is only %d"
|
||||
"bytes\n"
|
||||
"%sOnly %d bytes will actually be written\n",
|
||||
progname, size, wsize,
|
||||
progbuf, wsize);
|
||||
}
|
||||
|
||||
|
||||
|
@ -958,9 +946,8 @@ int avr_write(PROGRAMMER * pgm, AVRPART * p, char * memtype, int size,
|
|||
/* paged write failed, fall back to byte-at-a-time write below */
|
||||
failure = 1;
|
||||
} else if (verbose >= 3) {
|
||||
fprintf(stderr,
|
||||
"%s: avr_write(): skipping page %u: no interesting data\n",
|
||||
progname, pageaddr / m->page_size);
|
||||
avrdude_message("%s: avr_write(): skipping page %u: no interesting data\n",
|
||||
progname, pageaddr / m->page_size);
|
||||
}
|
||||
nwritten++;
|
||||
report_progress(nwritten, npages, NULL);
|
||||
|
@ -1019,8 +1006,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) {
|
||||
fprintf(stderr, " ***failed; ");
|
||||
fprintf(stderr, "\n");
|
||||
avrdude_message(" ***failed; ");
|
||||
avrdude_message("\n");
|
||||
pgm->err_led(pgm, ON);
|
||||
werror = 1;
|
||||
}
|
||||
|
@ -1033,19 +1020,18 @@ int avr_write(PROGRAMMER * pgm, AVRPART * p, char * memtype, int size,
|
|||
if (flush_page) {
|
||||
rc = avr_write_page(pgm, p, m, i);
|
||||
if (rc) {
|
||||
fprintf(stderr,
|
||||
" *** page %d (addresses 0x%04x - 0x%04x) failed "
|
||||
"to write\n",
|
||||
i % m->page_size,
|
||||
i - m->page_size + 1, i);
|
||||
fprintf(stderr, "\n");
|
||||
avrdude_message(" *** page %d (addresses 0x%04x - 0x%04x) failed "
|
||||
"to write\n",
|
||||
i % m->page_size,
|
||||
i - m->page_size + 1, i);
|
||||
avrdude_message("\n");
|
||||
pgm->err_led(pgm, ON);
|
||||
werror = 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (werror) {
|
||||
/*
|
||||
/*
|
||||
* make sure the error led stay on if there was a previous write
|
||||
* error, otherwise it gets cleared in avr_write_byte()
|
||||
*/
|
||||
|
@ -1068,9 +1054,8 @@ int avr_signature(PROGRAMMER * pgm, AVRPART * p)
|
|||
report_progress (0,1,"Reading");
|
||||
rc = avr_read(pgm, p, "signature", 0);
|
||||
if (rc < 0) {
|
||||
fprintf(stderr,
|
||||
"%s: error reading signature data for part \"%s\", rc=%d\n",
|
||||
progname, p->desc, rc);
|
||||
avrdude_message("%s: error reading signature data for part \"%s\", rc=%d\n",
|
||||
progname, p->desc, rc);
|
||||
return -1;
|
||||
}
|
||||
report_progress (1,1,NULL);
|
||||
|
@ -1095,17 +1080,15 @@ int avr_verify(AVRPART * p, AVRPART * v, char * memtype, int size)
|
|||
|
||||
a = avr_locate_mem(p, memtype);
|
||||
if (a == NULL) {
|
||||
fprintf(stderr,
|
||||
"avr_verify(): memory type \"%s\" not defined for part %s\n",
|
||||
memtype, p->desc);
|
||||
avrdude_message("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) {
|
||||
fprintf(stderr,
|
||||
"avr_verify(): memory type \"%s\" not defined for part %s\n",
|
||||
memtype, v->desc);
|
||||
avrdude_message("avr_verify(): memory type \"%s\" not defined for part %s\n",
|
||||
memtype, v->desc);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -1114,24 +1097,22 @@ int avr_verify(AVRPART * p, AVRPART * v, char * memtype, int size)
|
|||
vsize = a->size;
|
||||
|
||||
if (vsize < size) {
|
||||
fprintf(stderr,
|
||||
"%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,
|
||||
progbuf, memtype, vsize,
|
||||
progbuf, vsize);
|
||||
avrdude_message("%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,
|
||||
progbuf, memtype, vsize,
|
||||
progbuf, vsize);
|
||||
size = vsize;
|
||||
}
|
||||
|
||||
for (i=0; i<size; i++) {
|
||||
if ((b->tags[i] & TAG_ALLOCATED) != 0 &&
|
||||
buf1[i] != buf2[i]) {
|
||||
fprintf(stderr,
|
||||
"%s: verification error, first mismatch at byte 0x%04x\n"
|
||||
"%s0x%02x != 0x%02x\n",
|
||||
progname, i,
|
||||
progbuf, buf1[i], buf2[i]);
|
||||
avrdude_message("%s: verification error, first mismatch at byte 0x%04x\n"
|
||||
"%s0x%02x != 0x%02x\n",
|
||||
progname, i,
|
||||
progbuf, buf1[i], buf2[i]);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
@ -1156,7 +1137,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) {
|
||||
fprintf(stderr, "%s: WARNING: can't read memory for cycle count, rc=%d\n",
|
||||
avrdude_message("%s: WARNING: can't read memory for cycle count, rc=%d\n",
|
||||
progname, rc);
|
||||
return -1;
|
||||
}
|
||||
|
@ -1197,7 +1178,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) {
|
||||
fprintf(stderr, "%s: WARNING: can't write memory for cycle count, rc=%d\n",
|
||||
avrdude_message("%s: WARNING: can't write memory for cycle count, rc=%d\n",
|
||||
progname, rc);
|
||||
return -1;
|
||||
}
|
||||
|
|
65
avr910.c
65
avr910.c
|
@ -59,9 +59,8 @@ struct pdata
|
|||
static void avr910_setup(PROGRAMMER * pgm)
|
||||
{
|
||||
if ((pgm->cookie = malloc(sizeof(struct pdata))) == 0) {
|
||||
fprintf(stderr,
|
||||
"%s: avr910_setup(): Out of memory allocating private data\n",
|
||||
progname);
|
||||
avrdude_message("%s: avr910_setup(): Out of memory allocating private data\n",
|
||||
progname);
|
||||
exit(1);
|
||||
}
|
||||
memset(pgm->cookie, 0, sizeof(struct pdata));
|
||||
|
@ -86,9 +85,8 @@ static int avr910_recv(PROGRAMMER * pgm, char * buf, size_t len)
|
|||
|
||||
rv = serial_recv(&pgm->fd, (unsigned char *)buf, len);
|
||||
if (rv < 0) {
|
||||
fprintf(stderr,
|
||||
"%s: avr910_recv(): programmer is not responding\n",
|
||||
progname);
|
||||
avrdude_message("%s: avr910_recv(): programmer is not responding\n",
|
||||
progname);
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
|
@ -107,7 +105,7 @@ static int avr910_vfy_cmd_sent(PROGRAMMER * pgm, char * errmsg)
|
|||
|
||||
avr910_recv(pgm, &c, 1);
|
||||
if (c != '\r') {
|
||||
fprintf(stderr, "%s: error: programmer did not respond to command: %s\n",
|
||||
avrdude_message("%s: error: programmer did not respond to command: %s\n",
|
||||
progname, errmsg);
|
||||
return 1;
|
||||
}
|
||||
|
@ -189,16 +187,16 @@ static int avr910_initialize(PROGRAMMER * pgm, AVRPART * p)
|
|||
avr910_send(pgm, "p", 1);
|
||||
avr910_recv(pgm, &type, 1);
|
||||
|
||||
fprintf(stderr, "Found programmer: Id = \"%s\"; type = %c\n", id, type);
|
||||
fprintf(stderr, " Software Version = %c.%c; ", sw[0], sw[1]);
|
||||
fprintf(stderr, "Hardware Version = %c.%c\n", hw[0], hw[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]);
|
||||
|
||||
/* 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')
|
||||
fprintf(stderr, "Programmer supports auto addr increment.\n");
|
||||
avrdude_message("Programmer supports auto addr increment.\n");
|
||||
|
||||
/* Check support for buffered memory access, ignore if not available */
|
||||
|
||||
|
@ -210,10 +208,9 @@ 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;
|
||||
fprintf(stderr,
|
||||
"Programmer supports buffered memory access with "
|
||||
"buffersize = %u bytes.\n",
|
||||
PDATA(pgm)->buffersize);
|
||||
avrdude_message("Programmer supports buffered memory access with "
|
||||
"buffersize = %u bytes.\n",
|
||||
PDATA(pgm)->buffersize);
|
||||
PDATA(pgm)->use_blockmode = 1;
|
||||
} else {
|
||||
PDATA(pgm)->use_blockmode = 0;
|
||||
|
@ -229,7 +226,7 @@ static int avr910_initialize(PROGRAMMER * pgm, AVRPART * p)
|
|||
/* Get list of devices that the programmer supports. */
|
||||
|
||||
avr910_send(pgm, "t", 1);
|
||||
fprintf(stderr, "\nProgrammer supports the following devices:\n");
|
||||
avrdude_message("\nProgrammer supports the following devices:\n");
|
||||
devtype_1st = 0;
|
||||
while (1) {
|
||||
avr910_recv(pgm, &c, 1);
|
||||
|
@ -239,19 +236,18 @@ static int avr910_initialize(PROGRAMMER * pgm, AVRPART * p)
|
|||
break;
|
||||
part = locate_part_by_avr910_devcode(part_list, c);
|
||||
|
||||
fprintf(stderr, " Device code: 0x%02x = %s\n", c, part ? part->desc : "(unknown)");
|
||||
avrdude_message(" 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;
|
||||
};
|
||||
fprintf(stderr,"\n");
|
||||
avrdude_message("\n");
|
||||
|
||||
if (!dev_supported) {
|
||||
fprintf(stderr,
|
||||
"%s: %s: selected device is not supported by programmer: %s\n",
|
||||
progname, ovsigck? "warning": "error", p->id);
|
||||
avrdude_message("%s: %s: selected device is not supported by programmer: %s\n",
|
||||
progname, ovsigck? "warning": "error", p->id);
|
||||
if (!ovsigck)
|
||||
return -1;
|
||||
}
|
||||
|
@ -271,9 +267,8 @@ static int avr910_initialize(PROGRAMMER * pgm, AVRPART * p)
|
|||
avr910_vfy_cmd_sent(pgm, "select device");
|
||||
|
||||
if (verbose)
|
||||
fprintf(stderr,
|
||||
"%s: avr910_devcode selected: 0x%02x\n",
|
||||
progname, (unsigned)buf[1]);
|
||||
avrdude_message("%s: avr910_devcode selected: 0x%02x\n",
|
||||
progname, (unsigned)buf[1]);
|
||||
|
||||
avr910_enter_prog_mode(pgm);
|
||||
|
||||
|
@ -339,16 +334,14 @@ static int avr910_parseextparms(PROGRAMMER * pgm, LISTID extparms)
|
|||
int devcode;
|
||||
if (sscanf(extended_param, "devcode=%i", &devcode) != 1 ||
|
||||
devcode <= 0 || devcode > 255) {
|
||||
fprintf(stderr,
|
||||
"%s: avr910_parseextparms(): invalid devcode '%s'\n",
|
||||
progname, extended_param);
|
||||
avrdude_message("%s: avr910_parseextparms(): invalid devcode '%s'\n",
|
||||
progname, extended_param);
|
||||
rv = -1;
|
||||
continue;
|
||||
}
|
||||
if (verbose >= 2) {
|
||||
fprintf(stderr,
|
||||
"%s: avr910_parseextparms(): devcode overwritten as 0x%02x\n",
|
||||
progname, devcode);
|
||||
avrdude_message("%s: avr910_parseextparms(): devcode overwritten as 0x%02x\n",
|
||||
progname, devcode);
|
||||
}
|
||||
PDATA(pgm)->devcode = devcode;
|
||||
|
||||
|
@ -356,18 +349,16 @@ static int avr910_parseextparms(PROGRAMMER * pgm, LISTID extparms)
|
|||
}
|
||||
if (strncmp(extended_param, "no_blockmode", strlen("no_blockmode")) == 0) {
|
||||
if (verbose >= 2) {
|
||||
fprintf(stderr,
|
||||
"%s: avr910_parseextparms(-x): no testing for Blockmode\n",
|
||||
progname);
|
||||
avrdude_message("%s: avr910_parseextparms(-x): no testing for Blockmode\n",
|
||||
progname);
|
||||
}
|
||||
PDATA(pgm)->test_blockmode = 0;
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
fprintf(stderr,
|
||||
"%s: avr910_parseextparms(): invalid extended parameter '%s'\n",
|
||||
progname, extended_param);
|
||||
avrdude_message("%s: avr910_parseextparms(): invalid extended parameter '%s'\n",
|
||||
progname, extended_param);
|
||||
rv = -1;
|
||||
}
|
||||
|
||||
|
@ -739,7 +730,7 @@ static int avr910_read_sig_bytes(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m)
|
|||
unsigned char tmp;
|
||||
|
||||
if (m->size < 3) {
|
||||
fprintf(stderr, "%s: memsize too small for sig byte read", progname);
|
||||
avrdude_message("%s: memsize too small for sig byte read", progname);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
|
|
@ -28,6 +28,8 @@ 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, ...);
|
||||
|
||||
#if defined(WIN32NATIVE)
|
||||
|
||||
#include "ac_cfg.h"
|
||||
|
|
40
avrftdi.c
40
avrftdi.c
|
@ -54,9 +54,8 @@
|
|||
|
||||
static int avrftdi_noftdi_open (struct programmer_t *pgm, char * name)
|
||||
{
|
||||
fprintf(stderr,
|
||||
"%s: Error: no libftdi or libusb support. Install libftdi1/libusb-1.0 or libftdi/libusb and run configure/make again.\n",
|
||||
progname);
|
||||
avrdude_message("%s: Error: no libftdi or libusb support. Install libftdi1/libusb-1.0 or libftdi/libusb and run configure/make again.\n",
|
||||
progname);
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
@ -145,17 +144,17 @@ void avrftdi_log(int level, const char * func, int line,
|
|||
if(!skip_prefix)
|
||||
{
|
||||
switch(level) {
|
||||
case ERR: fprintf(stderr, "E "); break;
|
||||
case WARN: fprintf(stderr, "W "); break;
|
||||
case INFO: fprintf(stderr, "I "); break;
|
||||
case DEBUG: fprintf(stderr, "D "); break;
|
||||
case TRACE: fprintf(stderr, "T "); break;
|
||||
default: fprintf(stderr, " ");
|
||||
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(" ");
|
||||
}
|
||||
fprintf(stderr, "%s(%d): ", func, line);
|
||||
avrdude_message("%s(%d): ", func, line);
|
||||
}
|
||||
va_start(ap, fmt);
|
||||
vfprintf(stderr, fmt, ap);
|
||||
vavrdude_message(fmt, ap);
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
|
@ -175,16 +174,16 @@ static void buf_dump(const unsigned char *buf, int len, char *desc,
|
|||
int offset, int width)
|
||||
{
|
||||
int i;
|
||||
fprintf(stderr, "%s begin:\n", desc);
|
||||
avrdude_message("%s begin:\n", desc);
|
||||
for (i = 0; i < offset; i++)
|
||||
fprintf(stderr, "%02x ", buf[i]);
|
||||
fprintf(stderr, "\n");
|
||||
avrdude_message("%02x ", buf[i]);
|
||||
avrdude_message("\n");
|
||||
for (i++; i <= len; i++) {
|
||||
fprintf(stderr, "%02x ", buf[i-1]);
|
||||
avrdude_message("%02x ", buf[i-1]);
|
||||
if((i-offset) != 0 && (i-offset)%width == 0)
|
||||
fprintf(stderr, "\n");
|
||||
avrdude_message("\n");
|
||||
}
|
||||
fprintf(stderr, "%s end\n", desc);
|
||||
avrdude_message("%s end\n", desc);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -357,7 +356,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)));
|
||||
//fprintf(stderr,"blocksize %d \n",blocksize);
|
||||
//avrdude_message("blocksize %d \n",blocksize);
|
||||
|
||||
while(remaining)
|
||||
{
|
||||
|
@ -673,9 +672,8 @@ static int avrftdi_open(PROGRAMMER * pgm, char *port)
|
|||
if (usbpid) {
|
||||
pid = *(int *)(ldata(usbpid));
|
||||
if (lnext(usbpid))
|
||||
fprintf(stderr,
|
||||
"%s: Warning: using PID 0x%04x, ignoring remaining PIDs in list\n",
|
||||
progname, pid);
|
||||
avrdude_message("%s: Warning: using PID 0x%04x, ignoring remaining PIDs in list\n",
|
||||
progname, pid);
|
||||
} else
|
||||
pid = USB_DEVICE_FT2232;
|
||||
|
||||
|
|
|
@ -43,7 +43,7 @@ enum { ERR, WARN, INFO, DEBUG, TRACE };
|
|||
do { \
|
||||
if ((x)) \
|
||||
{ \
|
||||
fprintf(stderr, "%s:%d %s() %s: %s (%d)\n\t%s\n", \
|
||||
avrdude_message("%s:%d %s() %s: %s (%d)\n\t%s\n", \
|
||||
__FILE__, __LINE__, __FUNCTION__, \
|
||||
#x, strerror(errno), errno, ftdi_get_error_string(ftdi)); \
|
||||
return -1; \
|
||||
|
@ -54,7 +54,7 @@ enum { ERR, WARN, INFO, DEBUG, TRACE };
|
|||
do { \
|
||||
if ((x)) \
|
||||
{ \
|
||||
fprintf(stderr, "%s:%d %s() %s: %s (%d)\n\t%s\n", \
|
||||
avrdude_message("%s:%d %s() %s: %s (%d)\n\t%s\n", \
|
||||
__FILE__, __LINE__, __FUNCTION__, \
|
||||
#x, strerror(errno), errno, ftdi_get_error_string(ftdi)); \
|
||||
} \
|
||||
|
|
31
avrpart.c
31
avrpart.c
|
@ -37,7 +37,7 @@ OPCODE * avr_new_opcode(void)
|
|||
|
||||
m = (OPCODE *)malloc(sizeof(*m));
|
||||
if (m == NULL) {
|
||||
fprintf(stderr, "avr_new_opcode(): out of memory\n");
|
||||
avrdude_message("avr_new_opcode(): out of memory\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
@ -57,7 +57,7 @@ static OPCODE * avr_dup_opcode(OPCODE * op)
|
|||
|
||||
m = (OPCODE *)malloc(sizeof(*m));
|
||||
if (m == NULL) {
|
||||
fprintf(stderr, "avr_dup_opcode(): out of memory\n");
|
||||
avrdude_message("avr_dup_opcode(): out of memory\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
@ -250,7 +250,7 @@ AVRMEM * avr_new_memtype(void)
|
|||
|
||||
m = (AVRMEM *)malloc(sizeof(*m));
|
||||
if (m == NULL) {
|
||||
fprintf(stderr, "avr_new_memtype(): out of memory\n");
|
||||
avrdude_message("avr_new_memtype(): out of memory\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
@ -273,13 +273,13 @@ int avr_initmem(AVRPART * p)
|
|||
m = ldata(ln);
|
||||
m->buf = (unsigned char *) malloc(m->size);
|
||||
if (m->buf == NULL) {
|
||||
fprintf(stderr, "%s: can't alloc buffer for %s size of %d bytes\n",
|
||||
avrdude_message("%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) {
|
||||
fprintf(stderr, "%s: can't alloc buffer for %s size of %d bytes\n",
|
||||
avrdude_message("%s: can't alloc buffer for %s size of %d bytes\n",
|
||||
progname, m->desc, m->size);
|
||||
return -1;
|
||||
}
|
||||
|
@ -301,9 +301,8 @@ AVRMEM * avr_dup_mem(AVRMEM * m)
|
|||
if (m->buf != NULL) {
|
||||
n->buf = (unsigned char *)malloc(n->size);
|
||||
if (n->buf == NULL) {
|
||||
fprintf(stderr,
|
||||
"avr_dup_mem(): out of memory (memsize=%d)\n",
|
||||
n->size);
|
||||
avrdude_message("avr_dup_mem(): out of memory (memsize=%d)\n",
|
||||
n->size);
|
||||
exit(1);
|
||||
}
|
||||
memcpy(n->buf, m->buf, n->size);
|
||||
|
@ -312,9 +311,8 @@ AVRMEM * avr_dup_mem(AVRMEM * m)
|
|||
if (m->tags != NULL) {
|
||||
n->tags = (unsigned char *)malloc(n->size);
|
||||
if (n->tags == NULL) {
|
||||
fprintf(stderr,
|
||||
"avr_dup_mem(): out of memory (memsize=%d)\n",
|
||||
n->size);
|
||||
avrdude_message("avr_dup_mem(): out of memory (memsize=%d)\n",
|
||||
n->size);
|
||||
exit(1);
|
||||
}
|
||||
memcpy(n->tags, m->tags, n->size);
|
||||
|
@ -407,11 +405,10 @@ void avr_mem_display(const char * prefix, FILE * f, AVRMEM * m, int type,
|
|||
m->readback[0],
|
||||
m->readback[1]);
|
||||
if (verbose > 4) {
|
||||
fprintf(stderr,
|
||||
"%s Memory Ops:\n"
|
||||
"%s Oeration Inst Bit Bit Type Bitno Value\n"
|
||||
"%s ----------- -------- -------- ----- -----\n",
|
||||
prefix, prefix, prefix);
|
||||
avrdude_message("%s Memory Ops:\n"
|
||||
"%s Oeration Inst Bit Bit Type Bitno Value\n"
|
||||
"%s ----------- -------- -------- ----- -----\n",
|
||||
prefix, prefix, prefix);
|
||||
for (i=0; i<AVR_OP_MAX; i++) {
|
||||
if (m->op[i]) {
|
||||
for (j=31; j>=0; j--) {
|
||||
|
@ -445,7 +442,7 @@ AVRPART * avr_new_part(void)
|
|||
|
||||
p = (AVRPART *)malloc(sizeof(AVRPART));
|
||||
if (p == NULL) {
|
||||
fprintf(stderr, "new_part(): out of memory\n");
|
||||
avrdude_message("new_part(): out of memory\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
|
80
bitbang.c
80
bitbang.c
|
@ -75,9 +75,8 @@ static void bitbang_calibrate_delay(void)
|
|||
{
|
||||
has_perfcount = 1;
|
||||
if (verbose >= 2)
|
||||
fprintf(stderr,
|
||||
"%s: Using performance counter for bitbang delays\n",
|
||||
progname);
|
||||
avrdude_message("%s: Using performance counter for bitbang delays\n",
|
||||
progname);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -91,9 +90,8 @@ static void bitbang_calibrate_delay(void)
|
|||
* comparable hardware.
|
||||
*/
|
||||
if (verbose >= 2)
|
||||
fprintf(stderr,
|
||||
"%s: Using guessed per-microsecond delay count for bitbang delays\n",
|
||||
progname);
|
||||
avrdude_message("%s: Using guessed per-microsecond delay count for bitbang delays\n",
|
||||
progname);
|
||||
delay_decrement = 100;
|
||||
}
|
||||
#else /* !WIN32NATIVE */
|
||||
|
@ -101,9 +99,8 @@ static void bitbang_calibrate_delay(void)
|
|||
volatile int i;
|
||||
|
||||
if (verbose >= 2)
|
||||
fprintf(stderr,
|
||||
"%s: Calibrating delay loop...",
|
||||
progname);
|
||||
avrdude_message("%s: Calibrating delay loop...",
|
||||
progname);
|
||||
i = 0;
|
||||
done = 0;
|
||||
saved_alarmhandler = signal(SIGALRM, alarmhandler);
|
||||
|
@ -130,9 +127,8 @@ static void bitbang_calibrate_delay(void)
|
|||
*/
|
||||
delay_decrement = -i / 100000;
|
||||
if (verbose >= 2)
|
||||
fprintf(stderr,
|
||||
" calibrated to %d cycles per us\n",
|
||||
delay_decrement);
|
||||
avrdude_message(" calibrated to %d cycles per us\n",
|
||||
delay_decrement);
|
||||
#endif /* WIN32NATIVE */
|
||||
}
|
||||
|
||||
|
@ -271,7 +267,7 @@ int bitbang_tpi_rx(PROGRAMMER * pgm)
|
|||
break;
|
||||
}
|
||||
if (b != 0) {
|
||||
fprintf(stderr, "bitbang_tpi_rx: start bit not received correctly\n");
|
||||
avrdude_message("bitbang_tpi_rx: start bit not received correctly\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -286,7 +282,7 @@ int bitbang_tpi_rx(PROGRAMMER * pgm)
|
|||
|
||||
/* parity bit */
|
||||
if (bitbang_tpi_clk(pgm) != parity) {
|
||||
fprintf(stderr, "bitbang_tpi_rx: parity bit is wrong\n");
|
||||
avrdude_message("bitbang_tpi_rx: parity bit is wrong\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -295,7 +291,7 @@ int bitbang_tpi_rx(PROGRAMMER * pgm)
|
|||
b &= bitbang_tpi_clk(pgm);
|
||||
b &= bitbang_tpi_clk(pgm);
|
||||
if (b != 1) {
|
||||
fprintf(stderr, "bitbang_tpi_rx: stop bits not received correctly\n");
|
||||
avrdude_message("bitbang_tpi_rx: stop bits not received correctly\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -342,15 +338,15 @@ int bitbang_cmd(PROGRAMMER * pgm, const unsigned char *cmd,
|
|||
|
||||
if(verbose >= 2)
|
||||
{
|
||||
fprintf(stderr, "bitbang_cmd(): [ ");
|
||||
avrdude_message("bitbang_cmd(): [ ");
|
||||
for(i = 0; i < 4; i++)
|
||||
fprintf(stderr, "%02X ", cmd[i]);
|
||||
fprintf(stderr, "] [ ");
|
||||
avrdude_message("%02X ", cmd[i]);
|
||||
avrdude_message("] [ ");
|
||||
for(i = 0; i < 4; i++)
|
||||
{
|
||||
fprintf(stderr, "%02X ", res[i]);
|
||||
avrdude_message("%02X ", res[i]);
|
||||
}
|
||||
fprintf(stderr, "]\n");
|
||||
avrdude_message("]\n");
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -377,15 +373,15 @@ int bitbang_cmd_tpi(PROGRAMMER * pgm, const unsigned char *cmd,
|
|||
|
||||
if(verbose >= 2)
|
||||
{
|
||||
fprintf(stderr, "bitbang_cmd_tpi(): [ ");
|
||||
avrdude_message("bitbang_cmd_tpi(): [ ");
|
||||
for(i = 0; i < cmd_len; i++)
|
||||
fprintf(stderr, "%02X ", cmd[i]);
|
||||
fprintf(stderr, "] [ ");
|
||||
avrdude_message("%02X ", cmd[i]);
|
||||
avrdude_message("] [ ");
|
||||
for(i = 0; i < res_len; i++)
|
||||
{
|
||||
fprintf(stderr, "%02X ", res[i]);
|
||||
avrdude_message("%02X ", res[i]);
|
||||
}
|
||||
fprintf(stderr, "]\n");
|
||||
avrdude_message("]\n");
|
||||
}
|
||||
|
||||
pgm->pgm_led(pgm, OFF);
|
||||
|
@ -413,15 +409,15 @@ int bitbang_spi(PROGRAMMER * pgm, const unsigned char *cmd,
|
|||
|
||||
if(verbose >= 2)
|
||||
{
|
||||
fprintf(stderr, "bitbang_cmd(): [ ");
|
||||
avrdude_message("bitbang_cmd(): [ ");
|
||||
for(i = 0; i < count; i++)
|
||||
fprintf(stderr, "%02X ", cmd[i]);
|
||||
fprintf(stderr, "] [ ");
|
||||
avrdude_message("%02X ", cmd[i]);
|
||||
avrdude_message("] [ ");
|
||||
for(i = 0; i < count; i++)
|
||||
{
|
||||
fprintf(stderr, "%02X ", res[i]);
|
||||
avrdude_message("%02X ", res[i]);
|
||||
}
|
||||
fprintf(stderr, "]\n");
|
||||
avrdude_message("]\n");
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -449,7 +445,7 @@ int bitbang_chip_erase(PROGRAMMER * pgm, AVRPART * p)
|
|||
/* Set Pointer Register */
|
||||
mem = avr_locate_mem(p, "flash");
|
||||
if (mem == NULL) {
|
||||
fprintf(stderr, "No flash memory to erase for part %s\n",
|
||||
avrdude_message("No flash memory to erase for part %s\n",
|
||||
p->desc);
|
||||
return -1;
|
||||
}
|
||||
|
@ -470,7 +466,7 @@ int bitbang_chip_erase(PROGRAMMER * pgm, AVRPART * p)
|
|||
}
|
||||
|
||||
if (p->op[AVR_OP_CHIP_ERASE] == NULL) {
|
||||
fprintf(stderr, "chip erase instruction not defined for part \"%s\"\n",
|
||||
avrdude_message("chip erase instruction not defined for part \"%s\"\n",
|
||||
p->desc);
|
||||
return -1;
|
||||
}
|
||||
|
@ -511,7 +507,7 @@ int bitbang_program_enable(PROGRAMMER * pgm, AVRPART * p)
|
|||
}
|
||||
|
||||
if (p->op[AVR_OP_PGM_ENABLE] == NULL) {
|
||||
fprintf(stderr, "program enable instruction not defined for part \"%s\"\n",
|
||||
avrdude_message("program enable instruction not defined for part \"%s\"\n",
|
||||
p->desc);
|
||||
return -1;
|
||||
}
|
||||
|
@ -544,7 +540,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) {
|
||||
fprintf(stderr, "%s: Error: %s programmer does not support TPI\n",
|
||||
avrdude_message("%s: Error: %s programmer does not support TPI\n",
|
||||
progname, pgm->type);
|
||||
return -1;
|
||||
}
|
||||
|
@ -554,21 +550,21 @@ int bitbang_initialize(PROGRAMMER * pgm, AVRPART * p)
|
|||
usleep(1000);
|
||||
|
||||
if (verbose >= 2)
|
||||
fprintf(stderr, "doing MOSI-MISO link check\n");
|
||||
avrdude_message("doing MOSI-MISO link check\n");
|
||||
|
||||
pgm->setpin(pgm, PIN_AVR_MOSI, 0);
|
||||
if (pgm->getpin(pgm, PIN_AVR_MISO) != 0) {
|
||||
fprintf(stderr, "MOSI->MISO 0 failed\n");
|
||||
avrdude_message("MOSI->MISO 0 failed\n");
|
||||
return -1;
|
||||
}
|
||||
pgm->setpin(pgm, PIN_AVR_MOSI, 1);
|
||||
if (pgm->getpin(pgm, PIN_AVR_MISO) != 1) {
|
||||
fprintf(stderr, "MOSI->MISO 1 failed\n");
|
||||
avrdude_message("MOSI->MISO 1 failed\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (verbose >= 2)
|
||||
fprintf(stderr, "MOSI-MISO link present\n");
|
||||
avrdude_message("MOSI-MISO link present\n");
|
||||
}
|
||||
|
||||
pgm->setpin(pgm, PIN_AVR_SCK, 0);
|
||||
|
@ -589,7 +585,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) {
|
||||
fprintf(stderr, "TPIIR not correct\n");
|
||||
avrdude_message("TPIIR not correct\n");
|
||||
return -1;
|
||||
}
|
||||
} else {
|
||||
|
@ -623,7 +619,7 @@ int bitbang_initialize(PROGRAMMER * pgm, AVRPART * p)
|
|||
* can't sync with the device, maybe it's not attached?
|
||||
*/
|
||||
if (rc) {
|
||||
fprintf(stderr, "%s: AVR device not responding\n", progname);
|
||||
avrdude_message("%s: AVR device not responding\n", progname);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
@ -634,7 +630,7 @@ int bitbang_initialize(PROGRAMMER * pgm, AVRPART * p)
|
|||
static int verify_pin_assigned(PROGRAMMER * pgm, int pin, char * desc)
|
||||
{
|
||||
if (pgm->pinno[pin] == 0) {
|
||||
fprintf(stderr, "%s: error: no pin has been assigned for %s\n",
|
||||
avrdude_message("%s: error: no pin has been assigned for %s\n",
|
||||
progname, desc);
|
||||
return -1;
|
||||
}
|
||||
|
@ -658,7 +654,7 @@ int bitbang_check_prerequisites(PROGRAMMER *pgm)
|
|||
return -1;
|
||||
|
||||
if (pgm->cmd == NULL) {
|
||||
fprintf(stderr, "%s: error: no cmd() method defined for bitbang programmer\n",
|
||||
avrdude_message("%s: error: no cmd() method defined for bitbang programmer\n",
|
||||
progname);
|
||||
return -1;
|
||||
}
|
||||
|
|
150
buspirate.c
150
buspirate.c
|
@ -98,15 +98,15 @@ static void dump_mem(char *buf, size_t len)
|
|||
|
||||
for (i = 0; i<len; i++) {
|
||||
if (i % 8 == 0)
|
||||
fprintf(stderr, "\t");
|
||||
fprintf(stderr, "0x%02x ", (unsigned)buf[i] & 0xFF);
|
||||
avrdude_message("\t");
|
||||
avrdude_message("0x%02x ", (unsigned)buf[i] & 0xFF);
|
||||
if (i % 8 == 3)
|
||||
fprintf(stderr, " ");
|
||||
avrdude_message(" ");
|
||||
else if (i % 8 == 7)
|
||||
fprintf(stderr, "\n");
|
||||
avrdude_message("\n");
|
||||
}
|
||||
if (i % 8 != 7)
|
||||
fprintf(stderr, "\n");
|
||||
avrdude_message("\n");
|
||||
}
|
||||
|
||||
static int buspirate_send_bin(struct programmer_t *pgm, char *data, size_t len)
|
||||
|
@ -114,7 +114,7 @@ static int buspirate_send_bin(struct programmer_t *pgm, char *data, size_t len)
|
|||
int rc;
|
||||
|
||||
if (verbose > 1) {
|
||||
fprintf(stderr, "%s: buspirate_send_bin():\n", progname);
|
||||
avrdude_message("%s: buspirate_send_bin():\n", progname);
|
||||
dump_mem(data, len);
|
||||
}
|
||||
|
||||
|
@ -131,7 +131,7 @@ static int buspirate_recv_bin(struct programmer_t *pgm, char *buf, size_t len)
|
|||
if (rc < 0)
|
||||
return EOF;
|
||||
if (verbose > 1) {
|
||||
fprintf(stderr, "%s: buspirate_recv_bin():\n", progname);
|
||||
avrdude_message("%s: buspirate_recv_bin():\n", progname);
|
||||
dump_mem(buf, len);
|
||||
}
|
||||
|
||||
|
@ -144,7 +144,7 @@ static int buspirate_expect_bin(struct programmer_t *pgm,
|
|||
{
|
||||
char *recv_buf = alloca(expect_len);
|
||||
if (!pgm->flag & BP_FLAG_IN_BINMODE) {
|
||||
fprintf(stderr, "BusPirate: Internal error: buspirate_send_bin() called from ascii mode");
|
||||
avrdude_message("BusPirate: Internal error: buspirate_send_bin() called from ascii mode");
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -169,7 +169,7 @@ static int buspirate_getc(struct programmer_t *pgm)
|
|||
unsigned char ch = 0;
|
||||
|
||||
if (pgm->flag & BP_FLAG_IN_BINMODE) {
|
||||
fprintf(stderr, "BusPirate: Internal error: buspirate_getc() called from binmode");
|
||||
avrdude_message("BusPirate: Internal error: buspirate_getc() called from binmode");
|
||||
return EOF;
|
||||
}
|
||||
|
||||
|
@ -208,7 +208,7 @@ static char *buspirate_readline_noexit(struct programmer_t *pgm, char *buf, size
|
|||
}
|
||||
serial_recv_timeout = orig_serial_recv_timeout;
|
||||
if (verbose)
|
||||
fprintf(stderr, "%s: buspirate_readline(): %s%s",
|
||||
avrdude_message("%s: buspirate_readline(): %s%s",
|
||||
progname, buf,
|
||||
buf[strlen(buf) - 1] == '\n' ? "" : "\n");
|
||||
if (! buf[0])
|
||||
|
@ -223,9 +223,8 @@ static char *buspirate_readline(struct programmer_t *pgm, char *buf, size_t len)
|
|||
|
||||
ret = buspirate_readline_noexit(pgm, buf, len);
|
||||
if (! ret) {
|
||||
fprintf(stderr,
|
||||
"%s: buspirate_readline(): programmer is not responding\n",
|
||||
progname);
|
||||
avrdude_message("%s: buspirate_readline(): programmer is not responding\n",
|
||||
progname);
|
||||
return NULL;
|
||||
}
|
||||
return ret;
|
||||
|
@ -235,10 +234,10 @@ static int buspirate_send(struct programmer_t *pgm, char *str)
|
|||
int rc;
|
||||
|
||||
if (verbose)
|
||||
fprintf(stderr, "%s: buspirate_send(): %s", progname, str);
|
||||
avrdude_message("%s: buspirate_send(): %s", progname, str);
|
||||
|
||||
if (pgm->flag & BP_FLAG_IN_BINMODE) {
|
||||
fprintf(stderr, "BusPirate: Internal error: buspirate_send() called from binmode");
|
||||
avrdude_message("BusPirate: Internal error: buspirate_send() called from binmode");
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -311,8 +310,8 @@ buspirate_parseextparms(struct programmer_t *pgm, LISTID extparms)
|
|||
}
|
||||
if (sscanf(extended_param, "spifreq=%d", &spifreq) == 1) {
|
||||
if (spifreq & (~0x07)) {
|
||||
fprintf(stderr, "BusPirate: spifreq must be between 0 and 7.\n");
|
||||
fprintf(stderr, "BusPirate: see BusPirate manual for details.\n");
|
||||
avrdude_message("BusPirate: spifreq must be between 0 and 7.\n");
|
||||
avrdude_message("BusPirate: see BusPirate manual for details.\n");
|
||||
return -1;
|
||||
}
|
||||
pgm->flag = (pgm->flag & ~BP_FLAG_XPARM_RAWFREQ) |
|
||||
|
@ -324,7 +323,7 @@ buspirate_parseextparms(struct programmer_t *pgm, LISTID extparms)
|
|||
unsigned rawfreq;
|
||||
if (sscanf(extended_param, "rawfreq=%u", &rawfreq) == 1) {
|
||||
if (rawfreq >= 4) {
|
||||
fprintf(stderr, "BusPirate: rawfreq must be "
|
||||
avrdude_message("BusPirate: rawfreq must be "
|
||||
"between 0 and 3.\n");
|
||||
return -1;
|
||||
}
|
||||
|
@ -337,8 +336,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) {
|
||||
fprintf(stderr, "BusPirate: cpufreq must be between 125 and 4000 kHz.\n");
|
||||
fprintf(stderr, "BusPirate: see BusPirate manual for details.\n");
|
||||
avrdude_message("BusPirate: cpufreq must be between 125 and 4000 kHz.\n");
|
||||
avrdude_message("BusPirate: see BusPirate manual for details.\n");
|
||||
return -1;
|
||||
}
|
||||
PDATA(pgm)->cpufreq = cpufreq;
|
||||
|
@ -357,7 +356,7 @@ buspirate_parseextparms(struct programmer_t *pgm, LISTID extparms)
|
|||
else if (strcasecmp(resetpin, "aux2") == 0)
|
||||
PDATA(pgm)->reset |= BP_RESET_AUX2;
|
||||
else {
|
||||
fprintf(stderr, "BusPirate: reset must be either CS or AUX.\n");
|
||||
avrdude_message("BusPirate: reset must be either CS or AUX.\n");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
@ -376,7 +375,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) {
|
||||
fprintf(stderr, "BusPirate: serial_recv_timeout must be greater 0.\n");
|
||||
avrdude_message("BusPirate: serial_recv_timeout must be greater 0.\n");
|
||||
return -1;
|
||||
}
|
||||
PDATA(pgm)->serial_recv_timeout = serial_recv_timeout;
|
||||
|
@ -395,18 +394,18 @@ buspirate_verifyconfig(struct programmer_t *pgm)
|
|||
PDATA(pgm)->reset |= BP_RESET_CS;
|
||||
|
||||
if ((PDATA(pgm)->reset != BP_RESET_CS) && buspirate_uses_ascii(pgm)) {
|
||||
fprintf(stderr, "BusPirate: RESET pin other than CS is not supported in ASCII mode\n");
|
||||
avrdude_message("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)) {
|
||||
fprintf(stderr, "BusPirate: SPI speed selection is not supported in ASCII mode\n");
|
||||
avrdude_message("BusPirate: SPI speed selection is not supported in ASCII mode\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if ((pgm->flag & BP_FLAG_XPARM_CPUFREQ) && !buspirate_uses_ascii(pgm)) {
|
||||
fprintf(stderr, "BusPirate: Setting cpufreq is only supported in ASCII mode\n");
|
||||
avrdude_message("BusPirate: Setting cpufreq is only supported in ASCII mode\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -465,12 +464,12 @@ static void buspirate_reset_from_binmode(struct programmer_t *pgm)
|
|||
}
|
||||
|
||||
if (pgm->flag & BP_FLAG_IN_BINMODE) {
|
||||
fprintf(stderr, "BusPirate reset failed. You may need to powercycle it.\n");
|
||||
avrdude_message("BusPirate reset failed. You may need to powercycle it.\n");
|
||||
return;
|
||||
}
|
||||
|
||||
if (verbose)
|
||||
fprintf(stderr, "BusPirate is back in the text mode\n");
|
||||
avrdude_message("BusPirate is back in the text mode\n");
|
||||
}
|
||||
|
||||
static int buspirate_start_mode_bin(struct programmer_t *pgm)
|
||||
|
@ -515,12 +514,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) {
|
||||
fprintf(stderr, "Binary mode not confirmed: '%s'\n", buf);
|
||||
avrdude_message("Binary mode not confirmed: '%s'\n", buf);
|
||||
buspirate_reset_from_binmode(pgm);
|
||||
return -1;
|
||||
}
|
||||
if (verbose)
|
||||
fprintf(stderr, "BusPirate binmode version: %d\n",
|
||||
avrdude_message("BusPirate binmode version: %d\n",
|
||||
PDATA(pgm)->binmode_version);
|
||||
|
||||
pgm->flag |= BP_FLAG_IN_BINMODE;
|
||||
|
@ -532,18 +531,18 @@ 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) {
|
||||
fprintf(stderr, "%s mode not confirmed: '%s'\n",
|
||||
avrdude_message("%s mode not confirmed: '%s'\n",
|
||||
submode->name, buf);
|
||||
buspirate_reset_from_binmode(pgm);
|
||||
return -1;
|
||||
}
|
||||
if (verbose)
|
||||
fprintf(stderr, "BusPirate %s version: %d\n",
|
||||
avrdude_message("BusPirate %s version: %d\n",
|
||||
submode->name, PDATA(pgm)->submode_version);
|
||||
|
||||
if (pgm->flag & BP_FLAG_NOPAGEDWRITE) {
|
||||
if (verbose)
|
||||
fprintf(stderr, "%s: Paged flash write disabled.\n", progname);
|
||||
avrdude_message("%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: */
|
||||
|
@ -561,13 +560,13 @@ static int buspirate_start_mode_bin(struct programmer_t *pgm)
|
|||
buspirate_send_bin(pgm, buf, 1);
|
||||
|
||||
if (verbose)
|
||||
fprintf(stderr, "%s: Disabling paged flash write. (Need BusPirate firmware >=v5.10.)\n", progname);
|
||||
avrdude_message("%s: Disabling paged flash write. (Need BusPirate firmware >=v5.10.)\n", progname);
|
||||
|
||||
/* Flush serial buffer: */
|
||||
serial_drain(&pgm->fd, 0);
|
||||
} else {
|
||||
if (verbose)
|
||||
fprintf(stderr, "%s: Paged flash write enabled.\n", progname);
|
||||
avrdude_message("%s: Paged flash write enabled.\n", progname);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -589,7 +588,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)
|
||||
fprintf(stderr, "%s: Paged flash read disabled.\n", progname);
|
||||
avrdude_message("%s: Paged flash read disabled.\n", progname);
|
||||
pgm->paged_load = NULL;
|
||||
} else {
|
||||
int rv = buspirate_expect_bin_byte(pgm, 0x06, 0x01);
|
||||
|
@ -600,12 +599,12 @@ 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) fprintf(stderr, "AVR Extended Commands version %d\n", ver);
|
||||
if (verbose) avrdude_message("AVR Extended Commands version %d\n", ver);
|
||||
} else {
|
||||
if (verbose) fprintf(stderr, "AVR Extended Commands not found.\n");
|
||||
if (verbose) avrdude_message("AVR Extended Commands not found.\n");
|
||||
pgm->flag |= BP_FLAG_NOPAGEDREAD;
|
||||
pgm->paged_load = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -628,10 +627,9 @@ static int buspirate_start_spi_mode_ascii(struct programmer_t *pgm)
|
|||
break;
|
||||
}
|
||||
if (spi_cmd == -1) {
|
||||
fprintf(stderr,
|
||||
"%s: SPI mode number not found. Does your BusPirate support SPI?\n",
|
||||
avrdude_message("%s: SPI mode number not found. Does your BusPirate support SPI?\n",
|
||||
progname);
|
||||
fprintf(stderr, "%s: Try powercycling your BusPirate and try again.\n",
|
||||
avrdude_message("%s: Try powercycling your BusPirate and try again.\n",
|
||||
progname);
|
||||
return -1;
|
||||
}
|
||||
|
@ -649,7 +647,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) fprintf(stderr, "BusPirate is now configured for SPI\n");
|
||||
if (verbose) avrdude_message("BusPirate is now configured for SPI\n");
|
||||
break;
|
||||
}
|
||||
/* Not yet 'SPI>' prompt */
|
||||
|
@ -676,7 +674,7 @@ static void buspirate_enable(struct programmer_t *pgm)
|
|||
|
||||
/* Attempt to start binary SPI mode unless explicitly told otherwise: */
|
||||
if (!buspirate_uses_ascii(pgm)) {
|
||||
fprintf(stderr, "Attempting to initiate BusPirate binary mode...\n");
|
||||
avrdude_message("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);
|
||||
|
@ -688,23 +686,23 @@ static void buspirate_enable(struct programmer_t *pgm)
|
|||
if (buspirate_start_mode_bin(pgm) >= 0)
|
||||
return;
|
||||
else
|
||||
fprintf(stderr, "%s: Failed to start binary mode, falling back to ASCII...\n", progname);
|
||||
avrdude_message("%s: Failed to start binary mode, falling back to ASCII...\n", progname);
|
||||
}
|
||||
|
||||
fprintf(stderr, "Attempting to initiate BusPirate ASCII mode...\n");
|
||||
avrdude_message("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) {
|
||||
fprintf(stderr, "BusPirate is not responding. Serial port error: %d\n", rc);
|
||||
avrdude_message("BusPirate is not responding. Serial port error: %d\n", rc);
|
||||
return;
|
||||
}
|
||||
|
||||
while(1) {
|
||||
rcvd = buspirate_readline_noexit(pgm, NULL, 0);
|
||||
if (! rcvd) {
|
||||
fprintf(stderr, "%s: Fatal: Programmer is not responding.\n", progname);
|
||||
avrdude_message("%s: Fatal: Programmer is not responding.\n", progname);
|
||||
return;
|
||||
}
|
||||
if (strncmp(rcvd, "Are you sure?", 13) == 0) {
|
||||
|
@ -719,13 +717,13 @@ static void buspirate_enable(struct programmer_t *pgm)
|
|||
break;
|
||||
}
|
||||
if (print_banner)
|
||||
fprintf(stderr, "** %s", rcvd);
|
||||
avrdude_message("** %s", rcvd);
|
||||
}
|
||||
|
||||
if (!(pgm->flag & BP_FLAG_IN_BINMODE)) {
|
||||
fprintf(stderr, "BusPirate: using ASCII mode\n");
|
||||
avrdude_message("BusPirate: using ASCII mode\n");
|
||||
if (buspirate_start_spi_mode_ascii(pgm) < 0) {
|
||||
fprintf(stderr, "%s: Failed to start ascii SPI mode\n", progname);
|
||||
avrdude_message("%s: Failed to start ascii SPI mode\n", progname);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -766,15 +764,15 @@ static void buspirate_powerup(struct programmer_t *pgm)
|
|||
}
|
||||
}
|
||||
if(!ok) {
|
||||
fprintf(stderr, "%s: warning: did not get a response to start PWM command.\n", progname);
|
||||
avrdude_message("%s: warning: did not get a response to start PWM command.\n", progname);
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
fprintf(stderr, "%s: warning: did not get a response to PowerUp command.\n", progname);
|
||||
fprintf(stderr, "%s: warning: Trying to continue anyway...\n", progname);
|
||||
avrdude_message("%s: warning: did not get a response to PowerUp command.\n", progname);
|
||||
avrdude_message("%s: warning: Trying to continue anyway...\n", progname);
|
||||
}
|
||||
|
||||
static void buspirate_powerdown(struct programmer_t *pgm)
|
||||
|
@ -787,14 +785,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)) {
|
||||
fprintf(stderr, "%s: warning: did not get a response to stop PWM command.\n", progname);
|
||||
avrdude_message("%s: warning: did not get a response to stop PWM command.\n", progname);
|
||||
}
|
||||
}
|
||||
if (buspirate_expect(pgm, "w\n", "Power supplies OFF", 1))
|
||||
return;
|
||||
}
|
||||
|
||||
fprintf(stderr, "%s: warning: did not get a response to PowerDown command.\n", progname);
|
||||
avrdude_message("%s: warning: did not get a response to PowerDown command.\n", progname);
|
||||
}
|
||||
|
||||
static int buspirate_cmd_bin(struct programmer_t *pgm,
|
||||
|
@ -837,7 +835,7 @@ static int buspirate_cmd_ascii(struct programmer_t *pgm,
|
|||
}
|
||||
|
||||
if (i != 4) {
|
||||
fprintf(stderr, "%s: error: SPI has not read 4 bytes back\n", progname);
|
||||
avrdude_message("%s: error: SPI has not read 4 bytes back\n", progname);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -871,17 +869,17 @@ static int buspirate_paged_load(
|
|||
unsigned char buf[275];
|
||||
unsigned int addr = 0;
|
||||
|
||||
if (verbose > 1) fprintf(stderr, "BusPirate: buspirate_paged_load(..,%s,%d,%d,%d)\n",m->desc,m->page_size,address,n_bytes);
|
||||
if (verbose > 1) avrdude_message("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) {
|
||||
fprintf(stderr, "BusPirate: buspirate_paged_load() called while in nopagedread mode!\n");
|
||||
avrdude_message("BusPirate: buspirate_paged_load() called while in nopagedread mode!\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
// determine what type of memory to read, only flash is supported
|
||||
if (strcmp(m->desc, "flash") != 0) {
|
||||
return -1;
|
||||
return -1;
|
||||
}
|
||||
|
||||
// send command to read data
|
||||
|
@ -904,11 +902,11 @@ static int buspirate_paged_load(
|
|||
buspirate_recv_bin(pgm, buf, 1);
|
||||
|
||||
if (buf[0] != 0x01) {
|
||||
fprintf(stderr, "BusPirate: Paged Read command returned zero.\n");
|
||||
avrdude_message("BusPirate: Paged Read command returned zero.\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
for (addr = 0; addr < n_bytes; addr++) {
|
||||
for (addr = 0; addr < n_bytes; addr++) {
|
||||
buspirate_recv_bin(pgm, &m->buf[addr+address], 1);
|
||||
}
|
||||
|
||||
|
@ -951,15 +949,13 @@ static int buspirate_paged_write(struct programmer_t *pgm,
|
|||
|
||||
/* pre-check opcodes */
|
||||
if (m->op[AVR_OP_LOADPAGE_LO] == NULL) {
|
||||
fprintf(stderr,
|
||||
"%s failure: %s command not defined for %s\n",
|
||||
progname, "AVR_OP_LOADPAGE_LO", p->desc);
|
||||
avrdude_message("%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) {
|
||||
fprintf(stderr,
|
||||
"%s failure: %s command not defined for %s\n",
|
||||
progname, "AVR_OP_LOADPAGE_HI", p->desc);
|
||||
avrdude_message("%s failure: %s command not defined for %s\n",
|
||||
progname, "AVR_OP_LOADPAGE_HI", p->desc);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -1019,7 +1015,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)) {
|
||||
fprintf(stderr, "BusPirate: Fatal error: Write Then Read did not succeed.\n");
|
||||
avrdude_message("BusPirate: Fatal error: Write Then Read did not succeed.\n");
|
||||
pgm->pgm_led(pgm, OFF);
|
||||
pgm->err_led(pgm, ON);
|
||||
return -1;
|
||||
|
@ -1050,9 +1046,8 @@ 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) {
|
||||
fprintf(stderr,
|
||||
"program enable instruction not defined for part \"%s\"\n",
|
||||
p->desc);
|
||||
avrdude_message("program enable instruction not defined for part \"%s\"\n",
|
||||
p->desc);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -1072,9 +1067,8 @@ static int buspirate_chip_erase(struct programmer_t *pgm, AVRPART * p)
|
|||
unsigned char res[4];
|
||||
|
||||
if (p->op[AVR_OP_CHIP_ERASE] == NULL) {
|
||||
fprintf(stderr,
|
||||
"chip erase instruction not defined for part \"%s\"\n",
|
||||
p->desc);
|
||||
avrdude_message("chip erase instruction not defined for part \"%s\"\n",
|
||||
p->desc);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -1097,7 +1091,7 @@ static void buspirate_setup(struct programmer_t *pgm)
|
|||
{
|
||||
/* Allocate private data */
|
||||
if ((pgm->cookie = calloc(1, sizeof(struct pdata))) == 0) {
|
||||
fprintf(stderr, "%s: buspirate_initpgm(): Out of memory allocating private data\n",
|
||||
avrdude_message("%s: buspirate_initpgm(): Out of memory allocating private data\n",
|
||||
progname);
|
||||
exit(1);
|
||||
}
|
||||
|
@ -1151,7 +1145,7 @@ static void buspirate_bb_enable(struct programmer_t *pgm)
|
|||
if (bitbang_check_prerequisites(pgm) < 0)
|
||||
return; /* XXX should treat as error */
|
||||
|
||||
fprintf(stderr, "Attempting to initiate BusPirate bitbang binary mode...\n");
|
||||
avrdude_message("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);
|
||||
|
@ -1166,11 +1160,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) {
|
||||
fprintf(stderr, "Binary mode not confirmed: '%s'\n", buf);
|
||||
avrdude_message("Binary mode not confirmed: '%s'\n", buf);
|
||||
buspirate_reset_from_binmode(pgm);
|
||||
return;
|
||||
}
|
||||
fprintf(stderr, "BusPirate binmode version: %d\n",
|
||||
avrdude_message("BusPirate binmode version: %d\n",
|
||||
PDATA(pgm)->binmode_version);
|
||||
|
||||
pgm->flag |= BP_FLAG_IN_BINMODE;
|
||||
|
|
62
butterfly.c
62
butterfly.c
|
@ -64,9 +64,8 @@ struct pdata
|
|||
static void butterfly_setup(PROGRAMMER * pgm)
|
||||
{
|
||||
if ((pgm->cookie = malloc(sizeof(struct pdata))) == 0) {
|
||||
fprintf(stderr,
|
||||
"%s: butterfly_setup(): Out of memory allocating private data\n",
|
||||
progname);
|
||||
avrdude_message("%s: butterfly_setup(): Out of memory allocating private data\n",
|
||||
progname);
|
||||
exit(1);
|
||||
}
|
||||
memset(pgm->cookie, 0, sizeof(struct pdata));
|
||||
|
@ -89,9 +88,8 @@ static int butterfly_recv(PROGRAMMER * pgm, char * buf, size_t len)
|
|||
|
||||
rv = serial_recv(&pgm->fd, (unsigned char *)buf, len);
|
||||
if (rv < 0) {
|
||||
fprintf(stderr,
|
||||
"%s: butterfly_recv(): programmer is not responding\n",
|
||||
progname);
|
||||
avrdude_message("%s: butterfly_recv(): programmer is not responding\n",
|
||||
progname);
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
|
@ -110,7 +108,7 @@ static int butterfly_vfy_cmd_sent(PROGRAMMER * pgm, char * errmsg)
|
|||
|
||||
butterfly_recv(pgm, &c, 1);
|
||||
if (c != '\r') {
|
||||
fprintf(stderr, "%s: error: programmer did not respond to command: %s\n",
|
||||
avrdude_message("%s: error: programmer did not respond to command: %s\n",
|
||||
progname, errmsg);
|
||||
return -1;
|
||||
}
|
||||
|
@ -225,7 +223,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.
|
||||
*/
|
||||
fprintf(stderr, "Connecting to programmer: ");
|
||||
avrdude_message("Connecting to programmer: ");
|
||||
if (pgm->flag & IS_BUTTERFLY_MK)
|
||||
{
|
||||
char mk_reset_cmd[6] = {"#aR@S\r"};
|
||||
|
@ -247,9 +245,9 @@ static int butterfly_initialize(PROGRAMMER * pgm, AVRPART * p)
|
|||
} while (mk_timeout++ < 10);
|
||||
|
||||
butterfly_recv(pgm, &c, 1);
|
||||
if ( c != 'M' && c != '?')
|
||||
{
|
||||
fprintf(stderr, "\nConnection FAILED.");
|
||||
if ( c != 'M' && c != '?')
|
||||
{
|
||||
avrdude_message("\nConnection FAILED.");
|
||||
return -1;
|
||||
}
|
||||
else
|
||||
|
@ -296,12 +294,12 @@ static int butterfly_initialize(PROGRAMMER * pgm, AVRPART * p)
|
|||
butterfly_send(pgm, "p", 1);
|
||||
butterfly_recv(pgm, &type, 1);
|
||||
|
||||
fprintf(stderr, "Found programmer: Id = \"%s\"; type = %c\n", id, type);
|
||||
fprintf(stderr, " Software Version = %c.%c; ", sw[0], sw[1]);
|
||||
avrdude_message("Found programmer: Id = \"%s\"; type = %c\n", id, type);
|
||||
avrdude_message(" Software Version = %c.%c; ", sw[0], sw[1]);
|
||||
if (hw[0]=='?') {
|
||||
fprintf(stderr, "No Hardware Version given.\n");
|
||||
avrdude_message("No Hardware Version given.\n");
|
||||
} else {
|
||||
fprintf(stderr, "Hardware Version = %c.%c\n", hw[0], hw[1]);
|
||||
avrdude_message("Hardware Version = %c.%c\n", hw[0], hw[1]);
|
||||
};
|
||||
|
||||
/* See if programmer supports autoincrement of address. */
|
||||
|
@ -309,30 +307,28 @@ 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')
|
||||
fprintf(stderr, "Programmer supports auto addr increment.\n");
|
||||
avrdude_message("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') {
|
||||
fprintf(stderr,
|
||||
"%s: error: buffered memory access not supported. Maybe it isn't\n"\
|
||||
"a butterfly/AVR109 but a AVR910 device?\n", progname);
|
||||
avrdude_message("%s: error: buffered memory access not supported. Maybe it isn't\n"\
|
||||
"a butterfly/AVR109 but a AVR910 device?\n", progname);
|
||||
return -1;
|
||||
};
|
||||
butterfly_recv(pgm, &c, 1);
|
||||
PDATA(pgm)->buffersize = (unsigned int)(unsigned char)c<<8;
|
||||
butterfly_recv(pgm, &c, 1);
|
||||
PDATA(pgm)->buffersize += (unsigned int)(unsigned char)c;
|
||||
fprintf(stderr,
|
||||
"Programmer supports buffered memory access with buffersize=%i bytes.\n",
|
||||
PDATA(pgm)->buffersize);
|
||||
avrdude_message("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);
|
||||
fprintf(stderr, "\nProgrammer supports the following devices:\n");
|
||||
avrdude_message("\nProgrammer supports the following devices:\n");
|
||||
devtype_1st = 0;
|
||||
while (1) {
|
||||
butterfly_recv(pgm, &c, 1);
|
||||
|
@ -341,9 +337,9 @@ static int butterfly_initialize(PROGRAMMER * pgm, AVRPART * p)
|
|||
|
||||
if (c == 0)
|
||||
break;
|
||||
fprintf(stderr, " Device code: 0x%02x\n", (unsigned int)(unsigned char)c);
|
||||
avrdude_message(" Device code: 0x%02x\n", (unsigned int)(unsigned char)c);
|
||||
};
|
||||
fprintf(stderr,"\n");
|
||||
avrdude_message("\n");
|
||||
|
||||
/* Tell the programmer which part we selected.
|
||||
According to the AVR109 code, this is ignored by the bootloader. As
|
||||
|
@ -361,9 +357,8 @@ static int butterfly_initialize(PROGRAMMER * pgm, AVRPART * p)
|
|||
return -1;
|
||||
|
||||
if (verbose)
|
||||
fprintf(stderr,
|
||||
"%s: devcode selected: 0x%02x\n",
|
||||
progname, (unsigned)buf[1]);
|
||||
avrdude_message("%s: devcode selected: 0x%02x\n",
|
||||
progname, (unsigned)buf[1]);
|
||||
|
||||
butterfly_enter_prog_mode(pgm);
|
||||
butterfly_drain(pgm, 0);
|
||||
|
@ -556,9 +551,8 @@ 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 */
|
||||
fprintf(stderr,
|
||||
"%s: butterfly_page_erase() called on memory type \"%s\"\n",
|
||||
progname, m->desc);
|
||||
avrdude_message("%s: butterfly_page_erase() called on memory type \"%s\"\n",
|
||||
progname, m->desc);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -608,7 +602,7 @@ static int butterfly_paged_write(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m,
|
|||
int use_ext_addr = m->op[AVR_OP_LOAD_EXT_ADDR] != NULL;
|
||||
unsigned int wr_size = 2;
|
||||
|
||||
if (strcmp(m->desc, "flash") && strcmp(m->desc, "eeprom"))
|
||||
if (strcmp(m->desc, "flash") && strcmp(m->desc, "eeprom"))
|
||||
return -2;
|
||||
|
||||
if (m->desc[0] == 'e')
|
||||
|
@ -663,7 +657,7 @@ static int butterfly_paged_load(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m,
|
|||
int use_ext_addr = m->op[AVR_OP_LOAD_EXT_ADDR] != NULL;
|
||||
|
||||
/* check parameter syntax: only "flash" or "eeprom" is allowed */
|
||||
if (strcmp(m->desc, "flash") && strcmp(m->desc, "eeprom"))
|
||||
if (strcmp(m->desc, "flash") && strcmp(m->desc, "eeprom"))
|
||||
return -2;
|
||||
|
||||
if (m->desc[0] == 'e')
|
||||
|
@ -704,7 +698,7 @@ static int butterfly_read_sig_bytes(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m)
|
|||
unsigned char tmp;
|
||||
|
||||
if (m->size < 3) {
|
||||
fprintf(stderr, "%s: memsize too small for sig byte read", progname);
|
||||
avrdude_message("%s: memsize too small for sig byte read", progname);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
|
32
config.c
32
config.c
|
@ -93,7 +93,7 @@ TOKEN * new_token(int primary)
|
|||
|
||||
tkn = (TOKEN *)malloc(sizeof(TOKEN));
|
||||
if (tkn == NULL) {
|
||||
fprintf(stderr, "new_token(): out of memory\n");
|
||||
avrdude_message("new_token(): out of memory\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
@ -145,7 +145,7 @@ TOKEN * number(char * text)
|
|||
tkn->value.number = atoi(text);
|
||||
|
||||
#if DEBUG
|
||||
fprintf(stderr, "NUMBER(%d)\n", tkn->value.number);
|
||||
avrdude_message("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
|
||||
fprintf(stderr, "NUMBER(%g)\n", tkn->value.number_real);
|
||||
avrdude_message("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)) {
|
||||
fprintf(stderr, "error at %s:%d: can't scan hex number \"%s\"\n",
|
||||
avrdude_message("error at %s:%d: can't scan hex number \"%s\"\n",
|
||||
infile, lineno, text);
|
||||
}
|
||||
|
||||
#if DEBUG
|
||||
fprintf(stderr, "HEXNUMBER(%g)\n", tkn->value.number);
|
||||
avrdude_message("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) {
|
||||
fprintf(stderr, "id(): out of memory\n");
|
||||
avrdude_message("id(): out of memory\n");
|
||||
exit(1);
|
||||
}
|
||||
strcpy(tkn->value.string, text);
|
||||
|
||||
#if DEBUG
|
||||
fprintf(stderr, "STRING(%s)\n", tkn->value.string);
|
||||
avrdude_message("STRING(%s)\n", tkn->value.string);
|
||||
#endif
|
||||
|
||||
return tkn;
|
||||
|
@ -227,33 +227,33 @@ void print_token(TOKEN * tkn)
|
|||
if (!tkn)
|
||||
return;
|
||||
|
||||
fprintf(stderr, "token = %d = ", tkn->primary);
|
||||
avrdude_message("token = %d = ", tkn->primary);
|
||||
switch (tkn->value.type) {
|
||||
case V_NUM:
|
||||
fprintf(stderr, "NUMBER, value=%d", tkn->value.number);
|
||||
avrdude_message("NUMBER, value=%d", tkn->value.number);
|
||||
break;
|
||||
|
||||
case V_NUM_REAL:
|
||||
fprintf(stderr, "NUMBER, value=%g", tkn->value.number_real);
|
||||
avrdude_message("NUMBER, value=%g", tkn->value.number_real);
|
||||
break;
|
||||
|
||||
case V_STR:
|
||||
fprintf(stderr, "STRING, value=%s", tkn->value.string);
|
||||
avrdude_message("STRING, value=%s", tkn->value.string);
|
||||
break;
|
||||
|
||||
default:
|
||||
fprintf(stderr, "<other>");
|
||||
avrdude_message("<other>");
|
||||
break;
|
||||
}
|
||||
|
||||
fprintf(stderr, "\n");
|
||||
avrdude_message("\n");
|
||||
}
|
||||
|
||||
|
||||
void pyytext(void)
|
||||
{
|
||||
#if DEBUG
|
||||
fprintf(stderr, "TOKEN: \"%s\"\n", yytext);
|
||||
avrdude_message("TOKEN: \"%s\"\n", yytext);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -264,7 +264,7 @@ char * dup_string(const char * str)
|
|||
|
||||
s = strdup(str);
|
||||
if (s == NULL) {
|
||||
fprintf(stderr, "dup_string(): out of memory\n");
|
||||
avrdude_message("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) {
|
||||
fprintf(stderr, "%s: can't open config file \"%s\": %s\n",
|
||||
avrdude_message("%s: can't open config file \"%s\": %s\n",
|
||||
progname, file, strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
|
|
|
@ -276,20 +276,19 @@ prog_def :
|
|||
PROGRAMMER * existing_prog;
|
||||
char * id;
|
||||
if (lsize(current_prog->id) == 0) {
|
||||
fprintf(stderr,
|
||||
"%s: error at %s:%d: required parameter id not specified\n",
|
||||
avrdude_message("%s: error at %s:%d: required parameter id not specified\n",
|
||||
progname, infile, lineno);
|
||||
exit(1);
|
||||
}
|
||||
if (current_prog->initpgm == NULL) {
|
||||
fprintf(stderr, "%s: error at %s:%d: programmer type not specified\n",
|
||||
avrdude_message("%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) {
|
||||
fprintf(stderr, "%s: warning at %s:%d: programmer %s overwrites "
|
||||
avrdude_message("%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);
|
||||
|
@ -315,8 +314,7 @@ prog_decl :
|
|||
{
|
||||
struct programmer_t * pgm = locate_programmer(programmers, $3->value.string);
|
||||
if (pgm == NULL) {
|
||||
fprintf(stderr,
|
||||
"%s: error at %s:%d: parent programmer %s not found\n",
|
||||
avrdude_message("%s: error at %s:%d: parent programmer %s not found\n",
|
||||
progname, infile, lineno, $3->value.string);
|
||||
exit(1);
|
||||
}
|
||||
|
@ -336,8 +334,7 @@ part_def :
|
|||
AVRPART * existing_part;
|
||||
|
||||
if (current_part->id[0] == 0) {
|
||||
fprintf(stderr,
|
||||
"%s: error at %s:%d: required parameter id not specified\n",
|
||||
avrdude_message("%s: error at %s:%d: required parameter id not specified\n",
|
||||
progname, infile, lineno);
|
||||
exit(1);
|
||||
}
|
||||
|
@ -351,22 +348,19 @@ part_def :
|
|||
m = ldata(ln);
|
||||
if (m->paged) {
|
||||
if (m->page_size == 0) {
|
||||
fprintf(stderr,
|
||||
"%s: error at %s:%d: must specify page_size for paged "
|
||||
avrdude_message("%s: error at %s:%d: must specify page_size for paged "
|
||||
"memory\n",
|
||||
progname, infile, lineno);
|
||||
exit(1);
|
||||
}
|
||||
if (m->num_pages == 0) {
|
||||
fprintf(stderr,
|
||||
"%s: error at %s:%d: must specify num_pages for paged "
|
||||
avrdude_message("%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) {
|
||||
fprintf(stderr,
|
||||
"%s: error at %s:%d: page size (%u) * num_pages (%u) = "
|
||||
avrdude_message("%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,
|
||||
|
@ -381,7 +375,7 @@ part_def :
|
|||
|
||||
existing_part = locate_part(part_list, current_part->id);
|
||||
if (existing_part) {
|
||||
fprintf(stderr, "%s: warning at %s:%d: part %s overwrites "
|
||||
avrdude_message("%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);
|
||||
|
@ -404,8 +398,7 @@ part_decl :
|
|||
{
|
||||
AVRPART * parent_part = locate_part(part_list, $3->value.string);
|
||||
if (parent_part == NULL) {
|
||||
fprintf(stderr,
|
||||
"%s: error at %s:%d: can't find parent part",
|
||||
avrdude_message("%s: error at %s:%d: can't find parent part",
|
||||
progname, infile, lineno);
|
||||
exit(1);
|
||||
}
|
||||
|
@ -474,8 +467,7 @@ prog_parm_type_id:
|
|||
TKN_STRING {
|
||||
const struct programmer_type_t * pgm_type = locate_programmer_type($1->value.string);
|
||||
if (pgm_type == NULL) {
|
||||
fprintf(stderr,
|
||||
"%s: error at %s:%d: programmer type %s not found\n",
|
||||
avrdude_message("%s: error at %s:%d: programmer type %s not found\n",
|
||||
progname, infile, lineno, $1->value.string);
|
||||
exit(1);
|
||||
}
|
||||
|
@ -484,8 +476,7 @@ prog_parm_type_id:
|
|||
}
|
||||
| error
|
||||
{
|
||||
fprintf(stderr,
|
||||
"%s: error at %s:%d: programmer type must be written as \"id_type\"\n",
|
||||
avrdude_message("%s: error at %s:%d: programmer type must be written as \"id_type\"\n",
|
||||
progname, infile, lineno);
|
||||
exit(1);
|
||||
}
|
||||
|
@ -657,8 +648,7 @@ part_parm :
|
|||
|
||||
K_DEVICECODE TKN_EQUAL TKN_NUMBER {
|
||||
{
|
||||
fprintf(stderr,
|
||||
"%s: error at %s:%d: devicecode is deprecated, use "
|
||||
avrdude_message("%s: error at %s:%d: devicecode is deprecated, use "
|
||||
"stk500_devcode instead\n",
|
||||
progname, infile, lineno);
|
||||
exit(1);
|
||||
|
@ -723,8 +713,7 @@ part_parm :
|
|||
}
|
||||
if (!ok)
|
||||
{
|
||||
fprintf(stderr,
|
||||
"%s: Warning: line %d of %s: "
|
||||
avrdude_message("%s: Warning: line %d of %s: "
|
||||
"too many bytes in control stack\n",
|
||||
progname, lineno, infile);
|
||||
}
|
||||
|
@ -757,8 +746,7 @@ part_parm :
|
|||
}
|
||||
if (!ok)
|
||||
{
|
||||
fprintf(stderr,
|
||||
"%s: Warning: line %d of %s: "
|
||||
avrdude_message("%s: Warning: line %d of %s: "
|
||||
"too many bytes in control stack\n",
|
||||
progname, lineno, infile);
|
||||
}
|
||||
|
@ -790,8 +778,7 @@ part_parm :
|
|||
}
|
||||
if (!ok)
|
||||
{
|
||||
fprintf(stderr,
|
||||
"%s: Warning: line %d of %s: "
|
||||
avrdude_message("%s: Warning: line %d of %s: "
|
||||
"too many bytes in flash instructions\n",
|
||||
progname, lineno, infile);
|
||||
}
|
||||
|
@ -823,8 +810,7 @@ part_parm :
|
|||
}
|
||||
if (!ok)
|
||||
{
|
||||
fprintf(stderr,
|
||||
"%s: Warning: line %d of %s: "
|
||||
avrdude_message("%s: Warning: line %d of %s: "
|
||||
"too many bytes in EEPROM instructions\n",
|
||||
progname, lineno, infile);
|
||||
}
|
||||
|
@ -1230,8 +1216,7 @@ part_parm :
|
|||
op = avr_new_opcode();
|
||||
parse_cmdbits(op);
|
||||
if (current_part->op[opnum] != NULL) {
|
||||
/*fprintf(stderr,
|
||||
"%s: warning at %s:%d: operation redefined\n",
|
||||
/*avrdude_message("%s: warning at %s:%d: operation redefined\n",
|
||||
progname, infile, lineno);*/
|
||||
avr_free_opcode(current_part->op[opnum]);
|
||||
}
|
||||
|
@ -1357,8 +1342,7 @@ mem_spec :
|
|||
op = avr_new_opcode();
|
||||
parse_cmdbits(op);
|
||||
if (current_mem->op[opnum] != NULL) {
|
||||
/*fprintf(stderr,
|
||||
"%s: warning at %s:%d: operation redefined\n",
|
||||
/*avrdude_message("%s: warning at %s:%d: operation redefined\n",
|
||||
progname, infile, lineno);*/
|
||||
avr_free_opcode(current_mem->op[opnum]);
|
||||
}
|
||||
|
@ -1394,8 +1378,7 @@ static int assign_pin(int pinno, TOKEN * v, int invert)
|
|||
free_token(v);
|
||||
|
||||
if ((value < PIN_MIN) || (value > PIN_MAX)) {
|
||||
fprintf(stderr,
|
||||
"%s: error at line %d of %s: pin must be in the "
|
||||
avrdude_message("%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);
|
||||
|
@ -1416,8 +1399,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)) {
|
||||
fprintf(stderr,
|
||||
"%s: error at line %d of %s: pin must be in the "
|
||||
avrdude_message("%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);
|
||||
|
@ -1446,8 +1428,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 :
|
||||
fprintf(stderr,
|
||||
"%s: error at %s:%d: invalid opcode\n",
|
||||
avrdude_message("%s: error at %s:%d: invalid opcode\n",
|
||||
progname, infile, lineno);
|
||||
exit(1);
|
||||
break;
|
||||
|
@ -1475,8 +1456,7 @@ static int parse_cmdbits(OPCODE * op)
|
|||
|
||||
bitno--;
|
||||
if (bitno < 0) {
|
||||
fprintf(stderr,
|
||||
"%s: error at %s:%d: too many opcode bits for instruction\n",
|
||||
avrdude_message("%s: error at %s:%d: too many opcode bits for instruction\n",
|
||||
progname, infile, lineno);
|
||||
exit(1);
|
||||
}
|
||||
|
@ -1484,8 +1464,7 @@ static int parse_cmdbits(OPCODE * op)
|
|||
len = strlen(s);
|
||||
|
||||
if (len == 0) {
|
||||
fprintf(stderr,
|
||||
"%s: error at %s:%d: invalid bit specifier \"\"\n",
|
||||
avrdude_message("%s: error at %s:%d: invalid bit specifier \"\"\n",
|
||||
progname, infile, lineno);
|
||||
exit(1);
|
||||
}
|
||||
|
@ -1525,8 +1504,7 @@ static int parse_cmdbits(OPCODE * op)
|
|||
op->bit[bitno].bitno = bitno % 8;
|
||||
break;
|
||||
default :
|
||||
fprintf(stderr,
|
||||
"%s: error at %s:%d: invalid bit specifier '%c'\n",
|
||||
avrdude_message("%s: error at %s:%d: invalid bit specifier '%c'\n",
|
||||
progname, infile, lineno, ch);
|
||||
exit(1);
|
||||
break;
|
||||
|
@ -1537,8 +1515,7 @@ static int parse_cmdbits(OPCODE * op)
|
|||
q = &s[1];
|
||||
op->bit[bitno].bitno = strtol(q, &e, 0);
|
||||
if ((e == q)||(*e != 0)) {
|
||||
fprintf(stderr,
|
||||
"%s: error at %s:%d: can't parse bit number from \"%s\"\n",
|
||||
avrdude_message("%s: error at %s:%d: can't parse bit number from \"%s\"\n",
|
||||
progname, infile, lineno, q);
|
||||
exit(1);
|
||||
}
|
||||
|
@ -1546,8 +1523,7 @@ static int parse_cmdbits(OPCODE * op)
|
|||
op->bit[bitno].value = 0;
|
||||
}
|
||||
else {
|
||||
fprintf(stderr,
|
||||
"%s: error at %s:%d: invalid bit specifier \"%s\"\n",
|
||||
avrdude_message("%s: error at %s:%d: invalid bit specifier \"%s\"\n",
|
||||
progname, infile, lineno, s);
|
||||
exit(1);
|
||||
}
|
||||
|
|
88
dfu.c
88
dfu.c
|
@ -37,7 +37,7 @@
|
|||
#ifndef HAVE_LIBUSB
|
||||
|
||||
struct dfu_dev *dfu_open(char *port_name) {
|
||||
fprintf(stderr, "%s: Error: No USB support in this compile of avrdude\n",
|
||||
avrdude_message("%s: Error: No USB support in this compile of avrdude\n",
|
||||
progname);
|
||||
return NULL;
|
||||
}
|
||||
|
@ -110,7 +110,7 @@ struct dfu_dev * dfu_open(char *port_spec)
|
|||
*/
|
||||
|
||||
if (strncmp(port_spec, "usb", 3) != 0) {
|
||||
fprintf(stderr, "%s: Error: "
|
||||
avrdude_message("%s: Error: "
|
||||
"Invalid port specification \"%s\" for USB device\n",
|
||||
progname, port_spec);
|
||||
return NULL;
|
||||
|
@ -119,7 +119,7 @@ struct dfu_dev * dfu_open(char *port_spec)
|
|||
if(':' == port_spec[3]) {
|
||||
bus_name = strdup(port_spec + 3 + 1);
|
||||
if (bus_name == NULL) {
|
||||
fprintf(stderr, "%s: Out of memory in strdup\n", progname);
|
||||
avrdude_message("%s: Out of memory in strdup\n", progname);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -136,7 +136,7 @@ struct dfu_dev * dfu_open(char *port_spec)
|
|||
|
||||
if (dfu == NULL)
|
||||
{
|
||||
fprintf(stderr, "%s: out of memory\n", progname);
|
||||
avrdude_message("%s: out of memory\n", progname);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -169,7 +169,7 @@ int dfu_init(struct dfu_dev *dfu, unsigned short vid, unsigned short pid)
|
|||
*/
|
||||
|
||||
if (pid == 0 && dfu->dev_name == NULL) {
|
||||
fprintf(stderr, "%s: Error: No DFU support for part; "
|
||||
avrdude_message("%s: Error: No DFU support for part; "
|
||||
"specify PID in config or USB address (via -P) to override.\n",
|
||||
progname);
|
||||
return -1;
|
||||
|
@ -206,20 +206,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.
|
||||
*/
|
||||
|
||||
fprintf(stderr, "%s: Error: No matching USB device found\n", progname);
|
||||
avrdude_message("%s: Error: No matching USB device found\n", progname);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if(verbose)
|
||||
fprintf(stderr,
|
||||
"%s: Found VID=0x%04x PID=0x%04x at %s:%s\n",
|
||||
progname, found->descriptor.idVendor, found->descriptor.idProduct,
|
||||
found->bus->dirname, found->filename);
|
||||
avrdude_message("%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) {
|
||||
fprintf(stderr, "%s: Error: USB device at %s:%s: %s\n",
|
||||
avrdude_message("%s: Error: USB device at %s:%s: %s\n",
|
||||
progname, found->bus->dirname, found->filename, usb_strerror());
|
||||
return -1;
|
||||
}
|
||||
|
@ -271,7 +270,7 @@ int dfu_getstatus(struct dfu_dev *dfu, struct dfu_status *status)
|
|||
int result;
|
||||
|
||||
if (verbose > 3)
|
||||
fprintf(stderr, "%s: dfu_getstatus(): issuing control IN message\n",
|
||||
avrdude_message("%s: dfu_getstatus(): issuing control IN message\n",
|
||||
progname);
|
||||
|
||||
result = usb_control_msg(dfu->dev_handle,
|
||||
|
@ -279,31 +278,30 @@ int dfu_getstatus(struct dfu_dev *dfu, struct dfu_status *status)
|
|||
(char*) status, sizeof(struct dfu_status), dfu->timeout);
|
||||
|
||||
if (result < 0) {
|
||||
fprintf(stderr, "%s: Error: Failed to get DFU status: %s\n",
|
||||
avrdude_message("%s: Error: Failed to get DFU status: %s\n",
|
||||
progname, usb_strerror());
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (result < sizeof(struct dfu_status)) {
|
||||
fprintf(stderr, "%s: Error: Failed to get DFU status: %s\n",
|
||||
avrdude_message("%s: Error: Failed to get DFU status: %s\n",
|
||||
progname, "short read");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (result > sizeof(struct dfu_status)) {
|
||||
fprintf(stderr, "%s: Error: Oversize read (should not happen); "
|
||||
avrdude_message("%s: Error: Oversize read (should not happen); "
|
||||
"exiting\n", progname);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (verbose > 3)
|
||||
fprintf(stderr,
|
||||
"%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("%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;
|
||||
}
|
||||
|
@ -313,7 +311,7 @@ int dfu_clrstatus(struct dfu_dev *dfu)
|
|||
int result;
|
||||
|
||||
if (verbose > 3)
|
||||
fprintf(stderr, "%s: dfu_clrstatus(): issuing control OUT message\n",
|
||||
avrdude_message("%s: dfu_clrstatus(): issuing control OUT message\n",
|
||||
progname);
|
||||
|
||||
result = usb_control_msg(dfu->dev_handle,
|
||||
|
@ -321,7 +319,7 @@ int dfu_clrstatus(struct dfu_dev *dfu)
|
|||
NULL, 0, dfu->timeout);
|
||||
|
||||
if (result < 0) {
|
||||
fprintf(stderr, "%s: Error: Failed to clear DFU status: %s\n",
|
||||
avrdude_message("%s: Error: Failed to clear DFU status: %s\n",
|
||||
progname, usb_strerror());
|
||||
return -1;
|
||||
}
|
||||
|
@ -334,7 +332,7 @@ int dfu_abort(struct dfu_dev *dfu)
|
|||
int result;
|
||||
|
||||
if (verbose > 3)
|
||||
fprintf(stderr, "%s: dfu_abort(): issuing control OUT message\n",
|
||||
avrdude_message("%s: dfu_abort(): issuing control OUT message\n",
|
||||
progname);
|
||||
|
||||
result = usb_control_msg(dfu->dev_handle,
|
||||
|
@ -342,7 +340,7 @@ int dfu_abort(struct dfu_dev *dfu)
|
|||
NULL, 0, dfu->timeout);
|
||||
|
||||
if (result < 0) {
|
||||
fprintf(stderr, "%s: Error: Failed to reset DFU state: %s\n",
|
||||
avrdude_message("%s: Error: Failed to reset DFU state: %s\n",
|
||||
progname, usb_strerror());
|
||||
return -1;
|
||||
}
|
||||
|
@ -356,28 +354,27 @@ int dfu_dnload(struct dfu_dev *dfu, void *ptr, int size)
|
|||
int result;
|
||||
|
||||
if (verbose > 3)
|
||||
fprintf(stderr,
|
||||
"%s: dfu_dnload(): issuing control OUT message, wIndex = %d, ptr = %p, size = %d\n",
|
||||
progname, wIndex, ptr, size);
|
||||
avrdude_message("%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) {
|
||||
fprintf(stderr, "%s: Error: DFU_DNLOAD failed: %s\n",
|
||||
avrdude_message("%s: Error: DFU_DNLOAD failed: %s\n",
|
||||
progname, usb_strerror());
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (result < size) {
|
||||
fprintf(stderr, "%s: Error: DFU_DNLOAD failed: %s\n",
|
||||
avrdude_message("%s: Error: DFU_DNLOAD failed: %s\n",
|
||||
progname, "short write");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (result > size) {
|
||||
fprintf(stderr, "%s: Error: Oversize write (should not happen); " \
|
||||
avrdude_message("%s: Error: Oversize write (should not happen); " \
|
||||
"exiting\n", progname);
|
||||
exit(1);
|
||||
}
|
||||
|
@ -390,28 +387,27 @@ int dfu_upload(struct dfu_dev *dfu, void *ptr, int size)
|
|||
int result;
|
||||
|
||||
if (verbose > 3)
|
||||
fprintf(stderr,
|
||||
"%s: dfu_upload(): issuing control IN message, wIndex = %d, ptr = %p, size = %d\n",
|
||||
progname, wIndex, ptr, size);
|
||||
avrdude_message("%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) {
|
||||
fprintf(stderr, "%s: Error: DFU_UPLOAD failed: %s\n",
|
||||
avrdude_message("%s: Error: DFU_UPLOAD failed: %s\n",
|
||||
progname, usb_strerror());
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (result < size) {
|
||||
fprintf(stderr, "%s: Error: DFU_UPLOAD failed: %s\n",
|
||||
avrdude_message("%s: Error: DFU_UPLOAD failed: %s\n",
|
||||
progname, "short read");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (result > size) {
|
||||
fprintf(stderr, "%s: Error: Oversize read (should not happen); "
|
||||
avrdude_message("%s: Error: Oversize read (should not happen); "
|
||||
"exiting\n", progname);
|
||||
exit(1);
|
||||
}
|
||||
|
@ -422,26 +418,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)
|
||||
fprintf(stderr, " USB Vendor : %s (0x%04hX)\n",
|
||||
avrdude_message(" USB Vendor : %s (0x%04hX)\n",
|
||||
dfu->manf_str, (unsigned short) dfu->dev_desc.idVendor);
|
||||
else
|
||||
fprintf(stderr, " USB Vendor : 0x%04hX\n",
|
||||
avrdude_message(" USB Vendor : 0x%04hX\n",
|
||||
(unsigned short) dfu->dev_desc.idVendor);
|
||||
|
||||
if (dfu->prod_str != NULL)
|
||||
fprintf(stderr, " USB Product : %s (0x%04hX)\n",
|
||||
avrdude_message(" USB Product : %s (0x%04hX)\n",
|
||||
dfu->prod_str, (unsigned short) dfu->dev_desc.idProduct);
|
||||
else
|
||||
fprintf(stderr, " USB Product : 0x%04hX\n",
|
||||
avrdude_message(" USB Product : 0x%04hX\n",
|
||||
(unsigned short) dfu->dev_desc.idProduct);
|
||||
|
||||
fprintf(stderr, " USB Release : %hu.%hu.%hu\n",
|
||||
avrdude_message(" 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)
|
||||
fprintf(stderr, " USB Serial No : %s\n", dfu->serno_str);
|
||||
avrdude_message(" USB Serial No : %s\n", dfu->serno_str);
|
||||
}
|
||||
|
||||
/* INTERNAL FUNCTION DEFINITIONS
|
||||
|
@ -458,7 +454,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) {
|
||||
fprintf( stderr, "%s: Warning: Failed to read USB device string %d: %s\n",
|
||||
avrdude_message("%s: Warning: Failed to read USB device string %d: %s\n",
|
||||
progname, index, usb_strerror());
|
||||
return NULL;
|
||||
}
|
||||
|
@ -466,7 +462,7 @@ char * get_usb_string(usb_dev_handle * dev_handle, int index) {
|
|||
str = malloc(result+1);
|
||||
|
||||
if (str == NULL) {
|
||||
fprintf(stderr, "%s: Out of memory allocating a string\n", progname);
|
||||
avrdude_message("%s: Out of memory allocating a string\n", progname);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
292
fileio.c
292
fileio.c
|
@ -126,7 +126,7 @@ static int b2ihex(unsigned char * inbuf, int bufsize,
|
|||
unsigned char cksum;
|
||||
|
||||
if (recsize > 255) {
|
||||
fprintf(stderr, "%s: recsize=%d, must be < 256\n",
|
||||
avrdude_message("%s: recsize=%d, must be < 256\n",
|
||||
progname, recsize);
|
||||
return -1;
|
||||
}
|
||||
|
@ -306,14 +306,14 @@ static int ihex2b(char * infile, FILE * inf,
|
|||
continue;
|
||||
rc = ihex_readrec(&ihex, buffer);
|
||||
if (rc < 0) {
|
||||
fprintf(stderr, "%s: invalid record at line %d of \"%s\"\n",
|
||||
avrdude_message("%s: invalid record at line %d of \"%s\"\n",
|
||||
progname, lineno, infile);
|
||||
return -1;
|
||||
}
|
||||
else if (rc != ihex.cksum) {
|
||||
fprintf(stderr, "%s: ERROR: checksum mismatch at line %d of \"%s\"\n",
|
||||
avrdude_message("%s: ERROR: checksum mismatch at line %d of \"%s\"\n",
|
||||
progname, lineno, infile);
|
||||
fprintf(stderr, "%s: checksum=0x%02x, computed checksum=0x%02x\n",
|
||||
avrdude_message("%s: checksum=0x%02x, computed checksum=0x%02x\n",
|
||||
progname, ihex.cksum, rc);
|
||||
return -1;
|
||||
}
|
||||
|
@ -321,16 +321,14 @@ static int ihex2b(char * infile, FILE * inf,
|
|||
switch (ihex.rectyp) {
|
||||
case 0: /* data record */
|
||||
if (fileoffset != 0 && baseaddr < fileoffset) {
|
||||
fprintf(stderr,
|
||||
"%s: ERROR: address 0x%04x out of range (below fileoffset 0x%x) at line %d of %s\n",
|
||||
progname, baseaddr, fileoffset, lineno, infile);
|
||||
avrdude_message("%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) {
|
||||
fprintf(stderr,
|
||||
"%s: ERROR: address 0x%04x out of range at line %d of %s\n",
|
||||
progname, nextaddr+ihex.reclen, lineno, infile);
|
||||
avrdude_message("%s: ERROR: address 0x%04x out of range at line %d of %s\n",
|
||||
progname, nextaddr+ihex.reclen, lineno, infile);
|
||||
return -1;
|
||||
}
|
||||
for (i=0; i<ihex.reclen; i++) {
|
||||
|
@ -362,10 +360,9 @@ static int ihex2b(char * infile, FILE * inf,
|
|||
break;
|
||||
|
||||
default:
|
||||
fprintf(stderr,
|
||||
"%s: don't know how to deal with rectype=%d "
|
||||
"at line %d of %s\n",
|
||||
progname, ihex.rectyp, lineno, infile);
|
||||
avrdude_message("%s: don't know how to deal with rectype=%d "
|
||||
"at line %d of %s\n",
|
||||
progname, ihex.rectyp, lineno, infile);
|
||||
return -1;
|
||||
break;
|
||||
}
|
||||
|
@ -373,18 +370,16 @@ static int ihex2b(char * infile, FILE * inf,
|
|||
} /* while */
|
||||
|
||||
if (maxaddr == 0) {
|
||||
fprintf(stderr,
|
||||
"%s: ERROR: No valid record found in Intel Hex "
|
||||
"file \"%s\"\n",
|
||||
progname, infile);
|
||||
avrdude_message("%s: ERROR: No valid record found in Intel Hex "
|
||||
"file \"%s\"\n",
|
||||
progname, infile);
|
||||
|
||||
return -1;
|
||||
}
|
||||
else {
|
||||
fprintf(stderr,
|
||||
"%s: WARNING: no end of file record found for Intel Hex "
|
||||
"file \"%s\"\n",
|
||||
progname, infile);
|
||||
avrdude_message("%s: WARNING: no end of file record found for Intel Hex "
|
||||
"file \"%s\"\n",
|
||||
progname, infile);
|
||||
|
||||
return maxaddr;
|
||||
}
|
||||
|
@ -403,7 +398,7 @@ static int b2srec(unsigned char * inbuf, int bufsize,
|
|||
char * tmpl=0;
|
||||
|
||||
if (recsize > 255) {
|
||||
fprintf(stderr, "%s: ERROR: recsize=%d, must be < 256\n",
|
||||
avrdude_message("%s: ERROR: recsize=%d, must be < 256\n",
|
||||
progname, recsize);
|
||||
return -1;
|
||||
}
|
||||
|
@ -436,12 +431,12 @@ static int b2srec(unsigned char * inbuf, int bufsize,
|
|||
tmpl="S3%02X%08X";
|
||||
}
|
||||
else {
|
||||
fprintf(stderr, "%s: ERROR: address=%d, out of range\n",
|
||||
avrdude_message("%s: ERROR: address=%d, out of range\n",
|
||||
progname, nextaddr);
|
||||
return -1;
|
||||
}
|
||||
|
||||
fprintf(outf, tmpl, n + addr_width + 1, nextaddr);
|
||||
fprintf(outf, tmpl, n + addr_width + 1, nextaddr);
|
||||
|
||||
cksum += n + addr_width + 1;
|
||||
|
||||
|
@ -601,19 +596,19 @@ static int srec2b(char * infile, FILE * inf,
|
|||
rc = srec_readrec(&srec, buffer);
|
||||
|
||||
if (rc < 0) {
|
||||
fprintf(stderr, "%s: ERROR: invalid record at line %d of \"%s\"\n",
|
||||
avrdude_message("%s: ERROR: invalid record at line %d of \"%s\"\n",
|
||||
progname, lineno, infile);
|
||||
return -1;
|
||||
}
|
||||
else if (rc != srec.cksum) {
|
||||
fprintf(stderr, "%s: ERROR: checksum mismatch at line %d of \"%s\"\n",
|
||||
avrdude_message("%s: ERROR: checksum mismatch at line %d of \"%s\"\n",
|
||||
progname, lineno, infile);
|
||||
fprintf(stderr, "%s: checksum=0x%02x, computed checksum=0x%02x\n",
|
||||
avrdude_message("%s: checksum=0x%02x, computed checksum=0x%02x\n",
|
||||
progname, srec.cksum, rc);
|
||||
return -1;
|
||||
}
|
||||
|
||||
datarec=0;
|
||||
datarec=0;
|
||||
switch (srec.rectyp) {
|
||||
case 0x30: /* S0 - header record*/
|
||||
/* skip */
|
||||
|
@ -635,18 +630,16 @@ static int srec2b(char * infile, FILE * inf,
|
|||
break;
|
||||
|
||||
case 0x34: /* S4 - symbol record (LSI extension) */
|
||||
fprintf(stderr,
|
||||
"%s: ERROR: not supported record at line %d of %s\n",
|
||||
progname, lineno, infile);
|
||||
avrdude_message("%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){
|
||||
fprintf(stderr,
|
||||
"%s: ERROR: count of transmitted data records mismatch "
|
||||
"at line %d of \"%s\"\n",
|
||||
progname, lineno, infile);
|
||||
fprintf(stderr, "%s: transmitted data records= %d, expected "
|
||||
avrdude_message("%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 "
|
||||
"value= %d\n",
|
||||
progname, reccount, srec.loadofs);
|
||||
return -1;
|
||||
|
@ -659,24 +652,23 @@ static int srec2b(char * infile, FILE * inf,
|
|||
return maxaddr;
|
||||
|
||||
default:
|
||||
fprintf(stderr,
|
||||
"%s: ERROR: don't know how to deal with rectype S%d "
|
||||
"at line %d of %s\n",
|
||||
progname, srec.rectyp, lineno, infile);
|
||||
avrdude_message("%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;
|
||||
}
|
||||
|
||||
if (datarec == 1) {
|
||||
nextaddr = srec.loadofs;
|
||||
if (nextaddr < fileoffset) {
|
||||
fprintf(stderr, msg, progname, nextaddr,
|
||||
avrdude_message(msg, progname, nextaddr,
|
||||
"(below fileoffset) ",
|
||||
lineno, infile);
|
||||
return -1;
|
||||
}
|
||||
nextaddr -= fileoffset;
|
||||
if (nextaddr + srec.reclen > bufsize) {
|
||||
fprintf(stderr, msg, progname, nextaddr+srec.reclen, "",
|
||||
avrdude_message(msg, progname, nextaddr+srec.reclen, "",
|
||||
lineno, infile);
|
||||
return -1;
|
||||
}
|
||||
|
@ -686,15 +678,14 @@ static int srec2b(char * infile, FILE * inf,
|
|||
}
|
||||
if (nextaddr+srec.reclen > maxaddr)
|
||||
maxaddr = nextaddr+srec.reclen;
|
||||
reccount++;
|
||||
reccount++;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
fprintf(stderr,
|
||||
"%s: WARNING: no end of file record found for Motorola S-Records "
|
||||
"file \"%s\"\n",
|
||||
progname, infile);
|
||||
avrdude_message("%s: WARNING: no end of file record found for Motorola S-Records "
|
||||
"file \"%s\"\n",
|
||||
progname, infile);
|
||||
|
||||
return maxaddr;
|
||||
}
|
||||
|
@ -737,9 +728,8 @@ 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) {
|
||||
fprintf(stderr,
|
||||
"%s: ERROR: Error reading section #%u header: %s\n",
|
||||
progname, (unsigned int)ndx, elf_errmsg(-1));
|
||||
avrdude_message("%s: ERROR: Error reading section #%u header: %s\n",
|
||||
progname, (unsigned int)ndx, elf_errmsg(-1));
|
||||
continue;
|
||||
}
|
||||
if ((sh->sh_flags & SHF_ALLOC) == 0 ||
|
||||
|
@ -756,10 +746,9 @@ static Elf_Scn *elf_get_scn(Elf *e, Elf32_Phdr *ph, Elf32_Shdr **shptr)
|
|||
}
|
||||
}
|
||||
|
||||
fprintf(stderr,
|
||||
"%s: ERROR: Cannot find a matching section for "
|
||||
"program header entry @p_vaddr 0x%x\n",
|
||||
progname, ph->p_vaddr);
|
||||
avrdude_message("%s: ERROR: Cannot find a matching section for "
|
||||
"program header entry @p_vaddr 0x%x\n",
|
||||
progname, ph->p_vaddr);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -830,9 +819,8 @@ static int elf2b(char * infile, FILE * inf,
|
|||
unsigned int low, high, foff;
|
||||
|
||||
if (elf_mem_limits(mem, p, &low, &high, &foff) != 0) {
|
||||
fprintf(stderr,
|
||||
"%s: ERROR: Cannot handle \"%s\" memory region from ELF file\n",
|
||||
progname, mem->desc);
|
||||
avrdude_message("%s: ERROR: Cannot handle \"%s\" memory region from ELF file\n",
|
||||
progname, mem->desc);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -849,10 +837,9 @@ static int elf2b(char * infile, FILE * inf,
|
|||
strcmp(mem->desc, "apptable") == 0)) {
|
||||
AVRMEM *flashmem = avr_locate_mem(p, "flash");
|
||||
if (flashmem == NULL) {
|
||||
fprintf(stderr,
|
||||
"%s: ERROR: No \"flash\" memory region found, "
|
||||
"cannot compute bounds of \"%s\" sub-region.\n",
|
||||
progname, mem->desc);
|
||||
avrdude_message("%s: ERROR: No \"flash\" memory region found, "
|
||||
"cannot compute bounds of \"%s\" sub-region.\n",
|
||||
progname, mem->desc);
|
||||
return -1;
|
||||
}
|
||||
/* The config file offsets are PDI offsets, rebase to 0. */
|
||||
|
@ -861,21 +848,18 @@ static int elf2b(char * infile, FILE * inf,
|
|||
}
|
||||
|
||||
if (elf_version(EV_CURRENT) == EV_NONE) {
|
||||
fprintf(stderr,
|
||||
"%s: ERROR: ELF library initialization failed: %s\n",
|
||||
progname, elf_errmsg(-1));
|
||||
avrdude_message("%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) {
|
||||
fprintf(stderr,
|
||||
"%s: ERROR: Cannot open \"%s\" as an ELF file: %s\n",
|
||||
progname, infile, elf_errmsg(-1));
|
||||
avrdude_message("%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) {
|
||||
fprintf(stderr,
|
||||
"%s: ERROR: Cannot use \"%s\" as an ELF input file\n",
|
||||
progname, infile);
|
||||
avrdude_message("%s: ERROR: Cannot use \"%s\" as an ELF input file\n",
|
||||
progname, infile);
|
||||
goto done;
|
||||
}
|
||||
|
||||
|
@ -883,9 +867,8 @@ static int elf2b(char * infile, FILE * inf,
|
|||
const char *id = elf_getident(e, &isize);
|
||||
|
||||
if (id == NULL) {
|
||||
fprintf(stderr,
|
||||
"%s: ERROR: Error reading ident area of \"%s\": %s\n",
|
||||
progname, infile, elf_errmsg(-1));
|
||||
avrdude_message("%s: ERROR: Error reading ident area of \"%s\": %s\n",
|
||||
progname, infile, elf_errmsg(-1));
|
||||
goto done;
|
||||
}
|
||||
|
||||
|
@ -900,25 +883,22 @@ static int elf2b(char * infile, FILE * inf,
|
|||
}
|
||||
if (id[EI_CLASS] != ELFCLASS32 ||
|
||||
id[EI_DATA] != endianess) {
|
||||
fprintf(stderr,
|
||||
"%s: ERROR: ELF file \"%s\" is not a "
|
||||
"32-bit, %s-endian file that was expected\n",
|
||||
progname, infile, endianname);
|
||||
avrdude_message("%s: ERROR: ELF file \"%s\" is not a "
|
||||
"32-bit, %s-endian file that was expected\n",
|
||||
progname, infile, endianname);
|
||||
goto done;
|
||||
}
|
||||
|
||||
Elf32_Ehdr *eh;
|
||||
if ((eh = elf32_getehdr(e)) == NULL) {
|
||||
fprintf(stderr,
|
||||
"%s: ERROR: Error reading ehdr of \"%s\": %s\n",
|
||||
progname, infile, elf_errmsg(-1));
|
||||
avrdude_message("%s: ERROR: Error reading ehdr of \"%s\": %s\n",
|
||||
progname, infile, elf_errmsg(-1));
|
||||
goto done;
|
||||
}
|
||||
|
||||
if (eh->e_type != ET_EXEC) {
|
||||
fprintf(stderr,
|
||||
"%s: ERROR: ELF file \"%s\" is not an executable file\n",
|
||||
progname, infile);
|
||||
avrdude_message("%s: ERROR: ELF file \"%s\" is not an executable file\n",
|
||||
progname, infile);
|
||||
goto done;
|
||||
}
|
||||
|
||||
|
@ -932,32 +912,28 @@ static int elf2b(char * infile, FILE * inf,
|
|||
mname = "AVR";
|
||||
}
|
||||
if (eh->e_machine != machine) {
|
||||
fprintf(stderr,
|
||||
"%s: ERROR: ELF file \"%s\" is not for machine %s\n",
|
||||
progname, infile, mname);
|
||||
avrdude_message("%s: ERROR: ELF file \"%s\" is not for machine %s\n",
|
||||
progname, infile, mname);
|
||||
goto done;
|
||||
}
|
||||
if (eh->e_phnum == 0xffff /* PN_XNUM */) {
|
||||
fprintf(stderr,
|
||||
"%s: ERROR: ELF file \"%s\" uses extended "
|
||||
"program header numbers which are not expected\n",
|
||||
progname, infile);
|
||||
avrdude_message("%s: ERROR: ELF file \"%s\" uses extended "
|
||||
"program header numbers which are not expected\n",
|
||||
progname, infile);
|
||||
goto done;
|
||||
}
|
||||
|
||||
Elf32_Phdr *ph;
|
||||
if ((ph = elf32_getphdr(e)) == NULL) {
|
||||
fprintf(stderr,
|
||||
"%s: ERROR: Error reading program header table of \"%s\": %s\n",
|
||||
progname, infile, elf_errmsg(-1));
|
||||
avrdude_message("%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) {
|
||||
fprintf(stderr,
|
||||
"%s: ERROR: Error obtaining section name string table: %s\n",
|
||||
progname, elf_errmsg(-1));
|
||||
avrdude_message("%s: ERROR: Error obtaining section name string table: %s\n",
|
||||
progname, elf_errmsg(-1));
|
||||
sndx = 0;
|
||||
}
|
||||
|
||||
|
@ -971,10 +947,9 @@ static int elf2b(char * infile, FILE * inf,
|
|||
continue;
|
||||
|
||||
if (verbose >= 2) {
|
||||
fprintf(stderr,
|
||||
"%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("%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;
|
||||
|
@ -995,9 +970,8 @@ static int elf2b(char * infile, FILE * inf,
|
|||
lma = ph[i].p_paddr + sh->sh_offset - ph[i].p_offset;
|
||||
|
||||
if (verbose >= 2) {
|
||||
fprintf(stderr,
|
||||
"%s: Found section \"%s\", LMA 0x%x, sh_size %u\n",
|
||||
progname, sname, lma, sh->sh_size);
|
||||
avrdude_message("%s: Found section \"%s\", LMA 0x%x, sh_size %u\n",
|
||||
progname, sname, lma, sh->sh_size);
|
||||
}
|
||||
|
||||
if (lma >= low &&
|
||||
|
@ -1005,9 +979,8 @@ static int elf2b(char * infile, FILE * inf,
|
|||
/* OK */
|
||||
} else {
|
||||
if (verbose >= 2) {
|
||||
fprintf(stderr,
|
||||
" => skipping, inappropriate for \"%s\" memory region\n",
|
||||
mem->desc);
|
||||
avrdude_message(" => skipping, inappropriate for \"%s\" memory region\n",
|
||||
mem->desc);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
@ -1021,35 +994,30 @@ static int elf2b(char * infile, FILE * inf,
|
|||
*/
|
||||
if (mem->size != 1 &&
|
||||
sh->sh_size > mem->size) {
|
||||
fprintf(stderr,
|
||||
"%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);
|
||||
avrdude_message("%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);
|
||||
continue;
|
||||
}
|
||||
|
||||
Elf_Data *d = NULL;
|
||||
while ((d = elf_getdata(s, d)) != NULL) {
|
||||
if (verbose >= 2) {
|
||||
fprintf(stderr,
|
||||
" 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(" 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) {
|
||||
fprintf(stderr,
|
||||
"%s: ERROR: unexpected data block at offset != 0\n",
|
||||
progname);
|
||||
avrdude_message("%s: ERROR: unexpected data block at offset != 0\n",
|
||||
progname);
|
||||
} else if (foff >= d->d_size) {
|
||||
fprintf(stderr,
|
||||
"%s: ERROR: ELF file section does not contain byte at offset %d\n",
|
||||
progname, foff);
|
||||
avrdude_message("%s: ERROR: ELF file section does not contain byte at offset %d\n",
|
||||
progname, foff);
|
||||
} else {
|
||||
if (verbose >= 2) {
|
||||
fprintf(stderr,
|
||||
" Extracting one byte from file offset %d\n",
|
||||
foff);
|
||||
avrdude_message(" Extracting one byte from file offset %d\n",
|
||||
foff);
|
||||
}
|
||||
mem->buf[0] = ((unsigned char *)d->d_buf)[foff];
|
||||
mem->tags[0] = TAG_ALLOCATED;
|
||||
|
@ -1062,9 +1030,8 @@ static int elf2b(char * infile, FILE * inf,
|
|||
if ((int)(idx + d->d_size) > rv)
|
||||
rv = idx + d->d_size;
|
||||
if (verbose >= 3) {
|
||||
fprintf(stderr,
|
||||
" Writing %d bytes to mem offset 0x%x\n",
|
||||
d->d_size, idx);
|
||||
avrdude_message(" 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);
|
||||
|
@ -1134,16 +1101,15 @@ static int fileio_rbin(struct fioparms * fio,
|
|||
rc = fwrite(buf, 1, size, f);
|
||||
break;
|
||||
default:
|
||||
fprintf(stderr, "%s: fileio: invalid operation=%d\n",
|
||||
avrdude_message("%s: fileio: invalid operation=%d\n",
|
||||
progname, fio->op);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (rc < 0 || (fio->op == FIO_WRITE && rc < size)) {
|
||||
fprintf(stderr,
|
||||
"%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);
|
||||
avrdude_message("%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;
|
||||
}
|
||||
|
||||
|
@ -1170,9 +1136,8 @@ static int fileio_imm(struct fioparms * fio,
|
|||
strtoul (p, &e, 0):
|
||||
strtoul (p + 2, &e, 2);
|
||||
if (*e != 0) {
|
||||
fprintf(stderr,
|
||||
"%s: invalid byte value (%s) specified for immediate mode\n",
|
||||
progname, p);
|
||||
avrdude_message("%s: invalid byte value (%s) specified for immediate mode\n",
|
||||
progname, p);
|
||||
return -1;
|
||||
}
|
||||
mem->buf[loc] = b;
|
||||
|
@ -1182,16 +1147,15 @@ static int fileio_imm(struct fioparms * fio,
|
|||
}
|
||||
break;
|
||||
default:
|
||||
fprintf(stderr, "%s: fileio: invalid operation=%d\n",
|
||||
avrdude_message("%s: fileio: invalid operation=%d\n",
|
||||
progname, fio->op);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (rc < 0 || (fio->op == FIO_WRITE && rc < size)) {
|
||||
fprintf(stderr,
|
||||
"%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);
|
||||
avrdude_message("%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;
|
||||
}
|
||||
|
||||
|
@ -1219,7 +1183,7 @@ static int fileio_ihex(struct fioparms * fio,
|
|||
break;
|
||||
|
||||
default:
|
||||
fprintf(stderr, "%s: invalid Intex Hex file I/O operation=%d\n",
|
||||
avrdude_message("%s: invalid Intex Hex file I/O operation=%d\n",
|
||||
progname, fio->op);
|
||||
return -1;
|
||||
break;
|
||||
|
@ -1249,7 +1213,7 @@ static int fileio_srec(struct fioparms * fio,
|
|||
break;
|
||||
|
||||
default:
|
||||
fprintf(stderr, "%s: ERROR: invalid Motorola S-Records file I/O "
|
||||
avrdude_message("%s: ERROR: invalid Motorola S-Records file I/O "
|
||||
"operation=%d\n",
|
||||
progname, fio->op);
|
||||
return -1;
|
||||
|
@ -1269,7 +1233,7 @@ static int fileio_elf(struct fioparms * fio,
|
|||
|
||||
switch (fio->op) {
|
||||
case FIO_WRITE:
|
||||
fprintf(stderr, "%s: ERROR: write operation not (yet) "
|
||||
avrdude_message("%s: ERROR: write operation not (yet) "
|
||||
"supported for ELF\n",
|
||||
progname);
|
||||
return -1;
|
||||
|
@ -1280,7 +1244,7 @@ static int fileio_elf(struct fioparms * fio,
|
|||
return rc;
|
||||
|
||||
default:
|
||||
fprintf(stderr, "%s: ERROR: invalid ELF file I/O "
|
||||
avrdude_message("%s: ERROR: invalid ELF file I/O "
|
||||
"operation=%d\n",
|
||||
progname, fio->op);
|
||||
return -1;
|
||||
|
@ -1326,7 +1290,7 @@ static int fileio_num(struct fioparms * fio,
|
|||
case FIO_WRITE:
|
||||
break;
|
||||
default:
|
||||
fprintf(stderr, "%s: fileio: invalid operation=%d\n",
|
||||
avrdude_message("%s: fileio: invalid operation=%d\n",
|
||||
progname, fio->op);
|
||||
return -1;
|
||||
}
|
||||
|
@ -1356,7 +1320,7 @@ static int fileio_num(struct fioparms * fio,
|
|||
return 0;
|
||||
|
||||
writeerr:
|
||||
fprintf(stderr, "%s: error writing to %s: %s\n",
|
||||
avrdude_message("%s: error writing to %s: %s\n",
|
||||
progname, filename, strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
|
@ -1383,7 +1347,7 @@ int fileio_setparms(int op, struct fioparms * fp,
|
|||
break;
|
||||
|
||||
default:
|
||||
fprintf(stderr, "%s: invalid I/O operation %d\n",
|
||||
avrdude_message("%s: invalid I/O operation %d\n",
|
||||
progname, op);
|
||||
return -1;
|
||||
break;
|
||||
|
@ -1422,7 +1386,7 @@ static int fmt_autodetect(char * fname)
|
|||
f = fopen(fname, "rb");
|
||||
#endif
|
||||
if (f == NULL) {
|
||||
fprintf(stderr, "%s: error opening %s: %s\n",
|
||||
avrdude_message("%s: error opening %s: %s\n",
|
||||
progname, fname, strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
|
@ -1505,9 +1469,8 @@ int fileio(int op, char * filename, FILEFMT format,
|
|||
|
||||
mem = avr_locate_mem(p, memtype);
|
||||
if (mem == NULL) {
|
||||
fprintf(stderr,
|
||||
"fileio(): memory type \"%s\" not configured for device \"%s\"\n",
|
||||
memtype, p->desc);
|
||||
avrdude_message("fileio(): memory type \"%s\" not configured for device \"%s\"\n",
|
||||
memtype, p->desc);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -1544,23 +1507,21 @@ int fileio(int op, char * filename, FILEFMT format,
|
|||
|
||||
if (format == FMT_AUTO) {
|
||||
if (using_stdio) {
|
||||
fprintf(stderr,
|
||||
"%s: can't auto detect file format when using stdin/out.\n"
|
||||
"%s Please specify a file format and try again.\n",
|
||||
progname, progbuf);
|
||||
avrdude_message("%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;
|
||||
}
|
||||
|
||||
format = fmt_autodetect(fname);
|
||||
if (format < 0) {
|
||||
fprintf(stderr,
|
||||
"%s: can't determine file format for %s, specify explicitly\n",
|
||||
progname, fname);
|
||||
avrdude_message("%s: can't determine file format for %s, specify explicitly\n",
|
||||
progname, fname);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (quell_progress < 2) {
|
||||
fprintf(stderr, "%s: %s file %s auto detected as %s\n",
|
||||
avrdude_message("%s: %s file %s auto detected as %s\n",
|
||||
progname, fio.iodesc, fname, fmtstr(format));
|
||||
}
|
||||
}
|
||||
|
@ -1584,7 +1545,7 @@ int fileio(int op, char * filename, FILEFMT format,
|
|||
if (!using_stdio) {
|
||||
f = fopen(fname, fio.mode);
|
||||
if (f == NULL) {
|
||||
fprintf(stderr, "%s: can't open %s file %s: %s\n",
|
||||
avrdude_message("%s: can't open %s file %s: %s\n",
|
||||
progname, fio.iodesc, fname, strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
|
@ -1608,10 +1569,9 @@ int fileio(int op, char * filename, FILEFMT format,
|
|||
#ifdef HAVE_LIBELF
|
||||
rc = fileio_elf(&fio, fname, f, mem, p, size);
|
||||
#else
|
||||
fprintf(stderr,
|
||||
"%s: can't handle ELF file %s, "
|
||||
"ELF file support was not compiled in\n",
|
||||
progname, fname);
|
||||
avrdude_message("%s: can't handle ELF file %s, "
|
||||
"ELF file support was not compiled in\n",
|
||||
progname, fname);
|
||||
rc = -1;
|
||||
#endif
|
||||
break;
|
||||
|
@ -1628,7 +1588,7 @@ int fileio(int op, char * filename, FILEFMT format,
|
|||
break;
|
||||
|
||||
default:
|
||||
fprintf(stderr, "%s: invalid %s file format: %d\n",
|
||||
avrdude_message("%s: invalid %s file format: %d\n",
|
||||
progname, fio.iodesc, format);
|
||||
return -1;
|
||||
}
|
||||
|
|
104
flip1.c
104
flip1.c
|
@ -239,18 +239,16 @@ int flip1_initialize(PROGRAMMER* pgm, AVRPART *part)
|
|||
if (usbpid) {
|
||||
pid = *(int *)(ldata(usbpid));
|
||||
if (lnext(usbpid))
|
||||
fprintf(stderr,
|
||||
"%s: Warning: using PID 0x%04x, ignoring remaining PIDs in list\n",
|
||||
progname, pid);
|
||||
avrdude_message("%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)) {
|
||||
fprintf(stderr,
|
||||
"%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);
|
||||
avrdude_message("%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);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -262,31 +260,31 @@ int flip1_initialize(PROGRAMMER* pgm, AVRPART *part)
|
|||
/* Check if descriptor values are what we expect. */
|
||||
|
||||
if (dfu->dev_desc.idVendor != vid)
|
||||
fprintf( stderr, "%s: Warning: USB idVendor = 0x%04X (expected 0x%04X)\n",
|
||||
avrdude_message("%s: Warning: USB idVendor = 0x%04X (expected 0x%04X)\n",
|
||||
progname, dfu->dev_desc.idVendor, vid);
|
||||
|
||||
if (pid != 0 && dfu->dev_desc.idProduct != pid)
|
||||
fprintf( stderr, "%s: Warning: USB idProduct = 0x%04X (expected 0x%04X)\n",
|
||||
avrdude_message("%s: Warning: USB idProduct = 0x%04X (expected 0x%04X)\n",
|
||||
progname, dfu->dev_desc.idProduct, pid);
|
||||
|
||||
if (dfu->dev_desc.bNumConfigurations != 1)
|
||||
fprintf( stderr, "%s: Warning: USB bNumConfigurations = %d (expected 1)\n",
|
||||
avrdude_message("%s: Warning: USB bNumConfigurations = %d (expected 1)\n",
|
||||
progname, (int) dfu->dev_desc.bNumConfigurations);
|
||||
|
||||
if (dfu->conf_desc.bNumInterfaces != 1)
|
||||
fprintf( stderr, "%s: Warning: USB bNumInterfaces = %d (expected 1)\n",
|
||||
avrdude_message("%s: Warning: USB bNumInterfaces = %d (expected 1)\n",
|
||||
progname, (int) dfu->conf_desc.bNumInterfaces);
|
||||
|
||||
if (dfu->dev_desc.bDeviceClass != 254)
|
||||
fprintf( stderr, "%s: Warning: USB bDeviceClass = %d (expected 254)\n",
|
||||
avrdude_message("%s: Warning: USB bDeviceClass = %d (expected 254)\n",
|
||||
progname, (int) dfu->dev_desc.bDeviceClass);
|
||||
|
||||
if (dfu->dev_desc.bDeviceSubClass != 1)
|
||||
fprintf( stderr, "%s: Warning: USB bDeviceSubClass = %d (expected 1)\n",
|
||||
avrdude_message("%s: Warning: USB bDeviceSubClass = %d (expected 1)\n",
|
||||
progname, (int) dfu->dev_desc.bDeviceSubClass);
|
||||
|
||||
if (dfu->dev_desc.bDeviceProtocol != 0)
|
||||
fprintf( stderr, "%s: Warning: USB bDeviceProtocol = %d (expected 0)\n",
|
||||
avrdude_message("%s: Warning: USB bDeviceProtocol = %d (expected 0)\n",
|
||||
progname, (int) dfu->dev_desc.bDeviceProtocol);
|
||||
|
||||
/*
|
||||
|
@ -297,20 +295,20 @@ int flip1_initialize(PROGRAMMER* pgm, AVRPART *part)
|
|||
*/
|
||||
if (0) {
|
||||
if (dfu->intf_desc.bInterfaceClass != 254)
|
||||
fprintf( stderr, "%s: Warning: USB bInterfaceClass = %d (expected 254)\n",
|
||||
avrdude_message("%s: Warning: USB bInterfaceClass = %d (expected 254)\n",
|
||||
progname, (int) dfu->intf_desc.bInterfaceClass);
|
||||
|
||||
if (dfu->intf_desc.bInterfaceSubClass != 1)
|
||||
fprintf( stderr, "%s: Warning: USB bInterfaceSubClass = %d (expected 1)\n",
|
||||
avrdude_message("%s: Warning: USB bInterfaceSubClass = %d (expected 1)\n",
|
||||
progname, (int) dfu->intf_desc.bInterfaceSubClass);
|
||||
|
||||
if (dfu->intf_desc.bInterfaceProtocol != 0)
|
||||
fprintf( stderr, "%s: Warning: USB bInterfaceSubClass = %d (expected 0)\n",
|
||||
avrdude_message("%s: Warning: USB bInterfaceSubClass = %d (expected 0)\n",
|
||||
progname, (int) dfu->intf_desc.bInterfaceProtocol);
|
||||
}
|
||||
|
||||
if (dfu->dev_desc.bMaxPacketSize0 != 32)
|
||||
fprintf( stderr, "%s: Warning: bMaxPacketSize0 (%d) != 32, things might go wrong\n",
|
||||
avrdude_message("%s: Warning: bMaxPacketSize0 (%d) != 32, things might go wrong\n",
|
||||
progname, dfu->dev_desc.bMaxPacketSize0);
|
||||
|
||||
if (verbose)
|
||||
|
@ -367,7 +365,7 @@ int flip1_chip_erase(PROGRAMMER* pgm, AVRPART *part)
|
|||
unsigned int default_timeout = FLIP1(pgm)->dfu->timeout;
|
||||
|
||||
if (verbose > 1)
|
||||
fprintf(stderr, "%s: flip_chip_erase()\n", progname);
|
||||
avrdude_message("%s: flip_chip_erase()\n", progname);
|
||||
|
||||
struct flip1_cmd cmd = {
|
||||
FLIP1_CMD_WRITE_COMMAND, { 0, 0xff }
|
||||
|
@ -382,7 +380,7 @@ int flip1_chip_erase(PROGRAMMER* pgm, AVRPART *part)
|
|||
return -1;
|
||||
|
||||
if (status.bStatus != DFU_STATUS_OK) {
|
||||
fprintf(stderr, "%s: failed to send chip erase command: %s\n",
|
||||
avrdude_message("%s: failed to send chip erase command: %s\n",
|
||||
progname, flip1_status_str(&status));
|
||||
if (status.bState == STATE_dfuERROR)
|
||||
dfu_clrstatus(FLIP1(pgm)->dfu);
|
||||
|
@ -404,7 +402,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) {
|
||||
fprintf(stderr, "%s: flip1_read_byte(signature): address %lu out of range\n",
|
||||
avrdude_message("%s: flip1_read_byte(signature): address %lu out of range\n",
|
||||
progname, addr);
|
||||
return -1;
|
||||
}
|
||||
|
@ -415,10 +413,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) {
|
||||
fprintf(stderr, "%s: Error: "
|
||||
avrdude_message("%s: Error: "
|
||||
"\"%s\" memory not accessible using FLIP",
|
||||
progname, mem->desc);
|
||||
fprintf(stderr, "\n");
|
||||
avrdude_message("\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -440,10 +438,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) {
|
||||
fprintf(stderr, "%s: Error: "
|
||||
avrdude_message("%s: Error: "
|
||||
"\"%s\" memory not accessible using FLIP",
|
||||
progname, mem->desc);
|
||||
fprintf(stderr, "\n");
|
||||
avrdude_message("\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -461,10 +459,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) {
|
||||
fprintf(stderr, "%s: Error: "
|
||||
avrdude_message("%s: Error: "
|
||||
"\"%s\" memory not accessible using FLIP",
|
||||
progname, mem->desc);
|
||||
fprintf(stderr, "\n");
|
||||
avrdude_message("\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -487,16 +485,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) {
|
||||
fprintf(stderr, "%s: Error: "
|
||||
avrdude_message("%s: Error: "
|
||||
"\"%s\" memory not accessible using FLIP",
|
||||
progname, mem->desc);
|
||||
fprintf(stderr, "\n");
|
||||
avrdude_message("\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (n_bytes > INT_MAX) {
|
||||
/* This should never happen, unless the int type is only 16 bits. */
|
||||
fprintf(stderr, "%s: Error: Attempting to read more than %d bytes\n",
|
||||
avrdude_message("%s: Error: Attempting to read more than %d bytes\n",
|
||||
progname, INT_MAX);
|
||||
exit(1);
|
||||
}
|
||||
|
@ -510,13 +508,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)
|
||||
fprintf(stderr, "%s: flip1_read_sig_bytes(): ", progname);
|
||||
avrdude_message("%s: flip1_read_sig_bytes(): ", progname);
|
||||
|
||||
if (FLIP1(pgm)->dfu == NULL)
|
||||
return -1;
|
||||
|
||||
if (mem->size < sizeof(FLIP1(pgm)->part_sig)) {
|
||||
fprintf(stderr, "%s: Error: Signature read must be at least %u bytes\n",
|
||||
avrdude_message("%s: Error: Signature read must be at least %u bytes\n",
|
||||
progname, (unsigned int) sizeof(FLIP1(pgm)->part_sig));
|
||||
return -1;
|
||||
}
|
||||
|
@ -535,7 +533,7 @@ int flip1_read_sig_bytes(PROGRAMMER* pgm, AVRPART *part, AVRMEM *mem)
|
|||
};
|
||||
|
||||
if (verbose > 1)
|
||||
fprintf(stderr, "from device\n");
|
||||
avrdude_message("from device\n");
|
||||
|
||||
for (i = 0; i < 3; i++)
|
||||
{
|
||||
|
@ -552,7 +550,7 @@ int flip1_read_sig_bytes(PROGRAMMER* pgm, AVRPART *part, AVRMEM *mem)
|
|||
|
||||
if (status.bStatus != DFU_STATUS_OK)
|
||||
{
|
||||
fprintf(stderr, "%s: failed to send cmd for signature byte %d: %s\n",
|
||||
avrdude_message("%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);
|
||||
|
@ -567,7 +565,7 @@ int flip1_read_sig_bytes(PROGRAMMER* pgm, AVRPART *part, AVRMEM *mem)
|
|||
|
||||
if (status.bStatus != DFU_STATUS_OK)
|
||||
{
|
||||
fprintf(stderr, "%s: failed to read signature byte %d: %s\n",
|
||||
avrdude_message("%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);
|
||||
|
@ -578,7 +576,7 @@ int flip1_read_sig_bytes(PROGRAMMER* pgm, AVRPART *part, AVRMEM *mem)
|
|||
else
|
||||
{
|
||||
if (verbose > 1)
|
||||
fprintf(stderr, "cached\n");
|
||||
avrdude_message("cached\n");
|
||||
}
|
||||
|
||||
memcpy(mem->buf, FLIP1(pgm)->part_sig, sizeof(FLIP1(pgm)->part_sig));
|
||||
|
@ -591,7 +589,7 @@ void flip1_setup(PROGRAMMER * pgm)
|
|||
pgm->cookie = calloc(1, sizeof(struct flip1));
|
||||
|
||||
if (pgm->cookie == NULL) {
|
||||
fprintf(stderr, "%s: Out of memory allocating private data structure\n",
|
||||
avrdude_message("%s: Out of memory allocating private data structure\n",
|
||||
progname);
|
||||
exit(1);
|
||||
}
|
||||
|
@ -609,7 +607,7 @@ void flip1_teardown(PROGRAMMER * pgm)
|
|||
void flip1_show_info(struct flip1 *flip1)
|
||||
{
|
||||
dfu_show_info(flip1->dfu);
|
||||
fprintf(stderr, " USB max packet size : %hu\n",
|
||||
avrdude_message(" USB max packet size : %hu\n",
|
||||
(unsigned short) flip1->dfu->dev_desc.bMaxPacketSize0);
|
||||
}
|
||||
|
||||
|
@ -628,9 +626,8 @@ int flip1_read_memory(PROGRAMMER * pgm,
|
|||
|
||||
|
||||
if (verbose > 1)
|
||||
fprintf(stderr,
|
||||
"%s: flip_read_memory(%s, 0x%04x, %d)\n",
|
||||
progname, flip1_mem_unit_str(mem_unit), addr, size);
|
||||
avrdude_message("%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
|
||||
|
@ -660,7 +657,7 @@ int flip1_read_memory(PROGRAMMER * pgm,
|
|||
|
||||
if (status.bStatus != DFU_STATUS_OK)
|
||||
{
|
||||
fprintf(stderr, "%s: failed to read %u bytes of %s memory @%u: %s\n",
|
||||
avrdude_message("%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)
|
||||
|
@ -674,8 +671,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)
|
||||
fprintf(stderr,
|
||||
"\n%s:\n"
|
||||
avrdude_message("\n%s:\n"
|
||||
"%s***********************************************************************\n"
|
||||
"%sMaybe the device is in ``security mode´´, and needs a chip erase first?\n"
|
||||
"%s***********************************************************************\n"
|
||||
|
@ -689,7 +685,7 @@ int flip1_read_memory(PROGRAMMER * pgm,
|
|||
|
||||
if (status.bStatus != DFU_STATUS_OK)
|
||||
{
|
||||
fprintf(stderr, "%s: failed to read %u bytes of %s memory @%u: %s\n",
|
||||
avrdude_message("%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)
|
||||
|
@ -724,16 +720,14 @@ int flip1_write_memory(struct dfu_dev *dfu,
|
|||
unsigned char *buf;
|
||||
|
||||
if (verbose > 1)
|
||||
fprintf(stderr,
|
||||
"%s: flip_write_memory(%s, 0x%04x, %d)\n",
|
||||
progname, flip1_mem_unit_str(mem_unit), addr, size);
|
||||
avrdude_message("%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) {
|
||||
fprintf(stderr,
|
||||
"%s: flip_write_memory(): begin (0x%x) and end (0x%x) not within same 32-byte block\n",
|
||||
progname, addr, addr + size - 1);
|
||||
avrdude_message("%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;
|
||||
}
|
||||
write_size = 32;
|
||||
|
@ -744,7 +738,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) {
|
||||
fprintf(stderr, "%s: Out of memory\n", progname);
|
||||
avrdude_message("%s: Out of memory\n", progname);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -793,7 +787,7 @@ int flip1_write_memory(struct dfu_dev *dfu,
|
|||
|
||||
if (status.bStatus != DFU_STATUS_OK)
|
||||
{
|
||||
fprintf(stderr, "%s: failed to write %u bytes of %s memory @%u: %s\n",
|
||||
avrdude_message("%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)
|
||||
|
@ -824,7 +818,7 @@ int flip1_set_mem_page(struct dfu_dev *dfu,
|
|||
|
||||
if (status.bStatus != DFU_STATUS_OK)
|
||||
{
|
||||
fprintf(stderr, "%s: failed to set memory page: %s\n",
|
||||
avrdude_message("%s: failed to set memory page: %s\n",
|
||||
progname, flip1_status_str(&status));
|
||||
if (status.bState == STATE_dfuERROR)
|
||||
dfu_clrstatus(dfu);
|
||||
|
|
128
flip2.c
128
flip2.c
|
@ -233,19 +233,17 @@ int flip2_initialize(PROGRAMMER* pgm, AVRPART *part)
|
|||
if (usbpid) {
|
||||
pid = *(int *)(ldata(usbpid));
|
||||
if (lnext(usbpid))
|
||||
fprintf(stderr,
|
||||
"%s: Warning: using PID 0x%04x, ignoring remaining PIDs in list\n",
|
||||
progname, pid);
|
||||
avrdude_message("%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)) {
|
||||
fprintf(stderr,
|
||||
"%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);
|
||||
avrdude_message("%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);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -257,43 +255,43 @@ int flip2_initialize(PROGRAMMER* pgm, AVRPART *part)
|
|||
/* Check if descriptor values are what we expect. */
|
||||
|
||||
if (dfu->dev_desc.idVendor != vid)
|
||||
fprintf( stderr, "%s: Warning: USB idVendor = 0x%04X (expected 0x%04X)\n",
|
||||
avrdude_message("%s: Warning: USB idVendor = 0x%04X (expected 0x%04X)\n",
|
||||
progname, dfu->dev_desc.idVendor, vid);
|
||||
|
||||
if (pid != 0 && dfu->dev_desc.idProduct != pid)
|
||||
fprintf( stderr, "%s: Warning: USB idProduct = 0x%04X (expected 0x%04X)\n",
|
||||
avrdude_message("%s: Warning: USB idProduct = 0x%04X (expected 0x%04X)\n",
|
||||
progname, dfu->dev_desc.idProduct, pid);
|
||||
|
||||
if (dfu->dev_desc.bNumConfigurations != 1)
|
||||
fprintf( stderr, "%s: Warning: USB bNumConfigurations = %d (expected 1)\n",
|
||||
avrdude_message("%s: Warning: USB bNumConfigurations = %d (expected 1)\n",
|
||||
progname, (int) dfu->dev_desc.bNumConfigurations);
|
||||
|
||||
if (dfu->conf_desc.bNumInterfaces != 1)
|
||||
fprintf( stderr, "%s: Warning: USB bNumInterfaces = %d (expected 1)\n",
|
||||
avrdude_message("%s: Warning: USB bNumInterfaces = %d (expected 1)\n",
|
||||
progname, (int) dfu->conf_desc.bNumInterfaces);
|
||||
|
||||
if (dfu->dev_desc.bDeviceClass != 0)
|
||||
fprintf( stderr, "%s: Warning: USB bDeviceClass = %d (expected 0)\n",
|
||||
avrdude_message("%s: Warning: USB bDeviceClass = %d (expected 0)\n",
|
||||
progname, (int) dfu->dev_desc.bDeviceClass);
|
||||
|
||||
if (dfu->dev_desc.bDeviceSubClass != 0)
|
||||
fprintf( stderr, "%s: Warning: USB bDeviceSubClass = %d (expected 0)\n",
|
||||
avrdude_message("%s: Warning: USB bDeviceSubClass = %d (expected 0)\n",
|
||||
progname, (int) dfu->dev_desc.bDeviceSubClass);
|
||||
|
||||
if (dfu->dev_desc.bDeviceProtocol != 0)
|
||||
fprintf( stderr, "%s: Warning: USB bDeviceProtocol = %d (expected 0)\n",
|
||||
avrdude_message("%s: Warning: USB bDeviceProtocol = %d (expected 0)\n",
|
||||
progname, (int) dfu->dev_desc.bDeviceProtocol);
|
||||
|
||||
if (dfu->intf_desc.bInterfaceClass != 0xFF)
|
||||
fprintf( stderr, "%s: Warning: USB bInterfaceClass = %d (expected 255)\n",
|
||||
avrdude_message("%s: Warning: USB bInterfaceClass = %d (expected 255)\n",
|
||||
progname, (int) dfu->intf_desc.bInterfaceClass);
|
||||
|
||||
if (dfu->intf_desc.bInterfaceSubClass != 0)
|
||||
fprintf( stderr, "%s: Warning: USB bInterfaceSubClass = %d (expected 0)\n",
|
||||
avrdude_message("%s: Warning: USB bInterfaceSubClass = %d (expected 0)\n",
|
||||
progname, (int) dfu->intf_desc.bInterfaceSubClass);
|
||||
|
||||
if (dfu->intf_desc.bInterfaceProtocol != 0)
|
||||
fprintf( stderr, "%s: Warning: USB bInterfaceSubClass = %d (expected 0)\n",
|
||||
avrdude_message("%s: Warning: USB bInterfaceSubClass = %d (expected 0)\n",
|
||||
progname, (int) dfu->intf_desc.bInterfaceProtocol);
|
||||
|
||||
result = flip2_read_memory(FLIP2(pgm)->dfu,
|
||||
|
@ -359,7 +357,7 @@ int flip2_chip_erase(PROGRAMMER* pgm, AVRPART *part)
|
|||
int aux_result;
|
||||
|
||||
if (verbose > 1)
|
||||
fprintf(stderr, "%s: flip_chip_erase()\n", progname);
|
||||
avrdude_message("%s: flip_chip_erase()\n", progname);
|
||||
|
||||
struct flip2_cmd cmd = {
|
||||
FLIP2_CMD_GROUP_EXEC, FLIP2_CMD_CHIP_ERASE, { 0xFF, 0, 0, 0 }
|
||||
|
@ -378,7 +376,7 @@ int flip2_chip_erase(PROGRAMMER* pgm, AVRPART *part)
|
|||
{
|
||||
continue;
|
||||
} else
|
||||
fprintf(stderr, "%s: Error: DFU status %s\n", progname,
|
||||
avrdude_message("%s: Error: DFU status %s\n", progname,
|
||||
flip2_status_str(&status));
|
||||
dfu_clrstatus(FLIP2(pgm)->dfu);
|
||||
} else
|
||||
|
@ -399,12 +397,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) {
|
||||
fprintf(stderr, "%s: Error: "
|
||||
avrdude_message("%s: Error: "
|
||||
"\"%s\" memory not accessible using FLIP",
|
||||
progname, mem->desc);
|
||||
if (strcmp(mem->desc, "flash") == 0)
|
||||
fprintf(stderr, " (did you mean \"application\"?)");
|
||||
fprintf(stderr, "\n");
|
||||
avrdude_message(" (did you mean \"application\"?)");
|
||||
avrdude_message("\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -422,12 +420,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) {
|
||||
fprintf(stderr, "%s: Error: "
|
||||
avrdude_message("%s: Error: "
|
||||
"\"%s\" memory not accessible using FLIP",
|
||||
progname, mem->desc);
|
||||
if (strcmp(mem->desc, "flash") == 0)
|
||||
fprintf(stderr, " (did you mean \"application\"?)");
|
||||
fprintf(stderr, "\n");
|
||||
avrdude_message(" (did you mean \"application\"?)");
|
||||
avrdude_message("\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -446,18 +444,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) {
|
||||
fprintf(stderr, "%s: Error: "
|
||||
avrdude_message("%s: Error: "
|
||||
"\"%s\" memory not accessible using FLIP",
|
||||
progname, mem->desc);
|
||||
if (strcmp(mem->desc, "flash") == 0)
|
||||
fprintf(stderr, " (did you mean \"application\"?)");
|
||||
fprintf(stderr, "\n");
|
||||
avrdude_message(" (did you mean \"application\"?)");
|
||||
avrdude_message("\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (n_bytes > INT_MAX) {
|
||||
/* This should never happen, unless the int type is only 16 bits. */
|
||||
fprintf(stderr, "%s: Error: Attempting to read more than %d bytes\n",
|
||||
avrdude_message("%s: Error: Attempting to read more than %d bytes\n",
|
||||
progname, INT_MAX);
|
||||
exit(1);
|
||||
}
|
||||
|
@ -480,18 +478,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) {
|
||||
fprintf(stderr, "%s: Error: "
|
||||
avrdude_message("%s: Error: "
|
||||
"\"%s\" memory not accessible using FLIP",
|
||||
progname, mem->desc);
|
||||
if (strcmp(mem->desc, "flash") == 0)
|
||||
fprintf(stderr, " (did you mean \"application\"?)");
|
||||
fprintf(stderr, "\n");
|
||||
avrdude_message(" (did you mean \"application\"?)");
|
||||
avrdude_message("\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (n_bytes > INT_MAX) {
|
||||
/* This should never happen, unless the int type is only 16 bits. */
|
||||
fprintf(stderr, "%s: Error: Attempting to read more than %d bytes\n",
|
||||
avrdude_message("%s: Error: Attempting to read more than %d bytes\n",
|
||||
progname, INT_MAX);
|
||||
exit(1);
|
||||
}
|
||||
|
@ -508,7 +506,7 @@ int flip2_read_sig_bytes(PROGRAMMER* pgm, AVRPART *part, AVRMEM *mem)
|
|||
return -1;
|
||||
|
||||
if (mem->size < sizeof(FLIP2(pgm)->part_sig)) {
|
||||
fprintf(stderr, "%s: Error: Signature read must be at least %u bytes\n",
|
||||
avrdude_message("%s: Error: Signature read must be at least %u bytes\n",
|
||||
progname, (unsigned int) sizeof(FLIP2(pgm)->part_sig));
|
||||
return -1;
|
||||
}
|
||||
|
@ -522,7 +520,7 @@ void flip2_setup(PROGRAMMER * pgm)
|
|||
pgm->cookie = calloc(1, sizeof(struct flip2));
|
||||
|
||||
if (pgm->cookie == NULL) {
|
||||
fprintf(stderr, "%s: Out of memory allocating private data structure\n",
|
||||
avrdude_message("%s: Out of memory allocating private data structure\n",
|
||||
progname);
|
||||
exit(1);
|
||||
}
|
||||
|
@ -541,24 +539,24 @@ void flip2_show_info(struct flip2 *flip2)
|
|||
{
|
||||
dfu_show_info(flip2->dfu);
|
||||
|
||||
fprintf(stderr, " Part signature : 0x%02X%02X%02X\n",
|
||||
avrdude_message(" 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)
|
||||
fprintf(stderr, " Part revision : %c\n",
|
||||
avrdude_message(" Part revision : %c\n",
|
||||
(char) (flip2->part_rev + 'A'));
|
||||
else
|
||||
fprintf(stderr, " Part revision : %c%c\n",
|
||||
avrdude_message(" Part revision : %c%c\n",
|
||||
(char) (flip2->part_rev / 26 - 1 + 'A'),
|
||||
(char) (flip2->part_rev % 26 + 'A'));
|
||||
|
||||
fprintf(stderr, " Bootloader version : 2.%hu.%hu\n",
|
||||
avrdude_message(" Bootloader version : 2.%hu.%hu\n",
|
||||
((unsigned short) flip2->boot_ver >> 4) & 0xF,
|
||||
((unsigned short) flip2->boot_ver >> 0) & 0xF);
|
||||
|
||||
fprintf(stderr, " USB max packet size : %hu\n",
|
||||
avrdude_message(" USB max packet size : %hu\n",
|
||||
(unsigned short) flip2->dfu->dev_desc.bMaxPacketSize0);
|
||||
}
|
||||
|
||||
|
@ -572,18 +570,17 @@ int flip2_read_memory(struct dfu_dev *dfu,
|
|||
int result;
|
||||
|
||||
if (verbose > 1)
|
||||
fprintf(stderr,
|
||||
"%s: flip_read_memory(%s, 0x%04x, %d)\n",
|
||||
progname, flip2_mem_unit_str(mem_unit), addr, size);
|
||||
avrdude_message("%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)
|
||||
fprintf(stderr, "%s: Error: Failed to set memory unit 0x%02X (%s)\n",
|
||||
avrdude_message("%s: Error: Failed to set memory unit 0x%02X (%s)\n",
|
||||
progname, (int) mem_unit, mem_name);
|
||||
else
|
||||
fprintf(stderr, "%s: Error: Failed to set memory unit 0x%02X\n",
|
||||
avrdude_message("%s: Error: Failed to set memory unit 0x%02X\n",
|
||||
progname, (int) mem_unit);
|
||||
return -1;
|
||||
}
|
||||
|
@ -592,7 +589,7 @@ int flip2_read_memory(struct dfu_dev *dfu,
|
|||
result = flip2_set_mem_page(dfu, page_addr);
|
||||
|
||||
if (result != 0) {
|
||||
fprintf(stderr, "%s: Error: Failed to set memory page 0x%04hX\n",
|
||||
avrdude_message("%s: Error: Failed to set memory page 0x%04hX\n",
|
||||
progname, page_addr);
|
||||
return -1;
|
||||
}
|
||||
|
@ -604,7 +601,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) {
|
||||
fprintf(stderr, "%s: Error: Failed to set memory page 0x%04hX\n",
|
||||
avrdude_message("%s: Error: Failed to set memory page 0x%04hX\n",
|
||||
progname, page_addr);
|
||||
return -1;
|
||||
}
|
||||
|
@ -614,7 +611,7 @@ int flip2_read_memory(struct dfu_dev *dfu,
|
|||
result = flip2_read_max1k(dfu, addr & 0xFFFF, ptr, read_size);
|
||||
|
||||
if (result != 0) {
|
||||
fprintf(stderr, "%s: Error: Failed to read 0x%04X bytes at 0x%04lX\n",
|
||||
avrdude_message("%s: Error: Failed to read 0x%04X bytes at 0x%04lX\n",
|
||||
progname, read_size, (unsigned long) addr);
|
||||
return -1;
|
||||
}
|
||||
|
@ -637,18 +634,17 @@ int flip2_write_memory(struct dfu_dev *dfu,
|
|||
int result;
|
||||
|
||||
if (verbose > 1)
|
||||
fprintf(stderr,
|
||||
"%s: flip_write_memory(%s, 0x%04x, %d)\n",
|
||||
progname, flip2_mem_unit_str(mem_unit), addr, size);
|
||||
avrdude_message("%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)
|
||||
fprintf(stderr, "%s: Error: Failed to set memory unit 0x%02X (%s)\n",
|
||||
avrdude_message("%s: Error: Failed to set memory unit 0x%02X (%s)\n",
|
||||
progname, (int) mem_unit, mem_name);
|
||||
else
|
||||
fprintf(stderr, "%s: Error: Failed to set memory unit 0x%02X\n",
|
||||
avrdude_message("%s: Error: Failed to set memory unit 0x%02X\n",
|
||||
progname, (int) mem_unit);
|
||||
return -1;
|
||||
}
|
||||
|
@ -657,7 +653,7 @@ int flip2_write_memory(struct dfu_dev *dfu,
|
|||
result = flip2_set_mem_page(dfu, page_addr);
|
||||
|
||||
if (result != 0) {
|
||||
fprintf(stderr, "%s: Error: Failed to set memory page 0x%04hX\n",
|
||||
avrdude_message("%s: Error: Failed to set memory page 0x%04hX\n",
|
||||
progname, page_addr);
|
||||
return -1;
|
||||
}
|
||||
|
@ -669,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) {
|
||||
fprintf(stderr, "%s: Error: Failed to set memory page 0x%04hX\n",
|
||||
avrdude_message("%s: Error: Failed to set memory page 0x%04hX\n",
|
||||
progname, page_addr);
|
||||
return -1;
|
||||
}
|
||||
|
@ -679,7 +675,7 @@ int flip2_write_memory(struct dfu_dev *dfu,
|
|||
result = flip2_write_max1k(dfu, addr & 0xFFFF, ptr, write_size);
|
||||
|
||||
if (result != 0) {
|
||||
fprintf(stderr, "%s: Error: Failed to write 0x%04X bytes at 0x%04lX\n",
|
||||
avrdude_message("%s: Error: Failed to write 0x%04X bytes at 0x%04lX\n",
|
||||
progname, write_size, (unsigned long) addr);
|
||||
return -1;
|
||||
}
|
||||
|
@ -716,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))
|
||||
{
|
||||
fprintf(stderr, "%s: Error: Unknown memory unit (0x%02x)\n",
|
||||
avrdude_message("%s: Error: Unknown memory unit (0x%02x)\n",
|
||||
progname, (unsigned int) mem_unit);
|
||||
} else
|
||||
fprintf(stderr, "%s: Error: DFU status %s\n", progname,
|
||||
avrdude_message("%s: Error: DFU status %s\n", progname,
|
||||
flip2_status_str(&status));
|
||||
dfu_clrstatus(dfu);
|
||||
}
|
||||
|
@ -753,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))
|
||||
{
|
||||
fprintf(stderr, "%s: Error: Page address out of range (0x%04hx)\n",
|
||||
avrdude_message("%s: Error: Page address out of range (0x%04hx)\n",
|
||||
progname, page_addr);
|
||||
} else
|
||||
fprintf(stderr, "%s: Error: DFU status %s\n", progname,
|
||||
avrdude_message("%s: Error: DFU status %s\n", progname,
|
||||
flip2_status_str(&status));
|
||||
dfu_clrstatus(dfu);
|
||||
}
|
||||
|
@ -798,10 +794,10 @@ flip2_read_max1k_status:
|
|||
if (status.bStatus == ((FLIP2_STATUS_OUTOFRANGE >> 8) & 0xFF) &&
|
||||
status.bState == ((FLIP2_STATUS_OUTOFRANGE >> 0) & 0xFF))
|
||||
{
|
||||
fprintf(stderr, "%s: Error: Address out of range [0x%04hX,0x%04hX]\n",
|
||||
avrdude_message("%s: Error: Address out of range [0x%04hX,0x%04hX]\n",
|
||||
progname, offset, offset+size-1);
|
||||
} else
|
||||
fprintf(stderr, "%s: Error: DFU status %s\n", progname,
|
||||
avrdude_message("%s: Error: DFU status %s\n", progname,
|
||||
flip2_status_str(&status));
|
||||
dfu_clrstatus(dfu);
|
||||
}
|
||||
|
@ -828,7 +824,7 @@ int flip2_write_max1k(struct dfu_dev *dfu,
|
|||
cmd.args[3] = ((offset+size-1) >> 0) & 0xFF;
|
||||
|
||||
if (size > 0x400) {
|
||||
fprintf(stderr, "%s: Error: Write block too large (%hu > 1024)\n",
|
||||
avrdude_message("%s: Error: Write block too large (%hu > 1024)\n",
|
||||
progname, size);
|
||||
return -1;
|
||||
}
|
||||
|
@ -859,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))
|
||||
{
|
||||
fprintf(stderr, "%s: Error: Address out of range [0x%04hX,0x%04hX]\n",
|
||||
avrdude_message("%s: Error: Address out of range [0x%04hX,0x%04hX]\n",
|
||||
progname, offset, offset+size-1);
|
||||
} else
|
||||
fprintf(stderr, "%s: Error: DFU status %s\n", progname,
|
||||
avrdude_message("%s: Error: DFU status %s\n", progname,
|
||||
flip2_status_str(&status));
|
||||
dfu_clrstatus(dfu);
|
||||
}
|
||||
|
|
49
ft245r.c
49
ft245r.c
|
@ -92,8 +92,7 @@
|
|||
#ifndef HAVE_PTHREAD_H
|
||||
|
||||
static int ft245r_nopthread_open (struct programmer_t *pgm, char * name) {
|
||||
fprintf(stderr,
|
||||
"%s: error: no pthread support. Please compile again with pthread installed."
|
||||
avrdude_message("%s: error: no pthread support. Please compile again with pthread installed."
|
||||
#if defined(_WIN32)
|
||||
" See http://sourceware.org/pthreads-win32/."
|
||||
#endif
|
||||
|
@ -111,9 +110,8 @@ void ft245r_initpgm(PROGRAMMER * pgm) {
|
|||
#elif defined(DO_NOT_BUILD_FT245R)
|
||||
|
||||
static int ft245r_noftdi_open (struct programmer_t *pgm, char * name) {
|
||||
fprintf(stderr,
|
||||
"%s: error: no libftdi or libusb support. Install libftdi1/libusb-1.0 or libftdi/libusb and run configure/make again.\n",
|
||||
progname);
|
||||
avrdude_message("%s: error: no libftdi or libusb support. Install libftdi1/libusb-1.0 or libftdi/libusb and run configure/make again.\n",
|
||||
progname);
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
@ -170,7 +168,7 @@ static void add_to_buf (unsigned char c) {
|
|||
else nh = head + 1;
|
||||
|
||||
if (nh == tail) {
|
||||
fprintf (stderr, "buffer overflow. Cannot happen!\n");
|
||||
avrdude_message("buffer overflow. Cannot happen!\n");
|
||||
}
|
||||
buffer[head] = c;
|
||||
head = nh;
|
||||
|
@ -240,7 +238,7 @@ static int ft245r_chip_erase(PROGRAMMER * pgm, AVRPART * p) {
|
|||
unsigned char res[4];
|
||||
|
||||
if (p->op[AVR_OP_CHIP_ERASE] == NULL) {
|
||||
fprintf(stderr, "chip erase instruction not defined for part \"%s\"\n",
|
||||
avrdude_message("chip erase instruction not defined for part \"%s\"\n",
|
||||
p->desc);
|
||||
return -1;
|
||||
}
|
||||
|
@ -266,12 +264,12 @@ static int ft245r_set_bitclock(PROGRAMMER * pgm) {
|
|||
}
|
||||
|
||||
if ((verbose>1) || FT245R_DEBUG) {
|
||||
fprintf(stderr," ft245r: spi bitclk %d -> ft baudrate %d\n",
|
||||
avrdude_message(" ft245r: spi bitclk %d -> ft baudrate %d\n",
|
||||
rate / 2, rate);
|
||||
}
|
||||
r = ftdi_set_baudrate(handle, rate);
|
||||
if (r) {
|
||||
fprintf(stderr, "Set baudrate (%d) failed with error '%s'.\n",
|
||||
avrdude_message("Set baudrate (%d) failed with error '%s'.\n",
|
||||
rate, ftdi_get_error_string (handle));
|
||||
return -1;
|
||||
}
|
||||
|
@ -378,8 +376,8 @@ static int ft245r_program_enable(PROGRAMMER * pgm, AVRPART * p) {
|
|||
int i;
|
||||
|
||||
if (p->op[AVR_OP_PGM_ENABLE] == NULL) {
|
||||
fprintf(stderr,
|
||||
"%s: AVR_OP_PGM_ENABLE command not defined for %s\n", progname, p->desc);
|
||||
avrdude_message("%s: AVR_OP_PGM_ENABLE command not defined for %s\n",
|
||||
progname, p->desc);
|
||||
fflush(stderr);
|
||||
return -1;
|
||||
}
|
||||
|
@ -392,8 +390,8 @@ static int ft245r_program_enable(PROGRAMMER * pgm, AVRPART * p) {
|
|||
if (res[p->pollindex-1] == p->pollvalue) return 0;
|
||||
|
||||
if ((verbose>=1) || FT245R_DEBUG) {
|
||||
fprintf(stderr,
|
||||
"%s: Program enable command not successful. Retrying.\n", progname);
|
||||
avrdude_message("%s: Program enable command not successful. Retrying.\n",
|
||||
progname);
|
||||
fflush(stderr);
|
||||
}
|
||||
set_pin(pgm, PIN_AVR_RESET, ON);
|
||||
|
@ -406,8 +404,8 @@ static int ft245r_program_enable(PROGRAMMER * pgm, AVRPART * p) {
|
|||
}
|
||||
}
|
||||
|
||||
fprintf(stderr,
|
||||
"%s: Device is not responding to program enable. Check connection.\n", progname);
|
||||
avrdude_message("%s: Device is not responding to program enable. Check connection.\n",
|
||||
progname);
|
||||
fflush(stderr);
|
||||
|
||||
return -1;
|
||||
|
@ -546,9 +544,8 @@ static int ft245r_open(PROGRAMMER * pgm, char * port) {
|
|||
}
|
||||
}
|
||||
if (devnum < 0) {
|
||||
fprintf(stderr,
|
||||
"%s: invalid portname '%s': use 'ft[0-9]+'\n",
|
||||
progname,port);
|
||||
avrdude_message("%s: invalid portname '%s': use 'ft[0-9]+'\n",
|
||||
progname,port);
|
||||
return -1;
|
||||
}
|
||||
} else {
|
||||
|
@ -562,8 +559,7 @@ static int ft245r_open(PROGRAMMER * pgm, char * port) {
|
|||
if (usbpid) {
|
||||
pid = *(int *)(ldata(usbpid));
|
||||
if (lnext(usbpid))
|
||||
fprintf(stderr,
|
||||
"%s: Warning: using PID 0x%04x, ignoring remaining PIDs in list\n",
|
||||
avrdude_message("%s: Warning: using PID 0x%04x, ignoring remaining PIDs in list\n",
|
||||
progname, pid);
|
||||
} else {
|
||||
pid = USB_DEVICE_FT245;
|
||||
|
@ -575,7 +571,7 @@ static int ft245r_open(PROGRAMMER * pgm, char * port) {
|
|||
pgm->usbsn[0]?pgm->usbsn:NULL,
|
||||
devnum);
|
||||
if (rv) {
|
||||
fprintf (stderr, "can't open ftdi device %d. (%s)\n", devnum, ftdi_get_error_string(handle));
|
||||
avrdude_message("can't open ftdi device %d. (%s)\n", devnum, ftdi_get_error_string(handle));
|
||||
goto cleanup_no_usb;
|
||||
}
|
||||
|
||||
|
@ -605,9 +601,8 @@ static int ft245r_open(PROGRAMMER * pgm, char * port) {
|
|||
|
||||
rv = ftdi_set_bitmode(handle, ft245r_ddr, BITMODE_SYNCBB); // set Synchronous BitBang
|
||||
if (rv) {
|
||||
fprintf(stderr,
|
||||
"%s: Synchronous BitBangMode is not supported (%s)\n",
|
||||
progname, ftdi_get_error_string(handle));
|
||||
avrdude_message("%s: Synchronous BitBangMode is not supported (%s)\n",
|
||||
progname, ftdi_get_error_string(handle));
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
|
@ -660,7 +655,7 @@ static void ft245r_close(PROGRAMMER * pgm) {
|
|||
}
|
||||
|
||||
static void ft245r_display(PROGRAMMER * pgm, const char * p) {
|
||||
fprintf(stderr, "%sPin assignment : 0..7 = DBUS0..7\n",p);/* , 8..11 = GPIO0..3\n",p);*/
|
||||
avrdude_message("%sPin assignment : 0..7 = DBUS0..7\n",p);/* , 8..11 = GPIO0..3\n",p);*/
|
||||
pgm_display_generic_mask(pgm, p, SHOW_ALL_PINS);
|
||||
}
|
||||
|
||||
|
@ -713,7 +708,7 @@ static void put_request(int addr, int bytes, int n) {
|
|||
} else {
|
||||
p = malloc(sizeof(struct ft245r_request));
|
||||
if (!p) {
|
||||
fprintf(stderr, "can't alloc memory\n");
|
||||
avrdude_message("can't alloc memory\n");
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
@ -807,7 +802,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
|
||||
fprintf(stderr, "send addr 0x%04x bufsize %d [%02x %02x] page_write %d\n",
|
||||
avrdude_message("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) ),
|
||||
|
|
383
jtag3.c
383
jtag3.c
|
@ -110,9 +110,8 @@ 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) {
|
||||
fprintf(stderr,
|
||||
"%s: jtag3_setup(): Out of memory allocating private data\n",
|
||||
progname);
|
||||
avrdude_message("%s: jtag3_setup(): Out of memory allocating private data\n",
|
||||
progname);
|
||||
exit(1);
|
||||
}
|
||||
memset(pgm->cookie, 0, sizeof(struct pdata));
|
||||
|
@ -170,7 +169,7 @@ static void jtag3_print_data(unsigned char *b, size_t s)
|
|||
return;
|
||||
|
||||
for (i = 0; i < s; i++) {
|
||||
fprintf(stderr, "0x%02x", b[i]);
|
||||
avrdude_message("0x%02x", b[i]);
|
||||
if (i % 16 == 15)
|
||||
putc('\n', stderr);
|
||||
else
|
||||
|
@ -185,10 +184,10 @@ static void jtag3_prmsg(PROGRAMMER * pgm, unsigned char * data, size_t len)
|
|||
int i;
|
||||
|
||||
if (verbose >= 4) {
|
||||
fprintf(stderr, "Raw message:\n");
|
||||
avrdude_message("Raw message:\n");
|
||||
|
||||
for (i = 0; i < len; i++) {
|
||||
fprintf(stderr, "%02x ", data[i]);
|
||||
avrdude_message("%02x ", data[i]);
|
||||
if (i % 16 == 15)
|
||||
putc('\n', stderr);
|
||||
else
|
||||
|
@ -200,34 +199,34 @@ static void jtag3_prmsg(PROGRAMMER * pgm, unsigned char * data, size_t len)
|
|||
|
||||
switch (data[0]) {
|
||||
case SCOPE_INFO:
|
||||
fprintf(stderr, "[info] ");
|
||||
avrdude_message("[info] ");
|
||||
break;
|
||||
|
||||
case SCOPE_GENERAL:
|
||||
fprintf(stderr, "[general] ");
|
||||
avrdude_message("[general] ");
|
||||
break;
|
||||
|
||||
case SCOPE_AVR_ISP:
|
||||
fprintf(stderr, "[AVRISP] ");
|
||||
avrdude_message("[AVRISP] ");
|
||||
jtag3_print_data(data + 1, len - 1);
|
||||
return;
|
||||
|
||||
case SCOPE_AVR:
|
||||
fprintf(stderr, "[AVR] ");
|
||||
avrdude_message("[AVR] ");
|
||||
break;
|
||||
|
||||
default:
|
||||
fprintf(stderr, "[scope 0x%02x] ", data[0]);
|
||||
avrdude_message("[scope 0x%02x] ", data[0]);
|
||||
break;
|
||||
}
|
||||
|
||||
switch (data[1]) {
|
||||
case RSP3_OK:
|
||||
fprintf(stderr, "OK\n");
|
||||
avrdude_message("OK\n");
|
||||
break;
|
||||
|
||||
case RSP3_FAILED:
|
||||
fprintf(stderr, "FAILED");
|
||||
avrdude_message("FAILED");
|
||||
if (len > 3)
|
||||
{
|
||||
char reason[50];
|
||||
|
@ -266,26 +265,26 @@ static void jtag3_prmsg(PROGRAMMER * pgm, unsigned char * data, size_t len)
|
|||
strcpy(reason, "debugWIRE communication failed");
|
||||
break;
|
||||
}
|
||||
fprintf(stderr, ", reason: %s\n", reason);
|
||||
avrdude_message(", reason: %s\n", reason);
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf(stderr, ", unspecified reason\n");
|
||||
avrdude_message(", unspecified reason\n");
|
||||
}
|
||||
break;
|
||||
|
||||
case RSP3_DATA:
|
||||
fprintf(stderr, "Data returned:\n");
|
||||
avrdude_message("Data returned:\n");
|
||||
jtag3_print_data(data + 2, len - 2);
|
||||
break;
|
||||
|
||||
case RSP3_INFO:
|
||||
fprintf(stderr, "Info returned:\n");
|
||||
avrdude_message("Info returned:\n");
|
||||
for (i = 2; i < len; i++) {
|
||||
if (isprint(data[i]))
|
||||
putc(data[i], stderr);
|
||||
else
|
||||
fprintf(stderr, "\\%03o", data[i]);
|
||||
avrdude_message("\\%03o", data[i]);
|
||||
}
|
||||
putc('\n', stderr);
|
||||
break;
|
||||
|
@ -293,18 +292,18 @@ static void jtag3_prmsg(PROGRAMMER * pgm, unsigned char * data, size_t len)
|
|||
case RSP3_PC:
|
||||
if (len < 7)
|
||||
{
|
||||
fprintf(stderr, "PC reply too short\n");
|
||||
avrdude_message("PC reply too short\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
unsigned long pc = (data[6] << 24) | (data[5] << 16)
|
||||
| (data[4] << 8) | data[3];
|
||||
fprintf(stderr, "PC 0x%0lx\n", pc);
|
||||
avrdude_message("PC 0x%0lx\n", pc);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
fprintf(stderr, "unknown message 0x%02x\n", data[1]);
|
||||
avrdude_message("unknown message 0x%02x\n", data[1]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -313,10 +312,10 @@ static void jtag3_prevent(PROGRAMMER * pgm, unsigned char * data, size_t len)
|
|||
int i;
|
||||
|
||||
if (verbose >= 4) {
|
||||
fprintf(stderr, "Raw event:\n");
|
||||
avrdude_message("Raw event:\n");
|
||||
|
||||
for (i = 0; i < len; i++) {
|
||||
fprintf(stderr, "%02x ", data[i]);
|
||||
avrdude_message("%02x ", data[i]);
|
||||
if (i % 16 == 15)
|
||||
putc('\n', stderr);
|
||||
else
|
||||
|
@ -326,47 +325,47 @@ static void jtag3_prevent(PROGRAMMER * pgm, unsigned char * data, size_t len)
|
|||
putc('\n', stderr);
|
||||
}
|
||||
|
||||
fprintf(stderr, "Event serial 0x%04x, ",
|
||||
avrdude_message("Event serial 0x%04x, ",
|
||||
(data[3] << 8) | data[2]);
|
||||
|
||||
switch (data[4]) {
|
||||
case SCOPE_INFO:
|
||||
fprintf(stderr, "[info] ");
|
||||
avrdude_message("[info] ");
|
||||
break;
|
||||
|
||||
case SCOPE_GENERAL:
|
||||
fprintf(stderr, "[general] ");
|
||||
avrdude_message("[general] ");
|
||||
break;
|
||||
|
||||
case SCOPE_AVR:
|
||||
fprintf(stderr, "[AVR] ");
|
||||
avrdude_message("[AVR] ");
|
||||
break;
|
||||
|
||||
default:
|
||||
fprintf(stderr, "[scope 0x%02x] ", data[0]);
|
||||
avrdude_message("[scope 0x%02x] ", data[0]);
|
||||
break;
|
||||
}
|
||||
|
||||
switch (data[5]) {
|
||||
case EVT3_BREAK:
|
||||
fprintf(stderr, "BREAK");
|
||||
avrdude_message("BREAK");
|
||||
if (len >= 11) {
|
||||
fprintf(stderr, ", PC = 0x%lx, reason ", b4_to_u32(data + 6));
|
||||
avrdude_message(", PC = 0x%lx, reason ", b4_to_u32(data + 6));
|
||||
switch (data[10]) {
|
||||
case 0x00:
|
||||
fprintf(stderr, "unspecified");
|
||||
avrdude_message("unspecified");
|
||||
break;
|
||||
case 0x01:
|
||||
fprintf(stderr, "program break");
|
||||
avrdude_message("program break");
|
||||
break;
|
||||
case 0x02:
|
||||
fprintf(stderr, "data break PDSB");
|
||||
avrdude_message("data break PDSB");
|
||||
break;
|
||||
case 0x03:
|
||||
fprintf(stderr, "data break PDMSB");
|
||||
avrdude_message("data break PDMSB");
|
||||
break;
|
||||
default:
|
||||
fprintf(stderr, "unknown: 0x%02x", data[10]);
|
||||
avrdude_message("unknown: 0x%02x", data[10]);
|
||||
}
|
||||
/* There are two more bytes of data which always appear to be
|
||||
* 0x01, 0x00. Purpose unknown. */
|
||||
|
@ -375,24 +374,24 @@ static void jtag3_prevent(PROGRAMMER * pgm, unsigned char * data, size_t len)
|
|||
|
||||
case EVT3_SLEEP:
|
||||
if (len >= 8 && data[7] == 0)
|
||||
fprintf(stderr, "sleeping");
|
||||
avrdude_message("sleeping");
|
||||
else if (len >= 8 && data[7] == 1)
|
||||
fprintf(stderr, "wakeup");
|
||||
avrdude_message("wakeup");
|
||||
else
|
||||
fprintf(stderr, "unknown SLEEP event");
|
||||
avrdude_message("unknown SLEEP event");
|
||||
break;
|
||||
|
||||
case EVT3_POWER:
|
||||
if (len >= 8 && data[7] == 0)
|
||||
fprintf(stderr, "power-down");
|
||||
avrdude_message("power-down");
|
||||
else if (len >= 8 && data[7] == 1)
|
||||
fprintf(stderr, "power-up");
|
||||
avrdude_message("power-up");
|
||||
else
|
||||
fprintf(stderr, "unknown POWER event");
|
||||
avrdude_message("unknown POWER event");
|
||||
break;
|
||||
|
||||
default:
|
||||
fprintf(stderr, "UNKNOWN 0x%02x", data[5]);
|
||||
avrdude_message("UNKNOWN 0x%02x", data[5]);
|
||||
break;
|
||||
}
|
||||
putc('\n', stderr);
|
||||
|
@ -408,12 +407,12 @@ int jtag3_send(PROGRAMMER * pgm, unsigned char * data, size_t len)
|
|||
return jtag3_edbg_send(pgm, data, len);
|
||||
|
||||
if (verbose >= 3)
|
||||
fprintf(stderr, "\n%s: jtag3_send(): sending %lu bytes\n",
|
||||
avrdude_message("\n%s: jtag3_send(): sending %lu bytes\n",
|
||||
progname, (unsigned long)len);
|
||||
|
||||
if ((buf = malloc(len + 4)) == NULL)
|
||||
{
|
||||
fprintf(stderr, "%s: jtag3_send(): out of memory",
|
||||
avrdude_message("%s: jtag3_send(): out of memory",
|
||||
progname);
|
||||
return -1;
|
||||
}
|
||||
|
@ -424,9 +423,8 @@ 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) {
|
||||
fprintf(stderr,
|
||||
"%s: jtag3_send(): failed to send command to serial port\n",
|
||||
progname);
|
||||
avrdude_message("%s: jtag3_send(): failed to send command to serial port\n",
|
||||
progname);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -448,14 +446,13 @@ static int jtag3_edbg_send(PROGRAMMER * pgm, unsigned char * data, size_t len)
|
|||
}
|
||||
|
||||
if (verbose >= 3)
|
||||
fprintf(stderr, "\n%s: jtag3_edbg_send(): sending %lu bytes\n",
|
||||
avrdude_message("\n%s: jtag3_edbg_send(): sending %lu bytes\n",
|
||||
progname, (unsigned long)len);
|
||||
|
||||
if (len + 8 > USBDEV_MAX_XFER_3)
|
||||
{
|
||||
fprintf(stderr,
|
||||
"%s: jtag3_edbg_send(): Fragmentation not (yet) implemented!\n",
|
||||
progname);
|
||||
avrdude_message("%s: jtag3_edbg_send(): Fragmentation not (yet) implemented!\n",
|
||||
progname);
|
||||
return -1;
|
||||
}
|
||||
buf[0] = EDBG_VENDOR_AVR_CMD;
|
||||
|
@ -468,9 +465,8 @@ 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) {
|
||||
fprintf(stderr,
|
||||
"%s: jtag3_edbg_send(): failed to send command to serial port\n",
|
||||
progname);
|
||||
avrdude_message("%s: jtag3_edbg_send(): failed to send command to serial port\n",
|
||||
progname);
|
||||
return -1;
|
||||
}
|
||||
rv = serial_recv(&pgm->fd, status, USBDEV_MAX_XFER_3);
|
||||
|
@ -478,17 +474,15 @@ static int jtag3_edbg_send(PROGRAMMER * pgm, unsigned char * data, size_t len)
|
|||
if (rv < 0) {
|
||||
/* timeout in receive */
|
||||
if (verbose > 1)
|
||||
fprintf(stderr,
|
||||
"%s: jtag3_edbg_send(): Timeout receiving packet\n",
|
||||
progname);
|
||||
avrdude_message("%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? */
|
||||
fprintf(stderr,
|
||||
"%s: jtag3_edbg_send(): Unexpected response 0x%02x, 0x%02x\n",
|
||||
progname, status[0], status[1]);
|
||||
avrdude_message("%s: jtag3_edbg_send(): Unexpected response 0x%02x, 0x%02x\n",
|
||||
progname, status[0], status[1]);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -504,7 +498,7 @@ static int jtag3_edbg_prepare(PROGRAMMER * pgm)
|
|||
int rv;
|
||||
|
||||
if (verbose >= 3)
|
||||
fprintf(stderr, "\n%s: jtag3_edbg_prepare()\n",
|
||||
avrdude_message("\n%s: jtag3_edbg_prepare()\n",
|
||||
progname);
|
||||
|
||||
if (verbose >= 4)
|
||||
|
@ -513,49 +507,42 @@ 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) {
|
||||
fprintf(stderr,
|
||||
"%s: jtag3_edbg_prepare(): failed to send command to serial port\n",
|
||||
progname);
|
||||
avrdude_message("%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) {
|
||||
fprintf(stderr,
|
||||
"%s: jtag3_edbg_prepare(): failed to read from serial port (%d)\n",
|
||||
progname, rv);
|
||||
avrdude_message("%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)
|
||||
fprintf(stderr,
|
||||
"%s: jtag3_edbg_prepare(): unexpected response 0x%02x, 0x%02x\n",
|
||||
progname, status[0], status[1]);
|
||||
avrdude_message("%s: jtag3_edbg_prepare(): unexpected response 0x%02x, 0x%02x\n",
|
||||
progname, status[0], status[1]);
|
||||
if (verbose >= 2)
|
||||
fprintf(stderr,
|
||||
"%s: jtag3_edbg_prepare(): connection status 0x%02x\n",
|
||||
progname, status[1]);
|
||||
avrdude_message("%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) {
|
||||
fprintf(stderr,
|
||||
"%s: jtag3_edbg_prepare(): failed to send command to serial port\n",
|
||||
progname);
|
||||
avrdude_message("%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) {
|
||||
fprintf(stderr,
|
||||
"%s: jtag3_edbg_prepare(): failed to read from serial port (%d)\n",
|
||||
progname, rv);
|
||||
avrdude_message("%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)
|
||||
fprintf(stderr,
|
||||
"%s: jtag3_edbg_prepare(): unexpected response 0x%02x, 0x%02x\n",
|
||||
progname, status[0], status[1]);
|
||||
avrdude_message("%s: jtag3_edbg_prepare(): unexpected response 0x%02x, 0x%02x\n",
|
||||
progname, status[0], status[1]);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -571,7 +558,7 @@ static int jtag3_edbg_signoff(PROGRAMMER * pgm)
|
|||
int rv;
|
||||
|
||||
if (verbose >= 3)
|
||||
fprintf(stderr, "\n%s: jtag3_edbg_signoff()\n",
|
||||
avrdude_message("\n%s: jtag3_edbg_signoff()\n",
|
||||
progname);
|
||||
|
||||
if (verbose >= 4)
|
||||
|
@ -581,43 +568,37 @@ 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) {
|
||||
fprintf(stderr,
|
||||
"%s: jtag3_edbg_signoff(): failed to send command to serial port\n",
|
||||
progname);
|
||||
avrdude_message("%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) {
|
||||
fprintf(stderr,
|
||||
"%s: jtag3_edbg_signoff(): failed to read from serial port (%d)\n",
|
||||
progname, rv);
|
||||
avrdude_message("%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)
|
||||
fprintf(stderr,
|
||||
"%s: jtag3_edbg_signoff(): unexpected response 0x%02x, 0x%02x\n",
|
||||
progname, status[0], status[1]);
|
||||
avrdude_message("%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) {
|
||||
fprintf(stderr,
|
||||
"%s: jtag3_edbg_signoff(): failed to send command to serial port\n",
|
||||
progname);
|
||||
avrdude_message("%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) {
|
||||
fprintf(stderr,
|
||||
"%s: jtag3_edbg_signoff(): failed to read from serial port (%d)\n",
|
||||
progname, rv);
|
||||
avrdude_message("%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)
|
||||
fprintf(stderr,
|
||||
"%s: jtag3_edbg_signoff(): unexpected response 0x%02x, 0x%02x\n",
|
||||
progname, status[0], status[1]);
|
||||
avrdude_message("%s: jtag3_edbg_signoff(): unexpected response 0x%02x, 0x%02x\n",
|
||||
progname, status[0], status[1]);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -645,10 +626,10 @@ static int jtag3_recv_frame(PROGRAMMER * pgm, unsigned char **msg) {
|
|||
return jtag3_edbg_recv_frame(pgm, msg);
|
||||
|
||||
if (verbose >= 4)
|
||||
fprintf(stderr, "%s: jtag3_recv():\n", progname);
|
||||
avrdude_message("%s: jtag3_recv():\n", progname);
|
||||
|
||||
if ((buf = malloc(pgm->fd.usb.max_xfer)) == NULL) {
|
||||
fprintf(stderr, "%s: jtag3_recv(): out of memory\n",
|
||||
avrdude_message("%s: jtag3_recv(): out of memory\n",
|
||||
progname);
|
||||
return -1;
|
||||
}
|
||||
|
@ -660,9 +641,8 @@ static int jtag3_recv_frame(PROGRAMMER * pgm, unsigned char **msg) {
|
|||
if (rv < 0) {
|
||||
/* timeout in receive */
|
||||
if (verbose > 1)
|
||||
fprintf(stderr,
|
||||
"%s: jtag3_recv(): Timeout receiving packet\n",
|
||||
progname);
|
||||
avrdude_message("%s: jtag3_recv(): Timeout receiving packet\n",
|
||||
progname);
|
||||
free(buf);
|
||||
return -1;
|
||||
}
|
||||
|
@ -677,10 +657,10 @@ static int jtag3_edbg_recv_frame(PROGRAMMER * pgm, unsigned char **msg) {
|
|||
unsigned char *buf = NULL;
|
||||
|
||||
if (verbose >= 4)
|
||||
fprintf(stderr, "%s: jtag3_edbg_recv():\n", progname);
|
||||
avrdude_message("%s: jtag3_edbg_recv():\n", progname);
|
||||
|
||||
if ((buf = malloc(USBDEV_MAX_XFER_3)) == NULL) {
|
||||
fprintf(stderr, "%s: jtag3_edbg_recv(): out of memory\n",
|
||||
avrdude_message("%s: jtag3_edbg_recv(): out of memory\n",
|
||||
progname);
|
||||
return -1;
|
||||
}
|
||||
|
@ -688,9 +668,8 @@ 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) {
|
||||
fprintf(stderr,
|
||||
"%s: jtag3_edbg_recv(): error sending CMSIS-DAP vendor command\n",
|
||||
progname);
|
||||
avrdude_message("%s: jtag3_edbg_recv(): error sending CMSIS-DAP vendor command\n",
|
||||
progname);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -699,26 +678,23 @@ static int jtag3_edbg_recv_frame(PROGRAMMER * pgm, unsigned char **msg) {
|
|||
if (rv < 0) {
|
||||
/* timeout in receive */
|
||||
if (verbose > 1)
|
||||
fprintf(stderr,
|
||||
"%s: jtag3_edbg_recv(): Timeout receiving packet\n",
|
||||
progname);
|
||||
avrdude_message("%s: jtag3_edbg_recv(): Timeout receiving packet\n",
|
||||
progname);
|
||||
free(buf);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (buf[0] != EDBG_VENDOR_AVR_RSP ||
|
||||
buf[1] != ((1 << 4) | 1)) {
|
||||
fprintf(stderr,
|
||||
"%s: jtag3_edbg_recv(): Unexpected response 0x%02x, 0x%02x\n",
|
||||
progname, buf[0], buf[1]);
|
||||
avrdude_message("%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) {
|
||||
fprintf(stderr,
|
||||
"%s: jtag3_edbg_recv(): Unexpected length value (%d > %d)\n",
|
||||
progname, len, rv + 4);
|
||||
avrdude_message("%s: jtag3_edbg_recv(): Unexpected length value (%d > %d)\n",
|
||||
progname, len, rv + 4);
|
||||
len = rv + 4;
|
||||
}
|
||||
memmove(buf, buf + 4, len);
|
||||
|
@ -747,7 +723,7 @@ int jtag3_recv(PROGRAMMER * pgm, unsigned char **msg) {
|
|||
rv &= USB_RECV_LENGTH_MASK;
|
||||
r_seqno = ((*msg)[2] << 8) | (*msg)[1];
|
||||
if (verbose >= 3)
|
||||
fprintf(stderr, "%s: jtag3_recv(): "
|
||||
avrdude_message("%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) {
|
||||
|
@ -764,7 +740,7 @@ int jtag3_recv(PROGRAMMER * pgm, unsigned char **msg) {
|
|||
return rv;
|
||||
}
|
||||
if (verbose >= 2)
|
||||
fprintf(stderr, "%s: jtag3_recv(): "
|
||||
avrdude_message("%s: jtag3_recv(): "
|
||||
"got wrong sequence number, %u != %u\n",
|
||||
progname, r_seqno, PDATA(pgm)->command_sequence);
|
||||
|
||||
|
@ -779,7 +755,7 @@ int jtag3_recv(PROGRAMMER * pgm, unsigned char **msg) {
|
|||
unsigned char c;
|
||||
|
||||
if (verbose >= 2)
|
||||
fprintf(stderr, "%s: Sending %s command: ",
|
||||
avrdude_message("%s: Sending %s command: ",
|
||||
progname, descr);
|
||||
jtag3_send(pgm, cmd, cmdlen);
|
||||
|
||||
|
@ -787,21 +763,19 @@ int jtag3_recv(PROGRAMMER * pgm, unsigned char **msg) {
|
|||
if (status <= 0) {
|
||||
if (verbose >= 2)
|
||||
putc('\n', stderr);
|
||||
fprintf(stderr,
|
||||
"%s: %s command: timeout/error communicating with programmer (status %d)\n",
|
||||
progname, descr, status);
|
||||
avrdude_message("%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)
|
||||
fprintf(stderr, "0x%02x (%d bytes msg)\n", (*resp)[1], status);
|
||||
avrdude_message("0x%02x (%d bytes msg)\n", (*resp)[1], status);
|
||||
|
||||
c = (*resp)[1];
|
||||
if ((c & RSP3_STATUS_MASK) != RSP3_OK) {
|
||||
fprintf(stderr,
|
||||
"%s: bad response to %s command: 0x%02x\n",
|
||||
progname, descr, c);
|
||||
avrdude_message("%s: bad response to %s command: 0x%02x\n",
|
||||
progname, descr, c);
|
||||
free(*resp);
|
||||
resp = 0;
|
||||
return -1;
|
||||
|
@ -816,7 +790,7 @@ int jtag3_getsync(PROGRAMMER * pgm, int mode) {
|
|||
unsigned char buf[3], *resp;
|
||||
|
||||
if (verbose >= 3)
|
||||
fprintf(stderr, "%s: jtag3_getsync()\n", progname);
|
||||
avrdude_message("%s: jtag3_getsync()\n", progname);
|
||||
|
||||
if (pgm->flag & PGM_FL_IS_EDBG) {
|
||||
if (jtag3_edbg_prepare(pgm) < 0)
|
||||
|
@ -862,7 +836,7 @@ static int jtag3_chip_erase(PROGRAMMER * pgm, AVRPART * p)
|
|||
static int jtag3_chip_erase_dw(PROGRAMMER * pgm, AVRPART * p)
|
||||
{
|
||||
|
||||
fprintf(stderr, "%s: Chip erase not supported in debugWire mode\n",
|
||||
avrdude_message("%s: Chip erase not supported in debugWire mode\n",
|
||||
progname);
|
||||
|
||||
return 0;
|
||||
|
@ -893,9 +867,8 @@ static int jtag3_program_enable(PROGRAMMER * pgm)
|
|||
|
||||
/* XXX activate external reset here */
|
||||
if (verbose > 0)
|
||||
fprintf(stderr,
|
||||
"%s: retrying with external reset applied\n",
|
||||
progname);
|
||||
avrdude_message("%s: retrying with external reset applied\n",
|
||||
progname);
|
||||
}
|
||||
|
||||
PDATA(pgm)->prog_enabled = 1;
|
||||
|
@ -967,13 +940,11 @@ 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) {
|
||||
fprintf(stderr,
|
||||
"%s: the JTAGICE3's firmware %d.%d is broken on USB 1.1 connections, sorry\n",
|
||||
progname, parm[0], parm[1]);
|
||||
avrdude_message("%s: the JTAGICE3's firmware %d.%d is broken on USB 1.1 connections, sorry\n",
|
||||
progname, parm[0], parm[1]);
|
||||
if (ovsigck) {
|
||||
fprintf(stderr,
|
||||
"%s: forced to continue by option -F; THIS PUTS THE DEVICE'S DATA INTEGRITY AT RISK!\n",
|
||||
progname);
|
||||
avrdude_message("%s: forced to continue by option -F; THIS PUTS THE DEVICE'S DATA INTEGRITY AT RISK!\n",
|
||||
progname);
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
|
@ -994,7 +965,7 @@ static int jtag3_initialize(PROGRAMMER * pgm, AVRPART * p)
|
|||
}
|
||||
|
||||
if (conn == 0) {
|
||||
fprintf(stderr, "%s: jtag3_initialize(): part %s has no %s interface\n",
|
||||
avrdude_message("%s: jtag3_initialize(): part %s has no %s interface\n",
|
||||
progname, p->desc, ifname);
|
||||
return -1;
|
||||
}
|
||||
|
@ -1028,7 +999,7 @@ static int jtag3_initialize(PROGRAMMER * pgm, AVRPART * p)
|
|||
{
|
||||
unsigned int clock = 1E-3 / pgm->bitclock; /* kHz */
|
||||
if (verbose >= 2)
|
||||
fprintf(stderr, "%s: jtag3_initialize(): "
|
||||
avrdude_message("%s: jtag3_initialize(): "
|
||||
"trying to set JTAG clock to %u kHz\n",
|
||||
progname, clock);
|
||||
parm[0] = clock & 0xff;
|
||||
|
@ -1040,7 +1011,7 @@ static int jtag3_initialize(PROGRAMMER * pgm, AVRPART * p)
|
|||
if (conn == PARM3_CONN_JTAG)
|
||||
{
|
||||
if (verbose >= 2)
|
||||
fprintf(stderr, "%s: jtag3_initialize(): "
|
||||
avrdude_message("%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],
|
||||
|
@ -1132,9 +1103,8 @@ static int jtag3_initialize(PROGRAMMER * pgm, AVRPART * p)
|
|||
ocdrev = 4;
|
||||
else
|
||||
ocdrev = 3; /* many exceptions from that, actually */
|
||||
fprintf(stderr,
|
||||
"%s: part definition for %s lacks \"ocdrev\"; guessing %d\n",
|
||||
progname, p->desc, ocdrev);
|
||||
avrdude_message("%s: part definition for %s lacks \"ocdrev\"; guessing %d\n",
|
||||
progname, p->desc, ocdrev);
|
||||
md.ocd_revision = ocdrev;
|
||||
} else {
|
||||
md.ocd_revision = p->ocdrev;
|
||||
|
@ -1174,7 +1144,7 @@ static int jtag3_initialize(PROGRAMMER * pgm, AVRPART * p)
|
|||
*/
|
||||
if (resp[1] == RSP3_DATA && status >= 7 && verbose >= 1)
|
||||
/* JTAG ID has been returned */
|
||||
fprintf(stderr, "%s: JTAG ID returned: 0x%02x 0x%02x 0x%02x 0x%02x\n",
|
||||
avrdude_message("%s: JTAG ID returned: 0x%02x 0x%02x 0x%02x 0x%02x\n",
|
||||
progname, resp[3], resp[4], resp[5], resp[6]);
|
||||
|
||||
free(resp);
|
||||
|
@ -1188,9 +1158,8 @@ 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) {
|
||||
fprintf(stderr,
|
||||
"%s: jtagmk3_initialize(): Cannot locate \"flash\" and \"boot\" memories in description\n",
|
||||
progname);
|
||||
avrdude_message("%s: jtagmk3_initialize(): Cannot locate \"flash\" and \"boot\" memories in description\n",
|
||||
progname);
|
||||
} else {
|
||||
PDATA(pgm)->boot_start = bootmem->offset - flashmem->offset;
|
||||
}
|
||||
|
@ -1199,12 +1168,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) {
|
||||
fprintf(stderr, "%s: jtag3_initialize(): Out of memory\n",
|
||||
avrdude_message("%s: jtag3_initialize(): Out of memory\n",
|
||||
progname);
|
||||
return -1;
|
||||
}
|
||||
if ((PDATA(pgm)->eeprom_pagecache = malloc(PDATA(pgm)->eeprom_pagesize)) == NULL) {
|
||||
fprintf(stderr, "%s: jtag3_initialize(): Out of memory\n",
|
||||
avrdude_message("%s: jtag3_initialize(): Out of memory\n",
|
||||
progname);
|
||||
free(PDATA(pgm)->flash_pagecache);
|
||||
return -1;
|
||||
|
@ -1248,18 +1217,16 @@ 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) {
|
||||
fprintf(stderr,
|
||||
"%s: jtag3_parseextparms(): invalid JTAG chain '%s'\n",
|
||||
progname, extended_param);
|
||||
avrdude_message("%s: jtag3_parseextparms(): invalid JTAG chain '%s'\n",
|
||||
progname, extended_param);
|
||||
rv = -1;
|
||||
continue;
|
||||
}
|
||||
if (verbose >= 2) {
|
||||
fprintf(stderr,
|
||||
"%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);
|
||||
avrdude_message("%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;
|
||||
|
@ -1269,9 +1236,8 @@ static int jtag3_parseextparms(PROGRAMMER * pgm, LISTID extparms)
|
|||
continue;
|
||||
}
|
||||
|
||||
fprintf(stderr,
|
||||
"%s: jtag3_parseextparms(): invalid extended parameter '%s'\n",
|
||||
progname, extended_param);
|
||||
avrdude_message("%s: jtag3_parseextparms(): invalid extended parameter '%s'\n",
|
||||
progname, extended_param);
|
||||
rv = -1;
|
||||
}
|
||||
|
||||
|
@ -1285,14 +1251,13 @@ int jtag3_open_common(PROGRAMMER * pgm, char * port)
|
|||
int rv = -1;
|
||||
|
||||
#if !defined(HAVE_LIBUSB)
|
||||
fprintf(stderr, "avrdude was compiled without usb support.\n");
|
||||
avrdude_message("avrdude was compiled without usb support.\n");
|
||||
return -1;
|
||||
#endif
|
||||
|
||||
if (strncmp(port, "usb", 3) != 0) {
|
||||
fprintf(stderr,
|
||||
"%s: jtag3_open_common(): JTAGICE3/EDBG port names must start with \"usb\"\n",
|
||||
progname);
|
||||
avrdude_message("%s: jtag3_open_common(): JTAGICE3/EDBG port names must start with \"usb\"\n",
|
||||
progname);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -1318,14 +1283,13 @@ int jtag3_open_common(PROGRAMMER * pgm, char * port)
|
|||
rv = serial_open(port, pinfo, &pgm->fd);
|
||||
}
|
||||
if (rv < 0) {
|
||||
fprintf(stderr,
|
||||
"%s: jtag3_open_common(): Did not find any device matching VID 0x%04x and PID list: ",
|
||||
progname, (unsigned)pinfo.usbinfo.vid);
|
||||
avrdude_message("%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)
|
||||
fprintf(stderr, ", ");
|
||||
fprintf(stderr, "0x%04x", (unsigned int)(*(int *)(ldata(usbpid))));
|
||||
avrdude_message(", ");
|
||||
avrdude_message("0x%04x", (unsigned int)(*(int *)(ldata(usbpid))));
|
||||
notfirst = 1;
|
||||
}
|
||||
fputc('\n', stderr);
|
||||
|
@ -1339,9 +1303,8 @@ int jtag3_open_common(PROGRAMMER * pgm, char * port)
|
|||
running on a CMSIS-DAP device, using EDBG protocol */
|
||||
pgm->flag |= PGM_FL_IS_EDBG;
|
||||
if (verbose)
|
||||
fprintf(stderr,
|
||||
"%s: Found CMSIS-DAP compliant device, using EDBG protocol\n",
|
||||
progname);
|
||||
avrdude_message("%s: Found CMSIS-DAP compliant device, using EDBG protocol\n",
|
||||
progname);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -1357,7 +1320,7 @@ int jtag3_open_common(PROGRAMMER * pgm, char * port)
|
|||
static int jtag3_open(PROGRAMMER * pgm, char * port)
|
||||
{
|
||||
if (verbose >= 2)
|
||||
fprintf(stderr, "%s: jtag3_open()\n", progname);
|
||||
avrdude_message("%s: jtag3_open()\n", progname);
|
||||
|
||||
if (jtag3_open_common(pgm, port) < 0)
|
||||
return -1;
|
||||
|
@ -1371,7 +1334,7 @@ static int jtag3_open(PROGRAMMER * pgm, char * port)
|
|||
static int jtag3_open_dw(PROGRAMMER * pgm, char * port)
|
||||
{
|
||||
if (verbose >= 2)
|
||||
fprintf(stderr, "%s: jtag3_open_dw()\n", progname);
|
||||
avrdude_message("%s: jtag3_open_dw()\n", progname);
|
||||
|
||||
if (jtag3_open_common(pgm, port) < 0)
|
||||
return -1;
|
||||
|
@ -1385,7 +1348,7 @@ static int jtag3_open_dw(PROGRAMMER * pgm, char * port)
|
|||
static int jtag3_open_pdi(PROGRAMMER * pgm, char * port)
|
||||
{
|
||||
if (verbose >= 2)
|
||||
fprintf(stderr, "%s: jtag3_open_pdi()\n", progname);
|
||||
avrdude_message("%s: jtag3_open_pdi()\n", progname);
|
||||
|
||||
if (jtag3_open_common(pgm, port) < 0)
|
||||
return -1;
|
||||
|
@ -1402,7 +1365,7 @@ void jtag3_close(PROGRAMMER * pgm)
|
|||
unsigned char buf[4], *resp;
|
||||
|
||||
if (verbose >= 2)
|
||||
fprintf(stderr, "%s: jtag3_close()\n", progname);
|
||||
avrdude_message("%s: jtag3_close()\n", progname);
|
||||
|
||||
buf[0] = SCOPE_AVR;
|
||||
buf[1] = CMD3_SIGN_OFF;
|
||||
|
@ -1430,11 +1393,11 @@ static int jtag3_page_erase(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m,
|
|||
unsigned char cmd[8], *resp;
|
||||
|
||||
if (verbose >= 2)
|
||||
fprintf(stderr, "%s: jtag3_page_erase(.., %s, 0x%x)\n",
|
||||
avrdude_message("%s: jtag3_page_erase(.., %s, 0x%x)\n",
|
||||
progname, m->desc, addr);
|
||||
|
||||
if (!(p->flags & AVRPART_HAS_PDI)) {
|
||||
fprintf(stderr, "%s: jtag3_page_erase: not an Xmega device\n",
|
||||
avrdude_message("%s: jtag3_page_erase: not an Xmega device\n",
|
||||
progname);
|
||||
return -1;
|
||||
}
|
||||
|
@ -1482,7 +1445,7 @@ static int jtag3_paged_write(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m,
|
|||
long otimeout = serial_recv_timeout;
|
||||
|
||||
if (verbose >= 2)
|
||||
fprintf(stderr, "%s: jtag3_paged_write(.., %s, %d, %d)\n",
|
||||
avrdude_message("%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)
|
||||
|
@ -1491,7 +1454,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) {
|
||||
fprintf(stderr, "%s: jtag3_paged_write(): Out of memory\n",
|
||||
avrdude_message("%s: jtag3_paged_write(): Out of memory\n",
|
||||
progname);
|
||||
return -1;
|
||||
}
|
||||
|
@ -1539,7 +1502,7 @@ static int jtag3_paged_write(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m,
|
|||
else
|
||||
block_size = page_size;
|
||||
if (verbose >= 3)
|
||||
fprintf(stderr, "%s: jtag3_paged_write(): "
|
||||
avrdude_message("%s: jtag3_paged_write(): "
|
||||
"block_size at addr %d is %d\n",
|
||||
progname, addr, block_size);
|
||||
|
||||
|
@ -1588,7 +1551,7 @@ static int jtag3_paged_load(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m,
|
|||
long otimeout = serial_recv_timeout;
|
||||
|
||||
if (verbose >= 2)
|
||||
fprintf(stderr, "%s: jtag3_paged_load(.., %s, %d, %d)\n",
|
||||
avrdude_message("%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)
|
||||
|
@ -1627,7 +1590,7 @@ static int jtag3_paged_load(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m,
|
|||
else
|
||||
block_size = page_size;
|
||||
if (verbose >= 3)
|
||||
fprintf(stderr, "%s: jtag3_paged_load(): "
|
||||
avrdude_message("%s: jtag3_paged_load(): "
|
||||
"block_size at addr %d is %d\n",
|
||||
progname, addr, block_size);
|
||||
|
||||
|
@ -1642,7 +1605,7 @@ static int jtag3_paged_load(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m,
|
|||
|
||||
if (resp[1] != RSP3_DATA ||
|
||||
status < block_size + 4) {
|
||||
fprintf(stderr, "%s: wrong/short reply to read memory command\n",
|
||||
avrdude_message("%s: wrong/short reply to read memory command\n",
|
||||
progname);
|
||||
serial_recv_timeout = otimeout;
|
||||
free(resp);
|
||||
|
@ -1666,7 +1629,7 @@ static int jtag3_read_byte(PROGRAMMER * pgm, AVRPART * p, AVRMEM * mem,
|
|||
unsigned int pagesize = 0;
|
||||
|
||||
if (verbose >= 2)
|
||||
fprintf(stderr, "%s: jtag3_read_byte(.., %s, 0x%lx, ...)\n",
|
||||
avrdude_message("%s: jtag3_read_byte(.., %s, 0x%lx, ...)\n",
|
||||
progname, mem->desc, addr);
|
||||
|
||||
if (!(pgm->flag & PGM_FL_IS_DW) && jtag3_program_enable(pgm) < 0)
|
||||
|
@ -1754,7 +1717,7 @@ static int jtag3_read_byte(PROGRAMMER * pgm, AVRPART * p, AVRMEM * mem,
|
|||
return 0;
|
||||
} else {
|
||||
/* should not happen */
|
||||
fprintf(stderr, "address out of range for signature memory: %lu\n", addr);
|
||||
avrdude_message("address out of range for signature memory: %lu\n", addr);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
@ -1795,7 +1758,7 @@ static int jtag3_read_byte(PROGRAMMER * pgm, AVRPART * p, AVRMEM * mem,
|
|||
|
||||
if (resp[1] != RSP3_DATA ||
|
||||
status < (pagesize? pagesize: 1) + 4) {
|
||||
fprintf(stderr, "%s: wrong/short reply to read memory command\n",
|
||||
avrdude_message("%s: wrong/short reply to read memory command\n",
|
||||
progname);
|
||||
free(resp);
|
||||
return -1;
|
||||
|
@ -1822,7 +1785,7 @@ static int jtag3_write_byte(PROGRAMMER * pgm, AVRPART * p, AVRMEM * mem,
|
|||
unsigned int pagesize = 0;
|
||||
|
||||
if (verbose >= 2)
|
||||
fprintf(stderr, "%s: jtag3_write_byte(.., %s, 0x%lx, ...)\n",
|
||||
avrdude_message("%s: jtag3_write_byte(.., %s, 0x%lx, ...)\n",
|
||||
progname, mem->desc, addr);
|
||||
|
||||
cmd[0] = SCOPE_AVR;
|
||||
|
@ -1939,7 +1902,7 @@ static int jtag3_set_sck_period(PROGRAMMER * pgm, double v)
|
|||
parm[1] = (clock >> 8) & 0xff;
|
||||
|
||||
if (PDATA(pgm)->set_sck == NULL) {
|
||||
fprintf(stderr, "%s: No backend to set the SCK period for\n",
|
||||
avrdude_message("%s: No backend to set the SCK period for\n",
|
||||
progname);
|
||||
return -1;
|
||||
}
|
||||
|
@ -1960,7 +1923,7 @@ int jtag3_getparm(PROGRAMMER * pgm, unsigned char scope,
|
|||
char descr[60];
|
||||
|
||||
if (verbose >= 2)
|
||||
fprintf(stderr, "%s: jtag3_getparm()\n", progname);
|
||||
avrdude_message("%s: jtag3_getparm()\n", progname);
|
||||
|
||||
buf[0] = scope;
|
||||
buf[1] = CMD3_GET_PARAMETER;
|
||||
|
@ -1977,10 +1940,9 @@ int jtag3_getparm(PROGRAMMER * pgm, unsigned char scope,
|
|||
|
||||
c = resp[1];
|
||||
if (c != RSP3_DATA || status < 3) {
|
||||
fprintf(stderr,
|
||||
"%s: jtag3_getparm(): "
|
||||
"bad response to %s\n",
|
||||
progname, descr);
|
||||
avrdude_message("%s: jtag3_getparm(): "
|
||||
"bad response to %s\n",
|
||||
progname, descr);
|
||||
free(resp);
|
||||
return -1;
|
||||
}
|
||||
|
@ -2004,14 +1966,14 @@ int jtag3_setparm(PROGRAMMER * pgm, unsigned char scope,
|
|||
char descr[60];
|
||||
|
||||
if (verbose >= 2)
|
||||
fprintf(stderr, "%s: jtag3_setparm()\n", progname);
|
||||
avrdude_message("%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)
|
||||
{
|
||||
fprintf(stderr, "%s: jtag3_setparm(): Out of memory\n",
|
||||
avrdude_message("%s: jtag3_setparm(): Out of memory\n",
|
||||
progname);
|
||||
return -1;
|
||||
}
|
||||
|
@ -2060,20 +2022,19 @@ static void jtag3_display(PROGRAMMER * pgm, const char * p)
|
|||
|
||||
c = resp[1];
|
||||
if (c != RSP3_INFO) {
|
||||
fprintf(stderr,
|
||||
"%s: jtag3_display(): response is not RSP3_INFO\n",
|
||||
progname);
|
||||
avrdude_message("%s: jtag3_display(): response is not RSP3_INFO\n",
|
||||
progname);
|
||||
free(resp);
|
||||
return;
|
||||
}
|
||||
memmove(resp, resp + 3, status - 3);
|
||||
resp[status - 3] = 0;
|
||||
|
||||
fprintf(stderr, "%sICE hardware version: %d\n", p, parms[0]);
|
||||
fprintf(stderr, "%sICE firmware version: %d.%02d (rel. %d)\n", p,
|
||||
avrdude_message("%sICE hardware version: %d\n", p, parms[0]);
|
||||
avrdude_message("%sICE firmware version: %d.%02d (rel. %d)\n", p,
|
||||
parms[1], parms[2],
|
||||
(parms[3] | (parms[4] << 8)));
|
||||
fprintf(stderr, "%sSerial number : %s\n", p, resp);
|
||||
avrdude_message("%sSerial number : %s\n", p, resp);
|
||||
free(resp);
|
||||
|
||||
jtag3_print_parms1(pgm, p);
|
||||
|
@ -2087,27 +2048,27 @@ static void jtag3_print_parms1(PROGRAMMER * pgm, const char * p)
|
|||
if (jtag3_getparm(pgm, SCOPE_GENERAL, 1, PARM3_VTARGET, buf, 2) < 0)
|
||||
return;
|
||||
|
||||
fprintf(stderr, "%sVtarget : %.2f V\n", p,
|
||||
avrdude_message("%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;
|
||||
fprintf(stderr, "%sJTAG clock megaAVR/program: %u kHz\n", p,
|
||||
avrdude_message("%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;
|
||||
fprintf(stderr, "%sJTAG clock megaAVR/debug: %u kHz\n", p,
|
||||
avrdude_message("%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;
|
||||
fprintf(stderr, "%sJTAG clock Xmega: %u kHz\n", p,
|
||||
avrdude_message("%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;
|
||||
fprintf(stderr, "%sPDI clock Xmega : %u kHz\n", p,
|
||||
avrdude_message("%sPDI clock Xmega : %u kHz\n", p,
|
||||
b2_to_u16(buf));
|
||||
}
|
||||
|
||||
|
|
300
jtagmkI.c
300
jtagmkI.c
|
@ -112,9 +112,8 @@ static int jtagmkI_resync(PROGRAMMER *pgm, int maxtries, int signon);
|
|||
static void jtagmkI_setup(PROGRAMMER * pgm)
|
||||
{
|
||||
if ((pgm->cookie = malloc(sizeof(struct pdata))) == 0) {
|
||||
fprintf(stderr,
|
||||
"%s: jtagmkI_setup(): Out of memory allocating private data\n",
|
||||
progname);
|
||||
avrdude_message("%s: jtagmkI_setup(): Out of memory allocating private data\n",
|
||||
progname);
|
||||
exit(1);
|
||||
}
|
||||
memset(pgm->cookie, 0, sizeof(struct pdata));
|
||||
|
@ -146,10 +145,10 @@ static void jtagmkI_prmsg(PROGRAMMER * pgm, unsigned char * data, size_t len)
|
|||
int i;
|
||||
|
||||
if (verbose >= 4) {
|
||||
fprintf(stderr, "Raw message:\n");
|
||||
avrdude_message("Raw message:\n");
|
||||
|
||||
for (i = 0; i < len; i++) {
|
||||
fprintf(stderr, "0x%02x ", data[i]);
|
||||
avrdude_message("0x%02x ", data[i]);
|
||||
if (i % 16 == 15)
|
||||
putc('\n', stderr);
|
||||
else
|
||||
|
@ -161,34 +160,34 @@ static void jtagmkI_prmsg(PROGRAMMER * pgm, unsigned char * data, size_t len)
|
|||
|
||||
switch (data[0]) {
|
||||
case RESP_OK:
|
||||
fprintf(stderr, "OK\n");
|
||||
avrdude_message("OK\n");
|
||||
break;
|
||||
|
||||
case RESP_FAILED:
|
||||
fprintf(stderr, "FAILED\n");
|
||||
avrdude_message("FAILED\n");
|
||||
break;
|
||||
|
||||
case RESP_BREAK:
|
||||
fprintf(stderr, "breakpoint hit\n");
|
||||
avrdude_message("breakpoint hit\n");
|
||||
break;
|
||||
|
||||
case RESP_INFO:
|
||||
fprintf(stderr, "IDR dirty\n");
|
||||
avrdude_message("IDR dirty\n");
|
||||
break;
|
||||
|
||||
case RESP_SYNC_ERROR:
|
||||
fprintf(stderr, "Synchronization lost\n");
|
||||
avrdude_message("Synchronization lost\n");
|
||||
break;
|
||||
|
||||
case RESP_SLEEP:
|
||||
fprintf(stderr, "sleep instruction hit\n");
|
||||
avrdude_message("sleep instruction hit\n");
|
||||
break;
|
||||
|
||||
case RESP_POWER:
|
||||
fprintf(stderr, "target power lost\n");
|
||||
avrdude_message("target power lost\n");
|
||||
|
||||
default:
|
||||
fprintf(stderr, "unknown message 0x%02x\n", data[0]);
|
||||
avrdude_message("unknown message 0x%02x\n", data[0]);
|
||||
}
|
||||
|
||||
putc('\n', stderr);
|
||||
|
@ -200,12 +199,12 @@ static int jtagmkI_send(PROGRAMMER * pgm, unsigned char * data, size_t len)
|
|||
unsigned char *buf;
|
||||
|
||||
if (verbose >= 3)
|
||||
fprintf(stderr, "\n%s: jtagmkI_send(): sending %u bytes\n",
|
||||
avrdude_message("\n%s: jtagmkI_send(): sending %u bytes\n",
|
||||
progname, (unsigned int)len);
|
||||
|
||||
if ((buf = malloc(len + 2)) == NULL)
|
||||
{
|
||||
fprintf(stderr, "%s: jtagmkI_send(): out of memory",
|
||||
avrdude_message("%s: jtagmkI_send(): out of memory",
|
||||
progname);
|
||||
exit(1);
|
||||
}
|
||||
|
@ -215,9 +214,8 @@ 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) {
|
||||
fprintf(stderr,
|
||||
"%s: jtagmkI_send(): failed to send command to serial port\n",
|
||||
progname);
|
||||
avrdude_message("%s: jtagmkI_send(): failed to send command to serial port\n",
|
||||
progname);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -229,9 +227,8 @@ 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) {
|
||||
fprintf(stderr,
|
||||
"\n%s: jtagmkI_recv(): failed to send command to serial port\n",
|
||||
progname);
|
||||
avrdude_message("\n%s: jtagmkI_recv(): failed to send command to serial port\n",
|
||||
progname);
|
||||
return -1;
|
||||
}
|
||||
if (verbose >= 3) {
|
||||
|
@ -257,7 +254,7 @@ static int jtagmkI_resync(PROGRAMMER * pgm, int maxtries, int signon)
|
|||
serial_recv_timeout = 200;
|
||||
|
||||
if (verbose >= 3)
|
||||
fprintf(stderr, "%s: jtagmkI_resync()\n", progname);
|
||||
avrdude_message("%s: jtagmkI_resync()\n", progname);
|
||||
|
||||
jtagmkI_drain(pgm, 0);
|
||||
|
||||
|
@ -266,19 +263,18 @@ static int jtagmkI_resync(PROGRAMMER * pgm, int maxtries, int signon)
|
|||
/* Get the sign-on information. */
|
||||
buf[0] = CMD_GET_SYNC;
|
||||
if (verbose >= 2)
|
||||
fprintf(stderr, "%s: jtagmkI_resync(): Sending sync command: ",
|
||||
avrdude_message("%s: jtagmkI_resync(): Sending sync command: ",
|
||||
progname);
|
||||
|
||||
if (serial_send(&pgm->fd, buf, 1) != 0) {
|
||||
fprintf(stderr,
|
||||
"\n%s: jtagmkI_resync(): failed to send command to serial port\n",
|
||||
progname);
|
||||
avrdude_message("\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)
|
||||
fprintf(stderr, "got RESP_OK\n");
|
||||
avrdude_message("got RESP_OK\n");
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -298,29 +294,27 @@ static int jtagmkI_resync(PROGRAMMER * pgm, int maxtries, int signon)
|
|||
buf[2] = ' ';
|
||||
buf[3] = ' ';
|
||||
if (verbose >= 2)
|
||||
fprintf(stderr, "%s: jtagmkI_resync(): Sending sign-on command: ",
|
||||
avrdude_message("%s: jtagmkI_resync(): Sending sign-on command: ",
|
||||
progname);
|
||||
|
||||
if (serial_send(&pgm->fd, buf, 4) != 0) {
|
||||
fprintf(stderr,
|
||||
"\n%s: jtagmkI_resync(): failed to send command to serial port\n",
|
||||
progname);
|
||||
avrdude_message("\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)
|
||||
fprintf(stderr, "got RESP_OK\n");
|
||||
avrdude_message("got RESP_OK\n");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (tries >= maxtries) {
|
||||
if (verbose >= 2)
|
||||
fprintf(stderr,
|
||||
"%s: jtagmkI_resync(): "
|
||||
"timeout/error communicating with programmer\n",
|
||||
progname);
|
||||
avrdude_message("%s: jtagmkI_resync(): "
|
||||
"timeout/error communicating with programmer\n",
|
||||
progname);
|
||||
serial_recv_timeout = otimeout;
|
||||
return -1;
|
||||
}
|
||||
|
@ -341,7 +335,7 @@ static int jtagmkI_getsync(PROGRAMMER * pgm)
|
|||
jtagmkI_drain(pgm, 0);
|
||||
|
||||
if (verbose >= 2)
|
||||
fprintf(stderr, "%s: jtagmkI_getsync(): Sending sign-on command: ",
|
||||
avrdude_message("%s: jtagmkI_getsync(): Sending sign-on command: ",
|
||||
progname);
|
||||
|
||||
buf[0] = CMD_GET_SIGNON;
|
||||
|
@ -350,7 +344,7 @@ static int jtagmkI_getsync(PROGRAMMER * pgm)
|
|||
return -1;
|
||||
if (verbose >= 2) {
|
||||
resp[8] = '\0';
|
||||
fprintf(stderr, "got %s\n", resp + 1);
|
||||
avrdude_message("got %s\n", resp + 1);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -365,7 +359,7 @@ static int jtagmkI_chip_erase(PROGRAMMER * pgm, AVRPART * p)
|
|||
|
||||
buf[0] = CMD_CHIP_ERASE;
|
||||
if (verbose >= 2)
|
||||
fprintf(stderr, "%s: jtagmkI_chip_erase(): Sending chip erase command: ",
|
||||
avrdude_message("%s: jtagmkI_chip_erase(): Sending chip erase command: ",
|
||||
progname);
|
||||
jtagmkI_send(pgm, buf, 1);
|
||||
if (jtagmkI_recv(pgm, resp, 2) < 0)
|
||||
|
@ -373,14 +367,13 @@ static int jtagmkI_chip_erase(PROGRAMMER * pgm, AVRPART * p)
|
|||
if (resp[0] != RESP_OK) {
|
||||
if (verbose >= 2)
|
||||
putc('\n', stderr);
|
||||
fprintf(stderr,
|
||||
"%s: jtagmkI_chip_erase(): "
|
||||
"timeout/error communicating with programmer (resp %c)\n",
|
||||
progname, resp[0]);
|
||||
avrdude_message("%s: jtagmkI_chip_erase(): "
|
||||
"timeout/error communicating with programmer (resp %c)\n",
|
||||
progname, resp[0]);
|
||||
return -1;
|
||||
} else {
|
||||
if (verbose == 2)
|
||||
fprintf(stderr, "OK\n");
|
||||
avrdude_message("OK\n");
|
||||
}
|
||||
|
||||
pgm->initialize(pgm, p);
|
||||
|
@ -414,7 +407,7 @@ static void jtagmkI_set_devdescr(PROGRAMMER * pgm, AVRPART * p)
|
|||
}
|
||||
|
||||
if (verbose >= 2)
|
||||
fprintf(stderr, "%s: jtagmkI_set_devdescr(): "
|
||||
avrdude_message("%s: jtagmkI_set_devdescr(): "
|
||||
"Sending set device descriptor command: ",
|
||||
progname);
|
||||
jtagmkI_send(pgm, (unsigned char *)&sendbuf, sizeof(sendbuf));
|
||||
|
@ -424,13 +417,12 @@ static void jtagmkI_set_devdescr(PROGRAMMER * pgm, AVRPART * p)
|
|||
if (resp[0] != RESP_OK) {
|
||||
if (verbose >= 2)
|
||||
putc('\n', stderr);
|
||||
fprintf(stderr,
|
||||
"%s: jtagmkI_set_devdescr(): "
|
||||
"timeout/error communicating with programmer (resp %c)\n",
|
||||
progname, resp[0]);
|
||||
avrdude_message("%s: jtagmkI_set_devdescr(): "
|
||||
"timeout/error communicating with programmer (resp %c)\n",
|
||||
progname, resp[0]);
|
||||
} else {
|
||||
if (verbose == 2)
|
||||
fprintf(stderr, "OK\n");
|
||||
avrdude_message("OK\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -443,7 +435,7 @@ static int jtagmkI_reset(PROGRAMMER * pgm)
|
|||
|
||||
buf[0] = CMD_RESET;
|
||||
if (verbose >= 2)
|
||||
fprintf(stderr, "%s: jtagmkI_reset(): Sending reset command: ",
|
||||
avrdude_message("%s: jtagmkI_reset(): Sending reset command: ",
|
||||
progname);
|
||||
jtagmkI_send(pgm, buf, 1);
|
||||
|
||||
|
@ -452,14 +444,13 @@ static int jtagmkI_reset(PROGRAMMER * pgm)
|
|||
if (resp[0] != RESP_OK) {
|
||||
if (verbose >= 2)
|
||||
putc('\n', stderr);
|
||||
fprintf(stderr,
|
||||
"%s: jtagmkI_reset(): "
|
||||
"timeout/error communicating with programmer (resp %c)\n",
|
||||
progname, resp[0]);
|
||||
avrdude_message("%s: jtagmkI_reset(): "
|
||||
"timeout/error communicating with programmer (resp %c)\n",
|
||||
progname, resp[0]);
|
||||
return -1;
|
||||
} else {
|
||||
if (verbose == 2)
|
||||
fprintf(stderr, "OK\n");
|
||||
avrdude_message("OK\n");
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -480,7 +471,7 @@ static int jtagmkI_program_enable(PROGRAMMER * pgm)
|
|||
|
||||
buf[0] = CMD_ENTER_PROGMODE;
|
||||
if (verbose >= 2)
|
||||
fprintf(stderr, "%s: jtagmkI_program_enable(): "
|
||||
avrdude_message("%s: jtagmkI_program_enable(): "
|
||||
"Sending enter progmode command: ",
|
||||
progname);
|
||||
jtagmkI_send(pgm, buf, 1);
|
||||
|
@ -490,14 +481,13 @@ static int jtagmkI_program_enable(PROGRAMMER * pgm)
|
|||
if (resp[0] != RESP_OK) {
|
||||
if (verbose >= 2)
|
||||
putc('\n', stderr);
|
||||
fprintf(stderr,
|
||||
"%s: jtagmkI_program_enable(): "
|
||||
"timeout/error communicating with programmer (resp %c)\n",
|
||||
progname, resp[0]);
|
||||
avrdude_message("%s: jtagmkI_program_enable(): "
|
||||
"timeout/error communicating with programmer (resp %c)\n",
|
||||
progname, resp[0]);
|
||||
return -1;
|
||||
} else {
|
||||
if (verbose == 2)
|
||||
fprintf(stderr, "OK\n");
|
||||
avrdude_message("OK\n");
|
||||
}
|
||||
|
||||
PDATA(pgm)->prog_enabled = 1;
|
||||
|
@ -515,7 +505,7 @@ static int jtagmkI_program_disable(PROGRAMMER * pgm)
|
|||
if (pgm->fd.ifd != -1) {
|
||||
buf[0] = CMD_LEAVE_PROGMODE;
|
||||
if (verbose >= 2)
|
||||
fprintf(stderr, "%s: jtagmkI_program_disable(): "
|
||||
avrdude_message("%s: jtagmkI_program_disable(): "
|
||||
"Sending leave progmode command: ",
|
||||
progname);
|
||||
jtagmkI_send(pgm, buf, 1);
|
||||
|
@ -525,14 +515,13 @@ static int jtagmkI_program_disable(PROGRAMMER * pgm)
|
|||
if (resp[0] != RESP_OK) {
|
||||
if (verbose >= 2)
|
||||
putc('\n', stderr);
|
||||
fprintf(stderr,
|
||||
"%s: jtagmkI_program_disable(): "
|
||||
"timeout/error communicating with programmer (resp %c)\n",
|
||||
progname, resp[0]);
|
||||
avrdude_message("%s: jtagmkI_program_disable(): "
|
||||
"timeout/error communicating with programmer (resp %c)\n",
|
||||
progname, resp[0]);
|
||||
return -1;
|
||||
} else {
|
||||
if (verbose == 2)
|
||||
fprintf(stderr, "OK\n");
|
||||
avrdude_message("OK\n");
|
||||
}
|
||||
}
|
||||
PDATA(pgm)->prog_enabled = 0;
|
||||
|
@ -561,7 +550,7 @@ static int jtagmkI_initialize(PROGRAMMER * pgm, AVRPART * p)
|
|||
unsigned char b;
|
||||
|
||||
if (!(p->flags & AVRPART_HAS_JTAG)) {
|
||||
fprintf(stderr, "%s: jtagmkI_initialize(): part %s has no JTAG interface\n",
|
||||
avrdude_message("%s: jtagmkI_initialize(): part %s has no JTAG interface\n",
|
||||
progname, p->desc);
|
||||
return -1;
|
||||
}
|
||||
|
@ -570,11 +559,11 @@ 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) {
|
||||
fprintf(stderr, "%s: jtagmkI_initialize(): unsupported baudrate %d\n",
|
||||
avrdude_message("%s: jtagmkI_initialize(): unsupported baudrate %d\n",
|
||||
progname, pgm->baudrate);
|
||||
} else {
|
||||
if (verbose >= 2)
|
||||
fprintf(stderr, "%s: jtagmkI_initialize(): "
|
||||
avrdude_message("%s: jtagmkI_initialize(): "
|
||||
"trying to set baudrate to %d\n",
|
||||
progname, pgm->baudrate);
|
||||
if (jtagmkI_setparm(pgm, PARM_BITRATE, b) == 0) {
|
||||
|
@ -586,7 +575,7 @@ static int jtagmkI_initialize(PROGRAMMER * pgm, AVRPART * p)
|
|||
|
||||
if (pgm->bitclock != 0.0) {
|
||||
if (verbose >= 2)
|
||||
fprintf(stderr, "%s: jtagmkI_initialize(): "
|
||||
avrdude_message("%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)
|
||||
|
@ -600,13 +589,12 @@ static int jtagmkI_initialize(PROGRAMMER * pgm, AVRPART * p)
|
|||
if (resp[0] != RESP_OK) {
|
||||
if (verbose >= 2)
|
||||
putc('\n', stderr);
|
||||
fprintf(stderr,
|
||||
"%s: jtagmkI_initialize(): "
|
||||
"timeout/error communicating with programmer (resp %c)\n",
|
||||
progname, resp[0]);
|
||||
avrdude_message("%s: jtagmkI_initialize(): "
|
||||
"timeout/error communicating with programmer (resp %c)\n",
|
||||
progname, resp[0]);
|
||||
} else {
|
||||
if (verbose == 2)
|
||||
fprintf(stderr, "OK\n");
|
||||
avrdude_message("OK\n");
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -621,12 +609,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) {
|
||||
fprintf(stderr, "%s: jtagmkI_initialize(): Out of memory\n",
|
||||
avrdude_message("%s: jtagmkI_initialize(): Out of memory\n",
|
||||
progname);
|
||||
return -1;
|
||||
}
|
||||
if ((PDATA(pgm)->eeprom_pagecache = malloc(PDATA(pgm)->eeprom_pagesize)) == NULL) {
|
||||
fprintf(stderr, "%s: jtagmkI_initialize(): Out of memory\n",
|
||||
avrdude_message("%s: jtagmkI_initialize(): Out of memory\n",
|
||||
progname);
|
||||
free(PDATA(pgm)->flash_pagecache);
|
||||
return -1;
|
||||
|
@ -640,10 +628,9 @@ static int jtagmkI_initialize(PROGRAMMER * pgm, AVRPART * p)
|
|||
if (jtagmkI_read_byte(pgm, p, &hfuse, 1, &b) < 0)
|
||||
return -1;
|
||||
if ((b & OCDEN) != 0)
|
||||
fprintf(stderr,
|
||||
"%s: jtagmkI_initialize(): warning: OCDEN fuse not programmed, "
|
||||
"single-byte EEPROM updates not possible\n",
|
||||
progname);
|
||||
avrdude_message("%s: jtagmkI_initialize(): warning: OCDEN fuse not programmed, "
|
||||
"single-byte EEPROM updates not possible\n",
|
||||
progname);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -671,7 +658,7 @@ static int jtagmkI_open(PROGRAMMER * pgm, char * port)
|
|||
size_t i;
|
||||
|
||||
if (verbose >= 2)
|
||||
fprintf(stderr, "%s: jtagmkI_open()\n", progname);
|
||||
avrdude_message("%s: jtagmkI_open()\n", progname);
|
||||
|
||||
strcpy(pgm->port, port);
|
||||
PDATA(pgm)->initial_baudrate = -1L;
|
||||
|
@ -680,9 +667,8 @@ static int jtagmkI_open(PROGRAMMER * pgm, char * port)
|
|||
union pinfo pinfo;
|
||||
pinfo.baud = baudtab[i].baud;
|
||||
if (verbose >= 2)
|
||||
fprintf(stderr,
|
||||
"%s: jtagmkI_open(): trying to sync at baud rate %ld:\n",
|
||||
progname, pinfo.baud);
|
||||
avrdude_message("%s: jtagmkI_open(): trying to sync at baud rate %ld:\n",
|
||||
progname, pinfo.baud);
|
||||
if (serial_open(port, pinfo, &pgm->fd)==-1) {
|
||||
return -1;
|
||||
}
|
||||
|
@ -695,16 +681,15 @@ static int jtagmkI_open(PROGRAMMER * pgm, char * port)
|
|||
if (jtagmkI_getsync(pgm) == 0) {
|
||||
PDATA(pgm)->initial_baudrate = baudtab[i].baud;
|
||||
if (verbose >= 2)
|
||||
fprintf(stderr, "%s: jtagmkI_open(): succeeded\n", progname);
|
||||
avrdude_message("%s: jtagmkI_open(): succeeded\n", progname);
|
||||
return 0;
|
||||
}
|
||||
|
||||
serial_close(&pgm->fd);
|
||||
}
|
||||
|
||||
fprintf(stderr,
|
||||
"%s: jtagmkI_open(): failed to synchronize to ICE\n",
|
||||
progname);
|
||||
avrdude_message("%s: jtagmkI_open(): failed to synchronize to ICE\n",
|
||||
progname);
|
||||
pgm->fd.ifd = -1;
|
||||
|
||||
return -1;
|
||||
|
@ -716,7 +701,7 @@ static void jtagmkI_close(PROGRAMMER * pgm)
|
|||
unsigned char b;
|
||||
|
||||
if (verbose >= 2)
|
||||
fprintf(stderr, "%s: jtagmkI_close()\n", progname);
|
||||
avrdude_message("%s: jtagmkI_close()\n", progname);
|
||||
|
||||
/*
|
||||
* Revert baud rate to what it used to be when we started. This
|
||||
|
@ -725,11 +710,11 @@ 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) {
|
||||
fprintf(stderr, "%s: jtagmkI_close(): unsupported baudrate %d\n",
|
||||
avrdude_message("%s: jtagmkI_close(): unsupported baudrate %d\n",
|
||||
progname, PDATA(pgm)->initial_baudrate);
|
||||
} else {
|
||||
if (verbose >= 2)
|
||||
fprintf(stderr, "%s: jtagmkI_close(): "
|
||||
avrdude_message("%s: jtagmkI_close(): "
|
||||
"trying to set baudrate to %d\n",
|
||||
progname, PDATA(pgm)->initial_baudrate);
|
||||
if (jtagmkI_setparm(pgm, PARM_BITRATE, b) == 0) {
|
||||
|
@ -759,7 +744,7 @@ static int jtagmkI_paged_write(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m,
|
|||
#define MAXTRIES 3
|
||||
|
||||
if (verbose >= 2)
|
||||
fprintf(stderr, "%s: jtagmkI_paged_write(.., %s, %d, %d)\n",
|
||||
avrdude_message("%s: jtagmkI_paged_write(.., %s, %d, %d)\n",
|
||||
progname, m->desc, page_size, n_bytes);
|
||||
|
||||
if (jtagmkI_program_enable(pgm) < 0)
|
||||
|
@ -768,13 +753,13 @@ static int jtagmkI_paged_write(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m,
|
|||
if (page_size == 0) page_size = 256;
|
||||
|
||||
if (page_size > 256) {
|
||||
fprintf(stderr, "%s: jtagmkI_paged_write(): page size %d too large\n",
|
||||
avrdude_message("%s: jtagmkI_paged_write(): page size %d too large\n",
|
||||
progname, page_size);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if ((datacmd = malloc(page_size + 1)) == NULL) {
|
||||
fprintf(stderr, "%s: jtagmkI_paged_write(): Out of memory\n",
|
||||
avrdude_message("%s: jtagmkI_paged_write(): Out of memory\n",
|
||||
progname);
|
||||
return -1;
|
||||
}
|
||||
|
@ -798,9 +783,8 @@ static int jtagmkI_paged_write(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m,
|
|||
again:
|
||||
|
||||
if (tries != 0 && jtagmkI_resync(pgm, 2000, 0) < 0) {
|
||||
fprintf(stderr,
|
||||
"%s: jtagmkI_paged_write(): sync loss, retries exhausted\n",
|
||||
progname);
|
||||
avrdude_message("%s: jtagmkI_paged_write(): sync loss, retries exhausted\n",
|
||||
progname);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -809,7 +793,7 @@ static int jtagmkI_paged_write(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m,
|
|||
else
|
||||
block_size = page_size;
|
||||
if (verbose >= 3)
|
||||
fprintf(stderr, "%s: jtagmkI_paged_write(): "
|
||||
avrdude_message("%s: jtagmkI_paged_write(): "
|
||||
"block_size at addr %d is %d\n",
|
||||
progname, addr, block_size);
|
||||
|
||||
|
@ -824,7 +808,7 @@ static int jtagmkI_paged_write(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m,
|
|||
}
|
||||
|
||||
if (verbose >= 2)
|
||||
fprintf(stderr, "%s: jtagmkI_paged_write(): "
|
||||
avrdude_message("%s: jtagmkI_paged_write(): "
|
||||
"Sending write memory command: ",
|
||||
progname);
|
||||
|
||||
|
@ -835,17 +819,16 @@ static int jtagmkI_paged_write(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m,
|
|||
if (resp[0] != RESP_OK) {
|
||||
if (verbose >= 2)
|
||||
putc('\n', stderr);
|
||||
fprintf(stderr,
|
||||
"%s: jtagmkI_paged_write(): "
|
||||
"timeout/error communicating with programmer (resp %c)\n",
|
||||
progname, resp[0]);
|
||||
avrdude_message("%s: jtagmkI_paged_write(): "
|
||||
"timeout/error communicating with programmer (resp %c)\n",
|
||||
progname, resp[0]);
|
||||
if (tries++ < MAXTRIES)
|
||||
goto again;
|
||||
serial_recv_timeout = otimeout;
|
||||
return -1;
|
||||
} else {
|
||||
if (verbose == 2)
|
||||
fprintf(stderr, "OK\n");
|
||||
avrdude_message("OK\n");
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -865,17 +848,16 @@ static int jtagmkI_paged_write(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m,
|
|||
if (resp[1] != RESP_OK) {
|
||||
if (verbose >= 2)
|
||||
putc('\n', stderr);
|
||||
fprintf(stderr,
|
||||
"%s: jtagmkI_paged_write(): "
|
||||
"timeout/error communicating with programmer (resp %c)\n",
|
||||
progname, resp[0]);
|
||||
avrdude_message("%s: jtagmkI_paged_write(): "
|
||||
"timeout/error communicating with programmer (resp %c)\n",
|
||||
progname, resp[0]);
|
||||
if (tries++ < MAXTRIES)
|
||||
goto again;
|
||||
serial_recv_timeout = otimeout;
|
||||
return -1;
|
||||
} else {
|
||||
if (verbose == 2)
|
||||
fprintf(stderr, "OK\n");
|
||||
avrdude_message("OK\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -897,7 +879,7 @@ static int jtagmkI_paged_load(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m,
|
|||
#define MAXTRIES 3
|
||||
|
||||
if (verbose >= 2)
|
||||
fprintf(stderr, "%s: jtagmkI_paged_load(.., %s, %d, %d)\n",
|
||||
avrdude_message("%s: jtagmkI_paged_load(.., %s, %d, %d)\n",
|
||||
progname, m->desc, page_size, n_bytes);
|
||||
|
||||
if (jtagmkI_program_enable(pgm) < 0)
|
||||
|
@ -914,7 +896,7 @@ static int jtagmkI_paged_load(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m,
|
|||
}
|
||||
|
||||
if (page_size > (is_flash? 512: 256)) {
|
||||
fprintf(stderr, "%s: jtagmkI_paged_load(): page size %d too large\n",
|
||||
avrdude_message("%s: jtagmkI_paged_load(): page size %d too large\n",
|
||||
progname, page_size);
|
||||
return -1;
|
||||
}
|
||||
|
@ -924,9 +906,8 @@ static int jtagmkI_paged_load(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m,
|
|||
tries = 0;
|
||||
again:
|
||||
if (tries != 0 && jtagmkI_resync(pgm, 2000, 0) < 0) {
|
||||
fprintf(stderr,
|
||||
"%s: jtagmkI_paged_load(): sync loss, retries exhausted\n",
|
||||
progname);
|
||||
avrdude_message("%s: jtagmkI_paged_load(): sync loss, retries exhausted\n",
|
||||
progname);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -935,7 +916,7 @@ static int jtagmkI_paged_load(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m,
|
|||
else
|
||||
block_size = page_size;
|
||||
if (verbose >= 3)
|
||||
fprintf(stderr, "%s: jtagmkI_paged_load(): "
|
||||
avrdude_message("%s: jtagmkI_paged_load(): "
|
||||
"block_size at addr %d is %d\n",
|
||||
progname, addr, block_size);
|
||||
|
||||
|
@ -950,7 +931,7 @@ static int jtagmkI_paged_load(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m,
|
|||
}
|
||||
|
||||
if (verbose >= 2)
|
||||
fprintf(stderr, "%s: jtagmkI_paged_load(): Sending read memory command: ",
|
||||
avrdude_message("%s: jtagmkI_paged_load(): Sending read memory command: ",
|
||||
progname);
|
||||
|
||||
jtagmkI_send(pgm, cmd, 6);
|
||||
|
@ -960,10 +941,9 @@ 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);
|
||||
fprintf(stderr,
|
||||
"%s: jtagmkI_paged_load(): "
|
||||
"timeout/error communicating with programmer (resp %c)\n",
|
||||
progname, resp[read_size + 3 - 1]);
|
||||
avrdude_message("%s: jtagmkI_paged_load(): "
|
||||
"timeout/error communicating with programmer (resp %c)\n",
|
||||
progname, resp[read_size + 3 - 1]);
|
||||
if (tries++ < MAXTRIES)
|
||||
goto again;
|
||||
|
||||
|
@ -971,7 +951,7 @@ static int jtagmkI_paged_load(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m,
|
|||
return -1;
|
||||
} else {
|
||||
if (verbose == 2)
|
||||
fprintf(stderr, "OK\n");
|
||||
avrdude_message("OK\n");
|
||||
}
|
||||
|
||||
memcpy(m->buf + addr, resp + 1, block_size);
|
||||
|
@ -993,7 +973,7 @@ static int jtagmkI_read_byte(PROGRAMMER * pgm, AVRPART * p, AVRMEM * mem,
|
|||
int is_flash = 0;
|
||||
|
||||
if (verbose >= 2)
|
||||
fprintf(stderr, "%s: jtagmkI_read_byte(.., %s, 0x%lx, ...)\n",
|
||||
avrdude_message("%s: jtagmkI_read_byte(.., %s, 0x%lx, ...)\n",
|
||||
progname, mem->desc, addr);
|
||||
|
||||
if (jtagmkI_program_enable(pgm) < 0)
|
||||
|
@ -1077,14 +1057,13 @@ static int jtagmkI_read_byte(PROGRAMMER * pgm, AVRPART * p, AVRMEM * mem,
|
|||
if (resp[respsize - 1] != RESP_OK) {
|
||||
if (verbose >= 2)
|
||||
putc('\n', stderr);
|
||||
fprintf(stderr,
|
||||
"%s: jtagmkI_read_byte(): "
|
||||
"timeout/error communicating with programmer (resp %c)\n",
|
||||
progname, resp[respsize - 1]);
|
||||
avrdude_message("%s: jtagmkI_read_byte(): "
|
||||
"timeout/error communicating with programmer (resp %c)\n",
|
||||
progname, resp[respsize - 1]);
|
||||
return -1;
|
||||
} else {
|
||||
if (verbose == 2)
|
||||
fprintf(stderr, "OK\n");
|
||||
avrdude_message("OK\n");
|
||||
}
|
||||
|
||||
if (pagesize) {
|
||||
|
@ -1108,7 +1087,7 @@ static int jtagmkI_write_byte(PROGRAMMER * pgm, AVRPART * p, AVRMEM * mem,
|
|||
int len, need_progmode = 1;
|
||||
|
||||
if (verbose >= 2)
|
||||
fprintf(stderr, "%s: jtagmkI_write_byte(.., %s, 0x%lx, ...)\n",
|
||||
avrdude_message("%s: jtagmkI_write_byte(.., %s, 0x%lx, ...)\n",
|
||||
progname, mem->desc, addr);
|
||||
|
||||
writedata = data;
|
||||
|
@ -1163,14 +1142,13 @@ static int jtagmkI_write_byte(PROGRAMMER * pgm, AVRPART * p, AVRMEM * mem,
|
|||
if (resp[0] != RESP_OK) {
|
||||
if (verbose >= 2)
|
||||
putc('\n', stderr);
|
||||
fprintf(stderr,
|
||||
"%s: jtagmkI_write_byte(): "
|
||||
"timeout/error communicating with programmer (resp %c)\n",
|
||||
progname, resp[0]);
|
||||
avrdude_message("%s: jtagmkI_write_byte(): "
|
||||
"timeout/error communicating with programmer (resp %c)\n",
|
||||
progname, resp[0]);
|
||||
return -1;
|
||||
} else {
|
||||
if (verbose == 2)
|
||||
fprintf(stderr, "OK\n");
|
||||
avrdude_message("OK\n");
|
||||
}
|
||||
|
||||
/* Now, send the data buffer. */
|
||||
|
@ -1194,14 +1172,13 @@ static int jtagmkI_write_byte(PROGRAMMER * pgm, AVRPART * p, AVRMEM * mem,
|
|||
if (resp[0] != RESP_OK) {
|
||||
if (verbose >= 2)
|
||||
putc('\n', stderr);
|
||||
fprintf(stderr,
|
||||
"%s: jtagmkI_write_byte(): "
|
||||
"timeout/error communicating with programmer (resp %c)\n",
|
||||
progname, resp[0]);
|
||||
avrdude_message("%s: jtagmkI_write_byte(): "
|
||||
"timeout/error communicating with programmer (resp %c)\n",
|
||||
progname, resp[0]);
|
||||
return -1;
|
||||
} else {
|
||||
if (verbose == 2)
|
||||
fprintf(stderr, "OK\n");
|
||||
avrdude_message("OK\n");
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -1246,12 +1223,12 @@ static int jtagmkI_getparm(PROGRAMMER * pgm, unsigned char parm,
|
|||
unsigned char buf[2], resp[3];
|
||||
|
||||
if (verbose >= 2)
|
||||
fprintf(stderr, "%s: jtagmkI_getparm()\n", progname);
|
||||
avrdude_message("%s: jtagmkI_getparm()\n", progname);
|
||||
|
||||
buf[0] = CMD_GET_PARAM;
|
||||
buf[1] = parm;
|
||||
if (verbose >= 2)
|
||||
fprintf(stderr, "%s: jtagmkI_getparm(): "
|
||||
avrdude_message("%s: jtagmkI_getparm(): "
|
||||
"Sending get parameter command (parm 0x%02x): ",
|
||||
progname, parm);
|
||||
jtagmkI_send(pgm, buf, 2);
|
||||
|
@ -1261,22 +1238,20 @@ static int jtagmkI_getparm(PROGRAMMER * pgm, unsigned char parm,
|
|||
if (resp[0] != RESP_OK) {
|
||||
if (verbose >= 2)
|
||||
putc('\n', stderr);
|
||||
fprintf(stderr,
|
||||
"%s: jtagmkI_getparm(): "
|
||||
"timeout/error communicating with programmer (resp %c)\n",
|
||||
progname, resp[0]);
|
||||
avrdude_message("%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);
|
||||
fprintf(stderr,
|
||||
"%s: jtagmkI_getparm(): "
|
||||
"unknown parameter 0x%02x\n",
|
||||
progname, parm);
|
||||
avrdude_message("%s: jtagmkI_getparm(): "
|
||||
"unknown parameter 0x%02x\n",
|
||||
progname, parm);
|
||||
return -1;
|
||||
} else {
|
||||
if (verbose == 2)
|
||||
fprintf(stderr, "OK, value 0x%02x\n", resp[1]);
|
||||
avrdude_message("OK, value 0x%02x\n", resp[1]);
|
||||
}
|
||||
|
||||
*value = resp[1];
|
||||
|
@ -1293,13 +1268,13 @@ static int jtagmkI_setparm(PROGRAMMER * pgm, unsigned char parm,
|
|||
unsigned char buf[3], resp[2];
|
||||
|
||||
if (verbose >= 2)
|
||||
fprintf(stderr, "%s: jtagmkI_setparm()\n", progname);
|
||||
avrdude_message("%s: jtagmkI_setparm()\n", progname);
|
||||
|
||||
buf[0] = CMD_SET_PARAM;
|
||||
buf[1] = parm;
|
||||
buf[2] = value;
|
||||
if (verbose >= 2)
|
||||
fprintf(stderr, "%s: jtagmkI_setparm(): "
|
||||
avrdude_message("%s: jtagmkI_setparm(): "
|
||||
"Sending set parameter command (parm 0x%02x): ",
|
||||
progname, parm);
|
||||
jtagmkI_send(pgm, buf, 3);
|
||||
|
@ -1308,14 +1283,13 @@ static int jtagmkI_setparm(PROGRAMMER * pgm, unsigned char parm,
|
|||
if (resp[0] != RESP_OK) {
|
||||
if (verbose >= 2)
|
||||
putc('\n', stderr);
|
||||
fprintf(stderr,
|
||||
"%s: jtagmkI_setparm(): "
|
||||
"timeout/error communicating with programmer (resp %c)\n",
|
||||
progname, resp[0]);
|
||||
avrdude_message("%s: jtagmkI_setparm(): "
|
||||
"timeout/error communicating with programmer (resp %c)\n",
|
||||
progname, resp[0]);
|
||||
return -1;
|
||||
} else {
|
||||
if (verbose == 2)
|
||||
fprintf(stderr, "OK\n");
|
||||
avrdude_message("OK\n");
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -1331,8 +1305,8 @@ static void jtagmkI_display(PROGRAMMER * pgm, const char * p)
|
|||
jtagmkI_getparm(pgm, PARM_SW_VERSION, &fw) < 0)
|
||||
return;
|
||||
|
||||
fprintf(stderr, "%sICE hardware version: 0x%02x\n", p, hw);
|
||||
fprintf(stderr, "%sICE firmware version: 0x%02x\n", p, fw);
|
||||
avrdude_message("%sICE hardware version: 0x%02x\n", p, hw);
|
||||
avrdude_message("%sICE firmware version: 0x%02x\n", p, fw);
|
||||
|
||||
jtagmkI_print_parms1(pgm, p);
|
||||
|
||||
|
@ -1376,9 +1350,9 @@ static void jtagmkI_print_parms1(PROGRAMMER * pgm, const char * p)
|
|||
clk = 1e6;
|
||||
}
|
||||
|
||||
fprintf(stderr, "%sVtarget : %.1f V\n", p,
|
||||
avrdude_message("%sVtarget : %.1f V\n", p,
|
||||
6.25 * (unsigned)vtarget / 255.0);
|
||||
fprintf(stderr, "%sJTAG clock : %s (%.1f us)\n", p, clkstr,
|
||||
avrdude_message("%sJTAG clock : %s (%.1f us)\n", p, clkstr,
|
||||
1.0e6 / clk);
|
||||
|
||||
return;
|
||||
|
|
775
jtagmkII.c
775
jtagmkII.c
File diff suppressed because it is too large
Load Diff
10
lexer.l
10
lexer.l
|
@ -95,9 +95,9 @@ SIGN [+-]
|
|||
}
|
||||
|
||||
if (c == EOF) {
|
||||
fprintf(stderr, "error at %s:%d: EOF in comment\n",
|
||||
avrdude_message("error at %s:%d: EOF in comment\n",
|
||||
infile, lineno);
|
||||
fprintf(stderr, " comment started on line %d\n",
|
||||
avrdude_message(" comment started on line %d\n",
|
||||
comment_start);
|
||||
exit(1);
|
||||
break;
|
||||
|
@ -116,7 +116,7 @@ SIGN [+-]
|
|||
<strng>\\(.|\n) *(string_buf_ptr++) = yytext[1];
|
||||
<strng>[^\\\n\"]+ { char *yptr = yytext; while (*yptr)
|
||||
*(string_buf_ptr++) = *(yptr++); }
|
||||
<strng>\n { fprintf(stderr, "error at line %d: unterminated character constant\n",
|
||||
<strng>\n { avrdude_message("error at line %d: unterminated character constant\n",
|
||||
lineno);
|
||||
exit(1); }
|
||||
|
||||
|
@ -255,9 +255,9 @@ yes { yylval=new_token(K_YES); return K_YES; }
|
|||
"\n" { lineno++; }
|
||||
[ \r\t]+ { /* ignore whitespace */ }
|
||||
|
||||
c: { fprintf(stderr, "error at %s:%d: possible old-style config file entry\n",
|
||||
c: { avrdude_message("error at %s:%d: possible old-style config file entry\n",
|
||||
infile, lineno);
|
||||
fprintf(stderr, " Update your config file (see %s%s for a sample)\n",
|
||||
avrdude_message(" Update your config file (see %s%s for a sample)\n",
|
||||
CONFIG_DIR, "/avrdude.conf.sample");
|
||||
return YYERRCODE; }
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
|
||||
#define ppi_claim(fd) \
|
||||
if (ioctl(fd, PPCLAIM)) { \
|
||||
fprintf(stderr, "%s: can't claim device \"%s\": %s\n\n", \
|
||||
avrdude_message("%s: can't claim device \"%s\": %s\n\n", \
|
||||
progname, port, strerror(errno)); \
|
||||
close(fd); \
|
||||
exit(1); \
|
||||
|
@ -41,7 +41,7 @@
|
|||
|
||||
#define ppi_release(fd) \
|
||||
if (ioctl(fd, PPRELEASE)) { \
|
||||
fprintf(stderr, "%s: can't release device: %s\n\n", \
|
||||
avrdude_message("%s: can't release device: %s\n\n", \
|
||||
progname, strerror(errno)); \
|
||||
exit(1); \
|
||||
}
|
||||
|
|
|
@ -219,7 +219,7 @@ static int linuxgpio_highpulsepin(PROGRAMMER * pgm, int pinfunc)
|
|||
|
||||
static void linuxgpio_display(PROGRAMMER *pgm, const char *p)
|
||||
{
|
||||
fprintf(stderr, "%sPin assignment : /sys/class/gpio/gpio{n}\n",p);
|
||||
avrdude_message("%sPin assignment : /sys/class/gpio/gpio{n}\n",p);
|
||||
pgm_display_generic_mask(pgm, p, SHOW_AVR_PINS);
|
||||
}
|
||||
|
||||
|
@ -269,7 +269,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) {
|
||||
fprintf(stderr, "Can't export GPIO %d, already exported/busy?: %s",
|
||||
avrdude_message("Can't export GPIO %d, already exported/busy?: %s",
|
||||
pin, strerror(errno));
|
||||
return r;
|
||||
}
|
||||
|
@ -346,9 +346,8 @@ const char linuxgpio_desc[] = "GPIO bitbanging using the Linux sysfs interface";
|
|||
|
||||
void linuxgpio_initpgm(PROGRAMMER * pgm)
|
||||
{
|
||||
fprintf(stderr,
|
||||
"%s: Linux sysfs GPIO support not available in this configuration\n",
|
||||
progname);
|
||||
avrdude_message("%s: Linux sysfs GPIO support not available in this configuration\n",
|
||||
progname);
|
||||
}
|
||||
|
||||
const char linuxgpio_desc[] = "GPIO bitbanging using the Linux sysfs interface (not available)";
|
||||
|
|
334
main.c
334
main.c
|
@ -33,6 +33,7 @@
|
|||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdarg.h>
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <limits.h>
|
||||
|
@ -65,12 +66,21 @@ char progbuf[PATH_MAX]; /* temporary buffer of spaces the same
|
|||
length as progname; used for lining up
|
||||
multiline messages */
|
||||
|
||||
int yyerror(char * errmsg)
|
||||
int avrdude_message(const char *format, ...)
|
||||
{
|
||||
fprintf(stderr, "%s: %s at %s:%d\n", progname, errmsg, infile, lineno);
|
||||
exit(1);
|
||||
int rc;
|
||||
va_list ap;
|
||||
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);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
struct list_walk_cookie
|
||||
{
|
||||
|
@ -94,12 +104,14 @@ int quell_progress; /* un-verebose output */
|
|||
int ovsigck; /* 1=override sig check, 0=don't */
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* usage message
|
||||
*/
|
||||
static void usage(void)
|
||||
{
|
||||
fprintf(stderr,
|
||||
avrdude_message(
|
||||
"Usage: %s [options]\n"
|
||||
"Options:\n"
|
||||
" -p <partno> Required. Specify AVR device.\n"
|
||||
|
@ -153,18 +165,18 @@ static void update_progress_tty (int percent, double etime, char *hdr)
|
|||
}
|
||||
|
||||
if (hdr) {
|
||||
fprintf (stderr, "\n");
|
||||
avrdude_message("\n");
|
||||
last = 0;
|
||||
header = hdr;
|
||||
}
|
||||
|
||||
if (last == 0) {
|
||||
fprintf(stderr, "\r%s | %s | %d%% %0.2fs",
|
||||
avrdude_message("\r%s | %s | %d%% %0.2fs",
|
||||
header, hashes, percent, etime);
|
||||
}
|
||||
|
||||
if (percent == 100) {
|
||||
if (!last) fprintf (stderr, "\n\n");
|
||||
if (!last) avrdude_message("\n\n");
|
||||
last = 1;
|
||||
}
|
||||
|
||||
|
@ -180,19 +192,19 @@ static void update_progress_no_tty (int percent, double etime, char *hdr)
|
|||
setvbuf(stderr, (char*)NULL, _IONBF, 0);
|
||||
|
||||
if (hdr) {
|
||||
fprintf (stderr, "\n%s | ", hdr);
|
||||
avrdude_message("\n%s | ", hdr);
|
||||
last = 0;
|
||||
done = 0;
|
||||
}
|
||||
else {
|
||||
while ((cnt > last) && (done == 0)) {
|
||||
fprintf (stderr, "#");
|
||||
avrdude_message("#");
|
||||
cnt -= 2;
|
||||
}
|
||||
}
|
||||
|
||||
if ((percent == 100) && (done == 0)) {
|
||||
fprintf (stderr, " | 100%% %0.2fs\n\n", etime);
|
||||
avrdude_message(" | 100%% %0.2fs\n\n", etime);
|
||||
last = 0;
|
||||
done = 1;
|
||||
}
|
||||
|
@ -381,19 +393,19 @@ int main(int argc, char * argv [])
|
|||
|
||||
updates = lcreat(NULL, 0);
|
||||
if (updates == NULL) {
|
||||
fprintf(stderr, "%s: cannot initialize updater list\n", progname);
|
||||
avrdude_message("%s: cannot initialize updater list\n", progname);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
extended_params = lcreat(NULL, 0);
|
||||
if (extended_params == NULL) {
|
||||
fprintf(stderr, "%s: cannot initialize extended parameter list\n", progname);
|
||||
avrdude_message("%s: cannot initialize extended parameter list\n", progname);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
additional_config_files = lcreat(NULL, 0);
|
||||
if (additional_config_files == NULL) {
|
||||
fprintf(stderr, "%s: cannot initialize additional config files list\n", progname);
|
||||
avrdude_message("%s: cannot initialize additional config files list\n", progname);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
@ -466,7 +478,7 @@ int main(int argc, char * argv [])
|
|||
case 'b': /* override default programmer baud rate */
|
||||
baudrate = strtol(optarg, &e, 0);
|
||||
if ((e == optarg) || (*e != 0)) {
|
||||
fprintf(stderr, "%s: invalid baud rate specified '%s'\n",
|
||||
avrdude_message("%s: invalid baud rate specified '%s'\n",
|
||||
progname, optarg);
|
||||
exit(1);
|
||||
}
|
||||
|
@ -475,7 +487,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) {
|
||||
fprintf(stderr, "%s: invalid bit clock period specified '%s'\n",
|
||||
avrdude_message("%s: invalid bit clock period specified '%s'\n",
|
||||
progname, optarg);
|
||||
exit(1);
|
||||
}
|
||||
|
@ -484,7 +496,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) {
|
||||
fprintf(stderr, "%s: invalid isp clock delay specified '%s'\n",
|
||||
avrdude_message("%s: invalid isp clock delay specified '%s'\n",
|
||||
progname, optarg);
|
||||
exit(1);
|
||||
}
|
||||
|
@ -560,7 +572,7 @@ int main(int argc, char * argv [])
|
|||
case 'U':
|
||||
upd = parse_op(optarg);
|
||||
if (upd == NULL) {
|
||||
fprintf(stderr, "%s: error parsing update operation '%s'\n",
|
||||
avrdude_message("%s: error parsing update operation '%s'\n",
|
||||
progname, optarg);
|
||||
exit(1);
|
||||
}
|
||||
|
@ -586,12 +598,12 @@ int main(int argc, char * argv [])
|
|||
break;
|
||||
|
||||
case 'y':
|
||||
fprintf(stderr, "%s: erase cycle counter no longer supported\n",
|
||||
avrdude_message("%s: erase cycle counter no longer supported\n",
|
||||
progname);
|
||||
break;
|
||||
|
||||
case 'Y':
|
||||
fprintf(stderr, "%s: erase cycle counter no longer supported\n",
|
||||
avrdude_message("%s: erase cycle counter no longer supported\n",
|
||||
progname);
|
||||
break;
|
||||
|
||||
|
@ -601,7 +613,7 @@ int main(int argc, char * argv [])
|
|||
break;
|
||||
|
||||
default:
|
||||
fprintf(stderr, "%s: invalid option -%c\n\n", progname, ch);
|
||||
avrdude_message("%s: invalid option -%c\n\n", progname, ch);
|
||||
usage();
|
||||
exit(1);
|
||||
break;
|
||||
|
@ -637,45 +649,42 @@ int main(int argc, char * argv [])
|
|||
* Print out an identifying string so folks can tell what version
|
||||
* they are running
|
||||
*/
|
||||
fprintf(stderr,
|
||||
"\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);
|
||||
avrdude_message("\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) {
|
||||
fprintf(stderr, "%sSystem wide configuration file is \"%s\"\n",
|
||||
avrdude_message("%sSystem wide configuration file is \"%s\"\n",
|
||||
progbuf, sys_config);
|
||||
}
|
||||
|
||||
rc = read_config(sys_config);
|
||||
if (rc) {
|
||||
fprintf(stderr,
|
||||
"%s: error reading system wide configuration file \"%s\"\n",
|
||||
progname, sys_config);
|
||||
avrdude_message("%s: error reading system wide configuration file \"%s\"\n",
|
||||
progname, sys_config);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (usr_config[0] != 0) {
|
||||
if (verbose) {
|
||||
fprintf(stderr, "%sUser configuration file is \"%s\"\n",
|
||||
avrdude_message("%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) {
|
||||
fprintf(stderr,
|
||||
"%sUser configuration file does not exist or is not a "
|
||||
"regular file, skipping\n",
|
||||
progbuf);
|
||||
avrdude_message("%sUser configuration file does not exist or is not a "
|
||||
"regular file, skipping\n",
|
||||
progbuf);
|
||||
}
|
||||
}
|
||||
else {
|
||||
rc = read_config(usr_config);
|
||||
if (rc) {
|
||||
fprintf(stderr, "%s: error reading user configuration file \"%s\"\n",
|
||||
avrdude_message("%s: error reading user configuration file \"%s\"\n",
|
||||
progname, usr_config);
|
||||
exit(1);
|
||||
}
|
||||
|
@ -689,15 +698,14 @@ int main(int argc, char * argv [])
|
|||
for (ln1=lfirst(additional_config_files); ln1; ln1=lnext(ln1)) {
|
||||
p = ldata(ln1);
|
||||
if (verbose) {
|
||||
fprintf(stderr, "%sAdditional configuration file is \"%s\"\n",
|
||||
avrdude_message("%sAdditional configuration file is \"%s\"\n",
|
||||
progbuf, p);
|
||||
}
|
||||
|
||||
rc = read_config(p);
|
||||
if (rc) {
|
||||
fprintf(stderr,
|
||||
"%s: error reading additional configuration file \"%s\"\n",
|
||||
progname, p);
|
||||
avrdude_message("%s: error reading additional configuration file \"%s\"\n",
|
||||
progname, p);
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
@ -709,66 +717,62 @@ int main(int argc, char * argv [])
|
|||
}
|
||||
|
||||
if (verbose) {
|
||||
fprintf(stderr, "\n");
|
||||
avrdude_message("\n");
|
||||
}
|
||||
|
||||
if (partdesc) {
|
||||
if (strcmp(partdesc, "?") == 0) {
|
||||
fprintf(stderr, "\n");
|
||||
fprintf(stderr,"Valid parts are:\n");
|
||||
avrdude_message("\n");
|
||||
avrdude_message("Valid parts are:\n");
|
||||
list_parts(stderr, " ", part_list);
|
||||
fprintf(stderr, "\n");
|
||||
avrdude_message("\n");
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
if (programmer) {
|
||||
if (strcmp(programmer, "?") == 0) {
|
||||
fprintf(stderr, "\n");
|
||||
fprintf(stderr,"Valid programmers are:\n");
|
||||
avrdude_message("\n");
|
||||
avrdude_message("Valid programmers are:\n");
|
||||
list_programmers(stderr, " ", programmers);
|
||||
fprintf(stderr,"\n");
|
||||
avrdude_message("\n");
|
||||
exit(1);
|
||||
}
|
||||
if (strcmp(programmer, "?type") == 0) {
|
||||
fprintf(stderr, "\n");
|
||||
fprintf(stderr,"Valid programmer types are:\n");
|
||||
avrdude_message("\n");
|
||||
avrdude_message("Valid programmer types are:\n");
|
||||
list_programmer_types(stderr, " ");
|
||||
fprintf(stderr,"\n");
|
||||
avrdude_message("\n");
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (programmer[0] == 0) {
|
||||
fprintf(stderr,
|
||||
"\n%s: no programmer has been specified on the command line "
|
||||
"or the config file\n",
|
||||
progname);
|
||||
fprintf(stderr,
|
||||
"%sSpecify a programmer using the -c option and try again\n\n",
|
||||
progbuf);
|
||||
avrdude_message("\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",
|
||||
progbuf);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
pgm = locate_programmer(programmers, programmer);
|
||||
if (pgm == NULL) {
|
||||
fprintf(stderr,"\n");
|
||||
fprintf(stderr,
|
||||
"%s: Can't find programmer id \"%s\"\n",
|
||||
progname, programmer);
|
||||
fprintf(stderr,"\nValid programmers are:\n");
|
||||
avrdude_message("\n");
|
||||
avrdude_message("%s: Can't find programmer id \"%s\"\n",
|
||||
progname, programmer);
|
||||
avrdude_message("\nValid programmers are:\n");
|
||||
list_programmers(stderr, " ", programmers);
|
||||
fprintf(stderr,"\n");
|
||||
avrdude_message("\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (pgm->initpgm) {
|
||||
pgm->initpgm(pgm);
|
||||
} else {
|
||||
fprintf(stderr,
|
||||
"\n%s: Can't initialize the programmer.\n\n",
|
||||
progname);
|
||||
avrdude_message("\n%s: Can't initialize the programmer.\n\n",
|
||||
progname);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
@ -781,15 +785,13 @@ int main(int argc, char * argv [])
|
|||
|
||||
if (lsize(extended_params) > 0) {
|
||||
if (pgm->parseextparams == NULL) {
|
||||
fprintf(stderr,
|
||||
"%s: WARNING: Programmer doesn't support extended parameters,"
|
||||
" -x option(s) ignored\n",
|
||||
progname);
|
||||
avrdude_message("%s: WARNING: Programmer doesn't support extended parameters,"
|
||||
" -x option(s) ignored\n",
|
||||
progname);
|
||||
} else {
|
||||
if (pgm->parseextparams(pgm, extended_params) < 0) {
|
||||
fprintf(stderr,
|
||||
"%s: Error parsing extended parameter list\n",
|
||||
progname);
|
||||
avrdude_message("%s: Error parsing extended parameter list\n",
|
||||
progname);
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
@ -813,33 +815,30 @@ int main(int argc, char * argv [])
|
|||
}
|
||||
|
||||
if (partdesc == NULL) {
|
||||
fprintf(stderr,
|
||||
"%s: No AVR part has been specified, use \"-p Part\"\n\n",
|
||||
progname);
|
||||
fprintf(stderr,"Valid parts are:\n");
|
||||
avrdude_message("%s: No AVR part has been specified, use \"-p Part\"\n\n",
|
||||
progname);
|
||||
avrdude_message("Valid parts are:\n");
|
||||
list_parts(stderr, " ", part_list);
|
||||
fprintf(stderr, "\n");
|
||||
avrdude_message("\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
||||
p = locate_part(part_list, partdesc);
|
||||
if (p == NULL) {
|
||||
fprintf(stderr,
|
||||
"%s: AVR Part \"%s\" not found.\n\n",
|
||||
progname, partdesc);
|
||||
fprintf(stderr,"Valid parts are:\n");
|
||||
avrdude_message("%s: AVR Part \"%s\" not found.\n\n",
|
||||
progname, partdesc);
|
||||
avrdude_message("Valid parts are:\n");
|
||||
list_parts(stderr, " ", part_list);
|
||||
fprintf(stderr, "\n");
|
||||
avrdude_message("\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
||||
if (exitspecs != NULL) {
|
||||
if (pgm->parseexitspecs == NULL) {
|
||||
fprintf(stderr,
|
||||
"%s: WARNING: -E option not supported by this programmer type\n",
|
||||
progname);
|
||||
avrdude_message("%s: WARNING: -E option not supported by this programmer type\n",
|
||||
progname);
|
||||
exitspecs = NULL;
|
||||
}
|
||||
else if (pgm->parseexitspecs(pgm, exitspecs) < 0) {
|
||||
|
@ -873,7 +872,7 @@ int main(int argc, char * argv [])
|
|||
|
||||
if (avr_initmem(p) != 0)
|
||||
{
|
||||
fprintf(stderr, "\n%s: failed to initialize memories\n",
|
||||
avrdude_message("\n%s: failed to initialize memories\n",
|
||||
progname);
|
||||
exit(1);
|
||||
}
|
||||
|
@ -889,14 +888,13 @@ int main(int argc, char * argv [])
|
|||
if (upd->memtype == NULL) {
|
||||
const char *mtype = (p->flags & AVRPART_HAS_PDI)? "application": "flash";
|
||||
if (verbose >= 2) {
|
||||
fprintf(stderr,
|
||||
"%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("%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) {
|
||||
fprintf(stderr, "%s: out of memory\n", progname);
|
||||
avrdude_message("%s: out of memory\n", progname);
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
@ -906,41 +904,41 @@ int main(int argc, char * argv [])
|
|||
* open the programmer
|
||||
*/
|
||||
if (port[0] == 0) {
|
||||
fprintf(stderr, "\n%s: no port has been specified on the command line "
|
||||
avrdude_message("\n%s: no port has been specified on the command line "
|
||||
"or the config file\n",
|
||||
progname);
|
||||
fprintf(stderr, "%sSpecify a port using the -P option and try again\n\n",
|
||||
avrdude_message("%sSpecify a port using the -P option and try again\n\n",
|
||||
progbuf);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (verbose) {
|
||||
fprintf(stderr, "%sUsing Port : %s\n", progbuf, port);
|
||||
fprintf(stderr, "%sUsing Programmer : %s\n", progbuf, programmer);
|
||||
avrdude_message("%sUsing Port : %s\n", progbuf, port);
|
||||
avrdude_message("%sUsing Programmer : %s\n", progbuf, programmer);
|
||||
if ((strcmp(pgm->type, "avr910") == 0)) {
|
||||
fprintf(stderr, "%savr910_devcode (avrdude.conf) : ", progbuf);
|
||||
if(p->avr910_devcode)fprintf(stderr, "0x%x\n", p->avr910_devcode);
|
||||
else fprintf(stderr, "none\n");
|
||||
}
|
||||
avrdude_message("%savr910_devcode (avrdude.conf) : ", progbuf);
|
||||
if(p->avr910_devcode)avrdude_message("0x%x\n", p->avr910_devcode);
|
||||
else avrdude_message("none\n");
|
||||
}
|
||||
}
|
||||
|
||||
if (baudrate != 0) {
|
||||
if (verbose) {
|
||||
fprintf(stderr, "%sOverriding Baud Rate : %d\n", progbuf, baudrate);
|
||||
avrdude_message("%sOverriding Baud Rate : %d\n", progbuf, baudrate);
|
||||
}
|
||||
pgm->baudrate = baudrate;
|
||||
}
|
||||
|
||||
if (bitclock != 0.0) {
|
||||
if (verbose) {
|
||||
fprintf(stderr, "%sSetting bit clk period : %.1f\n", progbuf, bitclock);
|
||||
avrdude_message("%sSetting bit clk period : %.1f\n", progbuf, bitclock);
|
||||
}
|
||||
pgm->bitclock = bitclock * 1e-6;
|
||||
}
|
||||
|
||||
if (ispdelay != 0) {
|
||||
if (verbose) {
|
||||
fprintf(stderr, "%sSetting isp clock delay : %3i\n", progbuf, ispdelay);
|
||||
avrdude_message("%sSetting isp clock delay : %3i\n", progbuf, ispdelay);
|
||||
}
|
||||
pgm->ispdelay = ispdelay;
|
||||
}
|
||||
|
@ -959,30 +957,28 @@ int main(int argc, char * argv [])
|
|||
* as outlined in appnote AVR053
|
||||
*/
|
||||
if (pgm->perform_osccal == 0) {
|
||||
fprintf(stderr,
|
||||
"%s: programmer does not support RC oscillator calibration\n",
|
||||
progname);
|
||||
avrdude_message("%s: programmer does not support RC oscillator calibration\n",
|
||||
progname);
|
||||
exitrc = 1;
|
||||
} else {
|
||||
fprintf(stderr, "%s: performing RC oscillator calibration\n", progname);
|
||||
avrdude_message("%s: performing RC oscillator calibration\n", progname);
|
||||
exitrc = pgm->perform_osccal(pgm);
|
||||
}
|
||||
if (exitrc == 0 && quell_progress < 2) {
|
||||
fprintf(stderr,
|
||||
"%s: calibration value is now stored in EEPROM at address 0\n",
|
||||
progname);
|
||||
avrdude_message("%s: calibration value is now stored in EEPROM at address 0\n",
|
||||
progname);
|
||||
}
|
||||
goto main_exit;
|
||||
}
|
||||
|
||||
if (verbose) {
|
||||
avr_display(stderr, p, progbuf, verbose);
|
||||
fprintf(stderr, "\n");
|
||||
avrdude_message("\n");
|
||||
programmer_display(pgm, progbuf);
|
||||
}
|
||||
|
||||
if (quell_progress < 2) {
|
||||
fprintf(stderr, "\n");
|
||||
avrdude_message("\n");
|
||||
}
|
||||
|
||||
exitrc = 0;
|
||||
|
@ -1005,9 +1001,9 @@ int main(int argc, char * argv [])
|
|||
*/
|
||||
init_ok = (rc = pgm->initialize(pgm, p)) >= 0;
|
||||
if (!init_ok) {
|
||||
fprintf(stderr, "%s: initialization failed, rc=%d\n", progname, rc);
|
||||
avrdude_message("%s: initialization failed, rc=%d\n", progname, rc);
|
||||
if (!ovsigck) {
|
||||
fprintf(stderr, "%sDouble check connections and try again, "
|
||||
avrdude_message("%sDouble check connections and try again, "
|
||||
"or use -F to override\n"
|
||||
"%sthis check.\n\n",
|
||||
progbuf, progbuf);
|
||||
|
@ -1020,9 +1016,8 @@ int main(int argc, char * argv [])
|
|||
pgm->rdy_led(pgm, ON);
|
||||
|
||||
if (quell_progress < 2) {
|
||||
fprintf(stderr,
|
||||
"%s: AVR device initialized and ready to accept instructions\n",
|
||||
progname);
|
||||
avrdude_message("%s: AVR device initialized and ready to accept instructions\n",
|
||||
progname);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -1040,7 +1035,7 @@ int main(int argc, char * argv [])
|
|||
if (init_ok) {
|
||||
rc = avr_signature(pgm, p);
|
||||
if (rc != 0) {
|
||||
fprintf(stderr, "%s: error reading signature data, rc=%d\n",
|
||||
avrdude_message("%s: error reading signature data, rc=%d\n",
|
||||
progname, rc);
|
||||
exitrc = 1;
|
||||
goto main_exit;
|
||||
|
@ -1049,21 +1044,20 @@ int main(int argc, char * argv [])
|
|||
|
||||
sig = avr_locate_mem(p, "signature");
|
||||
if (sig == NULL) {
|
||||
fprintf(stderr,
|
||||
"%s: WARNING: signature data not defined for device \"%s\"\n",
|
||||
progname, p->desc);
|
||||
avrdude_message("%s: WARNING: signature data not defined for device \"%s\"\n",
|
||||
progname, p->desc);
|
||||
}
|
||||
|
||||
if (sig != NULL) {
|
||||
int ff, zz;
|
||||
|
||||
if (quell_progress < 2) {
|
||||
fprintf(stderr, "%s: Device signature = 0x", progname);
|
||||
avrdude_message("%s: Device signature = 0x", progname);
|
||||
}
|
||||
ff = zz = 1;
|
||||
for (i=0; i<sig->size; i++) {
|
||||
if (quell_progress < 2) {
|
||||
fprintf(stderr, "%02x", sig->buf[i]);
|
||||
avrdude_message("%02x", sig->buf[i]);
|
||||
}
|
||||
if (sig->buf[i] != 0xff)
|
||||
ff = 0;
|
||||
|
@ -1074,17 +1068,16 @@ int main(int argc, char * argv [])
|
|||
if (++attempt < 3) {
|
||||
waittime *= 5;
|
||||
if (quell_progress < 2) {
|
||||
fprintf(stderr, " (retrying)\n");
|
||||
avrdude_message(" (retrying)\n");
|
||||
}
|
||||
goto sig_again;
|
||||
}
|
||||
if (quell_progress < 2) {
|
||||
fprintf(stderr, "\n");
|
||||
avrdude_message("\n");
|
||||
}
|
||||
fprintf(stderr,
|
||||
"%s: Yikes! Invalid device signature.\n", progname);
|
||||
avrdude_message("%s: Yikes! Invalid device signature.\n", progname);
|
||||
if (!ovsigck) {
|
||||
fprintf(stderr, "%sDouble check connections and try again, "
|
||||
avrdude_message("%sDouble check connections and try again, "
|
||||
"or use -F to override\n"
|
||||
"%sthis check.\n\n",
|
||||
progbuf, progbuf);
|
||||
|
@ -1093,7 +1086,7 @@ int main(int argc, char * argv [])
|
|||
}
|
||||
} else {
|
||||
if (quell_progress < 2) {
|
||||
fprintf(stderr, "\n");
|
||||
avrdude_message("\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1101,12 +1094,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]) {
|
||||
fprintf(stderr,
|
||||
"%s: Expected signature for %s is %02X %02X %02X\n",
|
||||
progname, p->desc,
|
||||
p->signature[0], p->signature[1], p->signature[2]);
|
||||
avrdude_message("%s: Expected signature for %s is %02X %02X %02X\n",
|
||||
progname, p->desc,
|
||||
p->signature[0], p->signature[1], p->signature[2]);
|
||||
if (!ovsigck) {
|
||||
fprintf(stderr, "%sDouble check chip, "
|
||||
avrdude_message("%sDouble check chip, "
|
||||
"or use -F to override this check.\n",
|
||||
progbuf);
|
||||
exitrc = 1;
|
||||
|
@ -1130,7 +1122,7 @@ int main(int argc, char * argv [])
|
|||
{
|
||||
if (verbose > 0)
|
||||
{
|
||||
fprintf(stderr, "%s: safemode: Fuse reading not support by programmer.\n"
|
||||
avrdude_message("%s: safemode: Fuse reading not support by programmer.\n"
|
||||
" Safemode disabled.\n", progname);
|
||||
}
|
||||
safemode = 0;
|
||||
|
@ -1138,7 +1130,7 @@ int main(int argc, char * argv [])
|
|||
else
|
||||
{
|
||||
|
||||
fprintf(stderr, "%s: safemode: To protect your AVR the programming "
|
||||
avrdude_message("%s: safemode: To protect your AVR the programming "
|
||||
"will be aborted\n",
|
||||
progname);
|
||||
exitrc = 1;
|
||||
|
@ -1154,11 +1146,10 @@ int main(int argc, char * argv [])
|
|||
if ((p->flags & AVRPART_HAS_PDI) && pgm->page_erase != NULL &&
|
||||
lsize(updates) > 0) {
|
||||
if (quell_progress < 2) {
|
||||
fprintf(stderr,
|
||||
"%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);
|
||||
avrdude_message("%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);
|
||||
}
|
||||
} else {
|
||||
AVRMEM * m;
|
||||
|
@ -1173,11 +1164,10 @@ int main(int argc, char * argv [])
|
|||
if ((strcasecmp(m->desc, memname) == 0) && (upd->op == DEVICE_WRITE)) {
|
||||
erase = 1;
|
||||
if (quell_progress < 2) {
|
||||
fprintf(stderr,
|
||||
"%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);
|
||||
avrdude_message("%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);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -1191,12 +1181,11 @@ int main(int argc, char * argv [])
|
|||
* before the chip can accept new programming
|
||||
*/
|
||||
if (uflags & UF_NOWRITE) {
|
||||
fprintf(stderr,
|
||||
"%s: conflicting -e and -n options specified, NOT erasing chip\n",
|
||||
progname);
|
||||
avrdude_message("%s: conflicting -e and -n options specified, NOT erasing chip\n",
|
||||
progname);
|
||||
} else {
|
||||
if (quell_progress < 2) {
|
||||
fprintf(stderr, "%s: erasing chip\n", progname);
|
||||
avrdude_message("%s: erasing chip\n", progname);
|
||||
}
|
||||
exitrc = avr_chip_erase(pgm, p);
|
||||
if(exitrc) goto main_exit;
|
||||
|
@ -1241,7 +1230,7 @@ int main(int argc, char * argv [])
|
|||
char yes[1] = {'y'};
|
||||
|
||||
if (quell_progress < 2) {
|
||||
fprintf(stderr, "\n");
|
||||
avrdude_message("\n");
|
||||
}
|
||||
|
||||
//Restore the default fuse values
|
||||
|
@ -1252,20 +1241,19 @@ int main(int argc, char * argv [])
|
|||
&safemodeafter_efuse, &safemodeafter_fuse, pgm, p, verbose) != 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) {
|
||||
fprintf(stderr,
|
||||
"%s: safemode: Sorry, reading back fuses was unreliable. "
|
||||
"I have given up and exited programming mode\n",
|
||||
progname);
|
||||
&safemodeafter_efuse, &safemodeafter_fuse, pgm, p, verbose) != 0) {
|
||||
avrdude_message("%s: safemode: Sorry, reading back fuses was unreliable. "
|
||||
"I have given up and exited programming mode\n",
|
||||
progname);
|
||||
exitrc = 1;
|
||||
goto main_exit;
|
||||
goto main_exit;
|
||||
}
|
||||
}
|
||||
|
||||
/* Now check what fuses are against what they should be */
|
||||
if (safemodeafter_fuse != safemode_fuse) {
|
||||
fuses_updated = 1;
|
||||
fprintf(stderr, "%s: safemode: fuse changed! Was %x, and is now %x\n",
|
||||
avrdude_message("%s: safemode: fuse changed! Was %x, and is now %x\n",
|
||||
progname, safemode_fuse, safemodeafter_fuse);
|
||||
|
||||
|
||||
|
@ -1281,10 +1269,10 @@ 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) {
|
||||
fprintf(stderr, "%s: safemode: and is now rescued\n", progname);
|
||||
avrdude_message("%s: safemode: and is now rescued\n", progname);
|
||||
}
|
||||
else {
|
||||
fprintf(stderr, "%s: and COULD NOT be changed\n", progname);
|
||||
avrdude_message("%s: and COULD NOT be changed\n", progname);
|
||||
failures++;
|
||||
}
|
||||
}
|
||||
|
@ -1293,7 +1281,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;
|
||||
fprintf(stderr, "%s: safemode: lfuse changed! Was %x, and is now %x\n",
|
||||
avrdude_message("%s: safemode: lfuse changed! Was %x, and is now %x\n",
|
||||
progname, safemode_lfuse, safemodeafter_lfuse);
|
||||
|
||||
|
||||
|
@ -1309,10 +1297,10 @@ 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) {
|
||||
fprintf(stderr, "%s: safemode: and is now rescued\n", progname);
|
||||
avrdude_message("%s: safemode: and is now rescued\n", progname);
|
||||
}
|
||||
else {
|
||||
fprintf(stderr, "%s: and COULD NOT be changed\n", progname);
|
||||
avrdude_message("%s: and COULD NOT be changed\n", progname);
|
||||
failures++;
|
||||
}
|
||||
}
|
||||
|
@ -1321,7 +1309,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;
|
||||
fprintf(stderr, "%s: safemode: hfuse changed! Was %x, and is now %x\n",
|
||||
avrdude_message("%s: safemode: hfuse changed! Was %x, and is now %x\n",
|
||||
progname, safemode_hfuse, safemodeafter_hfuse);
|
||||
|
||||
/* Ask user - should we change them */
|
||||
|
@ -1334,10 +1322,10 @@ 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) {
|
||||
fprintf(stderr, "%s: safemode: and is now rescued\n", progname);
|
||||
avrdude_message("%s: safemode: and is now rescued\n", progname);
|
||||
}
|
||||
else {
|
||||
fprintf(stderr, "%s: and COULD NOT be changed\n", progname);
|
||||
avrdude_message("%s: and COULD NOT be changed\n", progname);
|
||||
failures++;
|
||||
}
|
||||
}
|
||||
|
@ -1346,7 +1334,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;
|
||||
fprintf(stderr, "%s: safemode: efuse changed! Was %x, and is now %x\n",
|
||||
avrdude_message("%s: safemode: efuse changed! Was %x, and is now %x\n",
|
||||
progname, safemode_efuse, safemodeafter_efuse);
|
||||
|
||||
/* Ask user - should we change them */
|
||||
|
@ -1359,23 +1347,23 @@ 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) {
|
||||
fprintf(stderr, "%s: safemode: and is now rescued\n", progname);
|
||||
avrdude_message("%s: safemode: and is now rescued\n", progname);
|
||||
}
|
||||
else {
|
||||
fprintf(stderr, "%s: and COULD NOT be changed\n", progname);
|
||||
avrdude_message("%s: and COULD NOT be changed\n", progname);
|
||||
failures++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (quell_progress < 2) {
|
||||
fprintf(stderr, "%s: safemode: ", progname);
|
||||
avrdude_message("%s: safemode: ", progname);
|
||||
if (failures == 0) {
|
||||
fprintf(stderr, "Fuses OK (E:%02X, H:%02X, L:%02X)\n",
|
||||
avrdude_message("Fuses OK (E:%02X, H:%02X, L:%02X)\n",
|
||||
safemode_efuse, safemode_hfuse, safemode_lfuse);
|
||||
}
|
||||
else {
|
||||
fprintf(stderr, "Fuses not recovered, sorry\n");
|
||||
avrdude_message("Fuses not recovered, sorry\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1403,7 +1391,7 @@ main_exit:
|
|||
}
|
||||
|
||||
if (quell_progress < 2) {
|
||||
fprintf(stderr, "\n%s done. Thank you.\n\n", progname);
|
||||
avrdude_message("\n%s done. Thank you.\n\n", progname);
|
||||
}
|
||||
|
||||
return exitrc;
|
||||
|
|
11
par.c
11
par.c
|
@ -242,7 +242,7 @@ static int par_open(PROGRAMMER * pgm, char * port)
|
|||
|
||||
ppi_open(port, &pgm->fd);
|
||||
if (pgm->fd.ifd < 0) {
|
||||
fprintf(stderr, "%s: failed to open parallel port \"%s\"\n\n",
|
||||
avrdude_message("%s: failed to open parallel port \"%s\"\n\n",
|
||||
progname, port);
|
||||
return -1;
|
||||
}
|
||||
|
@ -252,14 +252,14 @@ static int par_open(PROGRAMMER * pgm, char * port)
|
|||
*/
|
||||
rc = ppi_getall(&pgm->fd, PPIDATA);
|
||||
if (rc < 0) {
|
||||
fprintf(stderr, "%s: error reading status of ppi data port\n", progname);
|
||||
avrdude_message("%s: error reading status of ppi data port\n", progname);
|
||||
return -1;
|
||||
}
|
||||
pgm->ppidata = rc;
|
||||
|
||||
rc = ppi_getall(&pgm->fd, PPICTRL);
|
||||
if (rc < 0) {
|
||||
fprintf(stderr, "%s: error reading status of ppi ctrl port\n", progname);
|
||||
avrdude_message("%s: error reading status of ppi ctrl port\n", progname);
|
||||
return -1;
|
||||
}
|
||||
pgm->ppictrl = rc;
|
||||
|
@ -403,9 +403,8 @@ void par_initpgm(PROGRAMMER * pgm)
|
|||
|
||||
void par_initpgm(PROGRAMMER * pgm)
|
||||
{
|
||||
fprintf(stderr,
|
||||
"%s: parallel port access not available in this configuration\n",
|
||||
progname);
|
||||
avrdude_message("%s: parallel port access not available in this configuration\n",
|
||||
progname);
|
||||
}
|
||||
|
||||
#endif /* HAVE_PARPORT */
|
||||
|
|
34
pgm.c
34
pgm.c
|
@ -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)
|
||||
{
|
||||
fprintf (stderr, "\n%s: Fatal error: Programmer does not support open()",
|
||||
avrdude_message("\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) {
|
||||
fprintf(stderr, "%s: out of memory allocating programmer structure\n",
|
||||
avrdude_message("%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) {
|
||||
fprintf(stderr, "%s: out of memory allocating programmer structure\n",
|
||||
avrdude_message("%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) {
|
||||
fprintf(stderr, "%s: out of memory allocating programmer structure\n",
|
||||
avrdude_message("%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)
|
||||
{
|
||||
fprintf(stderr, "%s: programmer operation not supported\n", progname);
|
||||
avrdude_message("%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)
|
||||
{
|
||||
fprintf(stderr, "%sProgrammer Type : %s\n", p, pgm->type);
|
||||
fprintf(stderr, "%sDescription : %s\n", p, pgm->desc);
|
||||
avrdude_message("%sProgrammer Type : %s\n", p, pgm->type);
|
||||
avrdude_message("%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))
|
||||
fprintf(stderr, "%s VCC = %s\n", p, pins_to_str(&pgm->pin[PPI_AVR_VCC]));
|
||||
avrdude_message("%s VCC = %s\n", p, pins_to_str(&pgm->pin[PPI_AVR_VCC]));
|
||||
if(show & (1<<PPI_AVR_BUFF))
|
||||
fprintf(stderr, "%s BUFF = %s\n", p, pins_to_str(&pgm->pin[PPI_AVR_BUFF]));
|
||||
avrdude_message("%s BUFF = %s\n", p, pins_to_str(&pgm->pin[PPI_AVR_BUFF]));
|
||||
if(show & (1<<PIN_AVR_RESET))
|
||||
fprintf(stderr, "%s RESET = %s\n", p, pins_to_str(&pgm->pin[PIN_AVR_RESET]));
|
||||
avrdude_message("%s RESET = %s\n", p, pins_to_str(&pgm->pin[PIN_AVR_RESET]));
|
||||
if(show & (1<<PIN_AVR_SCK))
|
||||
fprintf(stderr, "%s SCK = %s\n", p, pins_to_str(&pgm->pin[PIN_AVR_SCK]));
|
||||
avrdude_message("%s SCK = %s\n", p, pins_to_str(&pgm->pin[PIN_AVR_SCK]));
|
||||
if(show & (1<<PIN_AVR_MOSI))
|
||||
fprintf(stderr, "%s MOSI = %s\n", p, pins_to_str(&pgm->pin[PIN_AVR_MOSI]));
|
||||
avrdude_message("%s MOSI = %s\n", p, pins_to_str(&pgm->pin[PIN_AVR_MOSI]));
|
||||
if(show & (1<<PIN_AVR_MISO))
|
||||
fprintf(stderr, "%s MISO = %s\n", p, pins_to_str(&pgm->pin[PIN_AVR_MISO]));
|
||||
avrdude_message("%s MISO = %s\n", p, pins_to_str(&pgm->pin[PIN_AVR_MISO]));
|
||||
if(show & (1<<PIN_LED_ERR))
|
||||
fprintf(stderr, "%s ERR LED = %s\n", p, pins_to_str(&pgm->pin[PIN_LED_ERR]));
|
||||
avrdude_message("%s ERR LED = %s\n", p, pins_to_str(&pgm->pin[PIN_LED_ERR]));
|
||||
if(show & (1<<PIN_LED_RDY))
|
||||
fprintf(stderr, "%s RDY LED = %s\n", p, pins_to_str(&pgm->pin[PIN_LED_RDY]));
|
||||
avrdude_message("%s RDY LED = %s\n", p, pins_to_str(&pgm->pin[PIN_LED_RDY]));
|
||||
if(show & (1<<PIN_LED_PGM))
|
||||
fprintf(stderr, "%s PGM LED = %s\n", p, pins_to_str(&pgm->pin[PIN_LED_PGM]));
|
||||
avrdude_message("%s PGM LED = %s\n", p, pins_to_str(&pgm->pin[PIN_LED_PGM]));
|
||||
if(show & (1<<PIN_LED_VFY))
|
||||
fprintf(stderr, "%s VFY LED = %s\n", p, pins_to_str(&pgm->pin[PIN_LED_VFY]));
|
||||
avrdude_message("%s VFY LED = %s\n", p, pins_to_str(&pgm->pin[PIN_LED_VFY]));
|
||||
}
|
||||
|
||||
void pgm_display_generic(PROGRAMMER * pgm, const char * p)
|
||||
|
|
87
pickit2.c
87
pickit2.c
|
@ -76,13 +76,13 @@
|
|||
#endif
|
||||
|
||||
#if 0
|
||||
#define DEBUG(...) do { fprintf(stderr, __VA_ARGS__); } while(0)
|
||||
#define DEBUG(...) do { avrdude_message(__VA_ARGS__); } while(0)
|
||||
#else
|
||||
#define DEBUG(...) ((void)0)
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
#define DEBUGRECV(...) do { fprintf(stderr, __VA_ARGS__); } while(0)
|
||||
#define DEBUGRECV(...) do { avrdude_message(__VA_ARGS__); } while(0)
|
||||
#else
|
||||
#define DEBUGRECV(...) ((void)0)
|
||||
#endif
|
||||
|
@ -169,9 +169,8 @@ static void pickit2_setup(PROGRAMMER * pgm)
|
|||
{
|
||||
if ((pgm->cookie = malloc(sizeof(struct pdata))) == 0)
|
||||
{
|
||||
fprintf(stderr,
|
||||
"%s: pickit2_setup(): Out of memory allocating private data\n",
|
||||
progname);
|
||||
avrdude_message("%s: pickit2_setup(): Out of memory allocating private data\n",
|
||||
progname);
|
||||
exit(1);
|
||||
}
|
||||
memset(pgm->cookie, 0, sizeof(struct pdata));
|
||||
|
@ -193,9 +192,8 @@ static int pickit2_open(PROGRAMMER * pgm, char * port)
|
|||
if (PDATA(pgm)->usb_handle == INVALID_HANDLE_VALUE)
|
||||
{
|
||||
/* no PICkit2 found */
|
||||
fprintf(stderr,
|
||||
"%s: error: could not find PICkit2 with vid=0x%x pid=0x%x\n",
|
||||
progname, PICKIT2_VID, PICKIT2_PID);
|
||||
avrdude_message("%s: error: could not find PICkit2 with vid=0x%x pid=0x%x\n",
|
||||
progname, PICKIT2_VID, PICKIT2_PID);
|
||||
return -1;
|
||||
}
|
||||
else
|
||||
|
@ -215,9 +213,8 @@ static int pickit2_open(PROGRAMMER * pgm, char * port)
|
|||
if (usb_open_device(&(PDATA(pgm)->usb_handle), PICKIT2_VID, PICKIT2_PID) < 0)
|
||||
{
|
||||
/* no PICkit2 found */
|
||||
fprintf(stderr,
|
||||
"%s: error: could not find PICkit2 with vid=0x%x pid=0x%x\n",
|
||||
progname, PICKIT2_VID, PICKIT2_PID);
|
||||
avrdude_message("%s: error: could not find PICkit2 with vid=0x%x pid=0x%x\n",
|
||||
progname, PICKIT2_VID, PICKIT2_PID);
|
||||
return -1;
|
||||
}
|
||||
#endif
|
||||
|
@ -267,7 +264,7 @@ static int pickit2_initialize(PROGRAMMER * pgm, AVRPART * p)
|
|||
{
|
||||
if (verbose)
|
||||
{
|
||||
fprintf(stderr, "%s: %s firmware version %d.%d.%d\n", progname, pgm->desc, (int)report[1], (int)report[2], (int)report[3]);
|
||||
avrdude_message("%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,
|
||||
|
@ -303,19 +300,19 @@ static int pickit2_initialize(PROGRAMMER * pgm, AVRPART * p)
|
|||
|
||||
if (pickit2_write_report(pgm, report) < 0)
|
||||
{
|
||||
fprintf(stderr, "pickit2_read_report failed (ec %d). %s\n", errorCode, usb_strerror());
|
||||
avrdude_message("pickit2_read_report failed (ec %d). %s\n", errorCode, usb_strerror());
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf(stderr, "pickit2_read_report failed (ec %d). %s\n", errorCode, usb_strerror());
|
||||
avrdude_message("pickit2_read_report failed (ec %d). %s\n", errorCode, usb_strerror());
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf(stderr, "pickit2_write_report failed (ec %d). %s\n", errorCode, usb_strerror());
|
||||
avrdude_message("pickit2_write_report failed (ec %d). %s\n", errorCode, usb_strerror());
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -428,7 +425,7 @@ static int pickit2_program_enable(struct programmer_t * pgm, AVRPART * p)
|
|||
|
||||
if (p->op[AVR_OP_PGM_ENABLE] == NULL)
|
||||
{
|
||||
fprintf(stderr, "program enable instruction not defined for part \"%s\"\n",
|
||||
avrdude_message("program enable instruction not defined for part \"%s\"\n",
|
||||
p->desc);
|
||||
return -1;
|
||||
}
|
||||
|
@ -440,13 +437,13 @@ static int pickit2_program_enable(struct programmer_t * pgm, AVRPART * p)
|
|||
if (verbose)
|
||||
{
|
||||
int i;
|
||||
fprintf(stderr, "program_enable(): sending command. Resp = ");
|
||||
avrdude_message("program_enable(): sending command. Resp = ");
|
||||
|
||||
for (i = 0; i < 4; i++)
|
||||
{
|
||||
fprintf(stderr, "%x ", (int)res[i]);
|
||||
avrdude_message("%x ", (int)res[i]);
|
||||
}
|
||||
fprintf(stderr, "\n");
|
||||
avrdude_message("\n");
|
||||
}
|
||||
|
||||
// check for sync character
|
||||
|
@ -463,7 +460,7 @@ static int pickit2_chip_erase(struct programmer_t * pgm, AVRPART * p)
|
|||
|
||||
if (p->op[AVR_OP_CHIP_ERASE] == NULL)
|
||||
{
|
||||
fprintf(stderr, "chip erase instruction not defined for part \"%s\"\n",
|
||||
avrdude_message("chip erase instruction not defined for part \"%s\"\n",
|
||||
p->desc);
|
||||
return -1;
|
||||
}
|
||||
|
@ -540,7 +537,7 @@ static int pickit2_paged_load(PROGRAMMER * pgm, AVRPART * p, AVRMEM * mem,
|
|||
}
|
||||
else
|
||||
{
|
||||
fprintf(stderr, "no read command specified\n");
|
||||
avrdude_message("no read command specified\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -552,7 +549,7 @@ static int pickit2_paged_load(PROGRAMMER * pgm, AVRPART * p, AVRMEM * mem,
|
|||
|
||||
if (bytes_read < 0)
|
||||
{
|
||||
fprintf(stderr, "Failed @ pgm->spi()\n");
|
||||
avrdude_message("Failed @ pgm->spi()\n");
|
||||
pgm->err_led(pgm, ON);
|
||||
return -1;
|
||||
}
|
||||
|
@ -586,9 +583,8 @@ static int pickit2_commit_page(PROGRAMMER * pgm, AVRPART * p, AVRMEM * mem,
|
|||
wp = mem->op[AVR_OP_WRITEPAGE];
|
||||
if (wp == NULL)
|
||||
{
|
||||
fprintf(stderr,
|
||||
"pickit2_commit_page(): memory \"%s\" not configured for page writes\n",
|
||||
mem->desc);
|
||||
avrdude_message("pickit2_commit_page(): memory \"%s\" not configured for page writes\n",
|
||||
mem->desc);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -635,7 +631,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)
|
||||
{
|
||||
fprintf(stderr, "Part does not support %d paged write of %s\n", page_size, mem->desc);
|
||||
avrdude_message("Part does not support %d paged write of %s\n", page_size, mem->desc);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -692,7 +688,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
|
||||
|
||||
fprintf(stderr, "Error AVR_OP_WRITE_LO defined only (where's the HIGH command?)\n");
|
||||
avrdude_message("Error AVR_OP_WRITE_LO defined only (where's the HIGH command?)\n");
|
||||
return -1;
|
||||
}
|
||||
else
|
||||
|
@ -717,7 +713,7 @@ static int pickit2_paged_write(PROGRAMMER * pgm, AVRPART * p, AVRMEM * mem,
|
|||
|
||||
if (bytes_read < 0)
|
||||
{
|
||||
fprintf(stderr, "Failed @ pgm->spi()\n");
|
||||
avrdude_message("Failed @ pgm->spi()\n");
|
||||
pgm->err_led(pgm, ON);
|
||||
return -1;
|
||||
}
|
||||
|
@ -1159,7 +1155,7 @@ static int usb_open_device(struct usb_dev_handle **device, int vendor, int produ
|
|||
if (handle == NULL)
|
||||
{
|
||||
errorCode = USB_ERROR_ACCESS;
|
||||
fprintf(stderr, "%s: Warning: cannot open USB device: %s\n", progname, usb_strerror());
|
||||
avrdude_message("%s: Warning: cannot open USB device: %s\n", progname, usb_strerror());
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -1168,18 +1164,18 @@ static int usb_open_device(struct usb_dev_handle **device, int vendor, int produ
|
|||
{
|
||||
if (verbose)
|
||||
{
|
||||
fprintf(stderr, "Device %p seemed to open OK.\n", handle);
|
||||
avrdude_message("Device %p seemed to open OK.\n", handle);
|
||||
}
|
||||
|
||||
if ((errorCode = usb_set_configuration(handle, 1)) < 0)
|
||||
{
|
||||
fprintf(stderr, "Could not set configuration. Error code %d, %s.\n"
|
||||
avrdude_message("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)
|
||||
{
|
||||
fprintf(stderr, "Could not claim interface. Error code %d, %s\n"
|
||||
avrdude_message("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());
|
||||
}
|
||||
|
||||
|
@ -1222,9 +1218,8 @@ 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)
|
||||
{
|
||||
fprintf(stderr,
|
||||
"%s: pickit2_parseextparms(): invalid clockrate '%s'\n",
|
||||
progname, extended_param);
|
||||
avrdude_message("%s: pickit2_parseextparms(): invalid clockrate '%s'\n",
|
||||
progname, extended_param);
|
||||
rv = -1;
|
||||
continue;
|
||||
}
|
||||
|
@ -1234,9 +1229,8 @@ static int pickit2_parseextparams(struct programmer_t * pgm, LISTID extparms)
|
|||
|
||||
if (verbose >= 2)
|
||||
{
|
||||
fprintf(stderr,
|
||||
"%s: pickit2_parseextparms(): clockrate set to 0x%02x\n",
|
||||
progname, clock_rate);
|
||||
avrdude_message("%s: pickit2_parseextparms(): clockrate set to 0x%02x\n",
|
||||
progname, clock_rate);
|
||||
}
|
||||
PDATA(pgm)->clock_period = clock_period;
|
||||
|
||||
|
@ -1248,27 +1242,24 @@ static int pickit2_parseextparams(struct programmer_t * pgm, LISTID extparms)
|
|||
int timeout;
|
||||
if (sscanf(extended_param, "timeout=%i", &timeout) != 1 || timeout <= 0)
|
||||
{
|
||||
fprintf(stderr,
|
||||
"%s: pickit2_parseextparms(): invalid timeout '%s'\n",
|
||||
progname, extended_param);
|
||||
avrdude_message("%s: pickit2_parseextparms(): invalid timeout '%s'\n",
|
||||
progname, extended_param);
|
||||
rv = -1;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (verbose >= 2)
|
||||
{
|
||||
fprintf(stderr,
|
||||
"%s: pickit2_parseextparms(): usb timeout set to 0x%02x\n",
|
||||
progname, timeout);
|
||||
avrdude_message("%s: pickit2_parseextparms(): usb timeout set to 0x%02x\n",
|
||||
progname, timeout);
|
||||
}
|
||||
PDATA(pgm)->transaction_timeout = timeout;
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
fprintf(stderr,
|
||||
"%s: pickit2_parseextparms(): invalid extended parameter '%s'\n",
|
||||
progname, extended_param);
|
||||
avrdude_message("%s: pickit2_parseextparms(): invalid extended parameter '%s'\n",
|
||||
progname, extended_param);
|
||||
rv = -1;
|
||||
}
|
||||
|
||||
|
@ -1333,7 +1324,7 @@ void pickit2_initpgm (PROGRAMMER * pgm)
|
|||
}
|
||||
#else
|
||||
static int pickit2_nousb_open (struct programmer_t *pgm, char * name) {
|
||||
fprintf(stderr,
|
||||
avrdude_message(
|
||||
#ifdef WIN32NATIVE
|
||||
"%s: error: no usb or hid support. Please compile again with libusb or HID support from Win32 DDK installed.\n",
|
||||
#else
|
||||
|
|
43
pindefs.c
43
pindefs.c
|
@ -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) {
|
||||
fprintf(stderr, "Multiple pins found\n"); //TODO
|
||||
avrdude_message("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) {
|
||||
fprintf(stderr, "Pins of higher index than max field size for old pinno found\n");
|
||||
avrdude_message("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 {
|
||||
fprintf(stderr, "pins have different polarity set\n");
|
||||
avrdude_message("pins have different polarity set\n");
|
||||
return -1;
|
||||
}
|
||||
} else if(pindef->mask[i] != 0) {
|
||||
fprintf(stderr, "Pins have higher number than fit in old format\n");
|
||||
avrdude_message("Pins have higher number than fit in old format\n");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
@ -270,12 +270,10 @@ int pins_check(const struct programmer_t * const pgm, const struct pin_checklist
|
|||
}
|
||||
if(invalid) {
|
||||
if(output) {
|
||||
fprintf(stderr,
|
||||
"%s: %s: Following pins are not valid pins for this function: %s\n",
|
||||
progname, avr_pin_name(pinname), pinmask_to_str(invalid_used));
|
||||
avrdude_message("%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) {
|
||||
fprintf(stderr,
|
||||
"%s: %s: Valid pins for this function are: %s\n",
|
||||
avrdude_message("%s: %s: Valid pins for this function are: %s\n",
|
||||
progname, avr_pin_name(pinname), pinmask_to_str(valid_pins->mask));
|
||||
}
|
||||
}
|
||||
|
@ -283,39 +281,34 @@ int pins_check(const struct programmer_t * const pgm, const struct pin_checklist
|
|||
}
|
||||
if(inverse) {
|
||||
if(output) {
|
||||
fprintf(stderr,
|
||||
"%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));
|
||||
avrdude_message("%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) {
|
||||
fprintf(stderr,
|
||||
"%s: %s: Valid inverse pins for this function are: %s\n",
|
||||
progname, avr_pin_name(pinname), pinmask_to_str(valid_pins->inverse));
|
||||
avrdude_message("%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) {
|
||||
fprintf(stderr,
|
||||
"%s: %s: Following pins are set for other functions too: %s\n",
|
||||
progname, avr_pin_name(pinname), pinmask_to_str(already_used));
|
||||
avrdude_message("%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) {
|
||||
fprintf(stderr,
|
||||
"%s: %s: Mandatory pin is not defined.\n",
|
||||
progname, avr_pin_name(pinname));
|
||||
avrdude_message("%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) {
|
||||
fprintf(stderr,
|
||||
"%s: %s: Pin is ok.\n",
|
||||
progname, avr_pin_name(pinname));
|
||||
avrdude_message("%s: %s: Pin is ok.\n",
|
||||
progname, avr_pin_name(pinname));
|
||||
}
|
||||
}
|
||||
return rv;
|
||||
|
@ -358,7 +351,7 @@ const char * pins_to_str(const struct pindef_t * const pindef) {
|
|||
|
||||
/**
|
||||
* Returns the name of the pin as string.
|
||||
*
|
||||
*
|
||||
* @param pinname the pinname which we want as string.
|
||||
* @returns a string with the pinname, or <unknown> if pinname is invalid.
|
||||
*/
|
||||
|
|
4
ppi.c
4
ppi.c
|
@ -69,7 +69,7 @@ static int ppi_shadow_access(union filedescriptor *fdp, int reg,
|
|||
shadow_num = 2;
|
||||
break;
|
||||
default:
|
||||
fprintf(stderr, "%s: avr_set(): invalid register=%d\n",
|
||||
avrdude_message("%s: avr_set(): invalid register=%d\n",
|
||||
progname, reg);
|
||||
return -1;
|
||||
break;
|
||||
|
@ -206,7 +206,7 @@ void ppi_open(char * port, union filedescriptor *fdp)
|
|||
|
||||
fd = open(port, O_RDWR);
|
||||
if (fd < 0) {
|
||||
fprintf(stderr, "%s: can't open device \"%s\": %s\n",
|
||||
avrdude_message("%s: can't open device \"%s\": %s\n",
|
||||
progname, port, strerror(errno));
|
||||
fdp->ifd = -1;
|
||||
return;
|
||||
|
|
11
ppiwin.c
11
ppiwin.c
|
@ -91,7 +91,7 @@ void ppi_open(char *port, union filedescriptor *fdp)
|
|||
|
||||
if(fd < 0)
|
||||
{
|
||||
fprintf(stderr, "%s: can't open device \"giveio\"\n\n", progname);
|
||||
avrdude_message("%s: can't open device \"giveio\"\n\n", progname);
|
||||
fdp->ifd = -1;
|
||||
return;
|
||||
}
|
||||
|
@ -119,15 +119,14 @@ void ppi_open(char *port, union filedescriptor *fdp)
|
|||
fd = strtol(port, &cp, 0);
|
||||
if(*port == '\0' || *cp != '\0')
|
||||
{
|
||||
fprintf(stderr,
|
||||
"%s: port name \"%s\" is neither lpt1/2/3 nor valid number\n",
|
||||
progname, port);
|
||||
avrdude_message("%s: port name \"%s\" is neither lpt1/2/3 nor valid number\n",
|
||||
progname, port);
|
||||
fd = -1;
|
||||
}
|
||||
}
|
||||
if(fd < 0)
|
||||
{
|
||||
fprintf(stderr, "%s: can't open device \"%s\"\n\n", progname, port);
|
||||
avrdude_message("%s: can't open device \"%s\"\n\n", progname, port);
|
||||
fdp->ifd = -1;
|
||||
return;
|
||||
}
|
||||
|
@ -361,7 +360,7 @@ int gettimeofday(struct timeval *tv, struct timezone *unused){
|
|||
unsigned long dt; \
|
||||
dt = (unsigned long)((stop.QuadPart - start.QuadPart) * 1000 * 1000 \
|
||||
/ freq.QuadPart); \
|
||||
fprintf(stderr, \
|
||||
avrdude_message(\
|
||||
"hpt:%i usleep usec:%lu sleep msec:%lu timed usec:%lu\n", \
|
||||
has_highperf, us, ((us + 999) / 1000), dt); \
|
||||
} while (0)
|
||||
|
|
57
safemode.c
57
safemode.c
|
@ -58,9 +58,8 @@ int safemode_writefuse (unsigned char fuse, char * fusename, PROGRAMMER * pgm,
|
|||
|
||||
/* Report information to user if needed */
|
||||
if (verbose > 0) {
|
||||
fprintf(stderr,
|
||||
"%s: safemode: Wrote %s to %x, read as %x. %d attempts left\n",
|
||||
progname, fusename, fuse, fuseread, tries-1);
|
||||
avrdude_message("%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 */
|
||||
|
@ -110,7 +109,7 @@ int safemode_readfuses (unsigned char * lfuse, unsigned char * hfuse,
|
|||
}
|
||||
if (verbose > 2)
|
||||
{
|
||||
fprintf(stderr, "%s: safemode read 1, fuse value: %x\n",progname, safemode_fuse);
|
||||
avrdude_message("%s: safemode read 1, fuse value: %x\n",progname, safemode_fuse);
|
||||
}
|
||||
if(pgm->read_byte(pgm, p, m, 0, &value) != 0)
|
||||
{
|
||||
|
@ -118,7 +117,7 @@ int safemode_readfuses (unsigned char * lfuse, unsigned char * hfuse,
|
|||
}
|
||||
if (verbose > 2)
|
||||
{
|
||||
fprintf(stderr, "%s: safemode read 2, fuse value: %x\n",progname, value);
|
||||
avrdude_message("%s: safemode read 2, fuse value: %x\n",progname, value);
|
||||
}
|
||||
if (value == safemode_fuse) {
|
||||
if (pgm->read_byte(pgm, p, m, 0, &value) != 0)
|
||||
|
@ -127,7 +126,7 @@ int safemode_readfuses (unsigned char * lfuse, unsigned char * hfuse,
|
|||
}
|
||||
if (verbose > 2)
|
||||
{
|
||||
fprintf(stderr, "%s: safemode read 3, fuse value: %x\n",progname, value);
|
||||
avrdude_message("%s: safemode read 3, fuse value: %x\n",progname, value);
|
||||
}
|
||||
if (value == safemode_fuse)
|
||||
{
|
||||
|
@ -143,13 +142,12 @@ int safemode_readfuses (unsigned char * lfuse, unsigned char * hfuse,
|
|||
}
|
||||
|
||||
if (fusegood == 0) {
|
||||
fprintf(stderr,
|
||||
"%s: safemode: Verify error - unable to read fuse properly. "
|
||||
"Programmer may not be reliable.\n", progname);
|
||||
avrdude_message("%s: safemode: Verify error - unable to read fuse properly. "
|
||||
"Programmer may not be reliable.\n", progname);
|
||||
return -1;
|
||||
}
|
||||
else if ((fusegood == 1) && (verbose > 0)) {
|
||||
fprintf(stderr, "%s: safemode: fuse reads as %X\n", progname, safemode_fuse);
|
||||
avrdude_message("%s: safemode: fuse reads as %X\n", progname, safemode_fuse);
|
||||
}
|
||||
|
||||
|
||||
|
@ -165,7 +163,7 @@ int safemode_readfuses (unsigned char * lfuse, unsigned char * hfuse,
|
|||
}
|
||||
if (verbose > 2)
|
||||
{
|
||||
fprintf(stderr, "%s: safemode read 1, lfuse value: %x\n",progname, safemode_lfuse);
|
||||
avrdude_message("%s: safemode read 1, lfuse value: %x\n",progname, safemode_lfuse);
|
||||
}
|
||||
if (pgm->read_byte(pgm, p, m, 0, &value) != 0)
|
||||
{
|
||||
|
@ -173,7 +171,7 @@ int safemode_readfuses (unsigned char * lfuse, unsigned char * hfuse,
|
|||
}
|
||||
if (verbose > 2)
|
||||
{
|
||||
fprintf(stderr, "%s: safemode read 2, lfuse value: %x\n",progname, value);
|
||||
avrdude_message("%s: safemode read 2, lfuse value: %x\n",progname, value);
|
||||
}
|
||||
if (value == safemode_lfuse) {
|
||||
if (pgm->read_byte(pgm, p, m, 0, &value) != 0)
|
||||
|
@ -182,7 +180,7 @@ int safemode_readfuses (unsigned char * lfuse, unsigned char * hfuse,
|
|||
}
|
||||
if (verbose > 2)
|
||||
{
|
||||
fprintf(stderr, "%s: safemode read 3, lfuse value: %x\n",progname, value);
|
||||
avrdude_message("%s: safemode read 3, lfuse value: %x\n",progname, value);
|
||||
}
|
||||
if (value == safemode_lfuse){
|
||||
fusegood = 1; /* Fuse read OK three times */
|
||||
|
@ -198,13 +196,12 @@ int safemode_readfuses (unsigned char * lfuse, unsigned char * hfuse,
|
|||
|
||||
|
||||
if (fusegood == 0) {
|
||||
fprintf(stderr,
|
||||
"%s: safemode: Verify error - unable to read lfuse properly. "
|
||||
"Programmer may not be reliable.\n", progname);
|
||||
avrdude_message("%s: safemode: Verify error - unable to read lfuse properly. "
|
||||
"Programmer may not be reliable.\n", progname);
|
||||
return -1;
|
||||
}
|
||||
else if ((fusegood == 1) && (verbose > 0)) {
|
||||
fprintf(stderr, "%s: safemode: lfuse reads as %X\n", progname, safemode_lfuse);
|
||||
avrdude_message("%s: safemode: lfuse reads as %X\n", progname, safemode_lfuse);
|
||||
}
|
||||
|
||||
/* Read hfuse three times */
|
||||
|
@ -219,7 +216,7 @@ int safemode_readfuses (unsigned char * lfuse, unsigned char * hfuse,
|
|||
}
|
||||
if (verbose > 2)
|
||||
{
|
||||
fprintf(stderr, "%s: safemode read 1, hfuse value: %x\n",progname, safemode_hfuse);
|
||||
avrdude_message("%s: safemode read 1, hfuse value: %x\n",progname, safemode_hfuse);
|
||||
}
|
||||
if (pgm->read_byte(pgm, p, m, 0, &value) != 0)
|
||||
{
|
||||
|
@ -227,7 +224,7 @@ int safemode_readfuses (unsigned char * lfuse, unsigned char * hfuse,
|
|||
}
|
||||
if (verbose > 2)
|
||||
{
|
||||
fprintf(stderr, "%s: safemode read 2, hfuse value: %x\n",progname, value);
|
||||
avrdude_message("%s: safemode read 2, hfuse value: %x\n",progname, value);
|
||||
}
|
||||
if (value == safemode_hfuse) {
|
||||
if (pgm->read_byte(pgm, p, m, 0, &value) != 0)
|
||||
|
@ -236,7 +233,7 @@ int safemode_readfuses (unsigned char * lfuse, unsigned char * hfuse,
|
|||
}
|
||||
if (verbose > 2)
|
||||
{
|
||||
fprintf(stderr, "%s: safemode read 3, hfuse value: %x\n",progname, value);
|
||||
avrdude_message("%s: safemode read 3, hfuse value: %x\n",progname, value);
|
||||
}
|
||||
if (value == safemode_hfuse){
|
||||
fusegood = 1; /* Fuse read OK three times */
|
||||
|
@ -251,13 +248,12 @@ int safemode_readfuses (unsigned char * lfuse, unsigned char * hfuse,
|
|||
}
|
||||
|
||||
if (fusegood == 0) {
|
||||
fprintf(stderr,
|
||||
"%s: safemode: Verify error - unable to read hfuse properly. "
|
||||
"Programmer may not be reliable.\n", progname);
|
||||
avrdude_message("%s: safemode: Verify error - unable to read hfuse properly. "
|
||||
"Programmer may not be reliable.\n", progname);
|
||||
return -2;
|
||||
}
|
||||
else if ((fusegood == 1) && (verbose > 0)){
|
||||
fprintf(stderr, "%s: safemode: hfuse reads as %X\n", progname, safemode_hfuse);
|
||||
avrdude_message("%s: safemode: hfuse reads as %X\n", progname, safemode_hfuse);
|
||||
}
|
||||
|
||||
/* Read efuse three times */
|
||||
|
@ -272,7 +268,7 @@ int safemode_readfuses (unsigned char * lfuse, unsigned char * hfuse,
|
|||
}
|
||||
if (verbose > 2)
|
||||
{
|
||||
fprintf(stderr, "%s: safemode read 1, efuse value: %x\n",progname, safemode_efuse);
|
||||
avrdude_message("%s: safemode read 1, efuse value: %x\n",progname, safemode_efuse);
|
||||
}
|
||||
if (pgm->read_byte(pgm, p, m, 0, &value) != 0)
|
||||
{
|
||||
|
@ -280,7 +276,7 @@ int safemode_readfuses (unsigned char * lfuse, unsigned char * hfuse,
|
|||
}
|
||||
if (verbose > 2)
|
||||
{
|
||||
fprintf(stderr, "%s: safemode read 2, efuse value: %x\n",progname, value);
|
||||
avrdude_message("%s: safemode read 2, efuse value: %x\n",progname, value);
|
||||
}
|
||||
if (value == safemode_efuse) {
|
||||
if (pgm->read_byte(pgm, p, m, 0, &value) != 0)
|
||||
|
@ -289,7 +285,7 @@ int safemode_readfuses (unsigned char * lfuse, unsigned char * hfuse,
|
|||
}
|
||||
if (verbose > 2)
|
||||
{
|
||||
fprintf(stderr, "%s: safemode read 3, efuse value: %x\n",progname, value);
|
||||
avrdude_message("%s: safemode read 3, efuse value: %x\n",progname, value);
|
||||
}
|
||||
if (value == safemode_efuse){
|
||||
fusegood = 1; /* Fuse read OK three times */
|
||||
|
@ -304,13 +300,12 @@ int safemode_readfuses (unsigned char * lfuse, unsigned char * hfuse,
|
|||
}
|
||||
|
||||
if (fusegood == 0) {
|
||||
fprintf(stderr,
|
||||
"%s: safemode: Verify error - unable to read efuse properly. "
|
||||
"Programmer may not be reliable.\n", progname);
|
||||
avrdude_message("%s: safemode: Verify error - unable to read efuse properly. "
|
||||
"Programmer may not be reliable.\n", progname);
|
||||
return -3;
|
||||
}
|
||||
else if ((fusegood == 1) && (verbose > 0)) {
|
||||
fprintf(stderr, "%s: safemode: efuse reads as %X\n", progname, safemode_efuse);
|
||||
avrdude_message("%s: safemode: efuse reads as %X\n", progname, safemode_efuse);
|
||||
}
|
||||
|
||||
*lfuse = safemode_lfuse;
|
||||
|
|
|
@ -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;
|
||||
fprintf(stderr, "Warning: cannot open USB device: %s\n",
|
||||
avrdude_message("Warning: cannot open USB device: %s\n",
|
||||
usb_strerror());
|
||||
continue;
|
||||
}
|
||||
|
@ -325,23 +325,21 @@ static int usbOpenDevice(union filedescriptor *fdp, int vendor, char *vendorName
|
|||
0x0409, string, sizeof(string));
|
||||
if(len < 0){
|
||||
errorCode = USB_ERROR_IO;
|
||||
fprintf(stderr,
|
||||
"Warning: cannot query manufacturer for device: %s\n",
|
||||
usb_strerror());
|
||||
avrdude_message("Warning: cannot query manufacturer for device: %s\n",
|
||||
usb_strerror());
|
||||
}else{
|
||||
errorCode = USB_ERROR_NOTFOUND;
|
||||
/* fprintf(stderr, "seen device from vendor ->%s<-\n", string); */
|
||||
/* avrdude_message("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;
|
||||
fprintf(stderr,
|
||||
"Warning: cannot query product for device: %s\n",
|
||||
usb_strerror());
|
||||
avrdude_message("Warning: cannot query product for device: %s\n",
|
||||
usb_strerror());
|
||||
}else{
|
||||
errorCode = USB_ERROR_NOTFOUND;
|
||||
/* fprintf(stderr, "seen product ->%s<-\n", string); */
|
||||
/* avrdude_message("seen product ->%s<-\n", string); */
|
||||
if(strcmp(string, productName) == 0)
|
||||
break;
|
||||
}
|
||||
|
@ -357,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)){
|
||||
fprintf(stderr, "Warning: could not set configuration: %s\n",
|
||||
avrdude_message("Warning: could not set configuration: %s\n",
|
||||
usb_strerror());
|
||||
}
|
||||
/* now try to claim the interface and detach the kernel HID driver on
|
||||
|
@ -366,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){
|
||||
fprintf(stderr, "Warning: could not detach kernel HID driver: %s\n",
|
||||
avrdude_message("Warning: could not detach kernel HID driver: %s\n",
|
||||
usb_strerror());
|
||||
}
|
||||
#endif
|
||||
}
|
||||
if(rval != 0)
|
||||
fprintf(stderr, "Warning: could not claim interface\n");
|
||||
avrdude_message("Warning: could not claim interface\n");
|
||||
/* Continue anyway, even if we could not claim the interface. Control transfers
|
||||
* should still work.
|
||||
*/
|
||||
|
@ -405,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)
|
||||
fprintf(stderr, "Error sending message: %s\n", usb_strerror());
|
||||
avrdude_message("Error sending message: %s\n", usb_strerror());
|
||||
return USB_ERROR_IO;
|
||||
}
|
||||
return 0;
|
||||
|
@ -426,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){
|
||||
fprintf(stderr, "Error sending message: %s\n", usb_strerror());
|
||||
avrdude_message("Error sending message: %s\n", usb_strerror());
|
||||
return USB_ERROR_IO;
|
||||
}
|
||||
*len = bytesReceived;
|
||||
|
@ -450,11 +448,11 @@ static void dumpBlock(char *prefix, unsigned char *buf, int len)
|
|||
int i;
|
||||
|
||||
if(len <= 8){ /* more compact format for short blocks */
|
||||
fprintf(stderr, "%s: %d bytes: ", prefix, len);
|
||||
avrdude_message("%s: %d bytes: ", prefix, len);
|
||||
for(i = 0; i < len; i++){
|
||||
fprintf(stderr, "%02x ", buf[i]);
|
||||
avrdude_message("%02x ", buf[i]);
|
||||
}
|
||||
fprintf(stderr, " \"");
|
||||
avrdude_message(" \"");
|
||||
for(i = 0; i < len; i++){
|
||||
if(buf[i] >= 0x20 && buf[i] < 0x7f){
|
||||
fputc(buf[i], stderr);
|
||||
|
@ -462,20 +460,20 @@ static void dumpBlock(char *prefix, unsigned char *buf, int len)
|
|||
fputc('.', stderr);
|
||||
}
|
||||
}
|
||||
fprintf(stderr, "\"\n");
|
||||
avrdude_message("\"\n");
|
||||
}else{
|
||||
fprintf(stderr, "%s: %d bytes:\n", prefix, len);
|
||||
avrdude_message("%s: %d bytes:\n", prefix, len);
|
||||
while(len > 0){
|
||||
for(i = 0; i < 16; i++){
|
||||
if(i < len){
|
||||
fprintf(stderr, "%02x ", buf[i]);
|
||||
avrdude_message("%02x ", buf[i]);
|
||||
}else{
|
||||
fprintf(stderr, " ");
|
||||
avrdude_message(" ");
|
||||
}
|
||||
if(i == 7)
|
||||
fputc(' ', stderr);
|
||||
}
|
||||
fprintf(stderr, " \"");
|
||||
avrdude_message(" \"");
|
||||
for(i = 0; i < 16; i++){
|
||||
if(i < len){
|
||||
if(buf[i] >= 0x20 && buf[i] < 0x7f){
|
||||
|
@ -485,7 +483,7 @@ static void dumpBlock(char *prefix, unsigned char *buf, int len)
|
|||
}
|
||||
}
|
||||
}
|
||||
fprintf(stderr, "\"\n");
|
||||
avrdude_message("\"\n");
|
||||
buf += 16;
|
||||
len -= 16;
|
||||
}
|
||||
|
@ -518,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){
|
||||
fprintf(stderr, "%s: avrdoper_open(): %s\n", progname, usbErrorText(rval));
|
||||
avrdude_message("%s: avrdoper_open(): %s\n", progname, usbErrorText(rval));
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
|
@ -557,11 +555,11 @@ static int avrdoper_send(union filedescriptor *fdp, unsigned char *buf, size_t b
|
|||
buffer[1] = thisLen;
|
||||
memcpy(buffer + 2, buf, thisLen);
|
||||
if(verbose > 3)
|
||||
fprintf(stderr, "Sending %d bytes data chunk\n", thisLen);
|
||||
avrdude_message("Sending %d bytes data chunk\n", thisLen);
|
||||
rval = usbSetReport(fdp, USB_HID_REPORT_TYPE_FEATURE, (char *)buffer,
|
||||
reportDataSizes[lenIndex] + 2);
|
||||
if(rval != 0){
|
||||
fprintf(stderr, "%s: avrdoper_send(): %s\n", progname, usbErrorText(rval));
|
||||
avrdude_message("%s: avrdoper_send(): %s\n", progname, usbErrorText(rval));
|
||||
return -1;
|
||||
}
|
||||
buflen -= thisLen;
|
||||
|
@ -587,19 +585,18 @@ static int avrdoperFillBuffer(union filedescriptor *fdp)
|
|||
usbErr = usbGetReport(fdp, USB_HID_REPORT_TYPE_FEATURE, lenIndex + 1,
|
||||
(char *)buffer, &len);
|
||||
if(usbErr != 0){
|
||||
fprintf(stderr, "%s: avrdoperFillBuffer(): %s\n", progname, usbErrorText(usbErr));
|
||||
avrdude_message("%s: avrdoperFillBuffer(): %s\n", progname, usbErrorText(usbErr));
|
||||
return -1;
|
||||
}
|
||||
if(verbose > 3)
|
||||
fprintf(stderr, "Received %d bytes data chunk of total %d\n", len - 2, buffer[1]);
|
||||
avrdude_message("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)){
|
||||
fprintf(stderr,
|
||||
"%s: avrdoperFillBuffer(): internal error: buffer overflow\n",
|
||||
progname);
|
||||
avrdude_message("%s: avrdoperFillBuffer(): internal error: buffer overflow\n",
|
||||
progname);
|
||||
return -1;
|
||||
}
|
||||
memcpy(avrdoperRxBuffer + avrdoperRxLength, buffer + 2, len);
|
||||
|
@ -646,7 +643,7 @@ static int avrdoper_drain(union filedescriptor *fdp, int display)
|
|||
|
||||
static int avrdoper_set_dtr_rts(union filedescriptor *fdp, int is_on)
|
||||
{
|
||||
fprintf(stderr, "%s: AVR-Doper doesn't support DTR/RTS setting\n", progname);
|
||||
avrdude_message("%s: AVR-Doper doesn't support DTR/RTS setting\n", progname);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
|
76
ser_posix.c
76
ser_posix.c
|
@ -91,7 +91,7 @@ static speed_t serial_baud_lookup(long baud)
|
|||
* a warning (if we are verbose) and return the raw rate
|
||||
*/
|
||||
if (verbose > 0)
|
||||
fprintf(stderr, "%s: serial_baud_lookup(): Using non-standard baud rate: %ld",
|
||||
avrdude_message("%s: serial_baud_lookup(): Using non-standard baud rate: %ld",
|
||||
progname, baud);
|
||||
|
||||
return baud;
|
||||
|
@ -111,7 +111,7 @@ static int ser_setspeed(union filedescriptor *fd, long baud)
|
|||
*/
|
||||
rc = tcgetattr(fd->ifd, &termios);
|
||||
if (rc < 0) {
|
||||
fprintf(stderr, "%s: ser_setspeed(): tcgetattr() failed",
|
||||
avrdude_message("%s: ser_setspeed(): tcgetattr() failed",
|
||||
progname);
|
||||
return -errno;
|
||||
}
|
||||
|
@ -135,7 +135,7 @@ static int ser_setspeed(union filedescriptor *fd, long baud)
|
|||
|
||||
rc = tcsetattr(fd->ifd, TCSANOW, &termios);
|
||||
if (rc < 0) {
|
||||
fprintf(stderr, "%s: ser_setspeed(): tcsetattr() failed\n",
|
||||
avrdude_message("%s: ser_setspeed(): tcsetattr() failed\n",
|
||||
progname);
|
||||
return -errno;
|
||||
}
|
||||
|
@ -167,13 +167,13 @@ net_open(const char *port, union filedescriptor *fdp)
|
|||
struct hostent *hp;
|
||||
|
||||
if ((hstr = strdup(port)) == NULL) {
|
||||
fprintf(stderr, "%s: net_open(): Out of memory!\n",
|
||||
avrdude_message("%s: net_open(): Out of memory!\n",
|
||||
progname);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (((pstr = strchr(hstr, ':')) == NULL) || (pstr == hstr)) {
|
||||
fprintf(stderr, "%s: net_open(): Mangled host:port string \"%s\"\n",
|
||||
avrdude_message("%s: net_open(): Mangled host:port string \"%s\"\n",
|
||||
progname, hstr);
|
||||
free(hstr);
|
||||
return -1;
|
||||
|
@ -187,14 +187,14 @@ net_open(const char *port, union filedescriptor *fdp)
|
|||
pnum = strtoul(pstr, &end, 10);
|
||||
|
||||
if ((*pstr == '\0') || (*end != '\0') || (pnum == 0) || (pnum > 65535)) {
|
||||
fprintf(stderr, "%s: net_open(): Bad port number \"%s\"\n",
|
||||
avrdude_message("%s: net_open(): Bad port number \"%s\"\n",
|
||||
progname, pstr);
|
||||
free(hstr);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if ((hp = gethostbyname(hstr)) == NULL) {
|
||||
fprintf(stderr, "%s: net_open(): unknown host \"%s\"\n",
|
||||
avrdude_message("%s: net_open(): unknown host \"%s\"\n",
|
||||
progname, hstr);
|
||||
free(hstr);
|
||||
return -1;
|
||||
|
@ -203,7 +203,7 @@ net_open(const char *port, union filedescriptor *fdp)
|
|||
free(hstr);
|
||||
|
||||
if ((fd = socket(PF_INET, SOCK_STREAM, 0)) < 0) {
|
||||
fprintf(stderr, "%s: net_open(): Cannot open socket: %s\n",
|
||||
avrdude_message("%s: net_open(): Cannot open socket: %s\n",
|
||||
progname, strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
|
@ -214,7 +214,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))) {
|
||||
fprintf(stderr, "%s: net_open(): Connect failed: %s\n",
|
||||
avrdude_message("%s: net_open(): Connect failed: %s\n",
|
||||
progname, strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
|
@ -271,7 +271,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) {
|
||||
fprintf(stderr, "%s: ser_open(): can't open device \"%s\": %s\n",
|
||||
avrdude_message("%s: ser_open(): can't open device \"%s\": %s\n",
|
||||
progname, port, strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
|
@ -283,9 +283,8 @@ static int ser_open(char * port, union pinfo pinfo, union filedescriptor *fdp)
|
|||
*/
|
||||
rc = ser_setspeed(fdp, pinfo.baud);
|
||||
if (rc) {
|
||||
fprintf(stderr,
|
||||
"%s: ser_open(): can't set attributes for device \"%s\": %s\n",
|
||||
progname, port, strerror(-rc));
|
||||
avrdude_message("%s: ser_open(): can't set attributes for device \"%s\": %s\n",
|
||||
progname, port, strerror(-rc));
|
||||
close(fd);
|
||||
return -1;
|
||||
}
|
||||
|
@ -301,9 +300,8 @@ static void ser_close(union filedescriptor *fd)
|
|||
if (saved_original_termios) {
|
||||
int rc = tcsetattr(fd->ifd, TCSANOW | TCSADRAIN, &original_termios);
|
||||
if (rc) {
|
||||
fprintf(stderr,
|
||||
"%s: ser_close(): can't reset attributes for device: %s\n",
|
||||
progname, strerror(errno));
|
||||
avrdude_message("%s: ser_close(): can't reset attributes for device: %s\n",
|
||||
progname, strerror(errno));
|
||||
}
|
||||
saved_original_termios = 0;
|
||||
}
|
||||
|
@ -323,29 +321,29 @@ static int ser_send(union filedescriptor *fd, unsigned char * buf, size_t buflen
|
|||
|
||||
if (verbose > 3)
|
||||
{
|
||||
fprintf(stderr, "%s: Send: ", progname);
|
||||
avrdude_message("%s: Send: ", progname);
|
||||
|
||||
while (buflen) {
|
||||
unsigned char c = *buf;
|
||||
if (isprint(c)) {
|
||||
fprintf(stderr, "%c ", c);
|
||||
avrdude_message("%c ", c);
|
||||
}
|
||||
else {
|
||||
fprintf(stderr, ". ");
|
||||
avrdude_message(". ");
|
||||
}
|
||||
fprintf(stderr, "[%02x] ", c);
|
||||
avrdude_message("[%02x] ", c);
|
||||
|
||||
buf++;
|
||||
buflen--;
|
||||
}
|
||||
|
||||
fprintf(stderr, "\n");
|
||||
avrdude_message("\n");
|
||||
}
|
||||
|
||||
while (len) {
|
||||
rc = write(fd->ifd, p, (len > 1024) ? 1024 : len);
|
||||
if (rc < 0) {
|
||||
fprintf(stderr, "%s: ser_send(): write error: %s\n",
|
||||
avrdude_message("%s: ser_send(): write error: %s\n",
|
||||
progname, strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
|
@ -378,20 +376,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)
|
||||
fprintf(stderr,
|
||||
"%s: ser_recv(): programmer is not responding\n",
|
||||
progname);
|
||||
avrdude_message("%s: ser_recv(): programmer is not responding\n",
|
||||
progname);
|
||||
return -1;
|
||||
}
|
||||
else if (nfds == -1) {
|
||||
if (errno == EINTR || errno == EAGAIN) {
|
||||
fprintf(stderr,
|
||||
"%s: ser_recv(): programmer is not responding,reselecting\n",
|
||||
progname);
|
||||
avrdude_message("%s: ser_recv(): programmer is not responding,reselecting\n",
|
||||
progname);
|
||||
goto reselect;
|
||||
}
|
||||
else {
|
||||
fprintf(stderr, "%s: ser_recv(): select(): %s\n",
|
||||
avrdude_message("%s: ser_recv(): select(): %s\n",
|
||||
progname, strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
|
@ -399,7 +395,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) {
|
||||
fprintf(stderr, "%s: ser_recv(): read error: %s\n",
|
||||
avrdude_message("%s: ser_recv(): read error: %s\n",
|
||||
progname, strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
|
@ -411,22 +407,22 @@ static int ser_recv(union filedescriptor *fd, unsigned char * buf, size_t buflen
|
|||
|
||||
if (verbose > 3)
|
||||
{
|
||||
fprintf(stderr, "%s: Recv: ", progname);
|
||||
avrdude_message("%s: Recv: ", progname);
|
||||
|
||||
while (len) {
|
||||
unsigned char c = *p;
|
||||
if (isprint(c)) {
|
||||
fprintf(stderr, "%c ", c);
|
||||
avrdude_message("%c ", c);
|
||||
}
|
||||
else {
|
||||
fprintf(stderr, ". ");
|
||||
avrdude_message(". ");
|
||||
}
|
||||
fprintf(stderr, "[%02x] ", c);
|
||||
avrdude_message("[%02x] ", c);
|
||||
|
||||
p++;
|
||||
len--;
|
||||
}
|
||||
fprintf(stderr, "\n");
|
||||
avrdude_message("\n");
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -445,7 +441,7 @@ static int ser_drain(union filedescriptor *fd, int display)
|
|||
timeout.tv_usec = 250000;
|
||||
|
||||
if (display) {
|
||||
fprintf(stderr, "drain>");
|
||||
avrdude_message("drain>");
|
||||
}
|
||||
|
||||
while (1) {
|
||||
|
@ -456,7 +452,7 @@ static int ser_drain(union filedescriptor *fd, int display)
|
|||
nfds = select(fd->ifd + 1, &rfds, NULL, NULL, &timeout);
|
||||
if (nfds == 0) {
|
||||
if (display) {
|
||||
fprintf(stderr, "<drain\n");
|
||||
avrdude_message("<drain\n");
|
||||
}
|
||||
|
||||
break;
|
||||
|
@ -466,7 +462,7 @@ static int ser_drain(union filedescriptor *fd, int display)
|
|||
goto reselect;
|
||||
}
|
||||
else {
|
||||
fprintf(stderr, "%s: ser_drain(): select(): %s\n",
|
||||
avrdude_message("%s: ser_drain(): select(): %s\n",
|
||||
progname, strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
|
@ -474,12 +470,12 @@ static int ser_drain(union filedescriptor *fd, int display)
|
|||
|
||||
rc = read(fd->ifd, &buf, 1);
|
||||
if (rc < 0) {
|
||||
fprintf(stderr, "%s: ser_drain(): read error: %s\n",
|
||||
avrdude_message("%s: ser_drain(): read error: %s\n",
|
||||
progname, strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
if (display) {
|
||||
fprintf(stderr, "%02x ", buf);
|
||||
avrdude_message("%02x ", buf);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
67
ser_win32.c
67
ser_win32.c
|
@ -71,7 +71,7 @@ static DWORD serial_baud_lookup(long baud)
|
|||
* a warning (if we are verbose) and return the raw rate
|
||||
*/
|
||||
if (verbose > 0)
|
||||
fprintf(stderr, "%s: serial_baud_lookup(): Using non-standard baud rate: %ld",
|
||||
avrdude_message("%s: serial_baud_lookup(): Using non-standard baud rate: %ld",
|
||||
progname, baud);
|
||||
|
||||
return baud;
|
||||
|
@ -124,10 +124,9 @@ 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) {
|
||||
fprintf(stderr,
|
||||
"%s: ser_open(): network connects are currently not"
|
||||
"implemented for Win32 environments\n",
|
||||
progname);
|
||||
avrdude_message("%s: ser_open(): network connects are currently not"
|
||||
"implemented for Win32 environments\n",
|
||||
progname);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -137,9 +136,8 @@ static int ser_open(char * port, union pinfo pinfo, union filedescriptor *fdp)
|
|||
newname = malloc(strlen("\\\\.\\") + strlen(port) + 1);
|
||||
|
||||
if (newname == 0) {
|
||||
fprintf(stderr,
|
||||
"%s: ser_open(): out of memory\n",
|
||||
progname);
|
||||
avrdude_message("%s: ser_open(): out of memory\n",
|
||||
progname);
|
||||
exit(1);
|
||||
}
|
||||
strcpy(newname, "\\\\.\\");
|
||||
|
@ -162,7 +160,7 @@ static int ser_open(char * port, union pinfo pinfo, union filedescriptor *fdp)
|
|||
(LPTSTR) &lpMsgBuf,
|
||||
0,
|
||||
NULL);
|
||||
fprintf(stderr, "%s: ser_open(): can't open device \"%s\": %s\n",
|
||||
avrdude_message("%s: ser_open(): can't open device \"%s\": %s\n",
|
||||
progname, port, (char*)lpMsgBuf);
|
||||
LocalFree( lpMsgBuf );
|
||||
return -1;
|
||||
|
@ -171,7 +169,7 @@ static int ser_open(char * port, union pinfo pinfo, union filedescriptor *fdp)
|
|||
if (!SetupComm(hComPort, W32SERBUFSIZE, W32SERBUFSIZE))
|
||||
{
|
||||
CloseHandle(hComPort);
|
||||
fprintf(stderr, "%s: ser_open(): can't set buffers for \"%s\"\n",
|
||||
avrdude_message("%s: ser_open(): can't set buffers for \"%s\"\n",
|
||||
progname, port);
|
||||
return -1;
|
||||
}
|
||||
|
@ -180,7 +178,7 @@ static int ser_open(char * port, union pinfo pinfo, union filedescriptor *fdp)
|
|||
if (ser_setspeed(fdp, pinfo.baud) != 0)
|
||||
{
|
||||
CloseHandle(hComPort);
|
||||
fprintf(stderr, "%s: ser_open(): can't set com-state for \"%s\"\n",
|
||||
avrdude_message("%s: ser_open(): can't set com-state for \"%s\"\n",
|
||||
progname, port);
|
||||
return -1;
|
||||
}
|
||||
|
@ -188,7 +186,7 @@ static int ser_open(char * port, union pinfo pinfo, union filedescriptor *fdp)
|
|||
if (!serial_w32SetTimeOut(hComPort,0))
|
||||
{
|
||||
CloseHandle(hComPort);
|
||||
fprintf(stderr, "%s: ser_open(): can't set initial timeout for \"%s\"\n",
|
||||
avrdude_message("%s: ser_open(): can't set initial timeout for \"%s\"\n",
|
||||
progname, port);
|
||||
return -1;
|
||||
}
|
||||
|
@ -234,7 +232,7 @@ static int ser_send(union filedescriptor *fd, unsigned char * buf, size_t buflen
|
|||
HANDLE hComPort=(HANDLE)fd->pfd;
|
||||
|
||||
if (hComPort == INVALID_HANDLE_VALUE) {
|
||||
fprintf(stderr, "%s: ser_send(): port not open\n",
|
||||
avrdude_message("%s: ser_send(): port not open\n",
|
||||
progname);
|
||||
return -1;
|
||||
}
|
||||
|
@ -244,33 +242,33 @@ static int ser_send(union filedescriptor *fd, unsigned char * buf, size_t buflen
|
|||
|
||||
if (verbose > 3)
|
||||
{
|
||||
fprintf(stderr, "%s: Send: ", progname);
|
||||
avrdude_message("%s: Send: ", progname);
|
||||
|
||||
while (len) {
|
||||
c = *b;
|
||||
if (isprint(c)) {
|
||||
fprintf(stderr, "%c ", c);
|
||||
avrdude_message("%c ", c);
|
||||
}
|
||||
else {
|
||||
fprintf(stderr, ". ");
|
||||
avrdude_message(". ");
|
||||
}
|
||||
fprintf(stderr, "[%02x] ", c);
|
||||
avrdude_message("[%02x] ", c);
|
||||
b++;
|
||||
len--;
|
||||
}
|
||||
fprintf(stderr, "\n");
|
||||
avrdude_message("\n");
|
||||
}
|
||||
|
||||
serial_w32SetTimeOut(hComPort,500);
|
||||
|
||||
if (!WriteFile (hComPort, buf, buflen, &written, NULL)) {
|
||||
fprintf(stderr, "%s: ser_send(): write error: %s\n",
|
||||
avrdude_message("%s: ser_send(): write error: %s\n",
|
||||
progname, "sorry no info avail"); // TODO
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (written != buflen) {
|
||||
fprintf(stderr, "%s: ser_send(): size/send mismatch\n",
|
||||
avrdude_message("%s: ser_send(): size/send mismatch\n",
|
||||
progname);
|
||||
return -1;
|
||||
}
|
||||
|
@ -288,7 +286,7 @@ static int ser_recv(union filedescriptor *fd, unsigned char * buf, size_t buflen
|
|||
HANDLE hComPort=(HANDLE)fd->pfd;
|
||||
|
||||
if (hComPort == INVALID_HANDLE_VALUE) {
|
||||
fprintf(stderr, "%s: ser_read(): port not open\n",
|
||||
avrdude_message("%s: ser_read(): port not open\n",
|
||||
progname);
|
||||
return -1;
|
||||
}
|
||||
|
@ -307,7 +305,7 @@ static int ser_recv(union filedescriptor *fd, unsigned char * buf, size_t buflen
|
|||
(LPTSTR) &lpMsgBuf,
|
||||
0,
|
||||
NULL );
|
||||
fprintf(stderr, "%s: ser_recv(): read error: %s\n",
|
||||
avrdude_message("%s: ser_recv(): read error: %s\n",
|
||||
progname, (char*)lpMsgBuf);
|
||||
LocalFree( lpMsgBuf );
|
||||
return -1;
|
||||
|
@ -316,9 +314,8 @@ static int ser_recv(union filedescriptor *fd, unsigned char * buf, size_t buflen
|
|||
/* time out detected */
|
||||
if (read == 0) {
|
||||
if (verbose > 1)
|
||||
fprintf(stderr,
|
||||
"%s: ser_recv(): programmer is not responding\n",
|
||||
progname);
|
||||
avrdude_message("%s: ser_recv(): programmer is not responding\n",
|
||||
progname);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -326,22 +323,22 @@ static int ser_recv(union filedescriptor *fd, unsigned char * buf, size_t buflen
|
|||
|
||||
if (verbose > 3)
|
||||
{
|
||||
fprintf(stderr, "%s: Recv: ", progname);
|
||||
avrdude_message("%s: Recv: ", progname);
|
||||
|
||||
while (read) {
|
||||
c = *p;
|
||||
if (isprint(c)) {
|
||||
fprintf(stderr, "%c ", c);
|
||||
avrdude_message("%c ", c);
|
||||
}
|
||||
else {
|
||||
fprintf(stderr, ". ");
|
||||
avrdude_message(". ");
|
||||
}
|
||||
fprintf(stderr, "[%02x] ", c);
|
||||
avrdude_message("[%02x] ", c);
|
||||
|
||||
p++;
|
||||
read--;
|
||||
}
|
||||
fprintf(stderr, "\n");
|
||||
avrdude_message("\n");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -357,7 +354,7 @@ static int ser_drain(union filedescriptor *fd, int display)
|
|||
HANDLE hComPort=(HANDLE)fd->pfd;
|
||||
|
||||
if (hComPort == INVALID_HANDLE_VALUE) {
|
||||
fprintf(stderr, "%s: ser_drain(): port not open\n",
|
||||
avrdude_message("%s: ser_drain(): port not open\n",
|
||||
progname);
|
||||
return -1;
|
||||
}
|
||||
|
@ -365,7 +362,7 @@ static int ser_drain(union filedescriptor *fd, int display)
|
|||
serial_w32SetTimeOut(hComPort,250);
|
||||
|
||||
if (display) {
|
||||
fprintf(stderr, "drain>");
|
||||
avrdude_message("drain>");
|
||||
}
|
||||
|
||||
while (1) {
|
||||
|
@ -382,17 +379,17 @@ static int ser_drain(union filedescriptor *fd, int display)
|
|||
(LPTSTR) &lpMsgBuf,
|
||||
0,
|
||||
NULL );
|
||||
fprintf(stderr, "%s: ser_drain(): read error: %s\n",
|
||||
avrdude_message("%s: ser_drain(): read error: %s\n",
|
||||
progname, (char*)lpMsgBuf);
|
||||
LocalFree( lpMsgBuf );
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (read) { // data avail
|
||||
if (display) fprintf(stderr, "%02x ", buf[0]);
|
||||
if (display) avrdude_message("%02x ", buf[0]);
|
||||
}
|
||||
else { // no more data
|
||||
if (display) fprintf(stderr, "<drain\n");
|
||||
if (display) avrdude_message("<drain\n");
|
||||
break;
|
||||
}
|
||||
} // while
|
||||
|
|
|
@ -239,7 +239,7 @@ static int serbb_open(PROGRAMMER *pgm, char *port)
|
|||
|
||||
r = tcgetattr(pgm->fd.ifd, &mode);
|
||||
if (r < 0) {
|
||||
fprintf(stderr, "%s: ", port);
|
||||
avrdude_message("%s: ", port);
|
||||
perror("tcgetattr");
|
||||
return(-1);
|
||||
}
|
||||
|
@ -253,7 +253,7 @@ static int serbb_open(PROGRAMMER *pgm, char *port)
|
|||
|
||||
r = tcsetattr(pgm->fd.ifd, TCSANOW, &mode);
|
||||
if (r < 0) {
|
||||
fprintf(stderr, "%s: ", port);
|
||||
avrdude_message("%s: ", port);
|
||||
perror("tcsetattr");
|
||||
return(-1);
|
||||
}
|
||||
|
@ -262,14 +262,14 @@ static int serbb_open(PROGRAMMER *pgm, char *port)
|
|||
flags = fcntl(pgm->fd.ifd, F_GETFL, 0);
|
||||
if (flags == -1)
|
||||
{
|
||||
fprintf(stderr, "%s: Can not get flags: %s\n",
|
||||
avrdude_message("%s: Can not get flags: %s\n",
|
||||
progname, strerror(errno));
|
||||
return(-1);
|
||||
}
|
||||
flags &= ~O_NONBLOCK;
|
||||
if (fcntl(pgm->fd.ifd, F_SETFL, flags) == -1)
|
||||
{
|
||||
fprintf(stderr, "%s: Can not clear nonblock flag: %s\n",
|
||||
avrdude_message("%s: Can not clear nonblock flag: %s\n",
|
||||
progname, strerror(errno));
|
||||
return(-1);
|
||||
}
|
||||
|
|
|
@ -98,15 +98,13 @@ static int serbb_setpin(PROGRAMMER * pgm, int pinfunc, int value)
|
|||
|
||||
default:
|
||||
if (verbose)
|
||||
fprintf(stderr,
|
||||
"%s: serbb_setpin(): unknown pin %d\n",
|
||||
progname, pin + 1);
|
||||
avrdude_message("%s: serbb_setpin(): unknown pin %d\n",
|
||||
progname, pin + 1);
|
||||
return -1;
|
||||
}
|
||||
if (verbose > 4)
|
||||
fprintf(stderr,
|
||||
"%s: serbb_setpin(): EscapeCommFunction(%s)\n",
|
||||
progname, name);
|
||||
avrdude_message("%s: serbb_setpin(): EscapeCommFunction(%s)\n",
|
||||
progname, name);
|
||||
if (!EscapeCommFunction(hComPort, dwFunc))
|
||||
{
|
||||
FormatMessage(
|
||||
|
@ -119,9 +117,8 @@ static int serbb_setpin(PROGRAMMER * pgm, int pinfunc, int value)
|
|||
(LPTSTR) &lpMsgBuf,
|
||||
0,
|
||||
NULL);
|
||||
fprintf(stderr,
|
||||
"%s: serbb_setpin(): SetCommState() failed: %s\n",
|
||||
progname, (char *)lpMsgBuf);
|
||||
avrdude_message("%s: serbb_setpin(): SetCommState() failed: %s\n",
|
||||
progname, (char *)lpMsgBuf);
|
||||
CloseHandle(hComPort);
|
||||
LocalFree(lpMsgBuf);
|
||||
return -1;
|
||||
|
@ -166,17 +163,15 @@ static int serbb_getpin(PROGRAMMER * pgm, int pinfunc)
|
|||
(LPTSTR) &lpMsgBuf,
|
||||
0,
|
||||
NULL);
|
||||
fprintf(stderr,
|
||||
"%s: serbb_setpin(): GetCommModemStatus() failed: %s\n",
|
||||
progname, (char *)lpMsgBuf);
|
||||
avrdude_message("%s: serbb_setpin(): GetCommModemStatus() failed: %s\n",
|
||||
progname, (char *)lpMsgBuf);
|
||||
CloseHandle(hComPort);
|
||||
LocalFree(lpMsgBuf);
|
||||
return -1;
|
||||
}
|
||||
if (verbose > 4)
|
||||
fprintf(stderr,
|
||||
"%s: serbb_getpin(): GetCommState() => 0x%lx\n",
|
||||
progname, modemstate);
|
||||
avrdude_message("%s: serbb_getpin(): GetCommState() => 0x%lx\n",
|
||||
progname, modemstate);
|
||||
switch (pin)
|
||||
{
|
||||
case 1:
|
||||
|
@ -212,15 +207,13 @@ static int serbb_getpin(PROGRAMMER * pgm, int pinfunc)
|
|||
break;
|
||||
default:
|
||||
if (verbose)
|
||||
fprintf(stderr,
|
||||
"%s: serbb_getpin(): unknown pin %d\n",
|
||||
progname, pin + 1);
|
||||
avrdude_message("%s: serbb_getpin(): unknown pin %d\n",
|
||||
progname, pin + 1);
|
||||
return -1;
|
||||
}
|
||||
if (verbose > 4)
|
||||
fprintf(stderr,
|
||||
"%s: serbb_getpin(): return cached state for %s\n",
|
||||
progname, name);
|
||||
avrdude_message("%s: serbb_getpin(): return cached state for %s\n",
|
||||
progname, name);
|
||||
if (invert)
|
||||
rv = !rv;
|
||||
|
||||
|
@ -288,7 +281,7 @@ static int serbb_open(PROGRAMMER *pgm, char *port)
|
|||
(LPTSTR) &lpMsgBuf,
|
||||
0,
|
||||
NULL);
|
||||
fprintf(stderr, "%s: ser_open(): can't open device \"%s\": %s\n",
|
||||
avrdude_message("%s: ser_open(): can't open device \"%s\": %s\n",
|
||||
progname, port, (char*)lpMsgBuf);
|
||||
LocalFree(lpMsgBuf);
|
||||
return -1;
|
||||
|
@ -297,7 +290,7 @@ static int serbb_open(PROGRAMMER *pgm, char *port)
|
|||
if (!SetupComm(hComPort, W32SERBUFSIZE, W32SERBUFSIZE))
|
||||
{
|
||||
CloseHandle(hComPort);
|
||||
fprintf(stderr, "%s: ser_open(): can't set buffers for \"%s\"\n",
|
||||
avrdude_message("%s: ser_open(): can't set buffers for \"%s\"\n",
|
||||
progname, port);
|
||||
return -1;
|
||||
}
|
||||
|
@ -316,13 +309,12 @@ static int serbb_open(PROGRAMMER *pgm, char *port)
|
|||
if (!SetCommState(hComPort, &dcb))
|
||||
{
|
||||
CloseHandle(hComPort);
|
||||
fprintf(stderr, "%s: ser_open(): can't set com-state for \"%s\"\n",
|
||||
avrdude_message("%s: ser_open(): can't set com-state for \"%s\"\n",
|
||||
progname, port);
|
||||
return -1;
|
||||
}
|
||||
if (verbose > 2)
|
||||
fprintf(stderr,
|
||||
"%s: ser_open(): opened comm port \"%s\", handle 0x%x\n",
|
||||
avrdude_message("%s: ser_open(): opened comm port \"%s\", handle 0x%x\n",
|
||||
progname, port, (int)hComPort);
|
||||
|
||||
pgm->fd.pfd = (void *)hComPort;
|
||||
|
@ -341,9 +333,8 @@ static void serbb_close(PROGRAMMER *pgm)
|
|||
CloseHandle (hComPort);
|
||||
}
|
||||
if (verbose > 2)
|
||||
fprintf(stderr,
|
||||
"%s: ser_close(): closed comm port handle 0x%x\n",
|
||||
progname, (int)hComPort);
|
||||
avrdude_message("%s: ser_close(): closed comm port handle 0x%x\n",
|
||||
progname, (int)hComPort);
|
||||
|
||||
hComPort = INVALID_HANDLE_VALUE;
|
||||
}
|
||||
|
|
299
stk500.c
299
stk500.c
|
@ -72,9 +72,8 @@ static int stk500_recv(PROGRAMMER * pgm, unsigned char * buf, size_t len)
|
|||
|
||||
rv = serial_recv(&pgm->fd, buf, len);
|
||||
if (rv < 0) {
|
||||
fprintf(stderr,
|
||||
"%s: stk500_recv(): programmer is not responding\n",
|
||||
progname);
|
||||
avrdude_message("%s: stk500_recv(): programmer is not responding\n",
|
||||
progname);
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
|
@ -112,9 +111,8 @@ int stk500_getsync(PROGRAMMER * pgm)
|
|||
if (resp[0] == Resp_STK_INSYNC){
|
||||
break;
|
||||
}
|
||||
fprintf(stderr,
|
||||
"%s: stk500_getsync() attempt %d of %d: not in sync: resp=0x%02x\n",
|
||||
progname, attempt + 1, MAX_SYNC_ATTEMPTS, resp[0]);
|
||||
avrdude_message("%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) {
|
||||
stk500_drain(pgm, 0);
|
||||
|
@ -124,10 +122,9 @@ int stk500_getsync(PROGRAMMER * pgm)
|
|||
if (stk500_recv(pgm, resp, 1) < 0)
|
||||
return -1;
|
||||
if (resp[0] != Resp_STK_OK) {
|
||||
fprintf(stderr,
|
||||
"%s: stk500_getsync(): can't communicate with device: "
|
||||
"resp=0x%02x\n",
|
||||
progname, resp[0]);
|
||||
avrdude_message("%s: stk500_getsync(): can't communicate with device: "
|
||||
"resp=0x%02x\n",
|
||||
progname, resp[0]);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -156,7 +153,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) {
|
||||
fprintf(stderr, "%s: stk500_cmd(): programmer is out of sync\n", progname);
|
||||
avrdude_message("%s: stk500_cmd(): programmer is out of sync\n", progname);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -169,7 +166,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) {
|
||||
fprintf(stderr, "%s: stk500_cmd(): protocol error\n", progname);
|
||||
avrdude_message("%s: stk500_cmd(): protocol error\n", progname);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -187,15 +184,14 @@ static int stk500_chip_erase(PROGRAMMER * pgm, AVRPART * p)
|
|||
unsigned char res[4];
|
||||
|
||||
if (pgm->cmd == NULL) {
|
||||
fprintf(stderr,
|
||||
"%s: Error: %s programmer uses stk500_chip_erase() but does not\n"
|
||||
"provide a cmd() method.\n",
|
||||
progname, pgm->type);
|
||||
avrdude_message("%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) {
|
||||
fprintf(stderr, "chip erase instruction not defined for part \"%s\"\n",
|
||||
avrdude_message("chip erase instruction not defined for part \"%s\"\n",
|
||||
p->desc);
|
||||
return -1;
|
||||
}
|
||||
|
@ -234,7 +230,7 @@ static int stk500_program_enable(PROGRAMMER * pgm, AVRPART * p)
|
|||
return -1;
|
||||
if (buf[0] == Resp_STK_NOSYNC) {
|
||||
if (tries > 33) {
|
||||
fprintf(stderr, "%s: stk500_program_enable(): can't get into sync\n",
|
||||
avrdude_message("%s: stk500_program_enable(): can't get into sync\n",
|
||||
progname);
|
||||
return -1;
|
||||
}
|
||||
|
@ -243,10 +239,9 @@ static int stk500_program_enable(PROGRAMMER * pgm, AVRPART * p)
|
|||
goto retry;
|
||||
}
|
||||
else if (buf[0] != Resp_STK_INSYNC) {
|
||||
fprintf(stderr,
|
||||
"%s: stk500_program_enable(): protocol error, "
|
||||
"expect=0x%02x, resp=0x%02x\n",
|
||||
progname, Resp_STK_INSYNC, buf[0]);
|
||||
avrdude_message("%s: stk500_program_enable(): protocol error, "
|
||||
"expect=0x%02x, resp=0x%02x\n",
|
||||
progname, Resp_STK_INSYNC, buf[0]);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -256,21 +251,20 @@ static int stk500_program_enable(PROGRAMMER * pgm, AVRPART * p)
|
|||
return 0;
|
||||
}
|
||||
else if (buf[0] == Resp_STK_NODEVICE) {
|
||||
fprintf(stderr, "%s: stk500_program_enable(): no device\n",
|
||||
avrdude_message("%s: stk500_program_enable(): no device\n",
|
||||
progname);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if(buf[0] == Resp_STK_FAILED)
|
||||
{
|
||||
fprintf(stderr,
|
||||
"%s: stk500_program_enable(): failed to enter programming mode\n",
|
||||
progname);
|
||||
avrdude_message("%s: stk500_program_enable(): failed to enter programming mode\n",
|
||||
progname);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
fprintf(stderr, "%s: stk500_program_enable(): unknown response=0x%02x\n",
|
||||
avrdude_message("%s: stk500_program_enable(): unknown response=0x%02x\n",
|
||||
progname, buf[0]);
|
||||
|
||||
return -1;
|
||||
|
@ -301,7 +295,7 @@ static int stk500_set_extended_parms(PROGRAMMER * pgm, int n,
|
|||
return -1;
|
||||
if (buf[0] == Resp_STK_NOSYNC) {
|
||||
if (tries > 33) {
|
||||
fprintf(stderr, "%s: stk500_set_extended_parms(): can't get into sync\n",
|
||||
avrdude_message("%s: stk500_set_extended_parms(): can't get into sync\n",
|
||||
progname);
|
||||
return -1;
|
||||
}
|
||||
|
@ -310,10 +304,9 @@ static int stk500_set_extended_parms(PROGRAMMER * pgm, int n,
|
|||
goto retry;
|
||||
}
|
||||
else if (buf[0] != Resp_STK_INSYNC) {
|
||||
fprintf(stderr,
|
||||
"%s: stk500_set_extended_parms(): protocol error, "
|
||||
"expect=0x%02x, resp=0x%02x\n",
|
||||
progname, Resp_STK_INSYNC, buf[0]);
|
||||
avrdude_message("%s: stk500_set_extended_parms(): protocol error, "
|
||||
"expect=0x%02x, resp=0x%02x\n",
|
||||
progname, Resp_STK_INSYNC, buf[0]);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -323,22 +316,21 @@ static int stk500_set_extended_parms(PROGRAMMER * pgm, int n,
|
|||
return 0;
|
||||
}
|
||||
else if (buf[0] == Resp_STK_NODEVICE) {
|
||||
fprintf(stderr, "%s: stk500_set_extended_parms(): no device\n",
|
||||
avrdude_message("%s: stk500_set_extended_parms(): no device\n",
|
||||
progname);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if(buf[0] == Resp_STK_FAILED)
|
||||
{
|
||||
fprintf(stderr,
|
||||
"%s: stk500_set_extended_parms(): failed to set extended "
|
||||
"device programming parameters\n",
|
||||
progname);
|
||||
avrdude_message("%s: stk500_set_extended_parms(): failed to set extended "
|
||||
"device programming parameters\n",
|
||||
progname);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
fprintf(stderr, "%s: stk500_set_extended_parms(): unknown response=0x%02x\n",
|
||||
avrdude_message("%s: stk500_set_extended_parms(): unknown response=0x%02x\n",
|
||||
progname, buf[0]);
|
||||
|
||||
return -1;
|
||||
|
@ -373,7 +365,7 @@ static int mib510_isp(PROGRAMMER * pgm, unsigned char cmd)
|
|||
return -1;
|
||||
if (buf[0] == Resp_STK_NOSYNC) {
|
||||
if (tries > 33) {
|
||||
fprintf(stderr, "%s: mib510_isp(): can't get into sync\n",
|
||||
avrdude_message("%s: mib510_isp(): can't get into sync\n",
|
||||
progname);
|
||||
return -1;
|
||||
}
|
||||
|
@ -382,10 +374,9 @@ static int mib510_isp(PROGRAMMER * pgm, unsigned char cmd)
|
|||
goto retry;
|
||||
}
|
||||
else if (buf[0] != Resp_STK_INSYNC) {
|
||||
fprintf(stderr,
|
||||
"%s: mib510_isp(): protocol error, "
|
||||
"expect=0x%02x, resp=0x%02x\n",
|
||||
progname, Resp_STK_INSYNC, buf[0]);
|
||||
avrdude_message("%s: mib510_isp(): protocol error, "
|
||||
"expect=0x%02x, resp=0x%02x\n",
|
||||
progname, Resp_STK_INSYNC, buf[0]);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -395,21 +386,20 @@ static int mib510_isp(PROGRAMMER * pgm, unsigned char cmd)
|
|||
return 0;
|
||||
}
|
||||
else if (buf[0] == Resp_STK_NODEVICE) {
|
||||
fprintf(stderr, "%s: mib510_isp(): no device\n",
|
||||
avrdude_message("%s: mib510_isp(): no device\n",
|
||||
progname);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (buf[0] == Resp_STK_FAILED)
|
||||
{
|
||||
fprintf(stderr,
|
||||
"%s: mib510_isp(): command %d failed\n",
|
||||
progname, cmd);
|
||||
avrdude_message("%s: mib510_isp(): command %d failed\n",
|
||||
progname, cmd);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
fprintf(stderr, "%s: mib510_isp(): unknown response=0x%02x\n",
|
||||
avrdude_message("%s: mib510_isp(): unknown response=0x%02x\n",
|
||||
progname, buf[0]);
|
||||
|
||||
return -1;
|
||||
|
@ -470,7 +460,7 @@ static int stk500_initialize(PROGRAMMER * pgm, AVRPART * p)
|
|||
}
|
||||
|
||||
#if 0
|
||||
fprintf(stderr, "%s: stk500_initialize(): n_extparms = %d\n",
|
||||
avrdude_message("%s: stk500_initialize(): n_extparms = %d\n",
|
||||
progname, n_extparms);
|
||||
#endif
|
||||
|
||||
|
@ -544,9 +534,8 @@ static int stk500_initialize(PROGRAMMER * pgm, AVRPART * p)
|
|||
if (stk500_recv(pgm, buf, 1) < 0)
|
||||
return -1;
|
||||
if (buf[0] == Resp_STK_NOSYNC) {
|
||||
fprintf(stderr,
|
||||
"%s: stk500_initialize(): programmer not in sync, resp=0x%02x\n",
|
||||
progname, buf[0]);
|
||||
avrdude_message("%s: stk500_initialize(): programmer not in sync, resp=0x%02x\n",
|
||||
progname, buf[0]);
|
||||
if (tries > 33)
|
||||
return -1;
|
||||
if (stk500_getsync(pgm) < 0)
|
||||
|
@ -554,30 +543,27 @@ static int stk500_initialize(PROGRAMMER * pgm, AVRPART * p)
|
|||
goto retry;
|
||||
}
|
||||
else if (buf[0] != Resp_STK_INSYNC) {
|
||||
fprintf(stderr,
|
||||
"%s: stk500_initialize(): (a) protocol error, "
|
||||
"expect=0x%02x, resp=0x%02x\n",
|
||||
progname, Resp_STK_INSYNC, buf[0]);
|
||||
avrdude_message("%s: stk500_initialize(): (a) protocol error, "
|
||||
"expect=0x%02x, resp=0x%02x\n",
|
||||
progname, Resp_STK_INSYNC, buf[0]);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (stk500_recv(pgm, buf, 1) < 0)
|
||||
return -1;
|
||||
if (buf[0] != Resp_STK_OK) {
|
||||
fprintf(stderr,
|
||||
"%s: stk500_initialize(): (b) protocol error, "
|
||||
"expect=0x%02x, resp=0x%02x\n",
|
||||
progname, Resp_STK_OK, buf[0]);
|
||||
avrdude_message("%s: stk500_initialize(): (b) protocol error, "
|
||||
"expect=0x%02x, resp=0x%02x\n",
|
||||
progname, Resp_STK_OK, buf[0]);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (n_extparms) {
|
||||
if ((p->pagel == 0) || (p->bs2 == 0)) {
|
||||
if (verbose > 1)
|
||||
fprintf(stderr,
|
||||
"%s: PAGEL and BS2 signals not defined in the configuration "
|
||||
"file for part %s, using dummy values\n",
|
||||
progname, p->desc);
|
||||
avrdude_message("%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, */
|
||||
buf[3] = 0xA0; /* don't they? ;) */
|
||||
}
|
||||
|
@ -605,7 +591,7 @@ static int stk500_initialize(PROGRAMMER * pgm, AVRPART * p)
|
|||
|
||||
rc = stk500_set_extended_parms(pgm, n_extparms+1, buf);
|
||||
if (rc) {
|
||||
fprintf(stderr, "%s: stk500_initialize(): failed\n", progname);
|
||||
avrdude_message("%s: stk500_initialize(): failed\n", progname);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
@ -631,7 +617,7 @@ static void stk500_disable(PROGRAMMER * pgm)
|
|||
return;
|
||||
if (buf[0] == Resp_STK_NOSYNC) {
|
||||
if (tries > 33) {
|
||||
fprintf(stderr, "%s: stk500_disable(): can't get into sync\n",
|
||||
avrdude_message("%s: stk500_disable(): can't get into sync\n",
|
||||
progname);
|
||||
return;
|
||||
}
|
||||
|
@ -640,10 +626,9 @@ static void stk500_disable(PROGRAMMER * pgm)
|
|||
goto retry;
|
||||
}
|
||||
else if (buf[0] != Resp_STK_INSYNC) {
|
||||
fprintf(stderr,
|
||||
"%s: stk500_disable(): protocol error, expect=0x%02x, "
|
||||
"resp=0x%02x\n",
|
||||
progname, Resp_STK_INSYNC, buf[0]);
|
||||
avrdude_message("%s: stk500_disable(): protocol error, expect=0x%02x, "
|
||||
"resp=0x%02x\n",
|
||||
progname, Resp_STK_INSYNC, buf[0]);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -653,12 +638,12 @@ static void stk500_disable(PROGRAMMER * pgm)
|
|||
return;
|
||||
}
|
||||
else if (buf[0] == Resp_STK_NODEVICE) {
|
||||
fprintf(stderr, "%s: stk500_disable(): no device\n",
|
||||
avrdude_message("%s: stk500_disable(): no device\n",
|
||||
progname);
|
||||
return;
|
||||
}
|
||||
|
||||
fprintf(stderr, "%s: stk500_disable(): unknown response=0x%02x\n",
|
||||
avrdude_message("%s: stk500_disable(): unknown response=0x%02x\n",
|
||||
progname, buf[0]);
|
||||
|
||||
return;
|
||||
|
@ -743,7 +728,7 @@ static int stk500_loadaddr(PROGRAMMER * pgm, AVRMEM * mem, unsigned int addr)
|
|||
return -1;
|
||||
if (buf[0] == Resp_STK_NOSYNC) {
|
||||
if (tries > 33) {
|
||||
fprintf(stderr, "%s: stk500_loadaddr(): can't get into sync\n",
|
||||
avrdude_message("%s: stk500_loadaddr(): can't get into sync\n",
|
||||
progname);
|
||||
return -1;
|
||||
}
|
||||
|
@ -752,10 +737,9 @@ static int stk500_loadaddr(PROGRAMMER * pgm, AVRMEM * mem, unsigned int addr)
|
|||
goto retry;
|
||||
}
|
||||
else if (buf[0] != Resp_STK_INSYNC) {
|
||||
fprintf(stderr,
|
||||
"%s: stk500_loadaddr(): (a) protocol error, "
|
||||
"expect=0x%02x, resp=0x%02x\n",
|
||||
progname, Resp_STK_INSYNC, buf[0]);
|
||||
avrdude_message("%s: stk500_loadaddr(): (a) protocol error, "
|
||||
"expect=0x%02x, resp=0x%02x\n",
|
||||
progname, Resp_STK_INSYNC, buf[0]);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -765,10 +749,9 @@ static int stk500_loadaddr(PROGRAMMER * pgm, AVRMEM * mem, unsigned int addr)
|
|||
return 0;
|
||||
}
|
||||
|
||||
fprintf(stderr,
|
||||
"%s: loadaddr(): (b) protocol error, "
|
||||
"expect=0x%02x, resp=0x%02x\n",
|
||||
progname, Resp_STK_INSYNC, buf[0]);
|
||||
avrdude_message("%s: loadaddr(): (b) protocol error, "
|
||||
"expect=0x%02x, resp=0x%02x\n",
|
||||
progname, Resp_STK_INSYNC, buf[0]);
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
@ -803,12 +786,11 @@ static int stk500_paged_write(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m,
|
|||
|
||||
n = addr + n_bytes;
|
||||
#if 0
|
||||
fprintf(stderr,
|
||||
"n_bytes = %d\n"
|
||||
"n = %u\n"
|
||||
"a_div = %d\n"
|
||||
"page_size = %d\n",
|
||||
n_bytes, n, a_div, page_size);
|
||||
avrdude_message("n_bytes = %d\n"
|
||||
"n = %u\n"
|
||||
"a_div = %d\n"
|
||||
"page_size = %d\n",
|
||||
n_bytes, n, a_div, page_size);
|
||||
#endif
|
||||
|
||||
for (; addr < n; addr += block_size) {
|
||||
|
@ -842,7 +824,7 @@ static int stk500_paged_write(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m,
|
|||
return -1;
|
||||
if (buf[0] == Resp_STK_NOSYNC) {
|
||||
if (tries > 33) {
|
||||
fprintf(stderr, "\n%s: stk500_paged_write(): can't get into sync\n",
|
||||
avrdude_message("\n%s: stk500_paged_write(): can't get into sync\n",
|
||||
progname);
|
||||
return -3;
|
||||
}
|
||||
|
@ -851,20 +833,18 @@ static int stk500_paged_write(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m,
|
|||
goto retry;
|
||||
}
|
||||
else if (buf[0] != Resp_STK_INSYNC) {
|
||||
fprintf(stderr,
|
||||
"\n%s: stk500_paged_write(): (a) protocol error, "
|
||||
"expect=0x%02x, resp=0x%02x\n",
|
||||
progname, Resp_STK_INSYNC, buf[0]);
|
||||
avrdude_message("\n%s: stk500_paged_write(): (a) protocol error, "
|
||||
"expect=0x%02x, resp=0x%02x\n",
|
||||
progname, Resp_STK_INSYNC, buf[0]);
|
||||
return -4;
|
||||
}
|
||||
|
||||
if (stk500_recv(pgm, buf, 1) < 0)
|
||||
return -1;
|
||||
if (buf[0] != Resp_STK_OK) {
|
||||
fprintf(stderr,
|
||||
"\n%s: stk500_paged_write(): (a) protocol error, "
|
||||
"expect=0x%02x, resp=0x%02x\n",
|
||||
progname, Resp_STK_INSYNC, buf[0]);
|
||||
avrdude_message("\n%s: stk500_paged_write(): (a) protocol error, "
|
||||
"expect=0x%02x, resp=0x%02x\n",
|
||||
progname, Resp_STK_INSYNC, buf[0]);
|
||||
return -5;
|
||||
}
|
||||
}
|
||||
|
@ -925,7 +905,7 @@ static int stk500_paged_load(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m,
|
|||
return -1;
|
||||
if (buf[0] == Resp_STK_NOSYNC) {
|
||||
if (tries > 33) {
|
||||
fprintf(stderr, "\n%s: stk500_paged_load(): can't get into sync\n",
|
||||
avrdude_message("\n%s: stk500_paged_load(): can't get into sync\n",
|
||||
progname);
|
||||
return -3;
|
||||
}
|
||||
|
@ -934,10 +914,9 @@ static int stk500_paged_load(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m,
|
|||
goto retry;
|
||||
}
|
||||
else if (buf[0] != Resp_STK_INSYNC) {
|
||||
fprintf(stderr,
|
||||
"\n%s: stk500_paged_load(): (a) protocol error, "
|
||||
"expect=0x%02x, resp=0x%02x\n",
|
||||
progname, Resp_STK_INSYNC, buf[0]);
|
||||
avrdude_message("\n%s: stk500_paged_load(): (a) protocol error, "
|
||||
"expect=0x%02x, resp=0x%02x\n",
|
||||
progname, Resp_STK_INSYNC, buf[0]);
|
||||
return -4;
|
||||
}
|
||||
|
||||
|
@ -949,19 +928,17 @@ 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) {
|
||||
fprintf(stderr,
|
||||
"\n%s: stk500_paged_load(): (a) protocol error, "
|
||||
"expect=0x%02x, resp=0x%02x\n",
|
||||
progname, Resp_STK_INSYNC, buf[0]);
|
||||
avrdude_message("\n%s: stk500_paged_load(): (a) protocol error, "
|
||||
"expect=0x%02x, resp=0x%02x\n",
|
||||
progname, Resp_STK_INSYNC, buf[0]);
|
||||
return -5;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (buf[0] != Resp_STK_OK) {
|
||||
fprintf(stderr,
|
||||
"\n%s: stk500_paged_load(): (a) protocol error, "
|
||||
"expect=0x%02x, resp=0x%02x\n",
|
||||
progname, Resp_STK_OK, buf[0]);
|
||||
avrdude_message("\n%s: stk500_paged_load(): (a) protocol error, "
|
||||
"expect=0x%02x, resp=0x%02x\n",
|
||||
progname, Resp_STK_OK, buf[0]);
|
||||
return -5;
|
||||
}
|
||||
}
|
||||
|
@ -978,16 +955,14 @@ static int stk500_set_vtarget(PROGRAMMER * pgm, double v)
|
|||
utarg = (unsigned)((v + 0.049) * 10);
|
||||
|
||||
if (stk500_getparm(pgm, Parm_STK_VADJUST, &uaref) != 0) {
|
||||
fprintf(stderr,
|
||||
"%s: stk500_set_vtarget(): cannot obtain V[aref]\n",
|
||||
progname);
|
||||
avrdude_message("%s: stk500_set_vtarget(): cannot obtain V[aref]\n",
|
||||
progname);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (uaref > utarg) {
|
||||
fprintf(stderr,
|
||||
"%s: stk500_set_vtarget(): reducing V[aref] from %.1f to %.1f\n",
|
||||
progname, uaref / 10.0, v);
|
||||
avrdude_message("%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)
|
||||
return -1;
|
||||
|
@ -1004,17 +979,15 @@ 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) {
|
||||
fprintf(stderr,
|
||||
"%s: stk500_set_varef(): cannot obtain V[target]\n",
|
||||
progname);
|
||||
avrdude_message("%s: stk500_set_varef(): cannot obtain V[target]\n",
|
||||
progname);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (uaref > utarg) {
|
||||
fprintf(stderr,
|
||||
"%s: stk500_set_varef(): V[aref] must not be greater than "
|
||||
"V[target] = %.1f\n",
|
||||
progname, utarg / 10.0);
|
||||
avrdude_message("%s: stk500_set_varef(): V[aref] must not be greater than "
|
||||
"V[target] = %.1f\n",
|
||||
progname, utarg / 10.0);
|
||||
return -1;
|
||||
}
|
||||
return stk500_setparm(pgm, Parm_STK_VADJUST, uaref);
|
||||
|
@ -1041,9 +1014,8 @@ static int stk500_set_fosc(PROGRAMMER * pgm, double v)
|
|||
unit = "kHz";
|
||||
} else
|
||||
unit = "Hz";
|
||||
fprintf(stderr,
|
||||
"%s: stk500_set_fosc(): f = %.3f %s too high, using %.3f MHz\n",
|
||||
progname, v, unit, STK500_XTAL / 2e6);
|
||||
avrdude_message("%s: stk500_set_fosc(): f = %.3f %s too high, using %.3f MHz\n",
|
||||
progname, v, unit, STK500_XTAL / 2e6);
|
||||
fosc = STK500_XTAL / 2;
|
||||
} else
|
||||
fosc = (unsigned)v;
|
||||
|
@ -1057,7 +1029,7 @@ static int stk500_set_fosc(PROGRAMMER * pgm, double v)
|
|||
}
|
||||
}
|
||||
if (idx == sizeof(ps) / sizeof(ps[0])) {
|
||||
fprintf(stderr, "%s: stk500_set_fosc(): f = %u Hz too low, %u Hz min\n",
|
||||
avrdude_message("%s: stk500_set_fosc(): f = %u Hz too low, %u Hz min\n",
|
||||
progname, fosc, STK500_XTAL / (256 * 1024 * 2));
|
||||
return -1;
|
||||
}
|
||||
|
@ -1089,14 +1061,12 @@ static int stk500_set_sck_period(PROGRAMMER * pgm, double v)
|
|||
|
||||
if (v < min) {
|
||||
dur = 1;
|
||||
fprintf(stderr,
|
||||
"%s: stk500_set_sck_period(): p = %.1f us too small, using %.1f us\n",
|
||||
progname, v / 1e-6, dur * min / 1e-6);
|
||||
avrdude_message("%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;
|
||||
fprintf(stderr,
|
||||
"%s: stk500_set_sck_period(): p = %.1f us too large, using %.1f us\n",
|
||||
progname, v / 1e-6, dur * min / 1e-6);
|
||||
avrdude_message("%s: stk500_set_sck_period(): p = %.1f us too large, using %.1f us\n",
|
||||
progname, v / 1e-6, dur * min / 1e-6);
|
||||
}
|
||||
|
||||
return stk500_setparm(pgm, Parm_STK_SCK_DURATION, dur);
|
||||
|
@ -1121,7 +1091,7 @@ static int stk500_getparm(PROGRAMMER * pgm, unsigned parm, unsigned * value)
|
|||
return -1;
|
||||
if (buf[0] == Resp_STK_NOSYNC) {
|
||||
if (tries > 33) {
|
||||
fprintf(stderr, "\n%s: stk500_getparm(): can't get into sync\n",
|
||||
avrdude_message("\n%s: stk500_getparm(): can't get into sync\n",
|
||||
progname);
|
||||
return -1;
|
||||
}
|
||||
|
@ -1130,10 +1100,9 @@ static int stk500_getparm(PROGRAMMER * pgm, unsigned parm, unsigned * value)
|
|||
goto retry;
|
||||
}
|
||||
else if (buf[0] != Resp_STK_INSYNC) {
|
||||
fprintf(stderr,
|
||||
"\n%s: stk500_getparm(): (a) protocol error, "
|
||||
"expect=0x%02x, resp=0x%02x\n",
|
||||
progname, Resp_STK_INSYNC, buf[0]);
|
||||
avrdude_message("\n%s: stk500_getparm(): (a) protocol error, "
|
||||
"expect=0x%02x, resp=0x%02x\n",
|
||||
progname, Resp_STK_INSYNC, buf[0]);
|
||||
return -2;
|
||||
}
|
||||
|
||||
|
@ -1144,16 +1113,14 @@ 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) {
|
||||
fprintf(stderr,
|
||||
"\n%s: stk500_getparm(): parameter 0x%02x failed\n",
|
||||
progname, v);
|
||||
avrdude_message("\n%s: stk500_getparm(): parameter 0x%02x failed\n",
|
||||
progname, v);
|
||||
return -3;
|
||||
}
|
||||
else if (buf[0] != Resp_STK_OK) {
|
||||
fprintf(stderr,
|
||||
"\n%s: stk500_getparm(): (a) protocol error, "
|
||||
"expect=0x%02x, resp=0x%02x\n",
|
||||
progname, Resp_STK_INSYNC, buf[0]);
|
||||
avrdude_message("\n%s: stk500_getparm(): (a) protocol error, "
|
||||
"expect=0x%02x, resp=0x%02x\n",
|
||||
progname, Resp_STK_INSYNC, buf[0]);
|
||||
return -3;
|
||||
}
|
||||
|
||||
|
@ -1181,7 +1148,7 @@ static int stk500_setparm(PROGRAMMER * pgm, unsigned parm, unsigned value)
|
|||
return -1;
|
||||
if (buf[0] == Resp_STK_NOSYNC) {
|
||||
if (tries > 33) {
|
||||
fprintf(stderr, "\n%s: stk500_setparm(): can't get into sync\n",
|
||||
avrdude_message("\n%s: stk500_setparm(): can't get into sync\n",
|
||||
progname);
|
||||
return -1;
|
||||
}
|
||||
|
@ -1190,10 +1157,9 @@ static int stk500_setparm(PROGRAMMER * pgm, unsigned parm, unsigned value)
|
|||
goto retry;
|
||||
}
|
||||
else if (buf[0] != Resp_STK_INSYNC) {
|
||||
fprintf(stderr,
|
||||
"\n%s: stk500_setparm(): (a) protocol error, "
|
||||
"expect=0x%02x, resp=0x%02x\n",
|
||||
progname, Resp_STK_INSYNC, buf[0]);
|
||||
avrdude_message("\n%s: stk500_setparm(): (a) protocol error, "
|
||||
"expect=0x%02x, resp=0x%02x\n",
|
||||
progname, Resp_STK_INSYNC, buf[0]);
|
||||
return -2;
|
||||
}
|
||||
|
||||
|
@ -1206,16 +1172,14 @@ 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) {
|
||||
fprintf(stderr,
|
||||
"\n%s: stk500_setparm(): parameter 0x%02x failed\n",
|
||||
progname, parm);
|
||||
avrdude_message("\n%s: stk500_setparm(): parameter 0x%02x failed\n",
|
||||
progname, parm);
|
||||
return -3;
|
||||
}
|
||||
else {
|
||||
fprintf(stderr,
|
||||
"\n%s: stk500_setparm(): (a) protocol error, "
|
||||
"expect=0x%02x, resp=0x%02x\n",
|
||||
progname, Resp_STK_INSYNC, buf[0]);
|
||||
avrdude_message("\n%s: stk500_setparm(): (a) protocol error, "
|
||||
"expect=0x%02x, resp=0x%02x\n",
|
||||
progname, Resp_STK_INSYNC, buf[0]);
|
||||
return -3;
|
||||
}
|
||||
}
|
||||
|
@ -1230,8 +1194,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);
|
||||
|
||||
fprintf(stderr, "%sHardware Version: %d\n", p, hdw);
|
||||
fprintf(stderr, "%sFirmware Version: %d.%d\n", p, maj, min);
|
||||
avrdude_message("%sHardware Version: %d\n", p, hdw);
|
||||
avrdude_message("%sFirmware Version: %d.%d\n", p, maj, min);
|
||||
if (topcard < 3) {
|
||||
const char *n = "Unknown";
|
||||
|
||||
|
@ -1244,7 +1208,7 @@ static void stk500_display(PROGRAMMER * pgm, const char * p)
|
|||
n = "STK501";
|
||||
break;
|
||||
}
|
||||
fprintf(stderr, "%sTopcard : %s\n", p, n);
|
||||
avrdude_message("%sTopcard : %s\n", p, n);
|
||||
}
|
||||
stk500_print_parms1(pgm, p);
|
||||
|
||||
|
@ -1262,11 +1226,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);
|
||||
|
||||
fprintf(stderr, "%sVtarget : %.1f V\n", p, vtarget / 10.0);
|
||||
fprintf(stderr, "%sVaref : %.1f V\n", p, vadjust / 10.0);
|
||||
fprintf(stderr, "%sOscillator : ", p);
|
||||
avrdude_message("%sVtarget : %.1f V\n", p, vtarget / 10.0);
|
||||
avrdude_message("%sVaref : %.1f V\n", p, vadjust / 10.0);
|
||||
avrdude_message("%sOscillator : ", p);
|
||||
if (osc_pscale == 0)
|
||||
fprintf(stderr, "Off\n");
|
||||
avrdude_message("Off\n");
|
||||
else {
|
||||
int prescale = 1;
|
||||
double f = STK500_XTAL / 2;
|
||||
|
@ -1290,9 +1254,9 @@ static void stk500_print_parms1(PROGRAMMER * pgm, const char * p)
|
|||
unit = "kHz";
|
||||
} else
|
||||
unit = "Hz";
|
||||
fprintf(stderr, "%.3f %s\n", f, unit);
|
||||
avrdude_message("%.3f %s\n", f, unit);
|
||||
}
|
||||
fprintf(stderr, "%sSCK period : %.1f us\n", p,
|
||||
avrdude_message("%sSCK period : %.1f us\n", p,
|
||||
sck_duration * 8.0e6 / STK500_XTAL + 0.05);
|
||||
|
||||
return;
|
||||
|
@ -1307,9 +1271,8 @@ static void stk500_print_parms(PROGRAMMER * pgm)
|
|||
static void stk500_setup(PROGRAMMER * pgm)
|
||||
{
|
||||
if ((pgm->cookie = malloc(sizeof(struct pdata))) == 0) {
|
||||
fprintf(stderr,
|
||||
"%s: stk500_setup(): Out of memory allocating private data\n",
|
||||
progname);
|
||||
avrdude_message("%s: stk500_setup(): Out of memory allocating private data\n",
|
||||
progname);
|
||||
return;
|
||||
}
|
||||
memset(pgm->cookie, 0, sizeof(struct pdata));
|
||||
|
|
|
@ -42,9 +42,8 @@ static int stk500generic_open(PROGRAMMER * pgm, char * port)
|
|||
stk500_initpgm(pgm);
|
||||
if (pgm->open(pgm, port) >= 0)
|
||||
{
|
||||
fprintf(stderr,
|
||||
"%s: successfully opened stk500v1 device -- please use -c stk500v1\n",
|
||||
progname);
|
||||
avrdude_message("%s: successfully opened stk500v1 device -- please use -c stk500v1\n",
|
||||
progname);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -53,15 +52,13 @@ static int stk500generic_open(PROGRAMMER * pgm, char * port)
|
|||
stk500v2_initpgm(pgm);
|
||||
if (pgm->open(pgm, port) >= 0)
|
||||
{
|
||||
fprintf(stderr,
|
||||
"%s: successfully opened stk500v2 device -- please use -c stk500v2\n",
|
||||
progname);
|
||||
avrdude_message("%s: successfully opened stk500v2 device -- please use -c stk500v2\n",
|
||||
progname);
|
||||
return 0;
|
||||
}
|
||||
|
||||
fprintf(stderr,
|
||||
"%s: cannot open either stk500v1 or stk500v2 programmer\n",
|
||||
progname);
|
||||
avrdude_message("%s: cannot open either stk500v1 or stk500v2 programmer\n",
|
||||
progname);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
|
629
stk500v2.c
629
stk500v2.c
File diff suppressed because it is too large
Load Diff
145
term.c
145
term.c
|
@ -248,7 +248,7 @@ static int cmd_dump(PROGRAMMER * pgm, struct avrpart * p,
|
|||
int rc;
|
||||
|
||||
if (!((argc == 2) || (argc == 4))) {
|
||||
fprintf(stderr, "Usage: dump <memtype> [<addr> <len>]\n");
|
||||
avrdude_message("Usage: dump <memtype> [<addr> <len>]\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -263,7 +263,7 @@ static int cmd_dump(PROGRAMMER * pgm, struct avrpart * p,
|
|||
|
||||
mem = avr_locate_mem(p, memtype);
|
||||
if (mem == NULL) {
|
||||
fprintf(stderr, "\"%s\" memory type not defined for part \"%s\"\n",
|
||||
avrdude_message("\"%s\" memory type not defined for part \"%s\"\n",
|
||||
memtype, p->desc);
|
||||
return -1;
|
||||
}
|
||||
|
@ -271,14 +271,14 @@ static int cmd_dump(PROGRAMMER * pgm, struct avrpart * p,
|
|||
if (argc == 4) {
|
||||
addr = strtoul(argv[2], &e, 0);
|
||||
if (*e || (e == argv[2])) {
|
||||
fprintf(stderr, "%s (dump): can't parse address \"%s\"\n",
|
||||
avrdude_message("%s (dump): can't parse address \"%s\"\n",
|
||||
progname, argv[2]);
|
||||
return -1;
|
||||
}
|
||||
|
||||
len = strtol(argv[3], &e, 0);
|
||||
if (*e || (e == argv[3])) {
|
||||
fprintf(stderr, "%s (dump): can't parse length \"%s\"\n",
|
||||
avrdude_message("%s (dump): can't parse length \"%s\"\n",
|
||||
progname, argv[3]);
|
||||
return -1;
|
||||
}
|
||||
|
@ -292,9 +292,8 @@ static int cmd_dump(PROGRAMMER * pgm, struct avrpart * p,
|
|||
addr = 0;
|
||||
}
|
||||
else {
|
||||
fprintf(stderr,
|
||||
"%s (dump): address 0x%05lx is out of range for %s memory\n",
|
||||
progname, addr, mem->desc);
|
||||
avrdude_message("%s (dump): address 0x%05lx is out of range for %s memory\n",
|
||||
progname, addr, mem->desc);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
@ -305,17 +304,17 @@ static int cmd_dump(PROGRAMMER * pgm, struct avrpart * p,
|
|||
|
||||
buf = malloc(len);
|
||||
if (buf == NULL) {
|
||||
fprintf(stderr, "%s (dump): out of memory\n", progname);
|
||||
avrdude_message("%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) {
|
||||
fprintf(stderr, "error reading %s address 0x%05lx of part %s\n",
|
||||
avrdude_message("error reading %s address 0x%05lx of part %s\n",
|
||||
mem->desc, addr+i, p->desc);
|
||||
if (rc == -1)
|
||||
fprintf(stderr, "read operation not supported on memory type \"%s\"\n",
|
||||
avrdude_message("read operation not supported on memory type \"%s\"\n",
|
||||
mem->desc);
|
||||
return -1;
|
||||
}
|
||||
|
@ -347,7 +346,7 @@ static int cmd_write(PROGRAMMER * pgm, struct avrpart * p,
|
|||
AVRMEM * mem;
|
||||
|
||||
if (argc < 4) {
|
||||
fprintf(stderr, "Usage: write <memtype> <addr> <byte1> "
|
||||
avrdude_message("Usage: write <memtype> <addr> <byte1> "
|
||||
"<byte2> ... byteN>\n");
|
||||
return -1;
|
||||
}
|
||||
|
@ -356,7 +355,7 @@ static int cmd_write(PROGRAMMER * pgm, struct avrpart * p,
|
|||
|
||||
mem = avr_locate_mem(p, memtype);
|
||||
if (mem == NULL) {
|
||||
fprintf(stderr, "\"%s\" memory type not defined for part \"%s\"\n",
|
||||
avrdude_message("\"%s\" memory type not defined for part \"%s\"\n",
|
||||
memtype, p->desc);
|
||||
return -1;
|
||||
}
|
||||
|
@ -365,15 +364,14 @@ static int cmd_write(PROGRAMMER * pgm, struct avrpart * p,
|
|||
|
||||
addr = strtoul(argv[2], &e, 0);
|
||||
if (*e || (e == argv[2])) {
|
||||
fprintf(stderr, "%s (write): can't parse address \"%s\"\n",
|
||||
avrdude_message("%s (write): can't parse address \"%s\"\n",
|
||||
progname, argv[2]);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (addr > maxsize) {
|
||||
fprintf(stderr,
|
||||
"%s (write): address 0x%05lx is out of range for %s memory\n",
|
||||
progname, addr, memtype);
|
||||
avrdude_message("%s (write): address 0x%05lx is out of range for %s memory\n",
|
||||
progname, addr, memtype);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -381,23 +379,22 @@ static int cmd_write(PROGRAMMER * pgm, struct avrpart * p,
|
|||
len = argc - 3;
|
||||
|
||||
if ((addr + len) > maxsize) {
|
||||
fprintf(stderr,
|
||||
"%s (write): selected address and # bytes exceed "
|
||||
"range for %s memory\n",
|
||||
progname, memtype);
|
||||
avrdude_message("%s (write): selected address and # bytes exceed "
|
||||
"range for %s memory\n",
|
||||
progname, memtype);
|
||||
return -1;
|
||||
}
|
||||
|
||||
buf = malloc(len);
|
||||
if (buf == NULL) {
|
||||
fprintf(stderr, "%s (write): out of memory\n", progname);
|
||||
avrdude_message("%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])) {
|
||||
fprintf(stderr, "%s (write): can't parse byte \"%s\"\n",
|
||||
avrdude_message("%s (write): can't parse byte \"%s\"\n",
|
||||
progname, argv[i]);
|
||||
free(buf);
|
||||
return -1;
|
||||
|
@ -409,20 +406,18 @@ static int cmd_write(PROGRAMMER * pgm, struct avrpart * p,
|
|||
|
||||
rc = avr_write_byte(pgm, p, mem, addr+i, buf[i]);
|
||||
if (rc) {
|
||||
fprintf(stderr, "%s (write): error writing 0x%02x at 0x%05lx, rc=%d\n",
|
||||
avrdude_message("%s (write): error writing 0x%02x at 0x%05lx, rc=%d\n",
|
||||
progname, buf[i], addr+i, rc);
|
||||
if (rc == -1)
|
||||
fprintf(stderr,
|
||||
"write operation not supported on memory type \"%s\"\n",
|
||||
mem->desc);
|
||||
avrdude_message("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]) {
|
||||
fprintf(stderr,
|
||||
"%s (write): error writing 0x%02x at 0x%05lx cell=0x%02x\n",
|
||||
progname, buf[i], addr+i, b);
|
||||
avrdude_message("%s (write): error writing 0x%02x at 0x%05lx cell=0x%02x\n",
|
||||
progname, buf[i], addr+i, b);
|
||||
werror = 1;
|
||||
}
|
||||
|
||||
|
@ -448,22 +443,20 @@ static int cmd_send(PROGRAMMER * pgm, struct avrpart * p,
|
|||
int len;
|
||||
|
||||
if (pgm->cmd == NULL) {
|
||||
fprintf(stderr,
|
||||
"The %s programmer does not support direct ISP commands.\n",
|
||||
pgm->type);
|
||||
avrdude_message("The %s programmer does not support direct ISP commands.\n",
|
||||
pgm->type);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (spi_mode && (pgm->spi == NULL)) {
|
||||
fprintf(stderr,
|
||||
"The %s programmer does not support direct SPI transfers.\n",
|
||||
pgm->type);
|
||||
avrdude_message("The %s programmer does not support direct SPI transfers.\n",
|
||||
pgm->type);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
if ((argc > 5) || ((argc < 5) && (!spi_mode))) {
|
||||
fprintf(stderr, spi_mode?
|
||||
avrdude_message(spi_mode?
|
||||
"Usage: send <byte1> [<byte2> [<byte3> [<byte4>]]]\n":
|
||||
"Usage: send <byte1> <byte2> <byte3> <byte4>\n");
|
||||
return -1;
|
||||
|
@ -476,7 +469,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])) {
|
||||
fprintf(stderr, "%s (send): can't parse byte \"%s\"\n",
|
||||
avrdude_message("%s (send): can't parse byte \"%s\"\n",
|
||||
progname, argv[i]);
|
||||
return -1;
|
||||
}
|
||||
|
@ -492,10 +485,10 @@ static int cmd_send(PROGRAMMER * pgm, struct avrpart * p,
|
|||
/*
|
||||
* display results
|
||||
*/
|
||||
fprintf(stderr, "results:");
|
||||
avrdude_message("results:");
|
||||
for (i=0; i<len; i++)
|
||||
fprintf(stderr, " %02x", res[i]);
|
||||
fprintf(stderr, "\n");
|
||||
avrdude_message(" %02x", res[i]);
|
||||
avrdude_message("\n");
|
||||
|
||||
fprintf(stdout, "\n");
|
||||
|
||||
|
@ -506,7 +499,7 @@ static int cmd_send(PROGRAMMER * pgm, struct avrpart * p,
|
|||
static int cmd_erase(PROGRAMMER * pgm, struct avrpart * p,
|
||||
int argc, char * argv[])
|
||||
{
|
||||
fprintf(stderr, "%s: erasing chip\n", progname);
|
||||
avrdude_message("%s: erasing chip\n", progname);
|
||||
pgm->chip_erase(pgm, p);
|
||||
return 0;
|
||||
}
|
||||
|
@ -532,15 +525,14 @@ static int cmd_sig(PROGRAMMER * pgm, struct avrpart * p,
|
|||
|
||||
rc = avr_signature(pgm, p);
|
||||
if (rc != 0) {
|
||||
fprintf(stderr, "error reading signature data, rc=%d\n",
|
||||
avrdude_message("error reading signature data, rc=%d\n",
|
||||
rc);
|
||||
}
|
||||
|
||||
m = avr_locate_mem(p, "signature");
|
||||
if (m == NULL) {
|
||||
fprintf(stderr,
|
||||
"signature data not defined for device \"%s\"\n",
|
||||
p->desc);
|
||||
avrdude_message("signature data not defined for device \"%s\"\n",
|
||||
p->desc);
|
||||
}
|
||||
else {
|
||||
fprintf(stdout, "Device signature = 0x");
|
||||
|
@ -564,10 +556,9 @@ static int cmd_parms(PROGRAMMER * pgm, struct avrpart * p,
|
|||
int argc, char * argv[])
|
||||
{
|
||||
if (pgm->print_parms == NULL) {
|
||||
fprintf(stderr,
|
||||
"%s (parms): the %s programmer does not support "
|
||||
"adjustable parameters\n",
|
||||
progname, pgm->type);
|
||||
avrdude_message("%s (parms): the %s programmer does not support "
|
||||
"adjustable parameters\n",
|
||||
progname, pgm->type);
|
||||
return -1;
|
||||
}
|
||||
pgm->print_parms(pgm);
|
||||
|
@ -584,22 +575,22 @@ static int cmd_vtarg(PROGRAMMER * pgm, struct avrpart * p,
|
|||
char *endp;
|
||||
|
||||
if (argc != 2) {
|
||||
fprintf(stderr, "Usage: vtarg <value>\n");
|
||||
avrdude_message("Usage: vtarg <value>\n");
|
||||
return -1;
|
||||
}
|
||||
v = strtod(argv[1], &endp);
|
||||
if (endp == argv[1]) {
|
||||
fprintf(stderr, "%s (vtarg): can't parse voltage \"%s\"\n",
|
||||
avrdude_message("%s (vtarg): can't parse voltage \"%s\"\n",
|
||||
progname, argv[1]);
|
||||
return -1;
|
||||
}
|
||||
if (pgm->set_vtarget == NULL) {
|
||||
fprintf(stderr, "%s (vtarg): the %s programmer cannot set V[target]\n",
|
||||
avrdude_message("%s (vtarg): the %s programmer cannot set V[target]\n",
|
||||
progname, pgm->type);
|
||||
return -2;
|
||||
}
|
||||
if ((rc = pgm->set_vtarget(pgm, v)) != 0) {
|
||||
fprintf(stderr, "%s (vtarg): failed to set V[target] (rc = %d)\n",
|
||||
avrdude_message("%s (vtarg): failed to set V[target] (rc = %d)\n",
|
||||
progname, rc);
|
||||
return -3;
|
||||
}
|
||||
|
@ -615,7 +606,7 @@ static int cmd_fosc(PROGRAMMER * pgm, struct avrpart * p,
|
|||
char *endp;
|
||||
|
||||
if (argc != 2) {
|
||||
fprintf(stderr, "Usage: fosc <value>[M|k] | off\n");
|
||||
avrdude_message("Usage: fosc <value>[M|k] | off\n");
|
||||
return -1;
|
||||
}
|
||||
v = strtod(argv[1], &endp);
|
||||
|
@ -623,7 +614,7 @@ static int cmd_fosc(PROGRAMMER * pgm, struct avrpart * p,
|
|||
if (strcmp(argv[1], "off") == 0)
|
||||
v = 0.0;
|
||||
else {
|
||||
fprintf(stderr, "%s (fosc): can't parse frequency \"%s\"\n",
|
||||
avrdude_message("%s (fosc): can't parse frequency \"%s\"\n",
|
||||
progname, argv[1]);
|
||||
return -1;
|
||||
}
|
||||
|
@ -633,13 +624,12 @@ static int cmd_fosc(PROGRAMMER * pgm, struct avrpart * p,
|
|||
else if (*endp == 'k' || *endp == 'K')
|
||||
v *= 1e3;
|
||||
if (pgm->set_fosc == NULL) {
|
||||
fprintf(stderr,
|
||||
"%s (fosc): the %s programmer cannot set oscillator frequency\n",
|
||||
progname, pgm->type);
|
||||
avrdude_message("%s (fosc): the %s programmer cannot set oscillator frequency\n",
|
||||
progname, pgm->type);
|
||||
return -2;
|
||||
}
|
||||
if ((rc = pgm->set_fosc(pgm, v)) != 0) {
|
||||
fprintf(stderr, "%s (fosc): failed to set oscillator_frequency (rc = %d)\n",
|
||||
avrdude_message("%s (fosc): failed to set oscillator_frequency (rc = %d)\n",
|
||||
progname, rc);
|
||||
return -3;
|
||||
}
|
||||
|
@ -655,24 +645,23 @@ static int cmd_sck(PROGRAMMER * pgm, struct avrpart * p,
|
|||
char *endp;
|
||||
|
||||
if (argc != 2) {
|
||||
fprintf(stderr, "Usage: sck <value>\n");
|
||||
avrdude_message("Usage: sck <value>\n");
|
||||
return -1;
|
||||
}
|
||||
v = strtod(argv[1], &endp);
|
||||
if (endp == argv[1]) {
|
||||
fprintf(stderr, "%s (sck): can't parse period \"%s\"\n",
|
||||
avrdude_message("%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) {
|
||||
fprintf(stderr,
|
||||
"%s (sck): the %s programmer cannot set SCK period\n",
|
||||
progname, pgm->type);
|
||||
avrdude_message("%s (sck): the %s programmer cannot set SCK period\n",
|
||||
progname, pgm->type);
|
||||
return -2;
|
||||
}
|
||||
if ((rc = pgm->set_sck_period(pgm, v)) != 0) {
|
||||
fprintf(stderr, "%s (sck): failed to set SCK period (rc = %d)\n",
|
||||
avrdude_message("%s (sck): failed to set SCK period (rc = %d)\n",
|
||||
progname, rc);
|
||||
return -3;
|
||||
}
|
||||
|
@ -689,38 +678,38 @@ static int cmd_varef(PROGRAMMER * pgm, struct avrpart * p,
|
|||
char *endp;
|
||||
|
||||
if (argc != 2 && argc != 3) {
|
||||
fprintf(stderr, "Usage: varef [channel] <value>\n");
|
||||
avrdude_message("Usage: varef [channel] <value>\n");
|
||||
return -1;
|
||||
}
|
||||
if (argc == 2) {
|
||||
chan = 0;
|
||||
v = strtod(argv[1], &endp);
|
||||
if (endp == argv[1]) {
|
||||
fprintf(stderr, "%s (varef): can't parse voltage \"%s\"\n",
|
||||
avrdude_message("%s (varef): can't parse voltage \"%s\"\n",
|
||||
progname, argv[1]);
|
||||
return -1;
|
||||
}
|
||||
} else {
|
||||
chan = strtoul(argv[1], &endp, 10);
|
||||
if (endp == argv[1]) {
|
||||
fprintf(stderr, "%s (varef): can't parse channel \"%s\"\n",
|
||||
avrdude_message("%s (varef): can't parse channel \"%s\"\n",
|
||||
progname, argv[1]);
|
||||
return -1;
|
||||
}
|
||||
v = strtod(argv[2], &endp);
|
||||
if (endp == argv[2]) {
|
||||
fprintf(stderr, "%s (varef): can't parse voltage \"%s\"\n",
|
||||
avrdude_message("%s (varef): can't parse voltage \"%s\"\n",
|
||||
progname, argv[2]);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
if (pgm->set_varef == NULL) {
|
||||
fprintf(stderr, "%s (varef): the %s programmer cannot set V[aref]\n",
|
||||
avrdude_message("%s (varef): the %s programmer cannot set V[aref]\n",
|
||||
progname, pgm->type);
|
||||
return -2;
|
||||
}
|
||||
if ((rc = pgm->set_varef(pgm, chan, v)) != 0) {
|
||||
fprintf(stderr, "%s (varef): failed to set V[aref] (rc = %d)\n",
|
||||
avrdude_message("%s (varef): failed to set V[aref] (rc = %d)\n",
|
||||
progname, rc);
|
||||
return -3;
|
||||
}
|
||||
|
@ -770,26 +759,26 @@ static int cmd_verbose(PROGRAMMER * pgm, struct avrpart * p,
|
|||
char *endp;
|
||||
|
||||
if (argc != 1 && argc != 2) {
|
||||
fprintf(stderr, "Usage: verbose [<value>]\n");
|
||||
avrdude_message("Usage: verbose [<value>]\n");
|
||||
return -1;
|
||||
}
|
||||
if (argc == 1) {
|
||||
fprintf(stderr, "Verbosity level: %d\n", verbose);
|
||||
avrdude_message("Verbosity level: %d\n", verbose);
|
||||
return 0;
|
||||
}
|
||||
nverb = strtol(argv[1], &endp, 0);
|
||||
if (endp == argv[2]) {
|
||||
fprintf(stderr, "%s: can't parse verbosity level \"%s\"\n",
|
||||
avrdude_message("%s: can't parse verbosity level \"%s\"\n",
|
||||
progname, argv[2]);
|
||||
return -1;
|
||||
}
|
||||
if (nverb < 0) {
|
||||
fprintf(stderr, "%s: verbosity level must be positive: %d\n",
|
||||
avrdude_message("%s: verbosity level must be positive: %d\n",
|
||||
progname, nverb);
|
||||
return -1;
|
||||
}
|
||||
verbose = nverb;
|
||||
fprintf(stderr, "New verbosity level: %d\n", verbose);
|
||||
avrdude_message("New verbosity level: %d\n", verbose);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -886,7 +875,7 @@ static int do_cmd(PROGRAMMER * pgm, struct avrpart * p,
|
|||
}
|
||||
else if (strncasecmp(argv[0], cmd[i].name, len)==0) {
|
||||
if (hold != -1) {
|
||||
fprintf(stderr, "%s: command \"%s\" is ambiguous\n",
|
||||
avrdude_message("%s: command \"%s\" is ambiguous\n",
|
||||
progname, argv[0]);
|
||||
return -1;
|
||||
}
|
||||
|
@ -897,7 +886,7 @@ static int do_cmd(PROGRAMMER * pgm, struct avrpart * p,
|
|||
if (hold != -1)
|
||||
return cmd[hold].func(pgm, p, argc, argv);
|
||||
|
||||
fprintf(stderr, "%s: invalid command \"%s\"\n",
|
||||
avrdude_message("%s: invalid command \"%s\"\n",
|
||||
progname, argv[0]);
|
||||
|
||||
return -1;
|
||||
|
|
77
update.c
77
update.c
|
@ -42,7 +42,7 @@ UPDATE * parse_op(char * s)
|
|||
|
||||
upd = (UPDATE *)malloc(sizeof(UPDATE));
|
||||
if (upd == NULL) {
|
||||
fprintf(stderr, "%s: out of memory\n", progname);
|
||||
avrdude_message("%s: out of memory\n", progname);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
@ -57,7 +57,7 @@ UPDATE * parse_op(char * s)
|
|||
upd->op = DEVICE_WRITE;
|
||||
upd->filename = (char *)malloc(strlen(buf) + 1);
|
||||
if (upd->filename == NULL) {
|
||||
fprintf(stderr, "%s: out of memory\n", progname);
|
||||
avrdude_message("%s: out of memory\n", progname);
|
||||
exit(1);
|
||||
}
|
||||
strcpy(upd->filename, buf);
|
||||
|
@ -67,7 +67,7 @@ UPDATE * parse_op(char * s)
|
|||
|
||||
upd->memtype = (char *)malloc(strlen(buf)+1);
|
||||
if (upd->memtype == NULL) {
|
||||
fprintf(stderr, "%s: out of memory\n", progname);
|
||||
avrdude_message("%s: out of memory\n", progname);
|
||||
exit(1);
|
||||
}
|
||||
strcpy(upd->memtype, buf);
|
||||
|
@ -83,13 +83,12 @@ UPDATE * parse_op(char * s)
|
|||
upd->op = DEVICE_VERIFY;
|
||||
}
|
||||
else {
|
||||
fprintf(stderr, "%s: invalid I/O mode '%c' in update specification\n",
|
||||
avrdude_message("%s: invalid I/O mode '%c' in update specification\n",
|
||||
progname, *p);
|
||||
fprintf(stderr,
|
||||
" allowed values are:\n"
|
||||
" r = read device\n"
|
||||
" w = write device\n"
|
||||
" v = verify device\n");
|
||||
avrdude_message(" allowed values are:\n"
|
||||
" r = read device\n"
|
||||
" w = write device\n"
|
||||
" v = verify device\n");
|
||||
free(upd->memtype);
|
||||
free(upd);
|
||||
return NULL;
|
||||
|
@ -98,7 +97,7 @@ UPDATE * parse_op(char * s)
|
|||
p++;
|
||||
|
||||
if (*p != ':') {
|
||||
fprintf(stderr, "%s: invalid update specification\n", progname);
|
||||
avrdude_message("%s: invalid update specification\n", progname);
|
||||
free(upd->memtype);
|
||||
free(upd);
|
||||
return NULL;
|
||||
|
@ -140,7 +139,7 @@ UPDATE * parse_op(char * s)
|
|||
case 'h': upd->format = FMT_HEX; break;
|
||||
case 'o': upd->format = FMT_OCT; break;
|
||||
default:
|
||||
fprintf(stderr, "%s: invalid file format '%s' in update specifier\n",
|
||||
avrdude_message("%s: invalid file format '%s' in update specifier\n",
|
||||
progname, p);
|
||||
free(upd->memtype);
|
||||
free(upd);
|
||||
|
@ -149,7 +148,7 @@ UPDATE * parse_op(char * s)
|
|||
}
|
||||
|
||||
if (upd->filename == NULL) {
|
||||
fprintf(stderr, "%s: out of memory\n", progname);
|
||||
avrdude_message("%s: out of memory\n", progname);
|
||||
free(upd->memtype);
|
||||
free(upd);
|
||||
return NULL;
|
||||
|
@ -166,7 +165,7 @@ UPDATE * dup_update(UPDATE * upd)
|
|||
|
||||
u = (UPDATE *)malloc(sizeof(UPDATE));
|
||||
if (u == NULL) {
|
||||
fprintf(stderr, "%s: out of memory\n", progname);
|
||||
avrdude_message("%s: out of memory\n", progname);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
@ -187,7 +186,7 @@ UPDATE * new_update(int op, char * memtype, int filefmt, char * filename)
|
|||
|
||||
u = (UPDATE *)malloc(sizeof(UPDATE));
|
||||
if (u == NULL) {
|
||||
fprintf(stderr, "%s: out of memory\n", progname);
|
||||
avrdude_message("%s: out of memory\n", progname);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
@ -224,7 +223,7 @@ int do_op(PROGRAMMER * pgm, struct avrpart * p, UPDATE * upd, enum updateflags f
|
|||
|
||||
mem = avr_locate_mem(p, upd->memtype);
|
||||
if (mem == NULL) {
|
||||
fprintf(stderr, "\"%s\" memory type not defined for part \"%s\"\n",
|
||||
avrdude_message("\"%s\" memory type not defined for part \"%s\"\n",
|
||||
upd->memtype, p->desc);
|
||||
return -1;
|
||||
}
|
||||
|
@ -234,13 +233,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) {
|
||||
fprintf(stderr, "%s: reading %s memory:\n",
|
||||
avrdude_message("%s: reading %s memory:\n",
|
||||
progname, mem->desc);
|
||||
}
|
||||
report_progress(0,1,"Reading");
|
||||
rc = avr_read(pgm, p, upd->memtype, 0);
|
||||
if (rc < 0) {
|
||||
fprintf(stderr, "%s: failed to read all of %s memory, rc=%d\n",
|
||||
avrdude_message("%s: failed to read all of %s memory, rc=%d\n",
|
||||
progname, mem->desc, rc);
|
||||
return -1;
|
||||
}
|
||||
|
@ -248,14 +247,13 @@ int do_op(PROGRAMMER * pgm, struct avrpart * p, UPDATE * upd, enum updateflags f
|
|||
size = rc;
|
||||
|
||||
if (quell_progress < 2) {
|
||||
fprintf(stderr,
|
||||
"%s: writing output file \"%s\"\n",
|
||||
progname,
|
||||
strcmp(upd->filename, "-")==0 ? "<stdout>" : upd->filename);
|
||||
avrdude_message("%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) {
|
||||
fprintf(stderr, "%s: write to file '%s' failed\n",
|
||||
avrdude_message("%s: write to file '%s' failed\n",
|
||||
progname, upd->filename);
|
||||
return -1;
|
||||
}
|
||||
|
@ -266,14 +264,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) {
|
||||
fprintf(stderr,
|
||||
"%s: reading input file \"%s\"\n",
|
||||
progname,
|
||||
strcmp(upd->filename, "-")==0 ? "<stdin>" : upd->filename);
|
||||
avrdude_message("%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) {
|
||||
fprintf(stderr, "%s: read from file '%s' failed\n",
|
||||
avrdude_message("%s: read from file '%s' failed\n",
|
||||
progname, upd->filename);
|
||||
return -1;
|
||||
}
|
||||
|
@ -283,7 +280,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) {
|
||||
fprintf(stderr, "%s: writing %s (%d bytes):\n",
|
||||
avrdude_message("%s: writing %s (%d bytes):\n",
|
||||
progname, mem->desc, size);
|
||||
}
|
||||
|
||||
|
@ -301,7 +298,7 @@ int do_op(PROGRAMMER * pgm, struct avrpart * p, UPDATE * upd, enum updateflags f
|
|||
}
|
||||
|
||||
if (rc < 0) {
|
||||
fprintf(stderr, "%s: failed to write %s memory, rc=%d\n",
|
||||
avrdude_message("%s: failed to write %s memory, rc=%d\n",
|
||||
progname, mem->desc, rc);
|
||||
return -1;
|
||||
}
|
||||
|
@ -309,7 +306,7 @@ int do_op(PROGRAMMER * pgm, struct avrpart * p, UPDATE * upd, enum updateflags f
|
|||
vsize = rc;
|
||||
|
||||
if (quell_progress < 2) {
|
||||
fprintf(stderr, "%s: %d bytes of %s written\n", progname,
|
||||
avrdude_message("%s: %d bytes of %s written\n", progname,
|
||||
vsize, mem->desc);
|
||||
}
|
||||
|
||||
|
@ -322,32 +319,32 @@ int do_op(PROGRAMMER * pgm, struct avrpart * p, UPDATE * upd, enum updateflags f
|
|||
pgm->vfy_led(pgm, ON);
|
||||
|
||||
if (quell_progress < 2) {
|
||||
fprintf(stderr, "%s: verifying %s memory against %s:\n",
|
||||
avrdude_message("%s: verifying %s memory against %s:\n",
|
||||
progname, mem->desc, upd->filename);
|
||||
|
||||
fprintf(stderr, "%s: load data %s data from input file %s:\n",
|
||||
avrdude_message("%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) {
|
||||
fprintf(stderr, "%s: read from file '%s' failed\n",
|
||||
avrdude_message("%s: read from file '%s' failed\n",
|
||||
progname, upd->filename);
|
||||
return -1;
|
||||
}
|
||||
v = avr_dup_part(p);
|
||||
size = rc;
|
||||
if (quell_progress < 2) {
|
||||
fprintf(stderr, "%s: input file %s contains %d bytes\n",
|
||||
avrdude_message("%s: input file %s contains %d bytes\n",
|
||||
progname, upd->filename, size);
|
||||
fprintf(stderr, "%s: reading on-chip %s data:\n",
|
||||
avrdude_message("%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) {
|
||||
fprintf(stderr, "%s: failed to read all of %s memory, rc=%d\n",
|
||||
avrdude_message("%s: failed to read all of %s memory, rc=%d\n",
|
||||
progname, mem->desc, rc);
|
||||
pgm->err_led(pgm, ON);
|
||||
return -1;
|
||||
|
@ -357,25 +354,25 @@ int do_op(PROGRAMMER * pgm, struct avrpart * p, UPDATE * upd, enum updateflags f
|
|||
|
||||
|
||||
if (quell_progress < 2) {
|
||||
fprintf(stderr, "%s: verifying ...\n", progname);
|
||||
avrdude_message("%s: verifying ...\n", progname);
|
||||
}
|
||||
rc = avr_verify(p, v, upd->memtype, size);
|
||||
if (rc < 0) {
|
||||
fprintf(stderr, "%s: verification error; content mismatch\n",
|
||||
avrdude_message("%s: verification error; content mismatch\n",
|
||||
progname);
|
||||
pgm->err_led(pgm, ON);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (quell_progress < 2) {
|
||||
fprintf(stderr, "%s: %d bytes of %s verified\n",
|
||||
avrdude_message("%s: %d bytes of %s verified\n",
|
||||
progname, rc, mem->desc);
|
||||
}
|
||||
|
||||
pgm->vfy_led(pgm, OFF);
|
||||
}
|
||||
else {
|
||||
fprintf(stderr, "%s: invalid update operation (%d) requested\n",
|
||||
avrdude_message("%s: invalid update operation (%d) requested\n",
|
||||
progname, upd->op);
|
||||
return -1;
|
||||
}
|
||||
|
|
117
usb_libusb.c
117
usb_libusb.c
|
@ -97,9 +97,8 @@ static int usbdev_open(char * port, union pinfo pinfo, union filedescriptor *fd)
|
|||
|
||||
if (strlen(serno) > 12)
|
||||
{
|
||||
fprintf(stderr,
|
||||
"%s: usbdev_open(): invalid serial number \"%s\"\n",
|
||||
progname, serno);
|
||||
avrdude_message("%s: usbdev_open(): invalid serial number \"%s\"\n",
|
||||
progname, serno);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
@ -127,9 +126,8 @@ static int usbdev_open(char * port, union pinfo pinfo, union filedescriptor *fd)
|
|||
dev->descriptor.iSerialNumber,
|
||||
string, sizeof(string)) < 0)
|
||||
{
|
||||
fprintf(stderr,
|
||||
"%s: usb_open(): cannot read serial number \"%s\"\n",
|
||||
progname, usb_strerror());
|
||||
avrdude_message("%s: usb_open(): cannot read serial number \"%s\"\n",
|
||||
progname, usb_strerror());
|
||||
/*
|
||||
* On some systems, libusb appears to have
|
||||
* problems sending control messages. Catch the
|
||||
|
@ -147,9 +145,8 @@ static int usbdev_open(char * port, union pinfo pinfo, union filedescriptor *fd)
|
|||
dev->descriptor.iProduct,
|
||||
product, sizeof(product)) < 0)
|
||||
{
|
||||
fprintf(stderr,
|
||||
"%s: usb_open(): cannot read product name \"%s\"\n",
|
||||
progname, usb_strerror());
|
||||
avrdude_message("%s: usb_open(): cannot read product name \"%s\"\n",
|
||||
progname, usb_strerror());
|
||||
strcpy(product, "[unnamed product]");
|
||||
}
|
||||
/*
|
||||
|
@ -169,9 +166,8 @@ static int usbdev_open(char * port, union pinfo pinfo, union filedescriptor *fd)
|
|||
}
|
||||
|
||||
if (verbose)
|
||||
fprintf(stderr,
|
||||
"%s: usbdev_open(): Found %s, serno: %s\n",
|
||||
progname, product, string);
|
||||
avrdude_message("%s: usbdev_open(): Found %s, serno: %s\n",
|
||||
progname, product, string);
|
||||
if (serno != NULL)
|
||||
{
|
||||
/*
|
||||
|
@ -183,9 +179,8 @@ static int usbdev_open(char * port, union pinfo pinfo, union filedescriptor *fd)
|
|||
if (strcasecmp(string + x, serno) != 0)
|
||||
{
|
||||
if (verbose > 2)
|
||||
fprintf(stderr,
|
||||
"%s: usbdev_open(): serial number doesn't match\n",
|
||||
progname);
|
||||
avrdude_message("%s: usbdev_open(): serial number doesn't match\n",
|
||||
progname);
|
||||
usb_close(udev);
|
||||
continue;
|
||||
}
|
||||
|
@ -193,18 +188,16 @@ static int usbdev_open(char * port, union pinfo pinfo, union filedescriptor *fd)
|
|||
|
||||
if (dev->config == NULL)
|
||||
{
|
||||
fprintf(stderr,
|
||||
"%s: usbdev_open(): USB device has no configuration\n",
|
||||
progname);
|
||||
avrdude_message("%s: usbdev_open(): USB device has no configuration\n",
|
||||
progname);
|
||||
goto trynext;
|
||||
}
|
||||
|
||||
if (usb_set_configuration(udev, dev->config[0].bConfigurationValue))
|
||||
{
|
||||
fprintf(stderr,
|
||||
"%s: usbdev_open(): WARNING: failed to set configuration %d: %s\n",
|
||||
progname, dev->config[0].bConfigurationValue,
|
||||
usb_strerror());
|
||||
avrdude_message("%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 */
|
||||
// goto trynext;
|
||||
}
|
||||
|
@ -223,9 +216,8 @@ static int usbdev_open(char * port, union pinfo pinfo, union filedescriptor *fd)
|
|||
#endif
|
||||
if (usb_claim_interface(udev, usb_interface))
|
||||
{
|
||||
fprintf(stderr,
|
||||
"%s: usbdev_open(): error claiming interface %d: %s\n",
|
||||
progname, usb_interface, usb_strerror());
|
||||
avrdude_message("%s: usbdev_open(): error claiming interface %d: %s\n",
|
||||
progname, usb_interface, usb_strerror());
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -242,9 +234,8 @@ static int usbdev_open(char * port, union pinfo pinfo, union filedescriptor *fd)
|
|||
}
|
||||
if (iface == dev->config[0].bNumInterfaces)
|
||||
{
|
||||
fprintf(stderr,
|
||||
"%s: usbdev_open(): no usable interface found\n",
|
||||
progname);
|
||||
avrdude_message("%s: usbdev_open(): no usable interface found\n",
|
||||
progname);
|
||||
goto trynext;
|
||||
}
|
||||
|
||||
|
@ -261,9 +252,8 @@ static int usbdev_open(char * port, union pinfo pinfo, union filedescriptor *fd)
|
|||
{
|
||||
if (verbose > 1)
|
||||
{
|
||||
fprintf(stderr,
|
||||
"%s: usbdev_open(): using read endpoint 0x%02x\n",
|
||||
progname, possible_ep);
|
||||
avrdude_message("%s: usbdev_open(): using read endpoint 0x%02x\n",
|
||||
progname, possible_ep);
|
||||
}
|
||||
fd->usb.rep = possible_ep;
|
||||
break;
|
||||
|
@ -271,9 +261,8 @@ static int usbdev_open(char * port, union pinfo pinfo, union filedescriptor *fd)
|
|||
}
|
||||
if (fd->usb.rep == 0)
|
||||
{
|
||||
fprintf(stderr,
|
||||
"%s: usbdev_open(): cannot find a read endpoint, using 0x%02x\n",
|
||||
progname, USBDEV_BULK_EP_READ_MKII);
|
||||
avrdude_message("%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;
|
||||
}
|
||||
}
|
||||
|
@ -284,34 +273,32 @@ static int usbdev_open(char * port, union pinfo pinfo, union filedescriptor *fd)
|
|||
dev->config[0].interface[iface].altsetting[0].endpoint[i].wMaxPacketSize < fd->usb.max_xfer)
|
||||
{
|
||||
if (verbose != 0)
|
||||
fprintf(stderr,
|
||||
"%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,
|
||||
dev->config[0].interface[iface].altsetting[0].endpoint[i].bEndpointAddress);
|
||||
avrdude_message("%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,
|
||||
dev->config[0].interface[iface].altsetting[0].endpoint[i].bEndpointAddress);
|
||||
fd->usb.max_xfer = dev->config[0].interface[iface].altsetting[0].endpoint[i].wMaxPacketSize;
|
||||
}
|
||||
}
|
||||
if (pinfo.usbinfo.flags & PINFO_FL_USEHID)
|
||||
{
|
||||
if (usb_control_msg(udev, 0x21, 0x0a /* SET_IDLE */, 0, 0, NULL, 0, 100) < 0)
|
||||
fprintf(stderr, "%s: usbdev_open(): SET_IDLE failed\n", progname);
|
||||
avrdude_message("%s: usbdev_open(): SET_IDLE failed\n", progname);
|
||||
}
|
||||
return 0;
|
||||
trynext:
|
||||
usb_close(udev);
|
||||
}
|
||||
else
|
||||
fprintf(stderr,
|
||||
"%s: usbdev_open(): cannot open device: %s\n",
|
||||
progname, usb_strerror());
|
||||
avrdude_message("%s: usbdev_open(): cannot open device: %s\n",
|
||||
progname, usb_strerror());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ((pinfo.usbinfo.flags & PINFO_FL_SILENT) == 0 || verbose > 0)
|
||||
fprintf(stderr, "%s: usbdev_open(): did not find any%s USB device \"%s\" (0x%04x:0x%04x)\n",
|
||||
avrdude_message("%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;
|
||||
|
@ -365,7 +352,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)
|
||||
{
|
||||
fprintf(stderr, "%s: usbdev_send(): wrote %d out of %d bytes, err = %s\n",
|
||||
avrdude_message("%s: usbdev_send(): wrote %d out of %d bytes, err = %s\n",
|
||||
progname, rv, tx_size, usb_strerror());
|
||||
return -1;
|
||||
}
|
||||
|
@ -375,22 +362,22 @@ static int usbdev_send(union filedescriptor *fd, unsigned char *bp, size_t mlen)
|
|||
|
||||
if (verbose > 3)
|
||||
{
|
||||
fprintf(stderr, "%s: Sent: ", progname);
|
||||
avrdude_message("%s: Sent: ", progname);
|
||||
|
||||
while (i) {
|
||||
unsigned char c = *p;
|
||||
if (isprint(c)) {
|
||||
fprintf(stderr, "%c ", c);
|
||||
avrdude_message("%c ", c);
|
||||
}
|
||||
else {
|
||||
fprintf(stderr, ". ");
|
||||
avrdude_message(". ");
|
||||
}
|
||||
fprintf(stderr, "[%02x] ", c);
|
||||
avrdude_message("[%02x] ", c);
|
||||
|
||||
p++;
|
||||
i--;
|
||||
}
|
||||
fprintf(stderr, "\n");
|
||||
avrdude_message("\n");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -415,7 +402,7 @@ usb_fill_buf(usb_dev_handle *udev, int maxsize, int ep, int use_interrupt_xfer)
|
|||
if (rv < 0)
|
||||
{
|
||||
if (verbose > 1)
|
||||
fprintf(stderr, "%s: usb_fill_buf(): usb_%s_read() error %s\n",
|
||||
avrdude_message("%s: usb_fill_buf(): usb_%s_read() error %s\n",
|
||||
progname, (use_interrupt_xfer? "interrupt": "bulk"),
|
||||
usb_strerror());
|
||||
return -1;
|
||||
|
@ -452,22 +439,22 @@ static int usbdev_recv(union filedescriptor *fd, unsigned char *buf, size_t nbyt
|
|||
|
||||
if (verbose > 4)
|
||||
{
|
||||
fprintf(stderr, "%s: Recv: ", progname);
|
||||
avrdude_message("%s: Recv: ", progname);
|
||||
|
||||
while (i) {
|
||||
unsigned char c = *p;
|
||||
if (isprint(c)) {
|
||||
fprintf(stderr, "%c ", c);
|
||||
avrdude_message("%c ", c);
|
||||
}
|
||||
else {
|
||||
fprintf(stderr, ". ");
|
||||
avrdude_message(". ");
|
||||
}
|
||||
fprintf(stderr, "[%02x] ", c);
|
||||
avrdude_message("[%02x] ", c);
|
||||
|
||||
p++;
|
||||
i--;
|
||||
}
|
||||
fprintf(stderr, "\n");
|
||||
avrdude_message("\n");
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -506,7 +493,7 @@ static int usbdev_recv_frame(union filedescriptor *fd, unsigned char *buf, size_
|
|||
}
|
||||
else if (rv > 0)
|
||||
{
|
||||
fprintf(stderr, "Short event len = %d, ignored.\n", rv);
|
||||
avrdude_message("Short event len = %d, ignored.\n", rv);
|
||||
/* fallthrough */
|
||||
}
|
||||
}
|
||||
|
@ -523,7 +510,7 @@ static int usbdev_recv_frame(union filedescriptor *fd, unsigned char *buf, size_
|
|||
if (rv < 0)
|
||||
{
|
||||
if (verbose > 1)
|
||||
fprintf(stderr, "%s: usbdev_recv_frame(): usb_%s_read(): %s\n",
|
||||
avrdude_message("%s: usbdev_recv_frame(): usb_%s_read(): %s\n",
|
||||
progname, (fd->usb.use_interrupt_xfer? "interrupt": "bulk"),
|
||||
usb_strerror());
|
||||
return -1;
|
||||
|
@ -547,22 +534,22 @@ static int usbdev_recv_frame(union filedescriptor *fd, unsigned char *buf, size_
|
|||
if (verbose > 3)
|
||||
{
|
||||
i = n & USB_RECV_LENGTH_MASK;
|
||||
fprintf(stderr, "%s: Recv: ", progname);
|
||||
avrdude_message("%s: Recv: ", progname);
|
||||
|
||||
while (i) {
|
||||
unsigned char c = *p;
|
||||
if (isprint(c)) {
|
||||
fprintf(stderr, "%c ", c);
|
||||
avrdude_message("%c ", c);
|
||||
}
|
||||
else {
|
||||
fprintf(stderr, ". ");
|
||||
avrdude_message(". ");
|
||||
}
|
||||
fprintf(stderr, "[%02x] ", c);
|
||||
avrdude_message("[%02x] ", c);
|
||||
|
||||
p++;
|
||||
i--;
|
||||
}
|
||||
fprintf(stderr, "\n");
|
||||
avrdude_message("\n");
|
||||
}
|
||||
return n;
|
||||
}
|
||||
|
@ -581,7 +568,7 @@ static int usbdev_drain(union filedescriptor *fd, int display)
|
|||
else
|
||||
rv = usb_bulk_read(udev, fd->usb.rep, usbbuf, fd->usb.max_xfer, 100);
|
||||
if (rv > 0 && verbose >= 4)
|
||||
fprintf(stderr, "%s: usbdev_drain(): flushed %d characters\n",
|
||||
avrdude_message("%s: usbdev_drain(): flushed %d characters\n",
|
||||
progname, rv);
|
||||
} while (rv > 0);
|
||||
|
||||
|
|
192
usbasp.c
192
usbasp.c
|
@ -180,9 +180,8 @@ 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) {
|
||||
fprintf(stderr,
|
||||
"%s: usbasp_setup(): Out of memory allocating private data\n",
|
||||
progname);
|
||||
avrdude_message("%s: usbasp_setup(): Out of memory allocating private data\n",
|
||||
progname);
|
||||
exit(1);
|
||||
}
|
||||
memset(pgm->cookie, 0, sizeof(struct pdata));
|
||||
|
@ -230,16 +229,15 @@ static int usbasp_transmit(PROGRAMMER * pgm,
|
|||
int nbytes;
|
||||
|
||||
if (verbose > 3) {
|
||||
fprintf(stderr,
|
||||
"%s: usbasp_transmit(\"%s\", 0x%02x, 0x%02x, 0x%02x, 0x%02x)\n",
|
||||
progname,
|
||||
usbasp_get_funcname(functionid), send[0], send[1], send[2], send[3]);
|
||||
avrdude_message("%s: usbasp_transmit(\"%s\", 0x%02x, 0x%02x, 0x%02x, 0x%02x)\n",
|
||||
progname,
|
||||
usbasp_get_funcname(functionid), send[0], send[1], send[2], send[3]);
|
||||
if (!receive && buffersize > 0) {
|
||||
int i;
|
||||
fprintf(stderr, "%s => ", progbuf);
|
||||
avrdude_message("%s => ", progbuf);
|
||||
for (i = 0; i < buffersize; i++)
|
||||
fprintf(stderr, "[%02x] ", buffer[i]);
|
||||
fprintf(stderr, "\n");
|
||||
avrdude_message("[%02x] ", buffer[i]);
|
||||
avrdude_message("\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -253,7 +251,7 @@ static int usbasp_transmit(PROGRAMMER * pgm,
|
|||
buffersize & 0xffff,
|
||||
5000);
|
||||
if(nbytes < 0){
|
||||
fprintf(stderr, "%s: error: usbasp_transmit: %s\n", progname, strerror(libusb_to_errno(nbytes)));
|
||||
avrdude_message("%s: error: usbasp_transmit: %s\n", progname, strerror(libusb_to_errno(nbytes)));
|
||||
return -1;
|
||||
}
|
||||
#else
|
||||
|
@ -265,17 +263,17 @@ static int usbasp_transmit(PROGRAMMER * pgm,
|
|||
(char *)buffer, buffersize,
|
||||
5000);
|
||||
if(nbytes < 0){
|
||||
fprintf(stderr, "%s: error: usbasp_transmit: %s\n", progname, usb_strerror());
|
||||
avrdude_message("%s: error: usbasp_transmit: %s\n", progname, usb_strerror());
|
||||
return -1;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (verbose > 3 && receive && nbytes > 0) {
|
||||
int i;
|
||||
fprintf(stderr, "%s<= ", progbuf);
|
||||
avrdude_message("%s<= ", progbuf);
|
||||
for (i = 0; i < nbytes; i++)
|
||||
fprintf(stderr, "[%02x] ", buffer[i]);
|
||||
fprintf(stderr, "\n");
|
||||
avrdude_message("[%02x] ", buffer[i]);
|
||||
avrdude_message("\n");
|
||||
}
|
||||
|
||||
return nbytes;
|
||||
|
@ -316,9 +314,8 @@ static int usbOpenDevice(libusb_device_handle **device, int vendor,
|
|||
r = libusb_open(dev, &handle);
|
||||
if (!handle) {
|
||||
errorCode = USB_ERROR_ACCESS;
|
||||
fprintf(stderr,
|
||||
"%s: Warning: cannot open USB device: %s\n",
|
||||
progname, strerror(libusb_to_errno(r)));
|
||||
avrdude_message("%s: Warning: cannot open USB device: %s\n",
|
||||
progname, strerror(libusb_to_errno(r)));
|
||||
continue;
|
||||
}
|
||||
errorCode = 0;
|
||||
|
@ -328,15 +325,13 @@ static int usbOpenDevice(libusb_device_handle **device, int vendor,
|
|||
if (r < 0) {
|
||||
if ((vendorName != NULL) && (vendorName[0] != 0)) {
|
||||
errorCode = USB_ERROR_IO;
|
||||
fprintf(stderr,
|
||||
"%s: Warning: cannot query manufacturer for device: %s\n",
|
||||
progname, strerror(libusb_to_errno(r)));
|
||||
avrdude_message("%s: Warning: cannot query manufacturer for device: %s\n",
|
||||
progname, strerror(libusb_to_errno(r)));
|
||||
}
|
||||
} else {
|
||||
if (verbose > 1)
|
||||
fprintf(stderr,
|
||||
"%s: seen device from vendor ->%s<-\n",
|
||||
progname, string);
|
||||
avrdude_message("%s: seen device from vendor ->%s<-\n",
|
||||
progname, string);
|
||||
if ((vendorName != NULL) && (vendorName[0] != 0) && (strcmp(string, vendorName) != 0))
|
||||
errorCode = USB_ERROR_NOTFOUND;
|
||||
}
|
||||
|
@ -345,15 +340,13 @@ static int usbOpenDevice(libusb_device_handle **device, int vendor,
|
|||
if (r < 0) {
|
||||
if ((productName != NULL) && (productName[0] != 0)) {
|
||||
errorCode = USB_ERROR_IO;
|
||||
fprintf(stderr,
|
||||
"%s: Warning: cannot query product for device: %s\n",
|
||||
progname, strerror(libusb_to_errno(r)));
|
||||
avrdude_message("%s: Warning: cannot query product for device: %s\n",
|
||||
progname, strerror(libusb_to_errno(r)));
|
||||
}
|
||||
} else {
|
||||
if (verbose > 1)
|
||||
fprintf(stderr,
|
||||
"%s: seen product ->%s<-\n",
|
||||
progname, string);
|
||||
avrdude_message("%s: seen product ->%s<-\n",
|
||||
progname, string);
|
||||
if((productName != NULL) && (productName[0] != 0) && (strcmp(string, productName) != 0))
|
||||
errorCode = USB_ERROR_NOTFOUND;
|
||||
}
|
||||
|
@ -396,9 +389,8 @@ static int didUsbInit = 0;
|
|||
handle = usb_open(dev);
|
||||
if(!handle){
|
||||
errorCode = USB_ERROR_ACCESS;
|
||||
fprintf(stderr,
|
||||
"%s: Warning: cannot open USB device: %s\n",
|
||||
progname, usb_strerror());
|
||||
avrdude_message("%s: Warning: cannot open USB device: %s\n",
|
||||
progname, usb_strerror());
|
||||
continue;
|
||||
}
|
||||
errorCode = 0;
|
||||
|
@ -409,15 +401,13 @@ static int didUsbInit = 0;
|
|||
if(len < 0){
|
||||
if ((vendorName != NULL) && (vendorName[0] != 0)) {
|
||||
errorCode = USB_ERROR_IO;
|
||||
fprintf(stderr,
|
||||
"%s: Warning: cannot query manufacturer for device: %s\n",
|
||||
progname, usb_strerror());
|
||||
avrdude_message("%s: Warning: cannot query manufacturer for device: %s\n",
|
||||
progname, usb_strerror());
|
||||
}
|
||||
} else {
|
||||
if (verbose > 1)
|
||||
fprintf(stderr,
|
||||
"%s: seen device from vendor ->%s<-\n",
|
||||
progname, string);
|
||||
avrdude_message("%s: seen device from vendor ->%s<-\n",
|
||||
progname, string);
|
||||
if((vendorName != NULL) && (vendorName[0] != 0) && (strcmp(string, vendorName) != 0))
|
||||
errorCode = USB_ERROR_NOTFOUND;
|
||||
}
|
||||
|
@ -427,15 +417,13 @@ static int didUsbInit = 0;
|
|||
if(len < 0){
|
||||
if ((productName != NULL) && (productName[0] != 0)) {
|
||||
errorCode = USB_ERROR_IO;
|
||||
fprintf(stderr,
|
||||
"%s: Warning: cannot query product for device: %s\n",
|
||||
progname, usb_strerror());
|
||||
avrdude_message("%s: Warning: cannot query product for device: %s\n",
|
||||
progname, usb_strerror());
|
||||
}
|
||||
} else {
|
||||
if (verbose > 1)
|
||||
fprintf(stderr,
|
||||
"%s: seen product ->%s<-\n",
|
||||
progname, string);
|
||||
avrdude_message("%s: seen product ->%s<-\n",
|
||||
progname, string);
|
||||
if((productName != NULL) && (productName[0] != 0) && (strcmp(string, productName) != 0))
|
||||
errorCode = USB_ERROR_NOTFOUND;
|
||||
}
|
||||
|
@ -461,7 +449,7 @@ static int didUsbInit = 0;
|
|||
static int usbasp_open(PROGRAMMER * pgm, char * port)
|
||||
{
|
||||
if (verbose > 2)
|
||||
fprintf(stderr, "%s: usbasp_open(\"%s\")\n",
|
||||
avrdude_message("%s: usbasp_open(\"%s\")\n",
|
||||
progname, port);
|
||||
|
||||
/* usb_init will be done in usbOpenDevice */
|
||||
|
@ -470,9 +458,8 @@ static int usbasp_open(PROGRAMMER * pgm, char * port)
|
|||
if (usbpid) {
|
||||
pid = *(int *)(ldata(usbpid));
|
||||
if (lnext(usbpid))
|
||||
fprintf(stderr,
|
||||
"%s: Warning: using PID 0x%04x, ignoring remaining PIDs in list\n",
|
||||
progname, pid);
|
||||
avrdude_message("%s: Warning: using PID 0x%04x, ignoring remaining PIDs in list\n",
|
||||
progname, pid);
|
||||
} else {
|
||||
pid = USBASP_SHARED_PID;
|
||||
}
|
||||
|
@ -482,16 +469,14 @@ 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) {
|
||||
fprintf(stderr,
|
||||
"%s: warning: Using \"-C usbasp -P nibobee\" is deprecated,"
|
||||
avrdude_message("%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) {
|
||||
fprintf(stderr,
|
||||
"%s: error: could not find USB device "
|
||||
"\"NIBObee\" with vid=0x%x pid=0x%x\n",
|
||||
progname, USBASP_NIBOBEE_VID, USBASP_NIBOBEE_PID);
|
||||
avrdude_message("%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;
|
||||
}
|
||||
return 0;
|
||||
|
@ -500,26 +485,24 @@ 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 */
|
||||
fprintf(stderr,
|
||||
"%s: Warning: Found USB device \"USBasp\" with "
|
||||
"old VID/PID! Please update firmware of USBasp!\n",
|
||||
progname);
|
||||
avrdude_message("%s: Warning: Found USB device \"USBasp\" with "
|
||||
"old VID/PID! Please update firmware of USBasp!\n",
|
||||
progname);
|
||||
return 0;
|
||||
}
|
||||
/* original USBasp is specified in config file, so no need to check it again here */
|
||||
/* no alternative found => fall through to generic error message */
|
||||
}
|
||||
|
||||
fprintf(stderr,
|
||||
"%s: error: could not find USB device with vid=0x%x pid=0x%x",
|
||||
progname, vid, pid);
|
||||
avrdude_message("%s: error: could not find USB device with vid=0x%x pid=0x%x",
|
||||
progname, vid, pid);
|
||||
if (pgm->usbvendor[0] != 0) {
|
||||
fprintf(stderr, " vendor='%s'", pgm->usbvendor);
|
||||
avrdude_message(" vendor='%s'", pgm->usbvendor);
|
||||
}
|
||||
if (pgm->usbproduct[0] != 0) {
|
||||
fprintf(stderr, " product='%s'", pgm->usbproduct);
|
||||
avrdude_message(" product='%s'", pgm->usbproduct);
|
||||
}
|
||||
fprintf(stderr,"\n");
|
||||
avrdude_message("\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -529,7 +512,7 @@ static int usbasp_open(PROGRAMMER * pgm, char * port)
|
|||
static void usbasp_close(PROGRAMMER * pgm)
|
||||
{
|
||||
if (verbose > 2)
|
||||
fprintf(stderr, "%s: usbasp_close()\n", progname);
|
||||
avrdude_message("%s: usbasp_close()\n", progname);
|
||||
|
||||
if (PDATA(pgm)->usbhandle!=NULL) {
|
||||
unsigned char temp[4];
|
||||
|
@ -584,7 +567,7 @@ static int usbasp_initialize(PROGRAMMER * pgm, AVRPART * p)
|
|||
IMPORT_PDATA(pgm);
|
||||
|
||||
if (verbose > 2)
|
||||
fprintf(stderr, "%s: usbasp_initialize()\n", progname);
|
||||
avrdude_message("%s: usbasp_initialize()\n", progname);
|
||||
|
||||
/* get capabilities */
|
||||
memset(temp, 0, sizeof(temp));
|
||||
|
@ -649,7 +632,7 @@ static int usbasp_spi_cmd(PROGRAMMER * pgm, const unsigned char *cmd,
|
|||
unsigned char *res)
|
||||
{
|
||||
if (verbose > 2)
|
||||
fprintf(stderr, "%s: usbasp_cpi_cmd(0x%02x, 0x%02x, 0x%02x, 0x%02x)%s",
|
||||
avrdude_message("%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": "");
|
||||
|
||||
|
@ -660,14 +643,14 @@ static int usbasp_spi_cmd(PROGRAMMER * pgm, const unsigned char *cmd,
|
|||
if (verbose == 3)
|
||||
putc('\n', stderr);
|
||||
|
||||
fprintf(stderr, "%s: error: wrong responds size\n",
|
||||
avrdude_message("%s: error: wrong responds size\n",
|
||||
progname);
|
||||
return -1;
|
||||
}
|
||||
if (verbose > 2) {
|
||||
if (verbose > 3)
|
||||
fprintf(stderr, "%s: usbasp_cpi_cmd()", progname);
|
||||
fprintf(stderr, " => 0x%02x, 0x%02x, 0x%02x, 0x%02x\n",
|
||||
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]);
|
||||
}
|
||||
|
||||
|
@ -684,14 +667,14 @@ static int usbasp_spi_program_enable(PROGRAMMER * pgm, AVRPART * p)
|
|||
cmd[0] = 0;
|
||||
|
||||
if (verbose > 2)
|
||||
fprintf(stderr, "%s: usbasp_program_enable()\n",
|
||||
avrdude_message("%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)) {
|
||||
fprintf(stderr, "%s: error: programm enable: target doesn't answer. %x \n",
|
||||
avrdude_message("%s: error: programm enable: target doesn't answer. %x \n",
|
||||
progname, res[0]);
|
||||
return -1;
|
||||
}
|
||||
|
@ -705,11 +688,11 @@ static int usbasp_spi_chip_erase(PROGRAMMER * pgm, AVRPART * p)
|
|||
unsigned char res[4];
|
||||
|
||||
if (verbose > 2)
|
||||
fprintf(stderr, "%s: usbasp_chip_erase()\n",
|
||||
avrdude_message("%s: usbasp_chip_erase()\n",
|
||||
progname);
|
||||
|
||||
if (p->op[AVR_OP_CHIP_ERASE] == NULL) {
|
||||
fprintf(stderr, "chip erase instruction not defined for part \"%s\"\n",
|
||||
avrdude_message("chip erase instruction not defined for part \"%s\"\n",
|
||||
p->desc);
|
||||
return -1;
|
||||
}
|
||||
|
@ -736,9 +719,8 @@ static int usbasp_spi_paged_load(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m,
|
|||
int function;
|
||||
|
||||
if (verbose > 2)
|
||||
fprintf(stderr,
|
||||
"%s: usbasp_program_paged_load(\"%s\", 0x%x, %d)\n",
|
||||
progname, m->desc, address, n_bytes);
|
||||
avrdude_message("%s: usbasp_program_paged_load(\"%s\", 0x%x, %d)\n",
|
||||
progname, m->desc, address, n_bytes);
|
||||
|
||||
if (strcmp(m->desc, "flash") == 0) {
|
||||
function = USBASP_FUNC_READFLASH;
|
||||
|
@ -781,7 +763,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) {
|
||||
fprintf(stderr, "%s: error: wrong reading bytes %x\n",
|
||||
avrdude_message("%s: error: wrong reading bytes %x\n",
|
||||
progname, n);
|
||||
return -3;
|
||||
}
|
||||
|
@ -806,9 +788,8 @@ static int usbasp_spi_paged_write(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m,
|
|||
int function;
|
||||
|
||||
if (verbose > 2)
|
||||
fprintf(stderr,
|
||||
"%s: usbasp_program_paged_write(\"%s\", 0x%x, %d)\n",
|
||||
progname, m->desc, address, n_bytes);
|
||||
avrdude_message("%s: usbasp_program_paged_write(\"%s\", 0x%x, %d)\n",
|
||||
progname, m->desc, address, n_bytes);
|
||||
|
||||
if (strcmp(m->desc, "flash") == 0) {
|
||||
function = USBASP_FUNC_WRITEFLASH;
|
||||
|
@ -856,7 +837,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) {
|
||||
fprintf(stderr, "%s: error: wrong count at writing %x\n",
|
||||
avrdude_message("%s: error: wrong count at writing %x\n",
|
||||
progname, n);
|
||||
return -3;
|
||||
}
|
||||
|
@ -896,9 +877,8 @@ static int usbasp_spi_set_sck_period(PROGRAMMER *pgm, double sckperiod)
|
|||
unsigned char cmd[4];
|
||||
|
||||
if (verbose > 2)
|
||||
fprintf(stderr,
|
||||
"%s: usbasp_spi_set_sck_period(%g)\n",
|
||||
progname, sckperiod);
|
||||
avrdude_message("%s: usbasp_spi_set_sck_period(%g)\n",
|
||||
progname, sckperiod);
|
||||
|
||||
memset(cmd, 0, sizeof(cmd));
|
||||
memset(res, 0, sizeof(res));
|
||||
|
@ -910,7 +890,7 @@ static int usbasp_spi_set_sck_period(PROGRAMMER *pgm, double sckperiod)
|
|||
/* auto sck set */
|
||||
|
||||
if (verbose >= 1)
|
||||
fprintf(stderr, "%s: auto set sck period (because given equals null)\n", progname);
|
||||
avrdude_message("%s: auto set sck period (because given equals null)\n", progname);
|
||||
|
||||
} else {
|
||||
|
||||
|
@ -918,7 +898,7 @@ static int usbasp_spi_set_sck_period(PROGRAMMER *pgm, double sckperiod)
|
|||
int usefreq = 0;
|
||||
|
||||
if (verbose >= 2)
|
||||
fprintf(stderr, "%s: try to set SCK period to %g s (= %i Hz)\n", progname, sckperiod, sckfreq);
|
||||
avrdude_message("%s: try to set SCK period to %g s (= %i Hz)\n", progname, sckperiod, sckfreq);
|
||||
|
||||
if (sckfreq >= usbaspSCKoptions[0].frequency) {
|
||||
clockoption = usbaspSCKoptions[0].id;
|
||||
|
@ -939,7 +919,7 @@ static int usbasp_spi_set_sck_period(PROGRAMMER *pgm, double sckperiod)
|
|||
/* save used sck frequency */
|
||||
PDATA(pgm)->sckfreq_hz = usefreq;
|
||||
|
||||
fprintf(stderr, "%s: set SCK frequency to %i Hz\n", progname, usefreq);
|
||||
avrdude_message("%s: set SCK frequency to %i Hz\n", progname, usefreq);
|
||||
}
|
||||
|
||||
cmd[0] = clockoption;
|
||||
|
@ -948,7 +928,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)) {
|
||||
fprintf(stderr, "%s: warning: cannot set sck period. please check for usbasp firmware update.\n",
|
||||
avrdude_message("%s: warning: cannot set sck period. please check for usbasp firmware update.\n",
|
||||
progname);
|
||||
return -1;
|
||||
}
|
||||
|
@ -975,7 +955,7 @@ static int usbasp_tpi_recv_byte(PROGRAMMER * pgm)
|
|||
|
||||
if(usbasp_transmit(pgm, 1, USBASP_FUNC_TPI_RAWREAD, temp, temp, sizeof(temp)) != 1)
|
||||
{
|
||||
fprintf(stderr, "%s: error: wrong responds size\n", progname);
|
||||
avrdude_message("%s: error: wrong responds size\n", progname);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -988,7 +968,7 @@ static int usbasp_tpi_nvm_waitbusy(PROGRAMMER * pgm)
|
|||
int retry;
|
||||
|
||||
if (verbose > 2)
|
||||
fprintf(stderr, "%s: usbasp_tpi_nvm_waitbusy() ...", progname);
|
||||
avrdude_message("%s: usbasp_tpi_nvm_waitbusy() ...", progname);
|
||||
|
||||
for(retry=50; retry>0; retry--)
|
||||
{
|
||||
|
@ -997,20 +977,20 @@ static int usbasp_tpi_nvm_waitbusy(PROGRAMMER * pgm)
|
|||
continue;
|
||||
|
||||
if (verbose > 2)
|
||||
fprintf(stderr, " ready\n");
|
||||
avrdude_message(" ready\n");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (verbose > 2)
|
||||
fprintf(stderr, " failure\n");
|
||||
avrdude_message(" failure\n");
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
static int usbasp_tpi_cmd(PROGRAMMER * pgm, const unsigned char *cmd, unsigned char *res)
|
||||
{
|
||||
fprintf(stderr, "%s: error: spi_cmd used in TPI mode: not allowed\n", progname);
|
||||
avrdude_message("%s: error: spi_cmd used in TPI mode: not allowed\n", progname);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -1019,7 +999,7 @@ static int usbasp_tpi_program_enable(PROGRAMMER * pgm, AVRPART * p)
|
|||
int retry;
|
||||
|
||||
if (verbose > 2)
|
||||
fprintf(stderr, "%s: usbasp_tpi_program_enable()\n", progname);
|
||||
avrdude_message("%s: usbasp_tpi_program_enable()\n", progname);
|
||||
|
||||
/* change guard time */
|
||||
usbasp_tpi_send_byte(pgm, TPI_OP_SSTCS(TPIPCR));
|
||||
|
@ -1049,7 +1029,7 @@ static int usbasp_tpi_program_enable(PROGRAMMER * pgm, AVRPART * p)
|
|||
}
|
||||
if(retry >= 10)
|
||||
{
|
||||
fprintf(stderr, "%s: error: programm enable: target doesn't answer.\n", progname);
|
||||
avrdude_message("%s: error: programm enable: target doesn't answer.\n", progname);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -1059,7 +1039,7 @@ static int usbasp_tpi_program_enable(PROGRAMMER * pgm, AVRPART * p)
|
|||
static int usbasp_tpi_chip_erase(PROGRAMMER * pgm, AVRPART * p)
|
||||
{
|
||||
if (verbose > 2)
|
||||
fprintf(stderr, "%s: usbasp_tpi_chip_erase()\n", progname);
|
||||
avrdude_message("%s: usbasp_tpi_chip_erase()\n", progname);
|
||||
|
||||
/* Set PR to flash */
|
||||
usbasp_tpi_send_byte(pgm, TPI_OP_SSTPR(0));
|
||||
|
@ -1091,7 +1071,7 @@ static int usbasp_tpi_paged_load(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m,
|
|||
|
||||
|
||||
if (verbose > 2)
|
||||
fprintf(stderr, "%s: usbasp_tpi_paged_load(\"%s\", 0x%0x, %d)\n",
|
||||
avrdude_message("%s: usbasp_tpi_paged_load(\"%s\", 0x%0x, %d)\n",
|
||||
progname, m->desc, addr, n_bytes);
|
||||
|
||||
dptr = addr + m->buf;
|
||||
|
@ -1112,7 +1092,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)
|
||||
{
|
||||
fprintf(stderr, "%s: error: wrong reading bytes %x\n", progname, n);
|
||||
avrdude_message("%s: error: wrong reading bytes %x\n", progname, n);
|
||||
return -3;
|
||||
}
|
||||
|
||||
|
@ -1135,7 +1115,7 @@ static int usbasp_tpi_paged_write(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m,
|
|||
|
||||
|
||||
if (verbose > 2)
|
||||
fprintf(stderr, "%s: usbasp_tpi_paged_write(\"%s\", 0x%0x, %d)\n",
|
||||
avrdude_message("%s: usbasp_tpi_paged_write(\"%s\", 0x%0x, %d)\n",
|
||||
progname, m->desc, addr, n_bytes);
|
||||
|
||||
sptr = addr + m->buf;
|
||||
|
@ -1162,7 +1142,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)
|
||||
{
|
||||
fprintf(stderr, "%s: error: wrong count at writing %x\n", progname, n);
|
||||
avrdude_message("%s: error: wrong count at writing %x\n", progname, n);
|
||||
return -3;
|
||||
}
|
||||
|
||||
|
@ -1186,7 +1166,7 @@ static int usbasp_tpi_read_byte(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m, unsig
|
|||
|
||||
|
||||
if (verbose > 2)
|
||||
fprintf(stderr, "%s: usbasp_tpi_read_byte(\"%s\", 0x%0lx)\n",
|
||||
avrdude_message("%s: usbasp_tpi_read_byte(\"%s\", 0x%0lx)\n",
|
||||
progname, m->desc, addr);
|
||||
|
||||
pr = m->offset + addr;
|
||||
|
@ -1199,7 +1179,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)
|
||||
{
|
||||
fprintf(stderr, "%s: error: wrong reading bytes %x\n", progname, n);
|
||||
avrdude_message("%s: error: wrong reading bytes %x\n", progname, n);
|
||||
return -3;
|
||||
}
|
||||
return 0;
|
||||
|
@ -1207,7 +1187,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)
|
||||
{
|
||||
fprintf(stderr, "%s: error: usbasp_write_byte in TPI mode: all writes have to be done at page level\n", progname);
|
||||
avrdude_message("%s: error: usbasp_write_byte in TPI mode: all writes have to be done at page level\n", progname);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -1249,7 +1229,7 @@ void usbasp_initpgm(PROGRAMMER * pgm)
|
|||
|
||||
static int usbasp_nousb_open (struct programmer_t *pgm, char * name)
|
||||
{
|
||||
fprintf(stderr, "%s: error: no usb support. please compile again with libusb installed.\n",
|
||||
avrdude_message("%s: error: no usb support. please compile again with libusb installed.\n",
|
||||
progname);
|
||||
|
||||
return -1;
|
||||
|
|
43
usbtiny.c
43
usbtiny.c
|
@ -76,9 +76,8 @@ struct pdata
|
|||
static void usbtiny_setup(PROGRAMMER * pgm)
|
||||
{
|
||||
if ((pgm->cookie = malloc(sizeof(struct pdata))) == 0) {
|
||||
fprintf(stderr,
|
||||
"%s: usbtiny_setup(): Out of memory allocating private data\n",
|
||||
progname);
|
||||
avrdude_message("%s: usbtiny_setup(): Out of memory allocating private data\n",
|
||||
progname);
|
||||
exit(1);
|
||||
}
|
||||
memset(pgm->cookie, 0, sizeof(struct pdata));
|
||||
|
@ -101,7 +100,7 @@ static int usb_control (PROGRAMMER * pgm,
|
|||
NULL, 0, // no data buffer in control messge
|
||||
USB_TIMEOUT ); // default timeout
|
||||
if(nbytes < 0){
|
||||
fprintf(stderr, "\n%s: error: usbtiny_transmit: %s\n", progname, usb_strerror());
|
||||
avrdude_message("\n%s: error: usbtiny_transmit: %s\n", progname, usb_strerror());
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -133,7 +132,7 @@ static int usb_in (PROGRAMMER * pgm,
|
|||
}
|
||||
PDATA(pgm)->retries++;
|
||||
}
|
||||
fprintf(stderr, "\n%s: error: usbtiny_receive: %s (expected %d, got %d)\n",
|
||||
avrdude_message("\n%s: error: usbtiny_receive: %s (expected %d, got %d)\n",
|
||||
progname, usb_strerror(), buflen, nbytes);
|
||||
return -1;
|
||||
}
|
||||
|
@ -142,7 +141,7 @@ static int usb_in (PROGRAMMER * pgm,
|
|||
static void check_retries (PROGRAMMER * pgm, const char* operation)
|
||||
{
|
||||
if (PDATA(pgm)->retries > 0 && quell_progress < 2) {
|
||||
fprintf(stderr, "%s: %d retries during %s\n", progname,
|
||||
avrdude_message("%s: %d retries during %s\n", progname,
|
||||
PDATA(pgm)->retries, operation);
|
||||
}
|
||||
PDATA(pgm)->retries = 0;
|
||||
|
@ -167,7 +166,7 @@ static int usb_out (PROGRAMMER * pgm,
|
|||
(char *)buffer, buflen,
|
||||
timeout);
|
||||
if (nbytes != buflen) {
|
||||
fprintf(stderr, "\n%s: error: usbtiny_send: %s (expected %d, got %d)\n",
|
||||
avrdude_message("\n%s: error: usbtiny_send: %s (expected %d, got %d)\n",
|
||||
progname, usb_strerror(), buflen, nbytes);
|
||||
return -1;
|
||||
}
|
||||
|
@ -186,7 +185,7 @@ static int usbtiny_avr_op (PROGRAMMER * pgm, AVRPART * p,
|
|||
unsigned char cmd[4];
|
||||
|
||||
if (p->op[op] == NULL) {
|
||||
fprintf( stderr, "Operation %d not defined for this chip!\n", op );
|
||||
avrdude_message("Operation %d not defined for this chip!\n", op );
|
||||
return -1;
|
||||
}
|
||||
memset(cmd, 0, sizeof(cmd));
|
||||
|
@ -236,9 +235,8 @@ static int usbtiny_open(PROGRAMMER* pgm, char* name)
|
|||
if (usbpid) {
|
||||
pid = *(int *)(ldata(usbpid));
|
||||
if (lnext(usbpid))
|
||||
fprintf(stderr,
|
||||
"%s: Warning: using PID 0x%04x, ignoring remaining PIDs in list\n",
|
||||
progname, pid);
|
||||
avrdude_message("%s: Warning: using PID 0x%04x, ignoring remaining PIDs in list\n",
|
||||
progname, pid);
|
||||
} else {
|
||||
pid = USBTINY_PRODUCT_DEFAULT;
|
||||
}
|
||||
|
@ -250,9 +248,8 @@ static int usbtiny_open(PROGRAMMER* pgm, char* name)
|
|||
if (dev->descriptor.idVendor == vid
|
||||
&& dev->descriptor.idProduct == pid ) { // found match?
|
||||
if(verbose)
|
||||
fprintf(stderr,
|
||||
"%s: usbdev_open(): Found USBtinyISP, bus:device: %s:%s\n",
|
||||
progname, bus->dirname, dev->filename);
|
||||
avrdude_message("%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 &&
|
||||
(NULL == dev_name ||
|
||||
|
@ -263,7 +260,7 @@ static int usbtiny_open(PROGRAMMER* pgm, char* name)
|
|||
|
||||
// wrong permissions or something?
|
||||
if (!PDATA(pgm)->usb_handle) {
|
||||
fprintf(stderr, "%s: Warning: cannot open USB device: %s\n",
|
||||
avrdude_message("%s: Warning: cannot open USB device: %s\n",
|
||||
progname, usb_strerror());
|
||||
continue;
|
||||
}
|
||||
|
@ -272,12 +269,12 @@ static int usbtiny_open(PROGRAMMER* pgm, char* name)
|
|||
}
|
||||
|
||||
if(NULL != name && NULL == dev_name) {
|
||||
fprintf(stderr, "%s: Error: Invalid -P value: '%s'\n", progname, name);
|
||||
fprintf(stderr, "%sUse -P usb:bus:device\n", progbuf);
|
||||
avrdude_message("%s: Error: Invalid -P value: '%s'\n", progname, name);
|
||||
avrdude_message("%sUse -P usb:bus:device\n", progbuf);
|
||||
return -1;
|
||||
}
|
||||
if (!PDATA(pgm)->usb_handle) {
|
||||
fprintf( stderr, "%s: Error: Could not find USBtiny device (0x%x/0x%x)\n",
|
||||
avrdude_message("%s: Error: Could not find USBtiny device (0x%x/0x%x)\n",
|
||||
progname, vid, pid );
|
||||
return -1;
|
||||
}
|
||||
|
@ -323,7 +320,7 @@ static int usbtiny_set_sck_period (PROGRAMMER *pgm, double v)
|
|||
PDATA(pgm)->sck_period = SCK_MAX;
|
||||
|
||||
if (verbose) {
|
||||
fprintf(stderr, "%s: Setting SCK period to %d usec\n", progname,
|
||||
avrdude_message("%s: Setting SCK period to %d usec\n", progname,
|
||||
PDATA(pgm)->sck_period );
|
||||
}
|
||||
|
||||
|
@ -350,7 +347,7 @@ static int usbtiny_initialize (PROGRAMMER *pgm, AVRPART *p )
|
|||
// -B option not specified: use default
|
||||
PDATA(pgm)->sck_period = SCK_DEFAULT;
|
||||
if (verbose) {
|
||||
fprintf(stderr, "%s: Using SCK period of %d usec\n",
|
||||
avrdude_message("%s: Using SCK period of %d usec\n",
|
||||
progname, PDATA(pgm)->sck_period );
|
||||
}
|
||||
if (usb_control(pgm, USBTINY_POWERUP,
|
||||
|
@ -406,7 +403,7 @@ static int usbtiny_cmd(PROGRAMMER * pgm, const unsigned char *cmd, unsigned char
|
|||
check_retries(pgm, "SPI command");
|
||||
if (verbose > 1) {
|
||||
// print out the data we sent and received
|
||||
fprintf(stderr, "CMD: [%02x %02x %02x %02x] [%02x %02x %02x %02x]\n",
|
||||
avrdude_message("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] );
|
||||
}
|
||||
|
@ -420,7 +417,7 @@ static int usbtiny_chip_erase(PROGRAMMER * pgm, AVRPART * p)
|
|||
unsigned char res[4];
|
||||
|
||||
if (p->op[AVR_OP_CHIP_ERASE] == NULL) {
|
||||
fprintf(stderr, "Chip erase instruction not defined for part \"%s\"\n",
|
||||
avrdude_message("Chip erase instruction not defined for part \"%s\"\n",
|
||||
p->desc);
|
||||
return -1;
|
||||
}
|
||||
|
@ -581,7 +578,7 @@ void usbtiny_initpgm ( PROGRAMMER* pgm )
|
|||
|
||||
static int usbtiny_nousb_open(struct programmer_t *pgm, char * name)
|
||||
{
|
||||
fprintf(stderr, "%s: error: no usb support. Please compile again with libusb installed.\n",
|
||||
avrdude_message("%s: error: no usb support. Please compile again with libusb installed.\n",
|
||||
progname);
|
||||
|
||||
return -1;
|
||||
|
|
40
wiring.c
40
wiring.c
|
@ -85,9 +85,8 @@ static void wiring_setup(PROGRAMMER * pgm)
|
|||
* Now prepare our data
|
||||
*/
|
||||
if ((mycookie = malloc(sizeof(struct wiringpdata))) == 0) {
|
||||
fprintf(stderr,
|
||||
"%s: wiring_setup(): Out of memory allocating private data\n",
|
||||
progname);
|
||||
avrdude_message("%s: wiring_setup(): Out of memory allocating private data\n",
|
||||
progname);
|
||||
exit(1);
|
||||
}
|
||||
memset(mycookie, 0, sizeof(struct wiringpdata));
|
||||
|
@ -124,25 +123,22 @@ static int wiring_parseextparms(PROGRAMMER * pgm, LISTID extparms)
|
|||
int newsnooze;
|
||||
if (sscanf(extended_param, "snooze=%i", &newsnooze) != 1 ||
|
||||
newsnooze < 0) {
|
||||
fprintf(stderr,
|
||||
"%s: wiring_parseextparms(): invalid snooze time '%s'\n",
|
||||
progname, extended_param);
|
||||
avrdude_message("%s: wiring_parseextparms(): invalid snooze time '%s'\n",
|
||||
progname, extended_param);
|
||||
rv = -1;
|
||||
continue;
|
||||
}
|
||||
if (verbose >= 2) {
|
||||
fprintf(stderr,
|
||||
"%s: wiring_parseextparms(): snooze time set to %d ms\n",
|
||||
progname, newsnooze);
|
||||
avrdude_message("%s: wiring_parseextparms(): snooze time set to %d ms\n",
|
||||
progname, newsnooze);
|
||||
}
|
||||
WIRINGPDATA(mycookie)->snoozetime = newsnooze;
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
fprintf(stderr,
|
||||
"%s: wiring_parseextparms(): invalid extended parameter '%s'\n",
|
||||
progname, extended_param);
|
||||
avrdude_message("%s: wiring_parseextparms(): invalid extended parameter '%s'\n",
|
||||
progname, extended_param);
|
||||
rv = -1;
|
||||
}
|
||||
|
||||
|
@ -165,16 +161,14 @@ static int wiring_open(PROGRAMMER * pgm, char * port)
|
|||
timetosnooze = WIRINGPDATA(mycookie)->snoozetime;
|
||||
|
||||
if (verbose >= 2) {
|
||||
fprintf(stderr,
|
||||
"%s: wiring_open(): snoozing for %d ms\n",
|
||||
progname, timetosnooze);
|
||||
avrdude_message("%s: wiring_open(): snoozing for %d ms\n",
|
||||
progname, timetosnooze);
|
||||
}
|
||||
while (timetosnooze--)
|
||||
usleep(1000);
|
||||
if (verbose >= 2) {
|
||||
fprintf(stderr,
|
||||
"%s: wiring_open(): done snoozing\n",
|
||||
progname);
|
||||
avrdude_message("%s: wiring_open(): done snoozing\n",
|
||||
progname);
|
||||
}
|
||||
|
||||
} else {
|
||||
|
@ -184,9 +178,8 @@ static int wiring_open(PROGRAMMER * pgm, char * port)
|
|||
/* since they are active LOW signals. */
|
||||
|
||||
if (verbose >= 2) {
|
||||
fprintf(stderr,
|
||||
"%s: wiring_open(): releasing DTR/RTS\n",
|
||||
progname);
|
||||
avrdude_message("%s: wiring_open(): releasing DTR/RTS\n",
|
||||
progname);
|
||||
}
|
||||
|
||||
serial_set_dtr_rts(&pgm->fd, 0);
|
||||
|
@ -196,9 +189,8 @@ static int wiring_open(PROGRAMMER * pgm, char * port)
|
|||
/* are asserted (i.e. logic LOW) again. */
|
||||
|
||||
if (verbose >= 2) {
|
||||
fprintf(stderr,
|
||||
"%s: wiring_open(): asserting DTR/RTS\n",
|
||||
progname);
|
||||
avrdude_message("%s: wiring_open(): asserting DTR/RTS\n",
|
||||
progname);
|
||||
}
|
||||
|
||||
serial_set_dtr_rts(&pgm->fd, 1);
|
||||
|
|
Loading…
Reference in New Issue