Review and overhaul AVRDUDE's messaging system (#1126)
* Change avrdude_message(MSG_XYZ, ...) to msg_xyz(...) * Define and use pmsg_xyz(...) instead of msg_xyz("%s: ...", progname, ...) * Review and change avrdude_message() levels - Introduce new levels warning, error and ext_error - Distribute info level to info, warning, error, ext_error - Assign levels (more) consistently - Unify grammar, punctuation and style of messages * Use imsg_xyz() to print indented messages * Show function name in errors and warnings on -v * Reduce effective verbosity level by number of -q above one
This commit is contained in:
parent
2503ae03ce
commit
e172877724
|
@ -44,7 +44,7 @@ static int arduino_read_sig_bytes(const PROGRAMMER *pgm, const AVRPART *p, const
|
|||
/* Signature byte reads are always 3 bytes. */
|
||||
|
||||
if (m->size < 3) {
|
||||
avrdude_message(MSG_INFO, "%s: memsize too small for sig byte read", progname);
|
||||
pmsg_error("memsize too small for sig byte read");
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -56,19 +56,16 @@ static int arduino_read_sig_bytes(const PROGRAMMER *pgm, const AVRPART *p, const
|
|||
if (serial_recv(&pgm->fd, buf, 5) < 0)
|
||||
return -1;
|
||||
if (buf[0] == Resp_STK_NOSYNC) {
|
||||
avrdude_message(MSG_INFO, "%s: stk500_cmd(): programmer is out of sync\n",
|
||||
progname);
|
||||
pmsg_error("programmer is out of sync\n");
|
||||
return -1;
|
||||
} else if (buf[0] != Resp_STK_INSYNC) {
|
||||
avrdude_message(MSG_INFO, "\n%s: arduino_read_sig_bytes(): (a) protocol error, "
|
||||
"expect=0x%02x, resp=0x%02x\n",
|
||||
progname, Resp_STK_INSYNC, buf[0]);
|
||||
msg_error("\n");
|
||||
pmsg_error("protocol expects sync byte 0x%02x but got 0x%02x\n", Resp_STK_INSYNC, buf[0]);
|
||||
return -2;
|
||||
}
|
||||
if (buf[4] != Resp_STK_OK) {
|
||||
avrdude_message(MSG_INFO, "\n%s: arduino_read_sig_bytes(): (a) protocol error, "
|
||||
"expect=0x%02x, resp=0x%02x\n",
|
||||
progname, Resp_STK_OK, buf[4]);
|
||||
msg_error("\n");
|
||||
pmsg_error("protocol expects OK byte 0x%02x but got 0x%02x\n", Resp_STK_OK, buf[4]);
|
||||
return -3;
|
||||
}
|
||||
|
||||
|
|
151
src/avr.c
151
src/avr.c
|
@ -58,8 +58,7 @@ int avr_tpi_chip_erase(const PROGRAMMER *pgm, const AVRPART *p) {
|
|||
/* Set Pointer Register */
|
||||
mem = avr_locate_mem(p, "flash");
|
||||
if (mem == NULL) {
|
||||
avrdude_message(MSG_INFO, "No flash memory to erase for part %s\n",
|
||||
p->desc);
|
||||
pmsg_error("no flash memory to erase for part %s\n", p->desc);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -91,7 +90,7 @@ int avr_tpi_chip_erase(const PROGRAMMER *pgm, const AVRPART *p) {
|
|||
|
||||
return 0;
|
||||
} else {
|
||||
avrdude_message(MSG_INFO, "%s called for a part that has no TPI\n", __func__);
|
||||
pmsg_error("part has no TPI\n");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
@ -115,7 +114,7 @@ int avr_tpi_program_enable(const PROGRAMMER *pgm, const AVRPART *p, unsigned cha
|
|||
cmd[0] = (TPI_CMD_SLDCS | TPI_REG_TPIIR);
|
||||
err = pgm->cmd_tpi(pgm, cmd, 1, &response, sizeof(response));
|
||||
if (err || response != TPI_IDENT_CODE) {
|
||||
avrdude_message(MSG_INFO, "TPIIR not correct\n");
|
||||
pmsg_error("TPIIR not correct\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -135,12 +134,11 @@ int avr_tpi_program_enable(const PROGRAMMER *pgm, const AVRPART *p, unsigned cha
|
|||
return 0;
|
||||
}
|
||||
|
||||
avrdude_message(MSG_INFO, "Error enabling TPI external programming mode:");
|
||||
avrdude_message(MSG_INFO, "Target does not reply\n");
|
||||
pmsg_error("target does not reply when enabling TPI external programming mode\n");
|
||||
return -1;
|
||||
|
||||
} else {
|
||||
avrdude_message(MSG_INFO, "%s called for a part that has no TPI\n", __func__);
|
||||
pmsg_error("part has no TPI\n");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
@ -185,9 +183,8 @@ int avr_read_byte_default(const PROGRAMMER *pgm, const AVRPART *p, const AVRMEM
|
|||
OPCODE * readop, * lext;
|
||||
|
||||
if (pgm->cmd == NULL) {
|
||||
avrdude_message(MSG_INFO, "%s: Error: %s programmer uses avr_read_byte_default() but does not\n"
|
||||
"provide a cmd() method.\n",
|
||||
progname, pgm->type);
|
||||
pmsg_error("%s programmer uses avr_read_byte_default() but does not\n", pgm->type);
|
||||
imsg_error("provide a cmd() method\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -196,8 +193,7 @@ int avr_read_byte_default(const PROGRAMMER *pgm, const AVRPART *p, const AVRMEM
|
|||
|
||||
if (p->prog_modes & PM_TPI) {
|
||||
if (pgm->cmd_tpi == NULL) {
|
||||
avrdude_message(MSG_INFO, "%s: Error: %s programmer does not support TPI\n",
|
||||
progname, pgm->type);
|
||||
pmsg_error("%s programmer does not support TPI\n", pgm->type);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -231,8 +227,7 @@ int avr_read_byte_default(const PROGRAMMER *pgm, const AVRPART *p, const AVRMEM
|
|||
|
||||
if (readop == NULL) {
|
||||
#if DEBUG
|
||||
avrdude_message(MSG_INFO, "avr_read_byte_default(): operation not supported on memory type \"%s\"\n",
|
||||
mem->desc);
|
||||
pmsg_error("operation not supported on memory type %s\n", mem->desc);
|
||||
#endif
|
||||
return -1;
|
||||
}
|
||||
|
@ -322,7 +317,7 @@ int avr_mem_hiaddr(const AVRMEM * mem)
|
|||
int avr_read(const PROGRAMMER *pgm, const AVRPART *p, const char *memtype, const AVRPART *v) {
|
||||
AVRMEM *mem = avr_locate_mem(p, memtype);
|
||||
if (mem == NULL) {
|
||||
avrdude_message(MSG_INFO, "No %s memory for part %s\n", memtype, p->desc);
|
||||
pmsg_error("no %s memory for part %s\n", memtype, p->desc);
|
||||
return LIBAVRDUDE_GENERAL_FAILURE;
|
||||
}
|
||||
|
||||
|
@ -373,7 +368,7 @@ int avr_read_mem(const PROGRAMMER *pgm, const AVRPART *p, const AVRMEM *mem, con
|
|||
rc = pgm->cmd_tpi(pgm, cmd, 1, mem->buf + i, 1);
|
||||
lastaddr++;
|
||||
if (rc == -1) {
|
||||
avrdude_message(MSG_INFO, "avr_read_mem(): error reading address 0x%04lx\n", i);
|
||||
pmsg_error("unable to read address 0x%04lx\n", i);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
@ -431,8 +426,7 @@ int avr_read_mem(const PROGRAMMER *pgm, const AVRPART *p, const AVRMEM *mem, con
|
|||
/* paged load failed, fall back to byte-at-a-time read below */
|
||||
failure = 1;
|
||||
} else {
|
||||
avrdude_message(MSG_DEBUG, "%s: avr_read_mem(): skipping page %u: no interesting data\n",
|
||||
progname, pageaddr / mem->page_size);
|
||||
pmsg_debug("avr_read_mem(): skipping page %u: no interesting data\n", pageaddr / mem->page_size);
|
||||
}
|
||||
nread++;
|
||||
report_progress(nread, npages, NULL);
|
||||
|
@ -454,13 +448,12 @@ int avr_read_mem(const PROGRAMMER *pgm, const AVRPART *p, const AVRMEM *mem, con
|
|||
{
|
||||
rc = pgm->read_byte(pgm, p, mem, i, mem->buf + i);
|
||||
if (rc != LIBAVRDUDE_SUCCESS) {
|
||||
avrdude_message(MSG_INFO, "avr_read_mem(): error reading address 0x%04lx\n", i);
|
||||
pmsg_error("unable to read byte at address 0x%04lx\n", i);
|
||||
if (rc == LIBAVRDUDE_GENERAL_FAILURE) {
|
||||
avrdude_message(MSG_INFO, " read operation not supported for memory %s\n",
|
||||
mem->desc);
|
||||
pmsg_error("read operation not supported for memory %s\n", mem->desc);
|
||||
return LIBAVRDUDE_NOTSUPPORTED;
|
||||
}
|
||||
avrdude_message(MSG_INFO, " read operation failed for memory %s\n", mem->desc);
|
||||
pmsg_error("read operation failed for memory %s\n", mem->desc);
|
||||
return LIBAVRDUDE_SOFTFAIL;
|
||||
}
|
||||
}
|
||||
|
@ -483,16 +476,14 @@ int avr_write_page(const PROGRAMMER *pgm, const AVRPART *p, const AVRMEM *mem,
|
|||
OPCODE * wp, * lext;
|
||||
|
||||
if (pgm->cmd == NULL) {
|
||||
avrdude_message(MSG_INFO, "%s: Error: %s programmer uses avr_write_page() but does not\n"
|
||||
"provide a cmd() method.\n",
|
||||
progname, pgm->type);
|
||||
pmsg_error("%s programmer uses avr_write_page() but does not\n", pgm->type);
|
||||
imsg_error("provide a cmd() method\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
wp = mem->op[AVR_OP_WRITEPAGE];
|
||||
if (wp == NULL) {
|
||||
avrdude_message(MSG_INFO, "avr_write_page(): memory \"%s\" not configured for page writes\n",
|
||||
mem->desc);
|
||||
pmsg_error("memory %s not configured for page writes\n", mem->desc);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -553,24 +544,22 @@ int avr_write_byte_default(const PROGRAMMER *pgm, const AVRPART *p, const AVRMEM
|
|||
struct timeval tv;
|
||||
|
||||
if (pgm->cmd == NULL) {
|
||||
avrdude_message(MSG_INFO, "%s: Error: %s programmer uses avr_write_byte_default() but does not\n"
|
||||
"provide a cmd() method.\n",
|
||||
progname, pgm->type);
|
||||
pmsg_error("%s programmer uses avr_write_byte_default() but does not\n", pgm->type);
|
||||
imsg_error("provide a cmd() method\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (p->prog_modes & PM_TPI) {
|
||||
if (pgm->cmd_tpi == NULL) {
|
||||
avrdude_message(MSG_INFO, "%s: Error: %s programmer does not support TPI\n",
|
||||
progname, pgm->type);
|
||||
pmsg_error("%s programmer does not support TPI\n", pgm->type);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (strcmp(mem->desc, "flash") == 0) {
|
||||
avrdude_message(MSG_INFO, "Writing a byte to flash is not supported for %s\n", p->desc);
|
||||
pmsg_error("writing a byte to flash is not supported for %s\n", p->desc);
|
||||
return -1;
|
||||
} else if ((mem->offset + addr) & 1) {
|
||||
avrdude_message(MSG_INFO, "Writing a byte to an odd location is not supported for %s\n", p->desc);
|
||||
pmsg_error("writing a byte to an odd location is not supported for %s\n", p->desc);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -657,8 +646,7 @@ int avr_write_byte_default(const PROGRAMMER *pgm, const AVRPART *p, const AVRMEM
|
|||
|
||||
if (writeop == NULL) {
|
||||
#if DEBUG
|
||||
avrdude_message(MSG_INFO, "avr_write_byte_default(): write not supported for memory type \"%s\"\n",
|
||||
mem->desc);
|
||||
pmsg_error("write not supported for memory type %s\n", mem->desc);
|
||||
#endif
|
||||
return -1;
|
||||
}
|
||||
|
@ -750,25 +738,20 @@ int avr_write_byte_default(const PROGRAMMER *pgm, const AVRPART *p, const AVRMEM
|
|||
* device if the data read back does not match what we wrote.
|
||||
*/
|
||||
pgm->pgm_led(pgm, OFF);
|
||||
avrdude_message(MSG_INFO, "%s: this device must be powered off and back on to continue\n",
|
||||
progname);
|
||||
pmsg_info("this device must be powered off and back on to continue\n");
|
||||
if (pgm->pinno[PPI_AVR_VCC]) {
|
||||
avrdude_message(MSG_INFO, "%s: attempting to do this now ...\n", progname);
|
||||
pmsg_info("attempting to do this now ...\n");
|
||||
pgm->powerdown(pgm);
|
||||
usleep(250000);
|
||||
rc = pgm->initialize(pgm, p);
|
||||
if (rc < 0) {
|
||||
avrdude_message(MSG_INFO, "%s: initialization failed, rc=%d\n", progname, rc);
|
||||
avrdude_message(MSG_INFO, "%s: can't re-initialize device after programming the "
|
||||
"%s bits\n", progname, mem->desc);
|
||||
avrdude_message(MSG_INFO, "%s: you must manually power-down the device and restart\n"
|
||||
"%s: %s to continue.\n",
|
||||
progname, progname, progname);
|
||||
pmsg_error("initialization failed, rc=%d\n", rc);
|
||||
imsg_error("cannot re-initialize device after programming the %s bits\n", mem->desc);
|
||||
imsg_error("you must manually power-down the device and restart %s to continue\n", progname);
|
||||
return -3;
|
||||
}
|
||||
|
||||
avrdude_message(MSG_INFO, "%s: device was successfully re-initialized\n",
|
||||
progname);
|
||||
pmsg_info("device was successfully re-initialized\n");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
@ -813,8 +796,7 @@ int avr_write_byte(const PROGRAMMER *pgm, const AVRPART *p, const AVRMEM *mem,
|
|||
int avr_write(const PROGRAMMER *pgm, const AVRPART *p, const char *memtype, int size, int auto_erase) {
|
||||
AVRMEM *m = avr_locate_mem(p, memtype);
|
||||
if (m == NULL) {
|
||||
avrdude_message(MSG_INFO, "No \"%s\" memory for part %s\n",
|
||||
memtype, p->desc);
|
||||
pmsg_error("no %s memory for part %s\n", memtype, p->desc);
|
||||
return LIBAVRDUDE_GENERAL_FAILURE;
|
||||
}
|
||||
|
||||
|
@ -847,11 +829,8 @@ int avr_write_mem(const PROGRAMMER *pgm, const AVRPART *p, const AVRMEM *m, int
|
|||
wsize = size;
|
||||
}
|
||||
else if (size > wsize) {
|
||||
avrdude_message(MSG_INFO, "%s: WARNING: %d bytes requested, but memory region is only %d"
|
||||
"bytes\n"
|
||||
"%sOnly %d bytes will actually be written\n",
|
||||
progname, size, wsize,
|
||||
progbuf, wsize);
|
||||
pmsg_warning("%d bytes requested, but memory region is only %d bytes\n", size, wsize);
|
||||
imsg_warning("Only %d bytes will actually be written\n", wsize);
|
||||
}
|
||||
|
||||
|
||||
|
@ -959,8 +938,7 @@ int avr_write_mem(const PROGRAMMER *pgm, const AVRPART *p, const AVRMEM *m, int
|
|||
/* paged write failed, fall back to byte-at-a-time write below */
|
||||
failure = 1;
|
||||
} else {
|
||||
avrdude_message(MSG_DEBUG, "%s: avr_write_mem(): skipping page %u: no interesting data\n",
|
||||
progname, pageaddr / m->page_size);
|
||||
pmsg_debug("avr_write_mem(): skipping page %u: no interesting data\n", pageaddr / m->page_size);
|
||||
}
|
||||
nwritten++;
|
||||
report_progress(nwritten, npages, NULL);
|
||||
|
@ -1019,8 +997,7 @@ int avr_write_mem(const PROGRAMMER *pgm, const AVRPART *p, const AVRMEM *m, int
|
|||
if (do_write) {
|
||||
rc = avr_write_byte(pgm, p, m, i, data);
|
||||
if (rc) {
|
||||
avrdude_message(MSG_INFO, " ***failed; ");
|
||||
avrdude_message(MSG_INFO, "\n");
|
||||
msg_error(" ***failed;\n");
|
||||
pgm->err_led(pgm, ON);
|
||||
werror = 1;
|
||||
}
|
||||
|
@ -1033,11 +1010,8 @@ int avr_write_mem(const PROGRAMMER *pgm, const AVRPART *p, const AVRMEM *m, int
|
|||
if (flush_page) {
|
||||
rc = avr_write_page(pgm, p, m, i);
|
||||
if (rc) {
|
||||
avrdude_message(MSG_INFO, " *** page %d (addresses 0x%04x - 0x%04x) failed "
|
||||
"to write\n",
|
||||
i % m->page_size,
|
||||
i - m->page_size + 1, i);
|
||||
avrdude_message(MSG_INFO, "\n");
|
||||
msg_error(" *** page %d (addresses 0x%04x - 0x%04x) failed to write\n\n",
|
||||
i / m->page_size, i - m->page_size + 1, i);
|
||||
pgm->err_led(pgm, ON);
|
||||
werror = 1;
|
||||
}
|
||||
|
@ -1066,8 +1040,7 @@ int avr_signature(const PROGRAMMER *pgm, const AVRPART *p) {
|
|||
report_progress (0,1,"Reading");
|
||||
rc = avr_read(pgm, p, "signature", 0);
|
||||
if (rc < LIBAVRDUDE_SUCCESS) {
|
||||
avrdude_message(MSG_INFO, "%s: error reading signature data for part \"%s\", rc=%d\n",
|
||||
progname, p->desc, rc);
|
||||
pmsg_error("unable to read signature data for part %s, rc=%d\n", p->desc, rc);
|
||||
return rc;
|
||||
}
|
||||
report_progress (1,1,NULL);
|
||||
|
@ -1121,15 +1094,13 @@ int avr_verify(const AVRPART * p, const AVRPART * v, const char * memtype, int s
|
|||
|
||||
a = avr_locate_mem(p, memtype);
|
||||
if (a == NULL) {
|
||||
avrdude_message(MSG_INFO, "avr_verify(): memory type \"%s\" not defined for part %s\n",
|
||||
memtype, p->desc);
|
||||
pmsg_error("memory type %s not defined for part %s\n", memtype, p->desc);
|
||||
return -1;
|
||||
}
|
||||
|
||||
b = avr_locate_mem(v, memtype);
|
||||
if (b == NULL) {
|
||||
avrdude_message(MSG_INFO, "avr_verify(): memory type \"%s\" not defined for part %s\n",
|
||||
memtype, v->desc);
|
||||
pmsg_error("memory type %s not defined for part %s\n", memtype, v->desc);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -1138,40 +1109,32 @@ int avr_verify(const AVRPART * p, const AVRPART * v, const char * memtype, int s
|
|||
vsize = a->size;
|
||||
|
||||
if (vsize < size) {
|
||||
avrdude_message(MSG_INFO, "%s: WARNING: requested verification for %d bytes\n"
|
||||
"%s%s memory region only contains %d bytes\n"
|
||||
"%sOnly %d bytes will be verified.\n",
|
||||
progname, size,
|
||||
progbuf, memtype, vsize,
|
||||
progbuf, vsize);
|
||||
pmsg_warning("requested verification for %d bytes\n", size);
|
||||
imsg_warning("%s memory region only contains %d bytes\n", memtype, vsize);
|
||||
imsg_warning("only %d bytes will be verified\n", vsize);
|
||||
size = vsize;
|
||||
}
|
||||
|
||||
for (i=0; i<size; i++) {
|
||||
if ((b->tags[i] & TAG_ALLOCATED) != 0 &&
|
||||
buf1[i] != buf2[i]) {
|
||||
if ((b->tags[i] & TAG_ALLOCATED) != 0 && buf1[i] != buf2[i]) {
|
||||
uint8_t bitmask = get_fuse_bitmask(a);
|
||||
if((buf1[i] & bitmask) != (buf2[i] & bitmask)) {
|
||||
// Mismatch is not just in unused bits
|
||||
avrdude_message(MSG_INFO, "%s: verification error, first mismatch at byte 0x%04x\n"
|
||||
"%s0x%02x != 0x%02x\n",
|
||||
progname, i,
|
||||
progbuf, buf1[i], buf2[i]);
|
||||
pmsg_error("verification mismatch, first encountered at addr 0x%04x\n", i);
|
||||
imsg_error("device 0x%02x != input 0x%02x\n", buf1[i], buf2[i]);
|
||||
return -1;
|
||||
} else {
|
||||
// Mismatch is only in unused bits
|
||||
if ((buf1[i] | bitmask) != 0xff) {
|
||||
// Programmer returned unused bits as 0, must be the part/programmer
|
||||
avrdude_message(MSG_INFO, "%s: WARNING: ignoring mismatch in unused bits of \"%s\"\n"
|
||||
"%s(0x%02x != 0x%02x). To prevent this warning fix the part\n"
|
||||
"%sor programmer definition in the config file.\n",
|
||||
progname, memtype, progbuf, buf1[i], buf2[i], progbuf);
|
||||
pmsg_warning("ignoring mismatch in unused bits of %s\n", memtype);
|
||||
imsg_warning("(device 0x%02x != input 0x%02x); to prevent this warning fix\n", buf1[i], buf2[i]);
|
||||
imsg_warning("the part or programmer definition in the config file\n");
|
||||
} else {
|
||||
// Programmer returned unused bits as 1, must be the user
|
||||
avrdude_message(MSG_INFO, "%s: WARNING: ignoring mismatch in unused bits of \"%s\"\n"
|
||||
"%s(0x%02x != 0x%02x). To prevent this warning set unused bits\n"
|
||||
"%sto 1 when writing (double check with your datasheet first).\n",
|
||||
progname, memtype, progbuf, buf1[i], buf2[i], progbuf);
|
||||
pmsg_warning("ignoring mismatch in unused bits of %s\n", memtype);
|
||||
imsg_warning("(device 0x%02x != input 0x%02x); to prevent this warning set\n", buf1[i], buf2[i]);
|
||||
imsg_warning("unused bits to 1 when writing (double check with datasheet)\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1196,8 +1159,7 @@ int avr_get_cycle_count(const PROGRAMMER *pgm, const AVRPART *p, int *cycles) {
|
|||
for (i=4; i>0; i--) {
|
||||
rc = pgm->read_byte(pgm, p, a, a->size-i, &v1);
|
||||
if (rc < 0) {
|
||||
avrdude_message(MSG_INFO, "%s: WARNING: can't read memory for cycle count, rc=%d\n",
|
||||
progname, rc);
|
||||
pmsg_warning("cannot read memory for cycle count, rc=%d\n", rc);
|
||||
return -1;
|
||||
}
|
||||
cycle_count = (cycle_count << 8) | v1;
|
||||
|
@ -1236,8 +1198,7 @@ int avr_put_cycle_count(const PROGRAMMER *pgm, const AVRPART *p, int cycles) {
|
|||
|
||||
rc = avr_write_byte(pgm, p, a, a->size-i, v1);
|
||||
if (rc < 0) {
|
||||
avrdude_message(MSG_INFO, "%s: WARNING: can't write memory for cycle count, rc=%d\n",
|
||||
progname, rc);
|
||||
pmsg_warning("cannot write memory for cycle count, rc=%d\n", rc);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
@ -1270,9 +1231,7 @@ void avr_add_mem_order(const char *str) {
|
|||
return;
|
||||
}
|
||||
}
|
||||
avrdude_message(MSG_INFO,
|
||||
"%s: avr_mem_order[] under-dimensioned in avr.c; increase and recompile\n",
|
||||
progname);
|
||||
pmsg_error("avr_mem_order[] under-dimensioned in avr.c; increase and recompile\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
|
52
src/avr910.c
52
src/avr910.c
|
@ -57,8 +57,7 @@ struct pdata
|
|||
static void avr910_setup(PROGRAMMER * pgm)
|
||||
{
|
||||
if ((pgm->cookie = malloc(sizeof(struct pdata))) == 0) {
|
||||
avrdude_message(MSG_INFO, "%s: avr910_setup(): Out of memory allocating private data\n",
|
||||
progname);
|
||||
pmsg_error("out of memory allocating private data\n");
|
||||
exit(1);
|
||||
}
|
||||
memset(pgm->cookie, 0, sizeof(struct pdata));
|
||||
|
@ -81,8 +80,7 @@ static int avr910_recv(const PROGRAMMER *pgm, char *buf, size_t len) {
|
|||
|
||||
rv = serial_recv(&pgm->fd, (unsigned char *)buf, len);
|
||||
if (rv < 0) {
|
||||
avrdude_message(MSG_INFO, "%s: avr910_recv(): programmer is not responding\n",
|
||||
progname);
|
||||
pmsg_error("programmer is not responding\n");
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
|
@ -99,8 +97,7 @@ static int avr910_vfy_cmd_sent(const PROGRAMMER *pgm, char *errmsg) {
|
|||
|
||||
avr910_recv(pgm, &c, 1);
|
||||
if (c != '\r') {
|
||||
avrdude_message(MSG_INFO, "%s: error: programmer did not respond to command: %s\n",
|
||||
progname, errmsg);
|
||||
pmsg_error("programmer did not respond to command: %s\n", errmsg);
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
|
@ -176,16 +173,16 @@ static int avr910_initialize(const PROGRAMMER *pgm, const AVRPART *p) {
|
|||
avr910_send(pgm, "p", 1);
|
||||
avr910_recv(pgm, &type, 1);
|
||||
|
||||
avrdude_message(MSG_INFO, "Found programmer: Id = \"%s\"; type = %c\n", id, type);
|
||||
avrdude_message(MSG_INFO, " Software Version = %c.%c; ", sw[0], sw[1]);
|
||||
avrdude_message(MSG_INFO, "Hardware Version = %c.%c\n", hw[0], hw[1]);
|
||||
msg_notice("Programmer id = %s; type = %c\n", id, type);
|
||||
msg_notice("Software version = %c.%c; ", sw[0], sw[1]);
|
||||
msg_notice("Hardware version = %c.%c\n", hw[0], hw[1]);
|
||||
|
||||
/* See if programmer supports autoincrement of address. */
|
||||
|
||||
avr910_send(pgm, "a", 1);
|
||||
avr910_recv(pgm, &PDATA(pgm)->has_auto_incr_addr, 1);
|
||||
if (PDATA(pgm)->has_auto_incr_addr == 'Y')
|
||||
avrdude_message(MSG_NOTICE, "Programmer supports auto addr increment.\n");
|
||||
msg_notice("programmer supports auto addr increment\n");
|
||||
|
||||
/* Check support for buffered memory access, ignore if not available */
|
||||
|
||||
|
@ -197,8 +194,8 @@ static int avr910_initialize(const PROGRAMMER *pgm, const AVRPART *p) {
|
|||
PDATA(pgm)->buffersize = (unsigned int)(unsigned char)c<<8;
|
||||
avr910_recv(pgm, &c, 1);
|
||||
PDATA(pgm)->buffersize += (unsigned int)(unsigned char)c;
|
||||
avrdude_message(MSG_NOTICE, "Programmer supports buffered memory access with "
|
||||
"buffersize = %u bytes.\n",
|
||||
msg_notice("programmer supports buffered memory access with "
|
||||
"buffersize = %u bytes\n",
|
||||
PDATA(pgm)->buffersize);
|
||||
PDATA(pgm)->use_blockmode = 1;
|
||||
} else {
|
||||
|
@ -215,7 +212,7 @@ static int avr910_initialize(const PROGRAMMER *pgm, const AVRPART *p) {
|
|||
/* Get list of devices that the programmer supports. */
|
||||
|
||||
avr910_send(pgm, "t", 1);
|
||||
avrdude_message(MSG_NOTICE, "\nProgrammer supports the following devices:\n");
|
||||
msg_notice2("\nProgrammer supports the following devices:\n");
|
||||
devtype_1st = 0;
|
||||
while (1) {
|
||||
avr910_recv(pgm, &c, 1);
|
||||
|
@ -225,21 +222,23 @@ static int avr910_initialize(const PROGRAMMER *pgm, const AVRPART *p) {
|
|||
break;
|
||||
part = locate_part_by_avr910_devcode(part_list, c);
|
||||
|
||||
avrdude_message(MSG_NOTICE, " Device code: 0x%02x = %s\n", c & 0xff, part? part->desc: "(unknown)");
|
||||
msg_notice2(" Device code: 0x%02x = %s\n", c & 0xff, part? part->desc: "(unknown)");
|
||||
|
||||
/* FIXME: Need to lookup devcode and report the device. */
|
||||
|
||||
if (p->avr910_devcode == c)
|
||||
dev_supported = 1;
|
||||
};
|
||||
avrdude_message(MSG_NOTICE, "\n");
|
||||
msg_notice2("\n");
|
||||
|
||||
if (!dev_supported) {
|
||||
avrdude_message(MSG_INFO, "%s: %s: selected device is not supported by programmer: %s\n",
|
||||
progname, ovsigck? "warning": "error", p->id);
|
||||
if (!ovsigck)
|
||||
if(ovsigck)
|
||||
pmsg_warning("selected device is not supported by programmer %s\n", p->id);
|
||||
else {
|
||||
pmsg_error("selected device is not supported by programmer %s\n", p->id);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
/* If the user forced the selection, use the first device
|
||||
type that is supported by the programmer. */
|
||||
buf[1] = ovsigck? devtype_1st: p->avr910_devcode;
|
||||
|
@ -255,8 +254,7 @@ static int avr910_initialize(const PROGRAMMER *pgm, const AVRPART *p) {
|
|||
avr910_send(pgm, buf, 2);
|
||||
avr910_vfy_cmd_sent(pgm, "select device");
|
||||
|
||||
avrdude_message(MSG_NOTICE, "%s: avr910_devcode selected: 0x%02x\n",
|
||||
progname, (unsigned)buf[1]);
|
||||
pmsg_notice("avr910_devcode selected: 0x%02x\n", (unsigned) buf[1]);
|
||||
|
||||
avr910_enter_prog_mode(pgm);
|
||||
|
||||
|
@ -319,27 +317,23 @@ static int avr910_parseextparms(const PROGRAMMER *pgm, const LISTID extparms) {
|
|||
int devcode;
|
||||
if (sscanf(extended_param, "devcode=%i", &devcode) != 1 ||
|
||||
devcode <= 0 || devcode > 255) {
|
||||
avrdude_message(MSG_INFO, "%s: avr910_parseextparms(): invalid devcode '%s'\n",
|
||||
progname, extended_param);
|
||||
pmsg_error("invalid devcode '%s'\n", extended_param);
|
||||
rv = -1;
|
||||
continue;
|
||||
}
|
||||
avrdude_message(MSG_NOTICE2, "%s: avr910_parseextparms(): devcode overwritten as 0x%02x\n",
|
||||
progname, devcode);
|
||||
pmsg_notice2("avr910_parseextparms(): devcode overwritten as 0x%02x\n", devcode);
|
||||
PDATA(pgm)->devcode = devcode;
|
||||
|
||||
continue;
|
||||
}
|
||||
if (strncmp(extended_param, "no_blockmode", strlen("no_blockmode")) == 0) {
|
||||
avrdude_message(MSG_NOTICE2, "%s: avr910_parseextparms(-x): no testing for Blockmode\n",
|
||||
progname);
|
||||
pmsg_notice2("avr910_parseextparms(-x): no testing for Blockmode\n");
|
||||
PDATA(pgm)->test_blockmode = 0;
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
avrdude_message(MSG_INFO, "%s: avr910_parseextparms(): invalid extended parameter '%s'\n",
|
||||
progname, extended_param);
|
||||
pmsg_error("invalid extended parameter '%s'\n", extended_param);
|
||||
rv = -1;
|
||||
}
|
||||
|
||||
|
@ -708,7 +702,7 @@ static int avr910_read_sig_bytes(const PROGRAMMER *pgm, const AVRPART *p, const
|
|||
unsigned char tmp;
|
||||
|
||||
if (m->size < 3) {
|
||||
avrdude_message(MSG_INFO, "%s: memsize too small for sig byte read", progname);
|
||||
pmsg_error("memsize too small for sig byte read");
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
|
|
@ -222,14 +222,12 @@ static int cacheAddress(int addr, const AVR_Cache *cp, const AVRMEM *mem) {
|
|||
int cacheaddr = addr + (int) (mem->offset - cp->offset);
|
||||
|
||||
if(cacheaddr < 0 || cacheaddr >= cp->size) { // Should never happen (unless offsets wrong in avrdude.conf)
|
||||
avrdude_message(MSG_INFO, "%s: cacheAddress() %s cache address 0x%04x out of range [0, 0x%04x]\n",
|
||||
progname, mem->desc, cacheaddr, cp->size);
|
||||
pmsg_error("%s cache address 0x%04x out of range [0, 0x%04x]\n", mem->desc, cacheaddr, cp->size);
|
||||
return LIBAVRDUDE_GENERAL_FAILURE;
|
||||
}
|
||||
|
||||
if(mem->page_size != cp->page_size) { // Should never happen (unless incompatible page sizes in avrdude.conf)
|
||||
avrdude_message(MSG_INFO, "%s: cacheAddress() %s page size %d incompatible with cache page size %d\n",
|
||||
progname, mem->desc, mem->page_size, cp->page_size);
|
||||
pmsg_error("%s page size %d incompatible with cache page size %d\n", mem->desc, mem->page_size, cp->page_size);
|
||||
return LIBAVRDUDE_GENERAL_FAILURE;
|
||||
}
|
||||
|
||||
|
@ -246,8 +244,8 @@ static int loadCachePage(AVR_Cache *cp, const PROGRAMMER *pgm, const AVRPART *p,
|
|||
if(avr_read_page_default(pgm, p, mem, addr & ~(cp->page_size-1), cp->cont + cachebase) < 0) {
|
||||
report_progress(1, -1, NULL);
|
||||
if(nlOnErr && quell_progress)
|
||||
avrdude_message(MSG_INFO, "\n");
|
||||
avrdude_message(MSG_INFO, "%s: loadCachePage() %s read error at addr 0x%04x\n", progname, mem->desc, addr);
|
||||
msg_info("\n");
|
||||
pmsg_error("unable to read %s page at addr 0x%04x\n", mem->desc, addr);
|
||||
return LIBAVRDUDE_GENERAL_FAILURE;
|
||||
}
|
||||
|
||||
|
@ -280,8 +278,8 @@ static int writeCachePage(AVR_Cache *cp, const PROGRAMMER *pgm, const AVRPART *p
|
|||
if(avr_read_page_default(pgm, p, mem, base, cp->copy + base) < 0) {
|
||||
report_progress(1, -1, NULL);
|
||||
if(nlOnErr && quell_progress)
|
||||
avrdude_message(MSG_INFO, "\n");
|
||||
avrdude_message(MSG_INFO, "%s: writeCachePage() %s read error at addr 0x%04x\n", progname, mem->desc, base);
|
||||
msg_info("\n");
|
||||
pmsg_error("unable to read %s page at addr 0x%04x\n", mem->desc, base);
|
||||
return LIBAVRDUDE_GENERAL_FAILURE;
|
||||
}
|
||||
|
||||
|
@ -351,7 +349,7 @@ int avr_flush_cache(const PROGRAMMER *pgm, const AVRPART *p) {
|
|||
if(!chpages)
|
||||
return LIBAVRDUDE_SUCCESS;
|
||||
|
||||
avrdude_message(MSG_INFO, "%s: synching cache to device... ", progname);
|
||||
pmsg_info("synching cache to device ... ");
|
||||
fflush(stderr);
|
||||
|
||||
// Check whether page erase needed and working and whether chip erase needed
|
||||
|
@ -361,7 +359,9 @@ int avr_flush_cache(const PROGRAMMER *pgm, const AVRPART *p) {
|
|||
|
||||
if(!cp->cont) // Ensure cache is initialised from now on
|
||||
if(initCache(cp, pgm, p) < 0) {
|
||||
avrdude_message(MSG_INFO, "%s: initialising the cache failed\n", progname);
|
||||
if(quell_progress)
|
||||
msg_info("\n");
|
||||
pmsg_error("unable to initialise the cache\n");
|
||||
return LIBAVRDUDE_GENERAL_FAILURE;
|
||||
}
|
||||
|
||||
|
@ -394,13 +394,13 @@ int avr_flush_cache(const PROGRAMMER *pgm, const AVRPART *p) {
|
|||
}
|
||||
|
||||
if(!chpages) {
|
||||
avrdude_message(MSG_INFO, "done\n");
|
||||
msg_info("done\n");
|
||||
return LIBAVRDUDE_SUCCESS;
|
||||
}
|
||||
|
||||
if(chiperase) {
|
||||
if(quell_progress) {
|
||||
avrdude_message(MSG_INFO, "reading/chip erase/writing cycle needed ... ");
|
||||
msg_info("reading/chip erase/writing cycle needed ... ");
|
||||
fflush(stderr);
|
||||
}
|
||||
|
||||
|
@ -441,8 +441,8 @@ int avr_flush_cache(const PROGRAMMER *pgm, const AVRPART *p) {
|
|||
if(avr_chip_erase(pgm, p) < 0) {
|
||||
report_progress(1, -1, NULL);
|
||||
if(quell_progress)
|
||||
avrdude_message(MSG_INFO, "\n");
|
||||
avrdude_message(MSG_INFO, "%s: avr_flush_cache() chip erase failed\n", progname);
|
||||
msg_info("\n");
|
||||
pmsg_error("chip erase failed\n");
|
||||
return LIBAVRDUDE_GENERAL_FAILURE;
|
||||
}
|
||||
|
||||
|
@ -465,8 +465,8 @@ int avr_flush_cache(const PROGRAMMER *pgm, const AVRPART *p) {
|
|||
if(avr_read_page_default(pgm, p, mem, n, cp->copy + n) < 0) {
|
||||
report_progress(1, -1, NULL);
|
||||
if(quell_progress)
|
||||
avrdude_message(MSG_INFO, "\n");
|
||||
avrdude_message(MSG_INFO, "%s: flash read failed at addr 0x%04x\n", progname, n);
|
||||
msg_info("\n");
|
||||
pmsg_error("flash read failed at addr 0x%04x\n", n);
|
||||
return LIBAVRDUDE_GENERAL_FAILURE;
|
||||
}
|
||||
}
|
||||
|
@ -478,8 +478,8 @@ int avr_flush_cache(const PROGRAMMER *pgm, const AVRPART *p) {
|
|||
if(avr_read_page_default(pgm, p, mem, n, cp->copy + n) < 0) {
|
||||
report_progress(1, -1, NULL);
|
||||
if(quell_progress)
|
||||
avrdude_message(MSG_INFO, "\n");
|
||||
avrdude_message(MSG_INFO, "%s: EEPROM read failed at addr 0x%04x\n", progname, n);
|
||||
msg_info("\n");
|
||||
pmsg_error("EEPROM read failed at addr 0x%04x\n", n);
|
||||
return LIBAVRDUDE_GENERAL_FAILURE;
|
||||
}
|
||||
// EEPROM zapped by chip erase? Set all copy to 0xff
|
||||
|
@ -524,8 +524,8 @@ int avr_flush_cache(const PROGRAMMER *pgm, const AVRPART *p) {
|
|||
if(memcmp(cp->copy + n, cp->cont + n, cp->page_size)) {
|
||||
report_progress(1, -1, NULL);
|
||||
if(quell_progress)
|
||||
avrdude_message(MSG_INFO, "\n");
|
||||
avrdude_message(MSG_INFO, "%s: %s verification error at addr 0x%04x\n", progname, mem->desc, n);
|
||||
msg_info("\n");
|
||||
pmsg_error("verification mismatch at %s page addr 0x%04x\n", mem->desc, n);
|
||||
return LIBAVRDUDE_GENERAL_FAILURE;
|
||||
}
|
||||
report_progress(iwr++, nwr, NULL);
|
||||
|
@ -535,7 +535,7 @@ int avr_flush_cache(const PROGRAMMER *pgm, const AVRPART *p) {
|
|||
}
|
||||
report_progress(1, 0, NULL);
|
||||
|
||||
avrdude_message(MSG_INFO, quell_progress? "done\n": "\n");
|
||||
msg_info(quell_progress? "done\n": "\n");
|
||||
return LIBAVRDUDE_SUCCESS;
|
||||
}
|
||||
|
||||
|
|
|
@ -28,20 +28,62 @@
|
|||
#define USER_CONF_FILE ".avrduderc"
|
||||
#endif
|
||||
|
||||
extern char * progname; /* name of program, for messages */
|
||||
extern char progbuf[]; /* spaces same length as progname */
|
||||
extern char *progname; // name of program, for messages
|
||||
extern char progbuf[]; // spaces same length as progname
|
||||
|
||||
extern int ovsigck; /* override signature check (-F) */
|
||||
extern int verbose; /* verbosity level (-v, -vv, ...) */
|
||||
extern int quell_progress; /* quietness level (-q, -qq) */
|
||||
extern int ovsigck; // override signature check (-F)
|
||||
extern int verbose; // verbosity level (-v, -vv, ...)
|
||||
extern int quell_progress; // quell progress report -q, reduce effective verbosity level (-qq, -qqq)
|
||||
|
||||
int avrdude_message(const int msglvl, const char *format, ...);
|
||||
int avrdude_message(int msglvl, const char *format, ...);
|
||||
int avrdude_message2(const char *fname, int msgmode, int msglvl, const char *format, ...);
|
||||
|
||||
#define MSG_INFO (0) /* no -v option, can be suppressed with -qq */
|
||||
#define MSG_NOTICE (1) /* displayed with -v */
|
||||
#define MSG_NOTICE2 (2) /* displayed with -vv, used rarely */
|
||||
#define MSG_DEBUG (3) /* displayed with -vvv */
|
||||
#define MSG_TRACE (4) /* displayed with -vvvv, show trace communication */
|
||||
#define MSG_TRACE2 (5) /* displayed with -vvvvv */
|
||||
#define MSG_EXT_ERROR (-3) // OS-type error, no -v option, can be suppressed with -qqqqq
|
||||
#define MSG_ERROR (-2) // Avrdude error, no -v option, can be suppressed with -qqqq
|
||||
#define MSG_WARNING (-1) // Warning, no -v option, can be suppressed with -qqq
|
||||
#define MSG_INFO 0 // Commentary, no -v option, can be suppressed with -qq
|
||||
#define MSG_NOTICE 1 // Displayed with -v
|
||||
#define MSG_NOTICE2 2 // Displayed with -vv
|
||||
#define MSG_DEBUG 3 // Displayed with -vvv
|
||||
#define MSG_TRACE 4 // Displayed with -vvvv, show trace communication
|
||||
#define MSG_TRACE2 5 // Displayed with -vvvvv
|
||||
|
||||
#define MSG2_PROGNAME 1 // Start by printing progname
|
||||
#define MSG2_FUNCTION 2 // Print calling function (1st arg) after progname
|
||||
#define MSG2_TYPE 4 // Print message type after function or progname
|
||||
#define MSG2_INDENT1 8 // Start by printing indentation of progname+1 blanks
|
||||
#define MSG2_INDENT2 16 // Start by printing indentation of progname+2 blanks
|
||||
#define MSG2_FLUSH 32 // Flush before and after printing
|
||||
|
||||
// Shortcuts
|
||||
#define msg_ext_error(...) avrdude_message2(__func__, 0, MSG_EXT_ERROR, __VA_ARGS__)
|
||||
#define msg_error(...) avrdude_message2(__func__, 0, MSG_ERROR, __VA_ARGS__)
|
||||
#define msg_warning(...) avrdude_message2(__func__, 0, MSG_WARNING, __VA_ARGS__)
|
||||
#define msg_info(...) avrdude_message2(__func__, 0, MSG_INFO, __VA_ARGS__)
|
||||
#define msg_notice(...) avrdude_message2(__func__, 0, MSG_NOTICE, __VA_ARGS__)
|
||||
#define msg_notice2(...) avrdude_message2(__func__, 0, MSG_NOTICE2, __VA_ARGS__)
|
||||
#define msg_debug(...) avrdude_message2(__func__, 0, MSG_DEBUG, __VA_ARGS__)
|
||||
#define msg_trace(...) avrdude_message2(__func__, 0, MSG_TRACE, __VA_ARGS__)
|
||||
#define msg_trace2(...) avrdude_message2(__func__, 0, MSG_TRACE2, __VA_ARGS__)
|
||||
|
||||
#define pmsg_ext_error(...) avrdude_message2(__func__, MSG2_PROGNAME|MSG2_FUNCTION|MSG2_TYPE|MSG2_FLUSH, MSG_EXT_ERROR, __VA_ARGS__)
|
||||
#define pmsg_error(...) avrdude_message2(__func__, MSG2_PROGNAME|MSG2_FUNCTION|MSG2_TYPE|MSG2_FLUSH, MSG_ERROR, __VA_ARGS__)
|
||||
#define pmsg_warning(...) avrdude_message2(__func__, MSG2_PROGNAME|MSG2_FUNCTION|MSG2_TYPE|MSG2_FLUSH, MSG_WARNING, __VA_ARGS__)
|
||||
#define pmsg_info(...) avrdude_message2(__func__, MSG2_PROGNAME|MSG2_FLUSH, MSG_INFO, __VA_ARGS__)
|
||||
#define pmsg_notice(...) avrdude_message2(__func__, MSG2_PROGNAME|MSG2_FLUSH, MSG_NOTICE, __VA_ARGS__)
|
||||
#define pmsg_notice2(...) avrdude_message2(__func__, MSG2_PROGNAME|MSG2_FLUSH, MSG_NOTICE2, __VA_ARGS__)
|
||||
#define pmsg_debug(...) avrdude_message2(__func__, MSG2_PROGNAME|MSG2_FLUSH, MSG_DEBUG, __VA_ARGS__)
|
||||
#define pmsg_trace(...) avrdude_message2(__func__, MSG2_PROGNAME|MSG2_FLUSH, MSG_TRACE, __VA_ARGS__)
|
||||
#define pmsg_trace2(...) avrdude_message2(__func__, MSG2_PROGNAME|MSG2_FLUSH, MSG_TRACE2, __VA_ARGS__)
|
||||
|
||||
#define imsg_ext_error(...) avrdude_message2(__func__, MSG2_INDENT1|MSG2_FLUSH, MSG_EXT_ERROR, __VA_ARGS__)
|
||||
#define imsg_error(...) avrdude_message2(__func__, MSG2_INDENT1|MSG2_FLUSH, MSG_ERROR, __VA_ARGS__)
|
||||
#define imsg_warning(...) avrdude_message2(__func__, MSG2_INDENT1|MSG2_FLUSH, MSG_WARNING, __VA_ARGS__)
|
||||
#define imsg_info(...) avrdude_message2(__func__, MSG2_INDENT2|MSG2_FLUSH, MSG_INFO, __VA_ARGS__)
|
||||
#define imsg_notice(...) avrdude_message2(__func__, MSG2_INDENT2|MSG2_FLUSH, MSG_NOTICE, __VA_ARGS__)
|
||||
#define imsg_notice2(...) avrdude_message2(__func__, MSG2_INDENT2|MSG2_FLUSH, MSG_NOTICE2, __VA_ARGS__)
|
||||
#define imsg_debug(...) avrdude_message2(__func__, MSG2_INDENT2|MSG2_FLUSH, MSG_DEBUG, __VA_ARGS__)
|
||||
#define imsg_trace(...) avrdude_message2(__func__, MSG2_INDENT2|MSG2_FLUSH, MSG_TRACE, __VA_ARGS__)
|
||||
#define imsg_trace2(...) avrdude_message2(__func__, MSG2_INDENT2|MSG2_FLUSH, MSG_TRACE2, __VA_ARGS__)
|
||||
|
||||
#endif
|
||||
|
|
|
@ -51,9 +51,7 @@
|
|||
#ifdef DO_NOT_BUILD_AVRFTDI
|
||||
|
||||
static int avrftdi_noftdi_open(PROGRAMMER *pgm, const char *name) {
|
||||
avrdude_message(MSG_INFO, "%s: Error: no libftdi or libusb support. Install libftdi1/libusb-1.0 or libftdi/libusb and run configure/make again.\n",
|
||||
progname);
|
||||
|
||||
pmsg_error("no libftdi or libusb support; install libftdi1/libusb-1.0 or libftdi/libusb and run configure/make again\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -140,14 +138,14 @@ void avrftdi_log(int level, const char * func, int line,
|
|||
if(!skip_prefix)
|
||||
{
|
||||
switch(level) {
|
||||
case ERR: avrdude_message(MSG_INFO, "E "); break;
|
||||
case WARN: avrdude_message(MSG_INFO, "W "); break;
|
||||
case INFO: avrdude_message(MSG_INFO, "I "); break;
|
||||
case DEBUG: avrdude_message(MSG_INFO, "D "); break;
|
||||
case TRACE: avrdude_message(MSG_INFO, "T "); break;
|
||||
default: avrdude_message(MSG_INFO, " "); break;
|
||||
case ERR: msg_error("E "); break;
|
||||
case WARN: msg_error("W "); break;
|
||||
case INFO: msg_error("I "); break;
|
||||
case DEBUG: msg_error("D "); break;
|
||||
case TRACE: msg_error("T "); break;
|
||||
default: msg_error(" "); break;
|
||||
}
|
||||
avrdude_message(MSG_INFO, "%s(%d): ", func, line);
|
||||
msg_error("%s(%d): ", func, line);
|
||||
}
|
||||
va_start(ap, fmt);
|
||||
vfprintf(stderr, fmt, ap);
|
||||
|
@ -170,16 +168,16 @@ static void buf_dump(const unsigned char *buf, int len, char *desc,
|
|||
int offset, int width)
|
||||
{
|
||||
int i;
|
||||
avrdude_message(MSG_INFO, "%s begin:\n", desc);
|
||||
msg_info("%s begin:\n", desc);
|
||||
for (i = 0; i < offset; i++)
|
||||
avrdude_message(MSG_INFO, "%02x ", buf[i]);
|
||||
avrdude_message(MSG_INFO, "\n");
|
||||
msg_info("%02x ", buf[i]);
|
||||
msg_info("\n");
|
||||
for (i++; i <= len; i++) {
|
||||
avrdude_message(MSG_INFO, "%02x ", buf[i-1]);
|
||||
msg_info("%02x ", buf[i-1]);
|
||||
if((i-offset) != 0 && (i-offset)%width == 0)
|
||||
avrdude_message(MSG_INFO, "\n");
|
||||
msg_info("\n");
|
||||
}
|
||||
avrdude_message(MSG_INFO, "%s end\n", desc);
|
||||
msg_info("%s end\n", desc);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -347,7 +345,7 @@ static int avrftdi_transmit_bb(const PROGRAMMER *pgm, unsigned char mode, const
|
|||
size_t max_size = MIN(pdata->ftdic->max_packet_size, (unsigned int) pdata->tx_buffer_size);
|
||||
// select block size so that resulting commands does not exceed max_size if possible
|
||||
blocksize = MAX(1,(max_size-7)/((8*2*6)+(8*1*2)));
|
||||
//avrdude_message(MSG_INFO, "blocksize %d \n",blocksize);
|
||||
// msg_info("blocksize %d \n", blocksize);
|
||||
|
||||
unsigned char* send_buffer = alloca((8 * 2 * 6) * blocksize + (8 * 1 * 2) * blocksize + 7);
|
||||
unsigned char* recv_buffer = alloca(2 * 16 * blocksize);
|
||||
|
@ -611,7 +609,8 @@ static int avrftdi_pin_setup(const PROGRAMMER *pgm) {
|
|||
}
|
||||
|
||||
pdata->use_bitbanging = !pin_check_mpsse;
|
||||
if (pdata->use_bitbanging) log_info("Because of pin configuration fallback to bitbanging mode.\n");
|
||||
if (pdata->use_bitbanging)
|
||||
log_info("Because of pin configuration fallback to bitbanging mode.\n");
|
||||
|
||||
/*
|
||||
* TODO: No need to fail for a wrongly configured led or something.
|
||||
|
@ -659,8 +658,7 @@ static int avrftdi_open(PROGRAMMER *pgm, const char *port) {
|
|||
if (usbpid) {
|
||||
pid = *(int *)(ldata(usbpid));
|
||||
if (lnext(usbpid))
|
||||
avrdude_message(MSG_INFO, "%s: Warning: using PID 0x%04x, ignoring remaining PIDs in list\n",
|
||||
progname, pid);
|
||||
pmsg_warning("using PID 0x%04x, ignoring remaining PIDs in list\n", pid);
|
||||
} else
|
||||
pid = USB_DEVICE_FT2232;
|
||||
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
#elif defined(HAVE_LIBFTDI)
|
||||
#include <ftdi.h>
|
||||
#else
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma message("No libftdi or libusb support. Install libftdi1/libusb-1.0 or libftdi/libusb and run configure/make again.")
|
||||
#else
|
||||
|
@ -43,7 +44,7 @@ enum { ERR, WARN, INFO, DEBUG, TRACE };
|
|||
do { \
|
||||
if ((x)) \
|
||||
{ \
|
||||
avrdude_message(MSG_INFO, "%s:%d %s() %s: %s (%d)\n\t%s\n", \
|
||||
msg_error("%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 +55,7 @@ enum { ERR, WARN, INFO, DEBUG, TRACE };
|
|||
do { \
|
||||
if ((x)) \
|
||||
{ \
|
||||
avrdude_message(MSG_INFO, "%s:%d %s() %s: %s (%d)\n\t%s\n", \
|
||||
msg_error("%s:%d %s() %s: %s (%d)\n\t%s\n", \
|
||||
__FILE__, __LINE__, __FUNCTION__, \
|
||||
#x, strerror(errno), errno, ftdi_get_error_string(ftdi)); \
|
||||
} \
|
||||
|
|
|
@ -538,7 +538,7 @@ void avr_mem_display(const char *prefix, FILE *f, const AVRMEM *m,
|
|||
m->readback[1]);
|
||||
}
|
||||
if (verbose > 4) {
|
||||
avrdude_message(MSG_TRACE2, "%s Memory Ops:\n"
|
||||
msg_trace2("%s Memory Ops:\n"
|
||||
"%s Oeration Inst Bit Bit Type Bitno Value\n"
|
||||
"%s ----------- -------- -------- ----- -----\n",
|
||||
prefix, prefix, prefix);
|
||||
|
|
|
@ -76,8 +76,7 @@ static void bitbang_calibrate_delay(void)
|
|||
if (QueryPerformanceFrequency(&freq))
|
||||
{
|
||||
has_perfcount = 1;
|
||||
avrdude_message(MSG_NOTICE2, "%s: Using performance counter for bitbang delays\n",
|
||||
progname);
|
||||
pmsg_notice2("using performance counter for bitbang delays\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -90,16 +89,14 @@ static void bitbang_calibrate_delay(void)
|
|||
* auto-calibration figures seen on various Unix systems on
|
||||
* comparable hardware.
|
||||
*/
|
||||
avrdude_message(MSG_NOTICE2, "%s: Using guessed per-microsecond delay count for bitbang delays\n",
|
||||
progname);
|
||||
pmsg_notice2("using guessed per-microsecond delay count for bitbang delays\n");
|
||||
delay_decrement = 100;
|
||||
}
|
||||
#else /* !WIN32 */
|
||||
struct itimerval itv;
|
||||
volatile int i;
|
||||
|
||||
avrdude_message(MSG_NOTICE2, "%s: Calibrating delay loop...",
|
||||
progname);
|
||||
pmsg_notice2("calibrating delay loop ...");
|
||||
i = 0;
|
||||
done = 0;
|
||||
saved_alarmhandler = signal(SIGALRM, alarmhandler);
|
||||
|
@ -125,7 +122,7 @@ static void bitbang_calibrate_delay(void)
|
|||
* Calculate back from 100 ms to 1 us.
|
||||
*/
|
||||
delay_decrement = -i / 100000;
|
||||
avrdude_message(MSG_NOTICE2, " calibrated to %d cycles per us\n",
|
||||
msg_notice2(" calibrated to %d cycles per us\n",
|
||||
delay_decrement);
|
||||
#endif /* WIN32 */
|
||||
}
|
||||
|
@ -261,7 +258,7 @@ int bitbang_tpi_rx(const PROGRAMMER *pgm) {
|
|||
break;
|
||||
}
|
||||
if (b != 0) {
|
||||
avrdude_message(MSG_INFO, "bitbang_tpi_rx: start bit not received correctly\n");
|
||||
pmsg_error("start bit not received correctly\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -276,7 +273,7 @@ int bitbang_tpi_rx(const PROGRAMMER *pgm) {
|
|||
|
||||
/* parity bit */
|
||||
if (bitbang_tpi_clk(pgm) != parity) {
|
||||
avrdude_message(MSG_INFO, "bitbang_tpi_rx: parity bit is wrong\n");
|
||||
pmsg_error("parity bit is wrong\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -285,7 +282,7 @@ int bitbang_tpi_rx(const PROGRAMMER *pgm) {
|
|||
b &= bitbang_tpi_clk(pgm);
|
||||
b &= bitbang_tpi_clk(pgm);
|
||||
if (b != 1) {
|
||||
avrdude_message(MSG_INFO, "bitbang_tpi_rx: stop bits not received correctly\n");
|
||||
pmsg_error("stop bits not received correctly\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -328,15 +325,15 @@ int bitbang_cmd(const PROGRAMMER *pgm, const unsigned char *cmd,
|
|||
|
||||
if(verbose >= 2)
|
||||
{
|
||||
avrdude_message(MSG_NOTICE2, "bitbang_cmd(): [ ");
|
||||
msg_notice2("bitbang_cmd(): [ ");
|
||||
for(i = 0; i < 4; i++)
|
||||
avrdude_message(MSG_NOTICE2, "%02X ", cmd[i]);
|
||||
avrdude_message(MSG_NOTICE2, "] [ ");
|
||||
msg_notice2("%02X ", cmd[i]);
|
||||
msg_notice2("] [ ");
|
||||
for(i = 0; i < 4; i++)
|
||||
{
|
||||
avrdude_message(MSG_NOTICE2, "%02X ", res[i]);
|
||||
msg_notice2("%02X ", res[i]);
|
||||
}
|
||||
avrdude_message(MSG_NOTICE2, "]\n");
|
||||
msg_notice2("]\n");
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -363,15 +360,15 @@ int bitbang_cmd_tpi(const PROGRAMMER *pgm, const unsigned char *cmd,
|
|||
|
||||
if(verbose >= 2)
|
||||
{
|
||||
avrdude_message(MSG_NOTICE2, "bitbang_cmd_tpi(): [ ");
|
||||
msg_notice2("bitbang_cmd_tpi(): [ ");
|
||||
for(i = 0; i < cmd_len; i++)
|
||||
avrdude_message(MSG_NOTICE2, "%02X ", cmd[i]);
|
||||
avrdude_message(MSG_NOTICE2, "] [ ");
|
||||
msg_notice2("%02X ", cmd[i]);
|
||||
msg_notice2("] [ ");
|
||||
for(i = 0; i < res_len; i++)
|
||||
{
|
||||
avrdude_message(MSG_NOTICE2, "%02X ", res[i]);
|
||||
msg_notice2("%02X ", res[i]);
|
||||
}
|
||||
avrdude_message(MSG_NOTICE2, "]\n");
|
||||
msg_notice2("]\n");
|
||||
}
|
||||
|
||||
pgm->pgm_led(pgm, OFF);
|
||||
|
@ -399,15 +396,15 @@ int bitbang_spi(const PROGRAMMER *pgm, const unsigned char *cmd,
|
|||
|
||||
if(verbose >= 2)
|
||||
{
|
||||
avrdude_message(MSG_NOTICE2, "bitbang_cmd(): [ ");
|
||||
msg_notice2("bitbang_cmd(): [ ");
|
||||
for(i = 0; i < count; i++)
|
||||
avrdude_message(MSG_NOTICE2, "%02X ", cmd[i]);
|
||||
avrdude_message(MSG_NOTICE2, "] [ ");
|
||||
msg_notice2("%02X ", cmd[i]);
|
||||
msg_notice2("] [ ");
|
||||
for(i = 0; i < count; i++)
|
||||
{
|
||||
avrdude_message(MSG_NOTICE2, "%02X ", res[i]);
|
||||
msg_notice2("%02X ", res[i]);
|
||||
}
|
||||
avrdude_message(MSG_NOTICE2, "]\n");
|
||||
msg_notice2("]\n");
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -434,8 +431,7 @@ int bitbang_chip_erase(const PROGRAMMER *pgm, const AVRPART *p) {
|
|||
/* Set Pointer Register */
|
||||
mem = avr_locate_mem(p, "flash");
|
||||
if (mem == NULL) {
|
||||
avrdude_message(MSG_INFO, "No flash memory to erase for part %s\n",
|
||||
p->desc);
|
||||
pmsg_error("no flash memory to erase for part %s\n", p->desc);
|
||||
return -1;
|
||||
}
|
||||
bitbang_tpi_tx(pgm, TPI_CMD_SSTPR | 0);
|
||||
|
@ -455,8 +451,7 @@ int bitbang_chip_erase(const PROGRAMMER *pgm, const AVRPART *p) {
|
|||
}
|
||||
|
||||
if (p->op[AVR_OP_CHIP_ERASE] == NULL) {
|
||||
avrdude_message(MSG_INFO, "chip erase instruction not defined for part \"%s\"\n",
|
||||
p->desc);
|
||||
pmsg_error("chip erase instruction not defined for part %s\n", p->desc);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -495,8 +490,7 @@ int bitbang_program_enable(const PROGRAMMER *pgm, const AVRPART *p) {
|
|||
}
|
||||
|
||||
if (p->op[AVR_OP_PGM_ENABLE] == NULL) {
|
||||
avrdude_message(MSG_INFO, "program enable instruction not defined for part \"%s\"\n",
|
||||
p->desc);
|
||||
pmsg_error("program enable instruction not defined for part %s\n", p->desc);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -527,8 +521,7 @@ int bitbang_initialize(const PROGRAMMER *pgm, const AVRPART *p) {
|
|||
if (p->prog_modes & PM_TPI) {
|
||||
/* make sure cmd_tpi() is defined */
|
||||
if (pgm->cmd_tpi == NULL) {
|
||||
avrdude_message(MSG_INFO, "%s: Error: %s programmer does not support TPI\n",
|
||||
progname, pgm->type);
|
||||
pmsg_error("%s programmer does not support TPI\n", pgm->type);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -539,20 +532,20 @@ int bitbang_initialize(const PROGRAMMER *pgm, const AVRPART *p) {
|
|||
/* RESET must be LOW in case the existing code is driving the TPI pins: */
|
||||
pgm->setpin(pgm, PIN_AVR_RESET, 0);
|
||||
|
||||
avrdude_message(MSG_NOTICE2, "doing MOSI-MISO link check\n");
|
||||
msg_notice2("doing MOSI-MISO link check\n");
|
||||
|
||||
pgm->setpin(pgm, PIN_AVR_MOSI, 0);
|
||||
if (pgm->getpin(pgm, PIN_AVR_MISO) != 0) {
|
||||
avrdude_message(MSG_INFO, "MOSI->MISO 0 failed\n");
|
||||
pmsg_error("MOSI->MISO 0 failed\n");
|
||||
return -1;
|
||||
}
|
||||
pgm->setpin(pgm, PIN_AVR_MOSI, 1);
|
||||
if (pgm->getpin(pgm, PIN_AVR_MISO) != 1) {
|
||||
avrdude_message(MSG_INFO, "MOSI->MISO 1 failed\n");
|
||||
pmsg_error("MOSI->MISO 1 failed\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
avrdude_message(MSG_NOTICE2, "MOSI-MISO link present\n");
|
||||
msg_notice2("MOSI-MISO link present\n");
|
||||
}
|
||||
|
||||
pgm->setpin(pgm, PIN_AVR_SCK, 0);
|
||||
|
@ -573,7 +566,7 @@ int bitbang_initialize(const PROGRAMMER *pgm, const AVRPART *p) {
|
|||
bitbang_tpi_tx(pgm, TPI_CMD_SLDCS | TPI_REG_TPIIR);
|
||||
rc = bitbang_tpi_rx(pgm);
|
||||
if (rc != 0x80) {
|
||||
avrdude_message(MSG_INFO, "TPIIR not correct\n");
|
||||
pmsg_error("TPIIR not correct\n");
|
||||
return -1;
|
||||
}
|
||||
} else {
|
||||
|
@ -607,7 +600,7 @@ int bitbang_initialize(const PROGRAMMER *pgm, const AVRPART *p) {
|
|||
* can't sync with the device, maybe it's not attached?
|
||||
*/
|
||||
if (rc) {
|
||||
avrdude_message(MSG_INFO, "%s: AVR device not responding\n", progname);
|
||||
pmsg_error("AVR device not responding\n");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
@ -617,8 +610,7 @@ int bitbang_initialize(const PROGRAMMER *pgm, const AVRPART *p) {
|
|||
|
||||
static int verify_pin_assigned(const PROGRAMMER *pgm, int pin, char *desc) {
|
||||
if (pgm->pinno[pin] == 0) {
|
||||
avrdude_message(MSG_INFO, "%s: error: no pin has been assigned for %s\n",
|
||||
progname, desc);
|
||||
pmsg_error("no pin has been assigned for %s\n", desc);
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
|
@ -640,8 +632,7 @@ int bitbang_check_prerequisites(const PROGRAMMER *pgm) {
|
|||
return -1;
|
||||
|
||||
if (pgm->cmd == NULL) {
|
||||
avrdude_message(MSG_INFO, "%s: error: no cmd() method defined for bitbang programmer\n",
|
||||
progname);
|
||||
pmsg_error("no cmd() method defined for bitbang programmer\n");
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
|
|
169
src/buspirate.c
169
src/buspirate.c
|
@ -88,28 +88,28 @@ buspirate_uses_ascii(const PROGRAMMER *pgm) {
|
|||
|
||||
/* ====== Serial talker functions - binmode ====== */
|
||||
|
||||
static void dump_mem(const int msglvl, const unsigned char *buf, size_t len)
|
||||
static void dump_mem(const unsigned char *buf, size_t len)
|
||||
{
|
||||
size_t i;
|
||||
|
||||
for (i = 0; i<len; i++) {
|
||||
if (i % 8 == 0)
|
||||
avrdude_message(msglvl, "\t");
|
||||
avrdude_message(msglvl, "0x%02x ", buf[i]);
|
||||
msg_debug("\t");
|
||||
msg_debug("0x%02x ", buf[i]);
|
||||
if (i % 8 == 3)
|
||||
avrdude_message(msglvl, " ");
|
||||
msg_debug(" ");
|
||||
else if (i % 8 == 7)
|
||||
avrdude_message(msglvl, "\n");
|
||||
msg_debug("\n");
|
||||
}
|
||||
if (i % 8 != 7)
|
||||
avrdude_message(msglvl, "\n");
|
||||
msg_debug("\n");
|
||||
}
|
||||
|
||||
static int buspirate_send_bin(const PROGRAMMER *pgm, const unsigned char *data, size_t len) {
|
||||
int rc;
|
||||
|
||||
avrdude_message(MSG_DEBUG, "%s: buspirate_send_bin():\n", progname);
|
||||
dump_mem(MSG_DEBUG, data, len);
|
||||
pmsg_debug("buspirate_send_bin():\n");
|
||||
dump_mem(data, len);
|
||||
|
||||
rc = serial_send(&pgm->fd, data, len);
|
||||
|
||||
|
@ -123,8 +123,8 @@ static int buspirate_recv_bin(const PROGRAMMER *pgm, unsigned char *buf, size_t
|
|||
if (rc < 0)
|
||||
return EOF;
|
||||
|
||||
avrdude_message(MSG_DEBUG, "%s: buspirate_recv_bin():\n", progname);
|
||||
dump_mem(MSG_DEBUG, buf, len);
|
||||
pmsg_debug("buspirate_recv_bin():\n");
|
||||
dump_mem(buf, len);
|
||||
|
||||
return len;
|
||||
}
|
||||
|
@ -135,7 +135,7 @@ static int buspirate_expect_bin(const PROGRAMMER *pgm,
|
|||
{
|
||||
unsigned char *recv_buf = alloca(expect_len);
|
||||
if ((PDATA(pgm)->flag & BP_FLAG_IN_BINMODE) == 0) {
|
||||
avrdude_message(MSG_INFO, "BusPirate: Internal error: buspirate_send_bin() called from ascii mode\n");
|
||||
pmsg_error("called from ascii mode\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -159,7 +159,7 @@ static int buspirate_getc(const PROGRAMMER *pgm) {
|
|||
unsigned char ch = 0;
|
||||
|
||||
if (PDATA(pgm)->flag & BP_FLAG_IN_BINMODE) {
|
||||
avrdude_message(MSG_INFO, "BusPirate: Internal error: buspirate_getc() called from binmode\n");
|
||||
pmsg_error("called from binmode\n");
|
||||
return EOF;
|
||||
}
|
||||
|
||||
|
@ -197,9 +197,7 @@ static char *buspirate_readline_noexit(const PROGRAMMER *pgm, char *buf, size_t
|
|||
serial_recv_timeout = PDATA(pgm)->serial_recv_timeout;
|
||||
}
|
||||
serial_recv_timeout = orig_serial_recv_timeout;
|
||||
avrdude_message(MSG_DEBUG, "%s: buspirate_readline(): %s%s",
|
||||
progname, buf,
|
||||
buf[strlen(buf) - 1] == '\n' ? "" : "\n");
|
||||
pmsg_debug("buspirate_readline(): %s%s", buf, *buf && buf[strlen(buf)-1] == '\n'? "": "\n");
|
||||
if (! buf[0])
|
||||
return NULL;
|
||||
|
||||
|
@ -211,8 +209,7 @@ static char *buspirate_readline(const PROGRAMMER *pgm, char *buf, size_t len) {
|
|||
|
||||
ret = buspirate_readline_noexit(pgm, buf, len);
|
||||
if (! ret) {
|
||||
avrdude_message(MSG_INFO, "%s: buspirate_readline(): programmer is not responding\n",
|
||||
progname);
|
||||
pmsg_error("programmer is not responding\n");
|
||||
return NULL;
|
||||
}
|
||||
return ret;
|
||||
|
@ -221,10 +218,10 @@ static int buspirate_send(const PROGRAMMER *pgm, const char *str) {
|
|||
int rc;
|
||||
const char * readline;
|
||||
|
||||
avrdude_message(MSG_DEBUG, "%s: buspirate_send(): %s", progname, str);
|
||||
pmsg_debug("buspirate_send(): %s", str);
|
||||
|
||||
if (PDATA(pgm)->flag & BP_FLAG_IN_BINMODE) {
|
||||
avrdude_message(MSG_INFO, "BusPirate: Internal error: buspirate_send() called from binmode\n");
|
||||
pmsg_error("called from binmode\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -303,12 +300,12 @@ buspirate_parseextparms(const PROGRAMMER *pgm, const LISTID extparms) {
|
|||
|
||||
if (sscanf(extended_param, "spifreq=%u", &spifreq) == 1) {
|
||||
if (spifreq & (~0x07)) {
|
||||
avrdude_message(MSG_INFO, "BusPirate: spifreq must be between 0 and 7.\n");
|
||||
avrdude_message(MSG_INFO, "BusPirate: see BusPirate manual for details.\n");
|
||||
pmsg_error("spifreq must be between 0 and 7\n");
|
||||
imsg_error("see BusPirate manual for details\n");
|
||||
return -1;
|
||||
}
|
||||
if (PDATA(pgm)->flag & BP_FLAG_XPARM_RAWFREQ) {
|
||||
avrdude_message(MSG_INFO, "BusPirate: set either spifreq or rawfreq\n");
|
||||
pmsg_error("set either spifreq or rawfreq\n");
|
||||
return -1;
|
||||
}
|
||||
PDATA(pgm)->flag |= BP_FLAG_XPARM_SPIFREQ;
|
||||
|
@ -318,12 +315,11 @@ buspirate_parseextparms(const PROGRAMMER *pgm, const LISTID extparms) {
|
|||
|
||||
if (sscanf(extended_param, "rawfreq=%u", &rawfreq) == 1) {
|
||||
if (rawfreq >= 4) {
|
||||
avrdude_message(MSG_INFO, "BusPirate: rawfreq must be "
|
||||
"between 0 and 3.\n");
|
||||
pmsg_error("rawfreq must be between 0 and 3\n");
|
||||
return -1;
|
||||
}
|
||||
if (PDATA(pgm)->flag & BP_FLAG_XPARM_SPIFREQ) {
|
||||
avrdude_message(MSG_INFO, "BusPirate: set either spifreq or rawfreq\n");
|
||||
pmsg_error("set either spifreq or rawfreq\n");
|
||||
return -1;
|
||||
}
|
||||
PDATA(pgm)->flag |= BP_FLAG_XPARM_RAWFREQ;
|
||||
|
@ -334,8 +330,8 @@ buspirate_parseextparms(const PROGRAMMER *pgm, const LISTID extparms) {
|
|||
if (sscanf(extended_param, "cpufreq=%u", &cpufreq) == 1) {
|
||||
/* lower limit comes from 'cpufreq > 4 * spifreq', spifreq in ascii mode is 30kHz. */
|
||||
if (cpufreq < 125 || cpufreq > 4000) {
|
||||
avrdude_message(MSG_INFO, "BusPirate: cpufreq must be between 125 and 4000 kHz.\n");
|
||||
avrdude_message(MSG_INFO, "BusPirate: see BusPirate manual for details.\n");
|
||||
pmsg_error("cpufreq must be between 125 and 4000 kHz\n");
|
||||
imsg_error("see BusPirate manual for details\n");
|
||||
return -1;
|
||||
}
|
||||
PDATA(pgm)->cpufreq = cpufreq;
|
||||
|
@ -354,7 +350,7 @@ buspirate_parseextparms(const PROGRAMMER *pgm, const LISTID extparms) {
|
|||
else if (strcasecmp(resetpin, "aux2") == 0)
|
||||
PDATA(pgm)->reset |= BP_RESET_AUX2;
|
||||
else {
|
||||
avrdude_message(MSG_INFO, "BusPirate: reset must be either CS or AUX.\n");
|
||||
pmsg_error("reset must be either CS or AUX\n");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
@ -374,14 +370,14 @@ buspirate_parseextparms(const PROGRAMMER *pgm, const LISTID extparms) {
|
|||
|
||||
if (sscanf(extended_param, "serial_recv_timeout=%d", &serial_recv_timeout) == 1) {
|
||||
if (serial_recv_timeout < 1) {
|
||||
avrdude_message(MSG_INFO, "BusPirate: serial_recv_timeout must be greater 0.\n");
|
||||
pmsg_error("serial_recv_timeout must be greater 0\n");
|
||||
return -1;
|
||||
}
|
||||
PDATA(pgm)->serial_recv_timeout = serial_recv_timeout;
|
||||
continue;
|
||||
}
|
||||
|
||||
avrdude_message(MSG_INFO, "BusPirate: do not understand extended param '%s'.\n", extended_param);
|
||||
pmsg_error("do not understand extended param '%s'\n", extended_param);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -395,13 +391,13 @@ buspirate_verifyconfig(const PROGRAMMER *pgm) {
|
|||
PDATA(pgm)->reset |= BP_RESET_CS;
|
||||
|
||||
if ((PDATA(pgm)->reset != BP_RESET_CS) && buspirate_uses_ascii(pgm)) {
|
||||
avrdude_message(MSG_INFO, "BusPirate: RESET pin other than CS is not supported in ASCII mode\n");
|
||||
pmsg_error("RESET pin other than CS is not supported in ASCII mode\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if ( ((PDATA(pgm)->flag & BP_FLAG_XPARM_SPIFREQ) || (PDATA(pgm)->flag & BP_FLAG_XPARM_RAWFREQ))
|
||||
&& buspirate_uses_ascii(pgm)) {
|
||||
avrdude_message(MSG_INFO, "BusPirate: SPI speed selection is not supported in ASCII mode\n");
|
||||
pmsg_error("SPI speed selection is not supported in ASCII mode\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -444,13 +440,13 @@ static void buspirate_reset_from_binmode(const PROGRAMMER *pgm) {
|
|||
if (PDATA(pgm)->flag & BP_FLAG_XPARM_CPUFREQ) {
|
||||
/* disable pwm */
|
||||
if (buspirate_expect_bin_byte(pgm, 0x13, 0x01) != 1) {
|
||||
avrdude_message(MSG_INFO, "%s: warning: did not get a response to stop PWM command.\n", progname);
|
||||
pmsg_error("did not get a response to stop PWM command\n");
|
||||
}
|
||||
}
|
||||
/* 0b0100wxyz - Configure peripherals w=power, x=pull-ups, y=AUX, z=CS
|
||||
* we want everything off -- 0b01000000 = 0x40 */
|
||||
if (buspirate_expect_bin_byte(pgm, 0x40, 0x00) == 1) {
|
||||
avrdude_message(MSG_INFO, "%s: warning: did not get a response to power off command.\n", progname);
|
||||
pmsg_error("did not get a response to power off command\n");
|
||||
}
|
||||
|
||||
buf[0] = 0x0F; /* BinMode: reset */
|
||||
|
@ -472,11 +468,11 @@ static void buspirate_reset_from_binmode(const PROGRAMMER *pgm) {
|
|||
}
|
||||
|
||||
if (PDATA(pgm)->flag & BP_FLAG_IN_BINMODE) {
|
||||
avrdude_message(MSG_INFO, "BusPirate reset failed. You may need to powercycle it.\n");
|
||||
pmsg_error("reset failed; you may need to powercycle it\n");
|
||||
return;
|
||||
}
|
||||
|
||||
avrdude_message(MSG_NOTICE, "BusPirate is back in the text mode\n");
|
||||
msg_notice("BusPirate is back in text mode\n");
|
||||
}
|
||||
|
||||
static int buspirate_start_mode_bin(PROGRAMMER *pgm)
|
||||
|
@ -517,11 +513,11 @@ static int buspirate_start_mode_bin(PROGRAMMER *pgm)
|
|||
memset(buf, 0, sizeof(buf));
|
||||
buspirate_recv_bin(pgm, buf, 5);
|
||||
if (sscanf((const char*)buf, "BBIO%1d", &PDATA(pgm)->binmode_version) != 1) {
|
||||
avrdude_message(MSG_INFO, "Binary mode not confirmed: '%s'\n", buf);
|
||||
pmsg_error("binary mode not confirmed: '%s'\n", buf);
|
||||
buspirate_reset_from_binmode(pgm);
|
||||
return -1;
|
||||
}
|
||||
avrdude_message(MSG_NOTICE, "BusPirate binmode version: %d\n",
|
||||
msg_notice("BusPirate binmode version: %d\n",
|
||||
PDATA(pgm)->binmode_version);
|
||||
|
||||
PDATA(pgm)->flag |= BP_FLAG_IN_BINMODE;
|
||||
|
@ -533,8 +529,8 @@ static int buspirate_start_mode_bin(PROGRAMMER *pgm)
|
|||
pwm_period = 16000/(PDATA(pgm)->cpufreq) - 1; // oscillator runs at 32MHz, we don't use a prescaler
|
||||
pwm_duty = pwm_period/2; // 50% duty cycle
|
||||
|
||||
avrdude_message(MSG_NOTICE, "Setting up PWM for cpufreq\n");
|
||||
avrdude_message(MSG_DEBUG, "PWM settings: Prescaler=1, Duty Cycle=%hd, Period=%hd\n", pwm_duty, pwm_period);
|
||||
msg_notice("setting up PWM for cpufreq\n");
|
||||
msg_debug("PWM settings: Prescaler=1, Duty Cycle=%hd, Period=%hd\n", pwm_duty, pwm_period);
|
||||
|
||||
buf[0] = 0x12; // pwm setup
|
||||
buf[1] = 0; // prescaler 1
|
||||
|
@ -546,7 +542,7 @@ static int buspirate_start_mode_bin(PROGRAMMER *pgm)
|
|||
|
||||
buspirate_recv_bin(pgm, buf, 1);
|
||||
if (buf[0] != 0x01)
|
||||
avrdude_message(MSG_INFO, "cpufreq (PWM) setup failed\n");
|
||||
pmsg_error("cpufreq (PWM) setup failed\n");
|
||||
}
|
||||
|
||||
/* == Set protocol sub-mode of binary mode == */
|
||||
|
@ -555,16 +551,14 @@ static int buspirate_start_mode_bin(PROGRAMMER *pgm)
|
|||
memset(buf, 0, sizeof(buf));
|
||||
buspirate_recv_bin(pgm, buf, 4);
|
||||
if (sscanf((const char*)buf, submode.entered_format, &PDATA(pgm)->submode_version) != 1) {
|
||||
avrdude_message(MSG_INFO, "%s mode not confirmed: '%s'\n",
|
||||
submode.name, buf);
|
||||
pmsg_error("%s mode not confirmed: '%s'\n", submode.name, buf);
|
||||
buspirate_reset_from_binmode(pgm);
|
||||
return -1;
|
||||
}
|
||||
avrdude_message(MSG_NOTICE, "BusPirate %s version: %d\n",
|
||||
msg_notice("BusPirate %s version: %d\n",
|
||||
submode.name, PDATA(pgm)->submode_version);
|
||||
|
||||
if (PDATA(pgm)->flag & BP_FLAG_NOPAGEDWRITE) {
|
||||
avrdude_message(MSG_NOTICE, "%s: Paged flash write disabled.\n", progname);
|
||||
pmsg_notice("paged flash write disabled\n");
|
||||
pgm->paged_write = NULL;
|
||||
} else {
|
||||
/* Check for write-then-read without !CS/CS and disable paged_write if absent: */
|
||||
|
@ -572,7 +566,6 @@ static int buspirate_start_mode_bin(PROGRAMMER *pgm)
|
|||
buspirate_send_bin(pgm, buf2, sizeof(buf2));
|
||||
buspirate_recv_bin(pgm, buf, 1);
|
||||
if (buf[0] != 0x01) {
|
||||
|
||||
/* Disable paged write: */
|
||||
PDATA(pgm)->flag |= BP_FLAG_NOPAGEDWRITE;
|
||||
pgm->paged_write = NULL;
|
||||
|
@ -581,12 +574,12 @@ static int buspirate_start_mode_bin(PROGRAMMER *pgm)
|
|||
buf[0] = 0x1;
|
||||
buspirate_send_bin(pgm, buf, 1);
|
||||
|
||||
avrdude_message(MSG_NOTICE, "%s: Disabling paged flash write. (Need BusPirate firmware >=v5.10.)\n", progname);
|
||||
pmsg_notice("disabling paged flash write (need BusPirate firmware >= v5.10)\n");
|
||||
|
||||
/* Flush serial buffer: */
|
||||
serial_drain(&pgm->fd, 0);
|
||||
} else {
|
||||
avrdude_message(MSG_INFO, "%s: Paged flash write enabled.\n", progname);
|
||||
pmsg_info("paged flash write enabled\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -607,7 +600,7 @@ static int buspirate_start_mode_bin(PROGRAMMER *pgm)
|
|||
|
||||
/* AVR Extended Commands - test for existence */
|
||||
if (PDATA(pgm)->flag & BP_FLAG_NOPAGEDREAD) {
|
||||
avrdude_message(MSG_NOTICE, "%s: Paged flash read disabled.\n", progname);
|
||||
pmsg_notice("paged flash read disabled\n");
|
||||
pgm->paged_load = NULL;
|
||||
} else {
|
||||
int rv = buspirate_expect_bin_byte(pgm, 0x06, 0x01);
|
||||
|
@ -619,9 +612,9 @@ static int buspirate_start_mode_bin(PROGRAMMER *pgm)
|
|||
buspirate_send_bin(pgm, buf2, sizeof(buf2));
|
||||
buspirate_recv_bin(pgm, buf, 3);
|
||||
ver = buf[1] << 8 | buf[2];
|
||||
avrdude_message(MSG_NOTICE, "AVR Extended Commands version %d\n", ver);
|
||||
msg_notice("AVR Extended Commands version %d\n", ver);
|
||||
} else {
|
||||
avrdude_message(MSG_NOTICE, "AVR Extended Commands not found.\n");
|
||||
msg_notice("AVR Extended Commands not found\n");
|
||||
PDATA(pgm)->flag |= BP_FLAG_NOPAGEDREAD;
|
||||
pgm->paged_load = NULL;
|
||||
}
|
||||
|
@ -651,10 +644,8 @@ static int buspirate_start_spi_mode_ascii(const PROGRAMMER *pgm) {
|
|||
break;
|
||||
}
|
||||
if (spi_cmd == -1) {
|
||||
avrdude_message(MSG_INFO, "%s: SPI mode number not found. Does your BusPirate support SPI?\n",
|
||||
progname);
|
||||
avrdude_message(MSG_INFO, "%s: Try powercycling your BusPirate and try again.\n",
|
||||
progname);
|
||||
pmsg_error("SPI mode number not found; does your BusPirate support SPI?\n");
|
||||
imsg_error("try powercycling your BusPirate and try again\n");
|
||||
return -1;
|
||||
}
|
||||
snprintf(buf, sizeof(buf), "%d\n", spi_cmd);
|
||||
|
@ -674,7 +665,7 @@ static int buspirate_start_spi_mode_ascii(const PROGRAMMER *pgm) {
|
|||
}
|
||||
if (buspirate_is_prompt(rcvd)) {
|
||||
if (strncmp(rcvd, "SPI>", 4) == 0) {
|
||||
avrdude_message(MSG_INFO, "BusPirate is now configured for SPI\n");
|
||||
msg_info("BusPirate is now configured for SPI\n");
|
||||
break;
|
||||
}
|
||||
/* Not yet 'SPI>' prompt */
|
||||
|
@ -700,7 +691,7 @@ static void buspirate_enable(PROGRAMMER *pgm, const AVRPART *p) {
|
|||
|
||||
/* Attempt to start binary SPI mode unless explicitly told otherwise: */
|
||||
if (!buspirate_uses_ascii(pgm)) {
|
||||
avrdude_message(MSG_INFO, "Attempting to initiate BusPirate binary mode...\n");
|
||||
msg_info("attempting to initiate BusPirate binary mode ...\n");
|
||||
|
||||
/* Send two CRs to ensure we're not in a sub-menu of the UI if we're in ASCII mode: */
|
||||
buspirate_send_bin(pgm, (const unsigned char*)"\n\n", 2);
|
||||
|
@ -712,23 +703,23 @@ static void buspirate_enable(PROGRAMMER *pgm, const AVRPART *p) {
|
|||
if (buspirate_start_mode_bin(pgm) >= 0)
|
||||
return;
|
||||
else
|
||||
avrdude_message(MSG_INFO, "%s: Failed to start binary mode, falling back to ASCII...\n", progname);
|
||||
pmsg_info("unable to start binary mode, falling back to ASCII ...\n");
|
||||
}
|
||||
|
||||
avrdude_message(MSG_INFO, "Attempting to initiate BusPirate ASCII mode...\n");
|
||||
msg_info("attempting to initiate BusPirate ASCII mode ...\n");
|
||||
|
||||
/* Call buspirate_send_bin() instead of buspirate_send()
|
||||
* because we don't know if BP is in text or bin mode */
|
||||
rc = buspirate_send_bin(pgm, (const unsigned char*)reset_str, strlen(reset_str));
|
||||
if (rc) {
|
||||
avrdude_message(MSG_INFO, "BusPirate is not responding. Serial port error: %d\n", rc);
|
||||
pmsg_error("BusPirate is not responding; serial port error code %d\n", rc);
|
||||
return;
|
||||
}
|
||||
|
||||
while(1) {
|
||||
rcvd = buspirate_readline_noexit(pgm, NULL, 0);
|
||||
if (! rcvd) {
|
||||
avrdude_message(MSG_INFO, "%s: Fatal: Programmer is not responding.\n", progname);
|
||||
pmsg_error("programmer is not responding\n");
|
||||
return;
|
||||
}
|
||||
if (strncmp(rcvd, "Are you sure?", 13) == 0) {
|
||||
|
@ -739,17 +730,17 @@ static void buspirate_enable(PROGRAMMER *pgm, const AVRPART *p) {
|
|||
continue;
|
||||
}
|
||||
if (buspirate_is_prompt(rcvd)) {
|
||||
avrdude_message(MSG_DEBUG, "**\n");
|
||||
msg_debug("**\n");
|
||||
break;
|
||||
}
|
||||
if (print_banner)
|
||||
avrdude_message(MSG_DEBUG, "** %s", rcvd);
|
||||
msg_debug("** %s", rcvd);
|
||||
}
|
||||
|
||||
if (!(PDATA(pgm)->flag & BP_FLAG_IN_BINMODE)) {
|
||||
avrdude_message(MSG_INFO, "BusPirate: using ASCII mode\n");
|
||||
msg_info("using ASCII mode\n");
|
||||
if (buspirate_start_spi_mode_ascii(pgm) < 0) {
|
||||
avrdude_message(MSG_INFO, "%s: Failed to start ascii SPI mode\n", progname);
|
||||
pmsg_error("unable to start ascii SPI mode\n");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -788,15 +779,15 @@ static void buspirate_powerup(const PROGRAMMER *pgm) {
|
|||
}
|
||||
}
|
||||
if(!ok) {
|
||||
avrdude_message(MSG_INFO, "%s: warning: did not get a response to start PWM command.\n", progname);
|
||||
pmsg_error("did not get a response to start PWM command\n");
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
avrdude_message(MSG_INFO, "%s: warning: did not get a response to PowerUp command.\n", progname);
|
||||
avrdude_message(MSG_INFO, "%s: warning: Trying to continue anyway...\n", progname);
|
||||
pmsg_warning("did not get a response to PowerUp command\n");
|
||||
imsg_warning("trying to continue anyway ...\n");
|
||||
}
|
||||
|
||||
static void buspirate_powerdown(const PROGRAMMER *pgm) {
|
||||
|
@ -806,14 +797,14 @@ static void buspirate_powerdown(const PROGRAMMER *pgm) {
|
|||
} else {
|
||||
if (PDATA(pgm)->flag & BP_FLAG_XPARM_CPUFREQ) {
|
||||
if (!buspirate_expect(pgm, "g\n", "PWM disabled", 1)) {
|
||||
avrdude_message(MSG_INFO, "%s: warning: did not get a response to stop PWM command.\n", progname);
|
||||
pmsg_error("did not get a response to stop PWM command\n");
|
||||
}
|
||||
}
|
||||
if (buspirate_expect(pgm, "w\n", "POWER SUPPLIES OFF", 1))
|
||||
return;
|
||||
}
|
||||
|
||||
avrdude_message(MSG_INFO, "%s: warning: did not get a response to PowerDown command.\n", progname);
|
||||
pmsg_error("did not get a response to PowerDown command\n");
|
||||
}
|
||||
|
||||
static int buspirate_cmd_bin(const PROGRAMMER *pgm,
|
||||
|
@ -860,7 +851,7 @@ static int buspirate_cmd_ascii(const PROGRAMMER *pgm,
|
|||
}
|
||||
|
||||
if (i != 4) {
|
||||
avrdude_message(MSG_INFO, "%s: error: SPI has not read 4 bytes back\n", progname);
|
||||
pmsg_error("SPI has not read 4 bytes back\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -889,11 +880,11 @@ static int buspirate_paged_load(const PROGRAMMER *pgm, const AVRPART *p, const A
|
|||
unsigned char buf[275];
|
||||
unsigned int addr = 0;
|
||||
|
||||
avrdude_message(MSG_NOTICE, "BusPirate: buspirate_paged_load(..,%s,%d,%d,%d)\n",m->desc,m->page_size,address,n_bytes);
|
||||
msg_notice("buspirate_paged_load(..,%s,%d,%d,%d)\n",m->desc,m->page_size,address,n_bytes);
|
||||
|
||||
// This should never happen, but still ...
|
||||
if (PDATA(pgm)->flag & BP_FLAG_NOPAGEDREAD) {
|
||||
avrdude_message(MSG_INFO, "BusPirate: buspirate_paged_load() called while in nopagedread mode!\n");
|
||||
pmsg_error("called while in nopagedread mode\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -923,7 +914,7 @@ static int buspirate_paged_load(const PROGRAMMER *pgm, const AVRPART *p, const A
|
|||
buspirate_recv_bin(pgm, buf, 1);
|
||||
|
||||
if (buf[0] != 0x01) {
|
||||
avrdude_message(MSG_INFO, "BusPirate: Paged Read command returned zero.\n");
|
||||
pmsg_error("Paged Read command returned zero\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -966,13 +957,11 @@ static int buspirate_paged_write(const PROGRAMMER *pgm, const AVRPART *p, const
|
|||
|
||||
/* pre-check opcodes */
|
||||
if (m->op[AVR_OP_LOADPAGE_LO] == NULL) {
|
||||
avrdude_message(MSG_INFO, "%s failure: %s command not defined for %s\n",
|
||||
progname, "AVR_OP_LOADPAGE_LO", p->desc);
|
||||
pmsg_error("AVR_OP_LOADPAGE_LO command not defined for %s\n", p->desc);
|
||||
return -1;
|
||||
}
|
||||
if (m->op[AVR_OP_LOADPAGE_HI] == NULL) {
|
||||
avrdude_message(MSG_INFO, "%s failure: %s command not defined for %s\n",
|
||||
progname, "AVR_OP_LOADPAGE_HI", p->desc);
|
||||
pmsg_error("AVR_OP_LOADPAGE_HI command not defined for %s\n", p->desc);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -1032,7 +1021,7 @@ static int buspirate_paged_write(const PROGRAMMER *pgm, const AVRPART *p, const
|
|||
|
||||
/* Check for write failure: */
|
||||
if ((buspirate_recv_bin(pgm, &recv_byte, 1) == EOF) || (recv_byte != 0x01)) {
|
||||
avrdude_message(MSG_INFO, "BusPirate: Fatal error: Write Then Read did not succeed.\n");
|
||||
pmsg_error("write then read did not succeed\n");
|
||||
pgm->pgm_led(pgm, OFF);
|
||||
pgm->err_led(pgm, ON);
|
||||
return -1;
|
||||
|
@ -1062,8 +1051,7 @@ static int buspirate_program_enable(const PROGRAMMER *pgm, const AVRPART *p) {
|
|||
buspirate_expect(pgm, "{\n", "CS ENABLED", 1);
|
||||
|
||||
if (p->op[AVR_OP_PGM_ENABLE] == NULL) {
|
||||
avrdude_message(MSG_INFO, "program enable instruction not defined for part \"%s\"\n",
|
||||
p->desc);
|
||||
pmsg_error("program enable instruction not defined for part %s\n", p->desc);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -1082,8 +1070,7 @@ static int buspirate_chip_erase(const PROGRAMMER *pgm, const AVRPART *p) {
|
|||
unsigned char res[4];
|
||||
|
||||
if (p->op[AVR_OP_CHIP_ERASE] == NULL) {
|
||||
avrdude_message(MSG_INFO, "chip erase instruction not defined for part \"%s\"\n",
|
||||
p->desc);
|
||||
pmsg_error("chip erase instruction not defined for part %s\n", p->desc);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -1106,8 +1093,7 @@ static void buspirate_setup(PROGRAMMER *pgm)
|
|||
{
|
||||
/* Allocate private data */
|
||||
if ((pgm->cookie = calloc(1, sizeof(struct pdata))) == 0) {
|
||||
avrdude_message(MSG_INFO, "%s: buspirate_initpgm(): Out of memory allocating private data\n",
|
||||
progname);
|
||||
pmsg_error("out of memory allocating private data\n");
|
||||
exit(1);
|
||||
}
|
||||
PDATA(pgm)->serial_recv_timeout = 100;
|
||||
|
@ -1158,7 +1144,7 @@ static void buspirate_bb_enable(PROGRAMMER *pgm, const AVRPART *p) {
|
|||
if (bitbang_check_prerequisites(pgm) < 0)
|
||||
return; /* XXX should treat as error */
|
||||
|
||||
avrdude_message(MSG_INFO, "Attempting to initiate BusPirate bitbang binary mode...\n");
|
||||
pmsg_error("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, (const unsigned char*)"\n\n", 2);
|
||||
|
@ -1173,12 +1159,11 @@ static void buspirate_bb_enable(PROGRAMMER *pgm, const AVRPART *p) {
|
|||
memset(buf, 0, sizeof(buf));
|
||||
buspirate_recv_bin(pgm, buf, 5);
|
||||
if (sscanf((char*)buf, "BBIO%1d", &PDATA(pgm)->binmode_version) != 1) {
|
||||
avrdude_message(MSG_INFO, "Binary mode not confirmed: '%s'\n", buf);
|
||||
pmsg_error("binary mode not confirmed: '%s'\n", buf);
|
||||
buspirate_reset_from_binmode(pgm);
|
||||
return;
|
||||
}
|
||||
avrdude_message(MSG_INFO, "BusPirate binmode version: %d\n",
|
||||
PDATA(pgm)->binmode_version);
|
||||
msg_info("BusPirate binmode version: %d\n", PDATA(pgm)->binmode_version);
|
||||
|
||||
PDATA(pgm)->flag |= BP_FLAG_IN_BINMODE;
|
||||
|
||||
|
@ -1241,7 +1226,7 @@ static int buspirate_bb_getpin(const PROGRAMMER *pgm, int pinfunc) {
|
|||
if (buf[0] & (1 << (pin - 1)))
|
||||
value ^= 1;
|
||||
|
||||
avrdude_message(MSG_DEBUG, "get pin %d = %d\n", pin, value);
|
||||
msg_debug("get pin %d = %d\n", pin, value);
|
||||
|
||||
return value;
|
||||
}
|
||||
|
@ -1257,7 +1242,7 @@ static int buspirate_bb_setpin_internal(const PROGRAMMER *pgm, int pin, int valu
|
|||
if ((pin < 1 || pin > 5) && (pin != 7)) // 7 is POWER
|
||||
return -1;
|
||||
|
||||
avrdude_message(MSG_DEBUG, "set pin %d = %d\n", pin, value);
|
||||
msg_debug("set pin %d = %d\n", pin, value);
|
||||
|
||||
if (value)
|
||||
PDATA(pgm)->pin_val |= (1 << (pin - 1));
|
||||
|
|
|
@ -63,8 +63,7 @@ struct pdata
|
|||
static void butterfly_setup(PROGRAMMER * pgm)
|
||||
{
|
||||
if ((pgm->cookie = malloc(sizeof(struct pdata))) == 0) {
|
||||
avrdude_message(MSG_INFO, "%s: butterfly_setup(): Out of memory allocating private data\n",
|
||||
progname);
|
||||
pmsg_error("out of memory allocating private data\n");
|
||||
exit(1);
|
||||
}
|
||||
memset(pgm->cookie, 0, sizeof(struct pdata));
|
||||
|
@ -85,8 +84,7 @@ static int butterfly_recv(const PROGRAMMER *pgm, char *buf, size_t len) {
|
|||
|
||||
rv = serial_recv(&pgm->fd, (unsigned char *)buf, len);
|
||||
if (rv < 0) {
|
||||
avrdude_message(MSG_INFO, "%s: butterfly_recv(): programmer is not responding\n",
|
||||
progname);
|
||||
pmsg_error("programmer is not responding\n");
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
|
@ -103,8 +101,7 @@ static int butterfly_vfy_cmd_sent(const PROGRAMMER *pgm, char *errmsg) {
|
|||
|
||||
butterfly_recv(pgm, &c, 1);
|
||||
if (c != '\r') {
|
||||
avrdude_message(MSG_INFO, "%s: error: programmer did not respond to command: %s\n",
|
||||
progname, errmsg);
|
||||
pmsg_error("programmer did not respond to command: %s\n", errmsg);
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
|
@ -207,13 +204,13 @@ static int butterfly_initialize(const PROGRAMMER *pgm, const AVRPART *p) {
|
|||
* Send some ESC to activate butterfly bootloader. This is not needed
|
||||
* for plain avr109 bootloaders but does not harm there either.
|
||||
*/
|
||||
avrdude_message(MSG_INFO, "Connecting to programmer: ");
|
||||
msg_notice("connecting to programmer: ");
|
||||
if (pgm->flag & IS_BUTTERFLY_MK)
|
||||
{
|
||||
char mk_reset_cmd[6] = {"#aR@S\r"};
|
||||
unsigned char mk_timeout = 0;
|
||||
|
||||
putc('.', stderr);
|
||||
msg_notice(".");
|
||||
butterfly_send(pgm, mk_reset_cmd, sizeof(mk_reset_cmd));
|
||||
usleep(20000);
|
||||
|
||||
|
@ -225,13 +222,15 @@ static int butterfly_initialize(const PROGRAMMER *pgm, const AVRPART *p) {
|
|||
c = 0xaa;
|
||||
usleep(80000);
|
||||
butterfly_send(pgm, &c, 1);
|
||||
if (mk_timeout % 10 == 0) putc('.', stderr);
|
||||
if (mk_timeout % 10 == 0)
|
||||
msg_notice(".");
|
||||
} while (mk_timeout++ < 10);
|
||||
|
||||
butterfly_recv(pgm, &c, 1);
|
||||
if ( c != 'M' && c != '?')
|
||||
{
|
||||
avrdude_message(MSG_INFO, "\nConnection FAILED.");
|
||||
msg_error("\n");
|
||||
pmsg_error("connection failed");
|
||||
return -1;
|
||||
}
|
||||
else
|
||||
|
@ -242,13 +241,13 @@ static int butterfly_initialize(const PROGRAMMER *pgm, const AVRPART *p) {
|
|||
else
|
||||
{
|
||||
do {
|
||||
putc('.', stderr);
|
||||
msg_notice(".");
|
||||
butterfly_send(pgm, "\033", 1);
|
||||
butterfly_drain(pgm, 0);
|
||||
butterfly_send(pgm, "S", 1);
|
||||
butterfly_recv(pgm, &c, 1);
|
||||
if (c != '?') {
|
||||
putc('\n', stderr);
|
||||
msg_notice("\n");
|
||||
/*
|
||||
* Got a useful response, continue getting the programmer
|
||||
* identifier. Programmer returns exactly 7 chars _without_
|
||||
|
@ -278,12 +277,12 @@ static int butterfly_initialize(const PROGRAMMER *pgm, const AVRPART *p) {
|
|||
butterfly_send(pgm, "p", 1);
|
||||
butterfly_recv(pgm, &type, 1);
|
||||
|
||||
avrdude_message(MSG_INFO, "Found programmer: Id = \"%s\"; type = %c\n", id, type);
|
||||
avrdude_message(MSG_INFO, " Software Version = %c.%c; ", sw[0], sw[1]);
|
||||
msg_notice("Programmer id = %s; type = %c\n", id, type);
|
||||
msg_notice("Software version = %c.%c; ", sw[0], sw[1]);
|
||||
if (hw[0]=='?') {
|
||||
avrdude_message(MSG_INFO, "No Hardware Version given.\n");
|
||||
msg_notice("no hardware version given\n");
|
||||
} else {
|
||||
avrdude_message(MSG_INFO, "Hardware Version = %c.%c\n", hw[0], hw[1]);
|
||||
msg_notice("Hardware version = %c.%c\n", hw[0], hw[1]);
|
||||
};
|
||||
|
||||
/* See if programmer supports autoincrement of address. */
|
||||
|
@ -291,28 +290,28 @@ static int butterfly_initialize(const PROGRAMMER *pgm, const AVRPART *p) {
|
|||
butterfly_send(pgm, "a", 1);
|
||||
butterfly_recv(pgm, &PDATA(pgm)->has_auto_incr_addr, 1);
|
||||
if (PDATA(pgm)->has_auto_incr_addr == 'Y')
|
||||
avrdude_message(MSG_INFO, "Programmer supports auto addr increment.\n");
|
||||
msg_notice("programmer supports auto addr increment\n");
|
||||
|
||||
/* Check support for buffered memory access, abort if not available */
|
||||
|
||||
butterfly_send(pgm, "b", 1);
|
||||
butterfly_recv(pgm, &c, 1);
|
||||
if (c != 'Y') {
|
||||
avrdude_message(MSG_INFO, "%s: error: buffered memory access not supported. Maybe it isn't\n"\
|
||||
"a butterfly/AVR109 but a AVR910 device?\n", progname);
|
||||
pmsg_notice("buffered memory access not supported; maybe it isn't\n"\
|
||||
"a butterfly/AVR109 but a AVR910 device?\n");
|
||||
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;
|
||||
avrdude_message(MSG_INFO, "Programmer supports buffered memory access with buffersize=%i bytes.\n",
|
||||
msg_notice("programmer supports buffered memory access with buffersize=%i bytes\n",
|
||||
PDATA(pgm)->buffersize);
|
||||
|
||||
/* Get list of devices that the programmer supports. */
|
||||
|
||||
butterfly_send(pgm, "t", 1);
|
||||
avrdude_message(MSG_INFO, "\nProgrammer supports the following devices:\n");
|
||||
msg_notice2("\nProgrammer supports the following devices:\n");
|
||||
devtype_1st = 0;
|
||||
while (1) {
|
||||
butterfly_recv(pgm, &c, 1);
|
||||
|
@ -321,9 +320,9 @@ static int butterfly_initialize(const PROGRAMMER *pgm, const AVRPART *p) {
|
|||
|
||||
if (c == 0)
|
||||
break;
|
||||
avrdude_message(MSG_INFO, " Device code: 0x%02x\n", (unsigned int)(unsigned char)c);
|
||||
msg_notice2(" Device code: 0x%02x\n", (unsigned int) (unsigned char) c);
|
||||
};
|
||||
avrdude_message(MSG_INFO, "\n");
|
||||
msg_notice2("\n");
|
||||
|
||||
/* Tell the programmer which part we selected.
|
||||
According to the AVR109 code, this is ignored by the bootloader. As
|
||||
|
@ -340,9 +339,7 @@ static int butterfly_initialize(const PROGRAMMER *pgm, const AVRPART *p) {
|
|||
if (butterfly_vfy_cmd_sent(pgm, "select device") < 0)
|
||||
return -1;
|
||||
|
||||
if (verbose)
|
||||
avrdude_message(MSG_INFO, "%s: devcode selected: 0x%02x\n",
|
||||
progname, (unsigned)buf[1]);
|
||||
pmsg_notice("devcode selected: 0x%02x\n", (unsigned) buf[1]);
|
||||
|
||||
butterfly_enter_prog_mode(pgm);
|
||||
butterfly_drain(pgm, 0);
|
||||
|
@ -545,8 +542,7 @@ static int butterfly_page_erase(const PROGRAMMER *pgm, const AVRPART *p, const A
|
|||
return -1; /* not supported */
|
||||
if (strcmp(m->desc, "eeprom") == 0)
|
||||
return 0; /* nothing to do */
|
||||
avrdude_message(MSG_INFO, "%s: butterfly_page_erase() called on memory type \"%s\"\n",
|
||||
progname, m->desc);
|
||||
pmsg_warning("called on memory type %s\n", m->desc);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -697,7 +693,7 @@ static int butterfly_read_sig_bytes(const PROGRAMMER *pgm, const AVRPART *p, con
|
|||
unsigned char tmp;
|
||||
|
||||
if (m->size < 3) {
|
||||
avrdude_message(MSG_INFO, "%s: memsize too small for sig byte read", progname);
|
||||
pmsg_error("memsize too small for sig byte read");
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
|
42
src/config.c
42
src/config.c
|
@ -105,7 +105,7 @@ int init_config(void)
|
|||
void *cfg_malloc(const char *funcname, size_t n) {
|
||||
void *ret = malloc(n);
|
||||
if(!ret) {
|
||||
avrdude_message(MSG_INFO, "%s: out of memory in %s (needed %lu bytes)\n", progname, funcname, (unsigned long) n);
|
||||
pmsg_error("out of memory in %s (needed %lu bytes)\n", funcname, (unsigned long) n);
|
||||
exit(1);
|
||||
}
|
||||
memset(ret, 0, n);
|
||||
|
@ -116,7 +116,7 @@ void *cfg_realloc(const char *funcname, void *p, size_t n) {
|
|||
void *ret;
|
||||
|
||||
if(!(ret = p? realloc(p, n): calloc(1, n))) {
|
||||
avrdude_message(MSG_INFO, "%s: out of memory in %s (needed %lu bytes)\n", progname, funcname, (unsigned long) n);
|
||||
pmsg_error("out of memory in %s (needed %lu bytes)\n", funcname, (unsigned long) n);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
@ -127,7 +127,7 @@ void *cfg_realloc(const char *funcname, void *p, size_t n) {
|
|||
char *cfg_strdup(const char *funcname, const char *s) {
|
||||
char *ret = strdup(s);
|
||||
if(!ret) {
|
||||
avrdude_message(MSG_INFO, "%s: out of memory in %s\n", progname, funcname);
|
||||
pmsg_error("out of memory in %s\n", funcname);
|
||||
exit(1);
|
||||
}
|
||||
return ret;
|
||||
|
@ -149,7 +149,7 @@ int yyerror(char * errmsg, ...)
|
|||
va_start(args, errmsg);
|
||||
|
||||
vsnprintf(message, sizeof(message), errmsg, args);
|
||||
avrdude_message(MSG_INFO, "%s: error at %s:%d: %s\n", progname, cfg_infile, cfg_lineno, message);
|
||||
pmsg_error("%s [%s:%d]\n", message, cfg_infile, cfg_lineno);
|
||||
|
||||
va_end(args);
|
||||
|
||||
|
@ -166,7 +166,7 @@ int yywarning(char * errmsg, ...)
|
|||
va_start(args, errmsg);
|
||||
|
||||
vsnprintf(message, sizeof(message), errmsg, args);
|
||||
avrdude_message(MSG_INFO, "%s: warning at %s:%d: %s\n", progname, cfg_infile, cfg_lineno, message);
|
||||
pmsg_warning("%s [%s:%d]\n", message, cfg_infile, cfg_lineno);
|
||||
|
||||
va_end(args);
|
||||
|
||||
|
@ -218,7 +218,7 @@ TOKEN *new_number(const char *text) {
|
|||
tkn->value.number = atoi(text);
|
||||
|
||||
#if DEBUG
|
||||
avrdude_message(MSG_INFO, "NUMBER(%d)\n", tkn->value.number);
|
||||
msg_info("NUMBER(%d)\n", tkn->value.number);
|
||||
#endif
|
||||
|
||||
return tkn;
|
||||
|
@ -230,7 +230,7 @@ TOKEN *new_number_real(const char *text) {
|
|||
tkn->value.number_real = atof(text);
|
||||
|
||||
#if DEBUG
|
||||
avrdude_message(MSG_INFO, "NUMBER(%g)\n", tkn->value.number_real);
|
||||
msg_info("NUMBER(%g)\n", tkn->value.number_real);
|
||||
#endif
|
||||
|
||||
return tkn;
|
||||
|
@ -243,13 +243,13 @@ TOKEN *new_hexnumber(const char *text) {
|
|||
tkn->value.type = V_NUM;
|
||||
tkn->value.number = strtoul(text, &e, 16);
|
||||
if ((e == text) || (*e != 0)) {
|
||||
yyerror("can't scan hex number \"%s\"", text);
|
||||
yyerror("cannot scan hex number %s", text);
|
||||
free_token(tkn);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#if DEBUG
|
||||
avrdude_message(MSG_INFO, "HEXNUMBER(%g)\n", tkn->value.number);
|
||||
msg_info("HEXNUMBER(%d)\n", tkn->value.number);
|
||||
#endif
|
||||
|
||||
return tkn;
|
||||
|
@ -283,7 +283,7 @@ TOKEN *new_constant(const char *con) {
|
|||
}
|
||||
|
||||
#if DEBUG
|
||||
avrdude_message(MSG_INFO, "CONSTANT(%s=%d)\n", con, tkn->value.number);
|
||||
msg_info("CONSTANT(%s=%d)\n", con, tkn->value.number);
|
||||
#endif
|
||||
|
||||
return tkn;
|
||||
|
@ -295,7 +295,7 @@ TOKEN *new_string(const char *text) {
|
|||
tkn->value.string = cfg_strdup("new_string()", text);
|
||||
|
||||
#if DEBUG
|
||||
avrdude_message(MSG_INFO, "STRING(%s)\n", tkn->value.string);
|
||||
msg_info("STRING(%s)\n", tkn->value.string);
|
||||
#endif
|
||||
|
||||
return tkn;
|
||||
|
@ -312,33 +312,33 @@ void print_token(TOKEN * tkn)
|
|||
if (!tkn)
|
||||
return;
|
||||
|
||||
avrdude_message(MSG_INFO, "token = %d = ", tkn->primary);
|
||||
msg_info("token = %d = ", tkn->primary);
|
||||
switch (tkn->value.type) {
|
||||
case V_NUM:
|
||||
avrdude_message(MSG_INFO, "NUMBER, value=%d", tkn->value.number);
|
||||
msg_info("NUMBER, value=%d", tkn->value.number);
|
||||
break;
|
||||
|
||||
case V_NUM_REAL:
|
||||
avrdude_message(MSG_INFO, "NUMBER, value=%g", tkn->value.number_real);
|
||||
msg_info("NUMBER, value=%g", tkn->value.number_real);
|
||||
break;
|
||||
|
||||
case V_STR:
|
||||
avrdude_message(MSG_INFO, "STRING, value=%s", tkn->value.string);
|
||||
msg_info("STRING, value=%s", tkn->value.string);
|
||||
break;
|
||||
|
||||
default:
|
||||
avrdude_message(MSG_INFO, "<other>");
|
||||
msg_info("<other>");
|
||||
break;
|
||||
}
|
||||
|
||||
avrdude_message(MSG_INFO, "\n");
|
||||
msg_info("\n");
|
||||
}
|
||||
|
||||
|
||||
void pyytext(void)
|
||||
{
|
||||
#if DEBUG
|
||||
avrdude_message(MSG_INFO, "TOKEN: \"%s\"\n", yytext);
|
||||
msg_info("TOKEN: %s\n", yytext);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -354,15 +354,13 @@ int read_config(const char * file)
|
|||
int r;
|
||||
|
||||
if(!(cfg_infile = realpath(file, NULL))) {
|
||||
avrdude_message(MSG_INFO, "%s: can't determine realpath() of config file \"%s\": %s\n",
|
||||
progname, file, strerror(errno));
|
||||
pmsg_ext_error("cannot determine realpath() of config file %s: %s\n", file, strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
|
||||
f = fopen(cfg_infile, "r");
|
||||
if (f == NULL) {
|
||||
avrdude_message(MSG_INFO, "%s: can't open config file \"%s\": %s\n",
|
||||
progname, cfg_infile, strerror(errno));
|
||||
pmsg_ext_error("cannot open config file %s: %s\n", cfg_infile, strerror(errno));
|
||||
free(cfg_infile);
|
||||
cfg_infile = NULL;
|
||||
return -1;
|
||||
|
|
|
@ -1410,9 +1410,7 @@ mem_spec :
|
|||
{
|
||||
int ps = $3->value.number;
|
||||
if (ps <= 0)
|
||||
avrdude_message(MSG_INFO,
|
||||
"%s, line %d: invalid page size %d, ignored\n",
|
||||
cfg_infile, cfg_lineno, ps);
|
||||
pmsg_warning("invalid page size %d, ignored [%s:%d]\n", ps, cfg_infile, cfg_lineno);
|
||||
else
|
||||
current_mem->page_size = ps;
|
||||
free_token($3);
|
||||
|
@ -1755,7 +1753,7 @@ static int parse_cmdbits(OPCODE * op, int opnum)
|
|||
op->bit[bitno].value = 0;
|
||||
}
|
||||
else {
|
||||
yyerror("invalid bit specifier \"%s\"", s);
|
||||
yyerror("invalid bit specifier %s", s);
|
||||
rv = -1;
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -528,7 +528,7 @@ static int avrpart_deep_copy(AVRPARTdeep *d, const AVRPART *p) {
|
|||
m = p->mem? avr_locate_mem_noalias(p, avr_mem_order[mi]): NULL;
|
||||
if(m) {
|
||||
if(di >= sizeof d->mems/sizeof *d->mems) {
|
||||
avrdude_message(MSG_INFO, "%s: ran out of mems[] space, increase size in AVRMEMdeep of developer_opts.c and recompile\n", progname);
|
||||
pmsg_error("ran out of mems[] space, increase size in AVRMEMdeep of developer_opts.c and recompile\n");
|
||||
exit(1);
|
||||
}
|
||||
avrmem_deep_copy(d->mems+di, m);
|
||||
|
@ -615,7 +615,7 @@ static void dev_part_strct(const AVRPART *p, bool tsv, const AVRPART *base, bool
|
|||
dev_print_comment(cp->comms);
|
||||
|
||||
if(p->parent_id && *p->parent_id)
|
||||
dev_info("part parent \"%s\"\n", p->parent_id);
|
||||
dev_info("part parent %s\n", p->parent_id);
|
||||
else
|
||||
dev_info("part\n");
|
||||
}
|
||||
|
|
97
src/dfu.c
97
src/dfu.c
|
@ -39,8 +39,7 @@
|
|||
#ifndef HAVE_LIBUSB
|
||||
|
||||
struct dfu_dev *dfu_open(const char *port_name) {
|
||||
avrdude_message(MSG_INFO, "%s: Error: No USB support in this compile of avrdude\n",
|
||||
progname);
|
||||
pmsg_error("no USB support compiled for avrdude\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -111,16 +110,14 @@ struct dfu_dev *dfu_open(const char *port_spec) {
|
|||
*/
|
||||
|
||||
if (strncmp(port_spec, "usb", 3) != 0) {
|
||||
avrdude_message(MSG_INFO, "%s: Error: "
|
||||
"Invalid port specification \"%s\" for USB device\n",
|
||||
progname, port_spec);
|
||||
pmsg_error("invalid port specification %s for USB device\n", port_spec);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if(':' == port_spec[3]) {
|
||||
bus_name = strdup(port_spec + 3 + 1);
|
||||
if (bus_name == NULL) {
|
||||
avrdude_message(MSG_INFO, "%s: Out of memory in strdup\n", progname);
|
||||
pmsg_error("out of memory in strdup\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -137,7 +134,7 @@ struct dfu_dev *dfu_open(const char *port_spec) {
|
|||
|
||||
if (dfu == NULL)
|
||||
{
|
||||
avrdude_message(MSG_INFO, "%s: out of memory\n", progname);
|
||||
pmsg_error("out of memory\n");
|
||||
free(bus_name);
|
||||
return NULL;
|
||||
}
|
||||
|
@ -171,9 +168,7 @@ int dfu_init(struct dfu_dev *dfu, unsigned short vid, unsigned short pid)
|
|||
*/
|
||||
|
||||
if (pid == 0 && dfu->dev_name == NULL) {
|
||||
avrdude_message(MSG_INFO, "%s: Error: No DFU support for part; "
|
||||
"specify PID in config or USB address (via -P) to override.\n",
|
||||
progname);
|
||||
pmsg_error("no DFU support for part; specify PID in config or USB address (via -P) to override\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -208,20 +203,18 @@ int dfu_init(struct dfu_dev *dfu, unsigned short vid, unsigned short pid)
|
|||
* why the match failed, and if we came across another DFU-capable part.
|
||||
*/
|
||||
|
||||
avrdude_message(MSG_INFO, "%s: Error: No matching USB device found\n", progname);
|
||||
pmsg_error("no matching USB device found\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if(verbose)
|
||||
avrdude_message(MSG_INFO, "%s: Found VID=0x%04x PID=0x%04x at %s:%s\n",
|
||||
progname, found->descriptor.idVendor, found->descriptor.idProduct,
|
||||
pmsg_notice("found VID=0x%04x PID=0x%04x at %s:%s\n",
|
||||
found->descriptor.idVendor, found->descriptor.idProduct,
|
||||
found->bus->dirname, found->filename);
|
||||
|
||||
dfu->dev_handle = usb_open(found);
|
||||
|
||||
if (dfu->dev_handle == NULL) {
|
||||
avrdude_message(MSG_INFO, "%s: Error: USB device at %s:%s: %s\n",
|
||||
progname, found->bus->dirname, found->filename, usb_strerror());
|
||||
pmsg_error("USB device at %s:%s: %s\n", found->bus->dirname, found->filename, usb_strerror());
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -271,33 +264,28 @@ int dfu_getstatus(struct dfu_dev *dfu, struct dfu_status *status)
|
|||
{
|
||||
int result;
|
||||
|
||||
avrdude_message(MSG_TRACE, "%s: dfu_getstatus(): issuing control IN message\n",
|
||||
progname);
|
||||
pmsg_trace("dfu_getstatus(): issuing control IN message\n");
|
||||
|
||||
result = usb_control_msg(dfu->dev_handle,
|
||||
0x80 | USB_TYPE_CLASS | USB_RECIP_INTERFACE, DFU_GETSTATUS, 0, 0,
|
||||
(char*) status, sizeof(struct dfu_status), dfu->timeout);
|
||||
|
||||
if (result < 0) {
|
||||
avrdude_message(MSG_INFO, "%s: Error: Failed to get DFU status: %s\n",
|
||||
progname, usb_strerror());
|
||||
pmsg_error("unable to get DFU status: %s\n", usb_strerror());
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (result < sizeof(struct dfu_status)) {
|
||||
avrdude_message(MSG_INFO, "%s: Error: Failed to get DFU status: %s\n",
|
||||
progname, "short read");
|
||||
pmsg_error("unable to get DFU status: %s\n", "short read");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (result > sizeof(struct dfu_status)) {
|
||||
avrdude_message(MSG_INFO, "%s: Error: Oversize read (should not happen); "
|
||||
"exiting\n", progname);
|
||||
pmsg_error("oversize read (should not happen); exiting\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
avrdude_message(MSG_TRACE, "%s: dfu_getstatus(): bStatus 0x%02x, bwPollTimeout %d, bState 0x%02x, iString %d\n",
|
||||
progname,
|
||||
pmsg_trace("dfu_getstatus(): bStatus 0x%02x, bwPollTimeout %d, bState 0x%02x, iString %d\n",
|
||||
status->bStatus,
|
||||
status->bwPollTimeout[0] | (status->bwPollTimeout[1] << 8) | (status->bwPollTimeout[2] << 16),
|
||||
status->bState,
|
||||
|
@ -310,16 +298,14 @@ int dfu_clrstatus(struct dfu_dev *dfu)
|
|||
{
|
||||
int result;
|
||||
|
||||
avrdude_message(MSG_TRACE, "%s: dfu_clrstatus(): issuing control OUT message\n",
|
||||
progname);
|
||||
pmsg_trace("dfu_clrstatus(): issuing control OUT message\n");
|
||||
|
||||
result = usb_control_msg(dfu->dev_handle,
|
||||
USB_TYPE_CLASS | USB_RECIP_INTERFACE, DFU_CLRSTATUS, 0, 0,
|
||||
NULL, 0, dfu->timeout);
|
||||
|
||||
if (result < 0) {
|
||||
avrdude_message(MSG_INFO, "%s: Error: Failed to clear DFU status: %s\n",
|
||||
progname, usb_strerror());
|
||||
pmsg_error("unable to clear DFU status: %s\n", usb_strerror());
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -330,16 +316,14 @@ int dfu_abort(struct dfu_dev *dfu)
|
|||
{
|
||||
int result;
|
||||
|
||||
avrdude_message(MSG_TRACE, "%s: dfu_abort(): issuing control OUT message\n",
|
||||
progname);
|
||||
pmsg_trace("dfu_abort(): issuing control OUT message\n");
|
||||
|
||||
result = usb_control_msg(dfu->dev_handle,
|
||||
USB_TYPE_CLASS | USB_RECIP_INTERFACE, DFU_ABORT, 0, 0,
|
||||
NULL, 0, dfu->timeout);
|
||||
|
||||
if (result < 0) {
|
||||
avrdude_message(MSG_INFO, "%s: Error: Failed to reset DFU state: %s\n",
|
||||
progname, usb_strerror());
|
||||
pmsg_error("unable to reset DFU state: %s\n", usb_strerror());
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -351,29 +335,26 @@ int dfu_dnload(struct dfu_dev *dfu, void *ptr, int size)
|
|||
{
|
||||
int result;
|
||||
|
||||
avrdude_message(MSG_TRACE, "%s: dfu_dnload(): issuing control OUT message, wIndex = %d, ptr = %p, size = %d\n",
|
||||
progname, wIndex, ptr, size);
|
||||
pmsg_trace("dfu_dnload(): issuing control OUT message, wIndex = %d, ptr = %p, size = %d\n",
|
||||
wIndex, ptr, size);
|
||||
|
||||
result = usb_control_msg(dfu->dev_handle,
|
||||
USB_TYPE_CLASS | USB_RECIP_INTERFACE, DFU_DNLOAD, wIndex++, 0,
|
||||
ptr, size, dfu->timeout);
|
||||
|
||||
if (result < 0) {
|
||||
avrdude_message(MSG_INFO, "%s: Error: DFU_DNLOAD failed: %s\n",
|
||||
progname, usb_strerror());
|
||||
pmsg_error("DFU_DNLOAD failed: %s\n", usb_strerror());
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (result < size) {
|
||||
avrdude_message(MSG_INFO, "%s: Error: DFU_DNLOAD failed: %s\n",
|
||||
progname, "short write");
|
||||
pmsg_error("DFU_DNLOAD failed: short write\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (result > size) {
|
||||
avrdude_message(MSG_INFO, "%s: Error: Oversize write (should not happen); " \
|
||||
"exiting\n", progname);
|
||||
exit(1);
|
||||
pmsg_error("DFU_DNLOAD failed: oversize write (should not happen)\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -383,28 +364,25 @@ int dfu_upload(struct dfu_dev *dfu, void *ptr, int size)
|
|||
{
|
||||
int result;
|
||||
|
||||
avrdude_message(MSG_TRACE, "%s: dfu_upload(): issuing control IN message, wIndex = %d, ptr = %p, size = %d\n",
|
||||
progname, wIndex, ptr, size);
|
||||
pmsg_trace("dfu_upload(): issuing control IN message, wIndex = %d, ptr = %p, size = %d\n",
|
||||
wIndex, ptr, size);
|
||||
|
||||
result = usb_control_msg(dfu->dev_handle,
|
||||
0x80 | USB_TYPE_CLASS | USB_RECIP_INTERFACE, DFU_UPLOAD, wIndex++, 0,
|
||||
ptr, size, dfu->timeout);
|
||||
|
||||
if (result < 0) {
|
||||
avrdude_message(MSG_INFO, "%s: Error: DFU_UPLOAD failed: %s\n",
|
||||
progname, usb_strerror());
|
||||
pmsg_error("DFU_UPLOAD failed: %s\n", usb_strerror());
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (result < size) {
|
||||
avrdude_message(MSG_INFO, "%s: Error: DFU_UPLOAD failed: %s\n",
|
||||
progname, "short read");
|
||||
pmsg_error("DFU_UPLOAD failed: %s\n", "short read");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (result > size) {
|
||||
avrdude_message(MSG_INFO, "%s: Error: Oversize read (should not happen); "
|
||||
"exiting\n", progname);
|
||||
pmsg_error("oversize read (should not happen); exiting\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
@ -414,26 +392,26 @@ int dfu_upload(struct dfu_dev *dfu, void *ptr, int size)
|
|||
void dfu_show_info(struct dfu_dev *dfu)
|
||||
{
|
||||
if (dfu->manf_str != NULL)
|
||||
avrdude_message(MSG_INFO, " USB Vendor : %s (0x%04hX)\n",
|
||||
msg_info(" USB Vendor : %s (0x%04hX)\n",
|
||||
dfu->manf_str, (unsigned short) dfu->dev_desc.idVendor);
|
||||
else
|
||||
avrdude_message(MSG_INFO, " USB Vendor : 0x%04hX\n",
|
||||
msg_info(" USB Vendor : 0x%04hX\n",
|
||||
(unsigned short) dfu->dev_desc.idVendor);
|
||||
|
||||
if (dfu->prod_str != NULL)
|
||||
avrdude_message(MSG_INFO, " USB Product : %s (0x%04hX)\n",
|
||||
msg_info(" USB Product : %s (0x%04hX)\n",
|
||||
dfu->prod_str, (unsigned short) dfu->dev_desc.idProduct);
|
||||
else
|
||||
avrdude_message(MSG_INFO, " USB Product : 0x%04hX\n",
|
||||
msg_info(" USB Product : 0x%04hX\n",
|
||||
(unsigned short) dfu->dev_desc.idProduct);
|
||||
|
||||
avrdude_message(MSG_INFO, " USB Release : %hu.%hu.%hu\n",
|
||||
msg_info(" USB Release : %hu.%hu.%hu\n",
|
||||
((unsigned short) dfu->dev_desc.bcdDevice >> 8) & 0xFF,
|
||||
((unsigned short) dfu->dev_desc.bcdDevice >> 4) & 0xF,
|
||||
((unsigned short) dfu->dev_desc.bcdDevice >> 0) & 0xF);
|
||||
|
||||
if (dfu->serno_str != NULL)
|
||||
avrdude_message(MSG_INFO, " USB Serial No : %s\n", dfu->serno_str);
|
||||
msg_info(" USB Serial No : %s\n", dfu->serno_str);
|
||||
}
|
||||
|
||||
/* INTERNAL FUNCTION DEFINITIONS
|
||||
|
@ -450,15 +428,14 @@ char * get_usb_string(usb_dev_handle * dev_handle, int index) {
|
|||
result = usb_get_string_simple(dev_handle, index, buffer, sizeof(buffer)-1);
|
||||
|
||||
if (result < 0) {
|
||||
avrdude_message(MSG_INFO, "%s: Warning: Failed to read USB device string %d: %s\n",
|
||||
progname, index, usb_strerror());
|
||||
pmsg_error("unable to read USB device string %d: %s\n", index, usb_strerror());
|
||||
return NULL;
|
||||
}
|
||||
|
||||
str = malloc(result+1);
|
||||
|
||||
if (str == NULL) {
|
||||
avrdude_message(MSG_INFO, "%s: Out of memory allocating a string\n", progname);
|
||||
pmsg_error("out of memory allocating a string\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
254
src/fileio.c
254
src/fileio.c
|
@ -126,8 +126,7 @@ static int b2ihex(unsigned char * inbuf, int bufsize,
|
|||
unsigned char cksum;
|
||||
|
||||
if (recsize > 255) {
|
||||
avrdude_message(MSG_INFO, "%s: recsize=%d, must be < 256\n",
|
||||
progname, recsize);
|
||||
pmsg_error("recsize=%d, must be < 256\n", recsize);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -319,36 +318,31 @@ static int ihex2b(char * infile, FILE * inf,
|
|||
continue;
|
||||
rc = ihex_readrec(&ihex, buffer);
|
||||
if (rc < 0) {
|
||||
avrdude_message(MSG_INFO, "%s: invalid record at line %d of \"%s\"\n",
|
||||
progname, lineno, infile);
|
||||
pmsg_error("invalid record at line %d of %s\n", lineno, infile);
|
||||
return -1;
|
||||
}
|
||||
else if (rc != ihex.cksum) {
|
||||
if(ffmt == FMT_IHEX) {
|
||||
avrdude_message(MSG_INFO, "%s: ERROR: checksum mismatch at line %d of \"%s\"\n",
|
||||
progname, lineno, infile);
|
||||
avrdude_message(MSG_INFO, "%s: checksum=0x%02x, computed checksum=0x%02x\n",
|
||||
progname, ihex.cksum, rc);
|
||||
pmsg_error("checksum mismatch at line %d of %s\n", lineno, infile);
|
||||
imsg_error("checksum=0x%02x, computed checksum=0x%02x\n", ihex.cksum, rc);
|
||||
return -1;
|
||||
} else { /* Just warn with more permissive format FMT_IHXC */
|
||||
avrdude_message(MSG_NOTICE, "%s: warning: checksum mismatch at line %d of \"%s\"\n",
|
||||
progname, lineno, infile);
|
||||
avrdude_message(MSG_NOTICE, "%s: checksum=0x%02x, computed checksum=0x%02x\n",
|
||||
progname, ihex.cksum, rc);
|
||||
pmsg_notice("checksum mismatch at line %d of %s\n", lineno, infile);
|
||||
imsg_notice("checksum=0x%02x, computed checksum=0x%02x\n", ihex.cksum, rc);
|
||||
}
|
||||
}
|
||||
|
||||
switch (ihex.rectyp) {
|
||||
case 0: /* data record */
|
||||
if (fileoffset != 0 && baseaddr < fileoffset) {
|
||||
avrdude_message(MSG_INFO, "%s: ERROR: address 0x%04x out of range (below fileoffset 0x%x) at line %d of %s\n",
|
||||
progname, baseaddr, fileoffset, lineno, infile);
|
||||
pmsg_error("address 0x%04x out of range (below fileoffset 0x%x) at line %d of %s\n",
|
||||
baseaddr, fileoffset, lineno, infile);
|
||||
return -1;
|
||||
}
|
||||
nextaddr = ihex.loadofs + baseaddr - fileoffset;
|
||||
if (nextaddr + ihex.reclen > (unsigned) bufsize) {
|
||||
avrdude_message(MSG_INFO, "%s: ERROR: address 0x%04x out of range at line %d of %s\n",
|
||||
progname, nextaddr+ihex.reclen, lineno, infile);
|
||||
pmsg_error("address 0x%04x out of range at line %d of %s\n",
|
||||
nextaddr+ihex.reclen, lineno, infile);
|
||||
return -1;
|
||||
}
|
||||
for (i=0; i<ihex.reclen; i++) {
|
||||
|
@ -380,9 +374,8 @@ static int ihex2b(char * infile, FILE * inf,
|
|||
break;
|
||||
|
||||
default:
|
||||
avrdude_message(MSG_INFO, "%s: don't know how to deal with rectype=%d "
|
||||
"at line %d of %s\n",
|
||||
progname, ihex.rectyp, lineno, infile);
|
||||
pmsg_error("do not know how to deal with rectype=%d "
|
||||
"at line %d of %s\n", ihex.rectyp, lineno, infile);
|
||||
return -1;
|
||||
break;
|
||||
}
|
||||
|
@ -390,16 +383,12 @@ static int ihex2b(char * infile, FILE * inf,
|
|||
} /* while */
|
||||
|
||||
if (maxaddr == 0) {
|
||||
avrdude_message(MSG_INFO, "%s: ERROR: No valid record found in Intel Hex "
|
||||
"file \"%s\"\n",
|
||||
progname, infile);
|
||||
pmsg_error("no valid record found in Intel Hex file %s\n", infile);
|
||||
|
||||
return -1;
|
||||
}
|
||||
else {
|
||||
avrdude_message(MSG_INFO, "%s: WARNING: no end of file record found for Intel Hex "
|
||||
"file \"%s\"\n",
|
||||
progname, infile);
|
||||
pmsg_warning("no end of file record found for Intel Hex file %s\n", infile);
|
||||
|
||||
return maxaddr;
|
||||
}
|
||||
|
@ -417,8 +406,7 @@ static int b2srec(unsigned char * inbuf, int bufsize,
|
|||
char * tmpl=0;
|
||||
|
||||
if (recsize > 255) {
|
||||
avrdude_message(MSG_INFO, "%s: ERROR: recsize=%d, must be < 256\n",
|
||||
progname, recsize);
|
||||
pmsg_error("recsize=%d, must be < 256\n", recsize);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -450,8 +438,7 @@ static int b2srec(unsigned char * inbuf, int bufsize,
|
|||
tmpl="S3%02X%08X";
|
||||
}
|
||||
else {
|
||||
avrdude_message(MSG_INFO, "%s: ERROR: address=%d, out of range\n",
|
||||
progname, nextaddr);
|
||||
pmsg_error("address=%d, out of range\n", nextaddr);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -599,7 +586,7 @@ static int srec2b(char * infile, FILE * inf,
|
|||
unsigned int reccount;
|
||||
unsigned char datarec;
|
||||
|
||||
char * msg = 0;
|
||||
char * msg = "";
|
||||
|
||||
lineno = 0;
|
||||
maxaddr = 0;
|
||||
|
@ -615,15 +602,12 @@ static int srec2b(char * infile, FILE * inf,
|
|||
rc = srec_readrec(&srec, buffer);
|
||||
|
||||
if (rc < 0) {
|
||||
avrdude_message(MSG_INFO, "%s: ERROR: invalid record at line %d of \"%s\"\n",
|
||||
progname, lineno, infile);
|
||||
pmsg_error("invalid record at line %d of %s\n", lineno, infile);
|
||||
return -1;
|
||||
}
|
||||
else if (rc != srec.cksum) {
|
||||
avrdude_message(MSG_INFO, "%s: ERROR: checksum mismatch at line %d of \"%s\"\n",
|
||||
progname, lineno, infile);
|
||||
avrdude_message(MSG_INFO, "%s: checksum=0x%02x, computed checksum=0x%02x\n",
|
||||
progname, srec.cksum, rc);
|
||||
pmsg_error("checksum mismatch at line %d of %s\n", lineno, infile);
|
||||
imsg_error("checksum=0x%02x, computed checksum=0x%02x\n", srec.cksum, rc);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -635,32 +619,27 @@ static int srec2b(char * infile, FILE * inf,
|
|||
|
||||
case 0x31: /* S1 - 16 bit address data record */
|
||||
datarec=1;
|
||||
msg="%s: ERROR: address 0x%04x out of range %sat line %d of %s\n";
|
||||
msg="address 0x%04x out of range %sat line %d of %s\n";
|
||||
break;
|
||||
|
||||
case 0x32: /* S2 - 24 bit address data record */
|
||||
datarec=1;
|
||||
msg="%s: ERROR: address 0x%06x out of range %sat line %d of %s\n";
|
||||
msg="address 0x%06x out of range %sat line %d of %s\n";
|
||||
break;
|
||||
|
||||
case 0x33: /* S3 - 32 bit address data record */
|
||||
datarec=1;
|
||||
msg="%s: ERROR: address 0x%08x out of range %sat line %d of %s\n";
|
||||
msg="address 0x%08x out of range %sat line %d of %s\n";
|
||||
break;
|
||||
|
||||
case 0x34: /* S4 - symbol record (LSI extension) */
|
||||
avrdude_message(MSG_INFO, "%s: ERROR: not supported record at line %d of %s\n",
|
||||
progname, lineno, infile);
|
||||
pmsg_error("not supported record at line %d of %s\n", lineno, infile);
|
||||
return -1;
|
||||
|
||||
case 0x35: /* S5 - count of S1,S2 and S3 records previously tx'd */
|
||||
if (srec.loadofs != reccount){
|
||||
avrdude_message(MSG_INFO, "%s: ERROR: count of transmitted data records mismatch "
|
||||
"at line %d of \"%s\"\n",
|
||||
progname, lineno, infile);
|
||||
avrdude_message(MSG_INFO, "%s: transmitted data records= %d, expected "
|
||||
"value= %d\n",
|
||||
progname, reccount, srec.loadofs);
|
||||
pmsg_error("count of transmitted data records mismatch at line %d of %s\n", lineno, infile);
|
||||
imsg_error("transmitted data records= %d, expected value= %d\n", reccount, srec.loadofs);
|
||||
return -1;
|
||||
}
|
||||
break;
|
||||
|
@ -671,24 +650,20 @@ static int srec2b(char * infile, FILE * inf,
|
|||
return maxaddr;
|
||||
|
||||
default:
|
||||
avrdude_message(MSG_INFO, "%s: ERROR: don't know how to deal with rectype S%d "
|
||||
"at line %d of %s\n",
|
||||
progname, srec.rectyp, lineno, infile);
|
||||
pmsg_error("do not know how to deal with rectype S%d at line %d of %s\n",
|
||||
srec.rectyp, lineno, infile);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (datarec == 1) {
|
||||
nextaddr = srec.loadofs;
|
||||
if (nextaddr < fileoffset) {
|
||||
avrdude_message(MSG_INFO, msg, progname, nextaddr,
|
||||
"(below fileoffset) ",
|
||||
lineno, infile);
|
||||
pmsg_error(msg, nextaddr, "(below fileoffset) ", lineno, infile);
|
||||
return -1;
|
||||
}
|
||||
nextaddr -= fileoffset;
|
||||
if (nextaddr + srec.reclen > (unsigned) bufsize) {
|
||||
avrdude_message(MSG_INFO, msg, progname, nextaddr+srec.reclen, "",
|
||||
lineno, infile);
|
||||
pmsg_error(msg, nextaddr+srec.reclen, "", lineno, infile);
|
||||
return -1;
|
||||
}
|
||||
for (i=0; i<srec.reclen; i++) {
|
||||
|
@ -702,9 +677,7 @@ static int srec2b(char * infile, FILE * inf,
|
|||
|
||||
}
|
||||
|
||||
avrdude_message(MSG_INFO, "%s: WARNING: no end of file record found for Motorola S-Records "
|
||||
"file \"%s\"\n",
|
||||
progname, infile);
|
||||
pmsg_warning("no end of file record found for Motorola S-Records file %s\n", infile);
|
||||
|
||||
return maxaddr;
|
||||
}
|
||||
|
@ -747,8 +720,7 @@ static Elf_Scn *elf_get_scn(Elf *e, Elf32_Phdr *ph, Elf32_Shdr **shptr)
|
|||
Elf32_Shdr *sh;
|
||||
size_t ndx = elf_ndxscn(s);
|
||||
if ((sh = elf32_getshdr(s)) == NULL) {
|
||||
avrdude_message(MSG_INFO, "%s: ERROR: Error reading section #%u header: %s\n",
|
||||
progname, (unsigned int)ndx, elf_errmsg(-1));
|
||||
pmsg_error("unable to read section #%u header: %s\n", (unsigned int)ndx, elf_errmsg(-1));
|
||||
continue;
|
||||
}
|
||||
if ((sh->sh_flags & SHF_ALLOC) == 0 ||
|
||||
|
@ -765,9 +737,7 @@ static Elf_Scn *elf_get_scn(Elf *e, Elf32_Phdr *ph, Elf32_Shdr **shptr)
|
|||
}
|
||||
}
|
||||
|
||||
avrdude_message(MSG_INFO, "%s: ERROR: Cannot find a matching section for "
|
||||
"program header entry @p_vaddr 0x%x\n",
|
||||
progname, ph->p_vaddr);
|
||||
pmsg_error("cannot find a matching section for program header entry @p_vaddr 0x%x\n", ph->p_vaddr);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -838,8 +808,7 @@ static int elf2b(char * infile, FILE * inf,
|
|||
unsigned int low, high, foff;
|
||||
|
||||
if (elf_mem_limits(mem, p, &low, &high, &foff) != 0) {
|
||||
avrdude_message(MSG_INFO, "%s: ERROR: Cannot handle \"%s\" memory region from ELF file\n",
|
||||
progname, mem->desc);
|
||||
pmsg_error("cannot handle %s memory region from ELF file\n", mem->desc);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -856,9 +825,7 @@ static int elf2b(char * infile, FILE * inf,
|
|||
strcmp(mem->desc, "apptable") == 0)) {
|
||||
AVRMEM *flashmem = avr_locate_mem(p, "flash");
|
||||
if (flashmem == NULL) {
|
||||
avrdude_message(MSG_INFO, "%s: ERROR: No \"flash\" memory region found, "
|
||||
"cannot compute bounds of \"%s\" sub-region.\n",
|
||||
progname, mem->desc);
|
||||
pmsg_error("no flash memory region found, cannot compute bounds of %s sub-region\n", mem->desc);
|
||||
return -1;
|
||||
}
|
||||
/* The config file offsets are PDI offsets, rebase to 0. */
|
||||
|
@ -867,18 +834,15 @@ static int elf2b(char * infile, FILE * inf,
|
|||
}
|
||||
|
||||
if (elf_version(EV_CURRENT) == EV_NONE) {
|
||||
avrdude_message(MSG_INFO, "%s: ERROR: ELF library initialization failed: %s\n",
|
||||
progname, elf_errmsg(-1));
|
||||
pmsg_error("ELF library initialization failed: %s\n", elf_errmsg(-1));
|
||||
return -1;
|
||||
}
|
||||
if ((e = elf_begin(fileno(inf), ELF_C_READ, NULL)) == NULL) {
|
||||
avrdude_message(MSG_INFO, "%s: ERROR: Cannot open \"%s\" as an ELF file: %s\n",
|
||||
progname, infile, elf_errmsg(-1));
|
||||
pmsg_error("cannot open %s as an ELF file: %s\n", infile, elf_errmsg(-1));
|
||||
return -1;
|
||||
}
|
||||
if (elf_kind(e) != ELF_K_ELF) {
|
||||
avrdude_message(MSG_INFO, "%s: ERROR: Cannot use \"%s\" as an ELF input file\n",
|
||||
progname, infile);
|
||||
pmsg_error("cannot use %s as an ELF input file\n", infile);
|
||||
goto done;
|
||||
}
|
||||
|
||||
|
@ -886,8 +850,7 @@ static int elf2b(char * infile, FILE * inf,
|
|||
const char *id = elf_getident(e, &isize);
|
||||
|
||||
if (id == NULL) {
|
||||
avrdude_message(MSG_INFO, "%s: ERROR: Error reading ident area of \"%s\": %s\n",
|
||||
progname, infile, elf_errmsg(-1));
|
||||
pmsg_error("unable to read ident area of %s: %s\n", infile, elf_errmsg(-1));
|
||||
goto done;
|
||||
}
|
||||
|
||||
|
@ -902,22 +865,19 @@ static int elf2b(char * infile, FILE * inf,
|
|||
}
|
||||
if (id[EI_CLASS] != ELFCLASS32 ||
|
||||
id[EI_DATA] != endianess) {
|
||||
avrdude_message(MSG_INFO, "%s: ERROR: ELF file \"%s\" is not a "
|
||||
"32-bit, %s-endian file that was expected\n",
|
||||
progname, infile, endianname);
|
||||
pmsg_error("ELF file %s is not a 32-bit, %s-endian file that was expected\n",
|
||||
infile, endianname);
|
||||
goto done;
|
||||
}
|
||||
|
||||
Elf32_Ehdr *eh;
|
||||
if ((eh = elf32_getehdr(e)) == NULL) {
|
||||
avrdude_message(MSG_INFO, "%s: ERROR: Error reading ehdr of \"%s\": %s\n",
|
||||
progname, infile, elf_errmsg(-1));
|
||||
pmsg_error("unable to read ehdr of %s: %s\n", infile, elf_errmsg(-1));
|
||||
goto done;
|
||||
}
|
||||
|
||||
if (eh->e_type != ET_EXEC) {
|
||||
avrdude_message(MSG_INFO, "%s: ERROR: ELF file \"%s\" is not an executable file\n",
|
||||
progname, infile);
|
||||
pmsg_error("ELF file %s is not an executable file\n", infile);
|
||||
goto done;
|
||||
}
|
||||
|
||||
|
@ -931,28 +891,23 @@ static int elf2b(char * infile, FILE * inf,
|
|||
mname = "AVR";
|
||||
}
|
||||
if (eh->e_machine != machine) {
|
||||
avrdude_message(MSG_INFO, "%s: ERROR: ELF file \"%s\" is not for machine %s\n",
|
||||
progname, infile, mname);
|
||||
pmsg_error("ELF file %s is not for machine %s\n", infile, mname);
|
||||
goto done;
|
||||
}
|
||||
if (eh->e_phnum == 0xffff /* PN_XNUM */) {
|
||||
avrdude_message(MSG_INFO, "%s: ERROR: ELF file \"%s\" uses extended "
|
||||
"program header numbers which are not expected\n",
|
||||
progname, infile);
|
||||
pmsg_error("ELF file %s uses extended program header numbers which are not expected\n", infile);
|
||||
goto done;
|
||||
}
|
||||
|
||||
Elf32_Phdr *ph;
|
||||
if ((ph = elf32_getphdr(e)) == NULL) {
|
||||
avrdude_message(MSG_INFO, "%s: ERROR: Error reading program header table of \"%s\": %s\n",
|
||||
progname, infile, elf_errmsg(-1));
|
||||
pmsg_error("unable to read program header table of %s: %s\n", infile, elf_errmsg(-1));
|
||||
goto done;
|
||||
}
|
||||
|
||||
size_t sndx;
|
||||
if (elf_getshdrstrndx(e, &sndx) != 0) {
|
||||
avrdude_message(MSG_INFO, "%s: ERROR: Error obtaining section name string table: %s\n",
|
||||
progname, elf_errmsg(-1));
|
||||
pmsg_error("unable to obtain section name string table: %s\n", elf_errmsg(-1));
|
||||
sndx = 0;
|
||||
}
|
||||
|
||||
|
@ -965,9 +920,8 @@ static int elf2b(char * infile, FILE * inf,
|
|||
ph[i].p_filesz == 0)
|
||||
continue;
|
||||
|
||||
avrdude_message(MSG_NOTICE2, "%s: Considering PT_LOAD program header entry #%d:\n"
|
||||
" p_vaddr 0x%x, p_paddr 0x%x, p_filesz %d\n",
|
||||
progname, i, ph[i].p_vaddr, ph[i].p_paddr, ph[i].p_filesz);
|
||||
pmsg_notice2("considering PT_LOAD program header entry #%d:\n"
|
||||
" p_vaddr 0x%x, p_paddr 0x%x, p_filesz %d\n", (int) i, ph[i].p_vaddr, ph[i].p_paddr, ph[i].p_filesz);
|
||||
|
||||
Elf32_Shdr *sh;
|
||||
Elf_Scn *s = elf_get_scn(e, ph + i, &sh);
|
||||
|
@ -986,15 +940,13 @@ static int elf2b(char * infile, FILE * inf,
|
|||
unsigned int lma;
|
||||
lma = ph[i].p_paddr + sh->sh_offset - ph[i].p_offset;
|
||||
|
||||
avrdude_message(MSG_NOTICE2, "%s: Found section \"%s\", LMA 0x%x, sh_size %u\n",
|
||||
progname, sname, lma, sh->sh_size);
|
||||
pmsg_notice2("found section %s, LMA 0x%x, sh_size %u\n", sname, lma, sh->sh_size);
|
||||
|
||||
if (lma >= low &&
|
||||
lma + sh->sh_size < high) {
|
||||
/* OK */
|
||||
} else {
|
||||
avrdude_message(MSG_NOTICE2, " => skipping, inappropriate for \"%s\" memory region\n",
|
||||
mem->desc);
|
||||
msg_notice2(" => skipping, inappropriate for %s memory region\n", mem->desc);
|
||||
continue;
|
||||
}
|
||||
/*
|
||||
|
@ -1006,26 +958,22 @@ static int elf2b(char * infile, FILE * inf,
|
|||
* from it, using the "foff" offset obtained above.
|
||||
*/
|
||||
if (mem->size != 1 && sh->sh_size > (unsigned) mem->size) {
|
||||
avrdude_message(MSG_INFO, "%s: ERROR: section \"%s\" does not fit into \"%s\" memory:\n"
|
||||
" 0x%x + %u > %u\n",
|
||||
progname, sname, mem->desc,
|
||||
lma, sh->sh_size, mem->size);
|
||||
pmsg_error("section %s does not fit into %s memory:\n"
|
||||
" 0x%x + %u > %u\n", sname, mem->desc, lma, sh->sh_size, mem->size);
|
||||
continue;
|
||||
}
|
||||
|
||||
Elf_Data *d = NULL;
|
||||
while ((d = elf_getdata(s, d)) != NULL) {
|
||||
avrdude_message(MSG_NOTICE2, " Data block: d_buf %p, d_off 0x%x, d_size %d\n",
|
||||
d->d_buf, (unsigned int)d->d_off, d->d_size);
|
||||
msg_notice2(" Data block: d_buf %p, d_off 0x%x, d_size %ld\n",
|
||||
d->d_buf, (unsigned int)d->d_off, (long) d->d_size);
|
||||
if (mem->size == 1) {
|
||||
if (d->d_off != 0) {
|
||||
avrdude_message(MSG_INFO, "%s: ERROR: unexpected data block at offset != 0\n",
|
||||
progname);
|
||||
pmsg_error("unexpected data block at offset != 0\n");
|
||||
} else if (foff >= d->d_size) {
|
||||
avrdude_message(MSG_INFO, "%s: ERROR: ELF file section does not contain byte at offset %d\n",
|
||||
progname, foff);
|
||||
pmsg_error("ELF file section does not contain byte at offset %d\n", foff);
|
||||
} else {
|
||||
avrdude_message(MSG_NOTICE2, " Extracting one byte from file offset %d\n",
|
||||
msg_notice2(" Extracting one byte from file offset %d\n",
|
||||
foff);
|
||||
mem->buf[0] = ((unsigned char *)d->d_buf)[foff];
|
||||
mem->tags[0] = TAG_ALLOCATED;
|
||||
|
@ -1037,8 +985,8 @@ static int elf2b(char * infile, FILE * inf,
|
|||
idx = lma - low + d->d_off;
|
||||
if ((int)(idx + d->d_size) > rv)
|
||||
rv = idx + d->d_size;
|
||||
avrdude_message(MSG_DEBUG, " Writing %d bytes to mem offset 0x%x\n",
|
||||
d->d_size, idx);
|
||||
msg_debug(" Writing %ld bytes to mem offset 0x%x\n",
|
||||
(long) d->d_size, idx);
|
||||
memcpy(mem->buf + idx, d->d_buf, d->d_size);
|
||||
memset(mem->tags + idx, TAG_ALLOCATED, d->d_size);
|
||||
}
|
||||
|
@ -1107,15 +1055,13 @@ static int fileio_rbin(struct fioparms * fio,
|
|||
rc = fwrite(buf, 1, size, f);
|
||||
break;
|
||||
default:
|
||||
avrdude_message(MSG_INFO, "%s: fileio: invalid operation=%d\n",
|
||||
progname, fio->op);
|
||||
pmsg_error("invalid fileio operation=%d\n", fio->op);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (rc < 0 || (fio->op == FIO_WRITE && rc < size)) {
|
||||
avrdude_message(MSG_INFO, "%s: %s error %s %s: %s; %s %d of the expected %d bytes\n",
|
||||
progname, fio->iodesc, fio->dir, filename, strerror(errno),
|
||||
fio->rw, rc, size);
|
||||
pmsg_ext_error("%s error %s %s: %s; %s %d of the expected %d bytes\n",
|
||||
fio->iodesc, fio->dir, filename, strerror(errno), fio->rw, rc, size);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -1142,8 +1088,7 @@ static int fileio_imm(struct fioparms * fio,
|
|||
strtoul (p, &e, 0):
|
||||
strtoul (p + 2, &e, 2);
|
||||
if (*e != 0) {
|
||||
avrdude_message(MSG_INFO, "%s: invalid byte value (%s) specified for immediate mode\n",
|
||||
progname, p);
|
||||
pmsg_error("invalid byte value (%s) specified for immediate mode\n", p);
|
||||
return -1;
|
||||
}
|
||||
mem->buf[loc] = b;
|
||||
|
@ -1154,21 +1099,17 @@ static int fileio_imm(struct fioparms * fio,
|
|||
break;
|
||||
|
||||
case FIO_WRITE:
|
||||
avrdude_message(MSG_INFO,
|
||||
"%s: Invalid file format 'immediate' for output\n",
|
||||
progname);
|
||||
pmsg_error("invalid file format 'immediate' for output\n");
|
||||
return -1;
|
||||
|
||||
default:
|
||||
avrdude_message(MSG_INFO, "%s: fileio: invalid operation=%d\n",
|
||||
progname, fio->op);
|
||||
pmsg_error("invalid operation=%d\n", fio->op);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (rc < 0 || (fio->op == FIO_WRITE && rc < size)) {
|
||||
avrdude_message(MSG_INFO, "%s: %s error %s %s: %s; %s %d of the expected %d bytes\n",
|
||||
progname, fio->iodesc, fio->dir, filename, strerror(errno),
|
||||
fio->rw, rc, size);
|
||||
pmsg_ext_error("%s error %s %s: %s; %s %d of the expected %d bytes\n",
|
||||
fio->iodesc, fio->dir, filename, strerror(errno), fio->rw, rc, size);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -1197,8 +1138,7 @@ static int fileio_ihex(struct fioparms * fio,
|
|||
break;
|
||||
|
||||
default:
|
||||
avrdude_message(MSG_INFO, "%s: invalid Intel Hex file I/O operation=%d\n",
|
||||
progname, fio->op);
|
||||
pmsg_error("invalid Intel Hex file I/O operation=%d\n", fio->op);
|
||||
return -1;
|
||||
break;
|
||||
}
|
||||
|
@ -1227,9 +1167,7 @@ static int fileio_srec(struct fioparms * fio,
|
|||
break;
|
||||
|
||||
default:
|
||||
avrdude_message(MSG_INFO, "%s: ERROR: invalid Motorola S-Records file I/O "
|
||||
"operation=%d\n",
|
||||
progname, fio->op);
|
||||
pmsg_error("invalid Motorola S-Records file I/O operation=%d\n", fio->op);
|
||||
return -1;
|
||||
break;
|
||||
}
|
||||
|
@ -1247,9 +1185,7 @@ static int fileio_elf(struct fioparms * fio,
|
|||
|
||||
switch (fio->op) {
|
||||
case FIO_WRITE:
|
||||
avrdude_message(MSG_INFO, "%s: ERROR: write operation not (yet) "
|
||||
"supported for ELF\n",
|
||||
progname);
|
||||
pmsg_error("write operation not supported for ELF\n");
|
||||
return -1;
|
||||
break;
|
||||
|
||||
|
@ -1258,9 +1194,7 @@ static int fileio_elf(struct fioparms * fio,
|
|||
return rc;
|
||||
|
||||
default:
|
||||
avrdude_message(MSG_INFO, "%s: ERROR: invalid ELF file I/O "
|
||||
"operation=%d\n",
|
||||
progname, fio->op);
|
||||
pmsg_error("invalid ELF file I/O operation=%d\n", fio->op);
|
||||
return -1;
|
||||
break;
|
||||
}
|
||||
|
@ -1310,14 +1244,11 @@ static int fileio_num(struct fioparms * fio,
|
|||
break;
|
||||
|
||||
case FIO_READ:
|
||||
avrdude_message(MSG_INFO,
|
||||
"%s: Invalid file format '%s' for input\n",
|
||||
progname, name);
|
||||
pmsg_error("invalid file format '%s' for input\n", name);
|
||||
return -1;
|
||||
|
||||
default:
|
||||
avrdude_message(MSG_INFO, "%s: fileio: invalid operation=%d\n",
|
||||
progname, fio->op);
|
||||
pmsg_error("invalid operation=%d\n", fio->op);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -1346,8 +1277,7 @@ static int fileio_num(struct fioparms * fio,
|
|||
return 0;
|
||||
|
||||
writeerr:
|
||||
avrdude_message(MSG_INFO, "%s: error writing to %s: %s\n",
|
||||
progname, filename, strerror(errno));
|
||||
pmsg_ext_error("unable to write to %s: %s\n", filename, strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -1373,8 +1303,7 @@ int fileio_setparms(int op, struct fioparms * fp,
|
|||
break;
|
||||
|
||||
default:
|
||||
avrdude_message(MSG_INFO, "%s: invalid I/O operation %d\n",
|
||||
progname, op);
|
||||
pmsg_error("invalid I/O operation %d\n", op);
|
||||
return -1;
|
||||
break;
|
||||
}
|
||||
|
@ -1405,8 +1334,7 @@ int fileio_fmt_autodetect(const char * fname)
|
|||
f = fopen(fname, "rb");
|
||||
#endif
|
||||
if (f == NULL) {
|
||||
avrdude_message(MSG_INFO, "%s: error opening %s: %s\n",
|
||||
progname, fname, strerror(errno));
|
||||
pmsg_ext_error("unable to open %s: %s\n", fname, strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -1489,8 +1417,7 @@ int fileio(int oprwv, char * filename, FILEFMT format,
|
|||
op = oprwv == FIO_READ_FOR_VERIFY? FIO_READ: oprwv;
|
||||
mem = avr_locate_mem(p, memtype);
|
||||
if (mem == NULL) {
|
||||
avrdude_message(MSG_INFO, "fileio(): memory type \"%s\" not configured for device \"%s\"\n",
|
||||
memtype, p->desc);
|
||||
pmsg_error("memory type %s not configured for device %s\n", memtype, p->desc);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -1529,24 +1456,21 @@ int fileio(int oprwv, char * filename, FILEFMT format,
|
|||
int format_detect;
|
||||
|
||||
if (using_stdio) {
|
||||
avrdude_message(MSG_INFO, "%s: can't auto detect file format when using stdin/out.\n"
|
||||
"%s Please specify a file format and try again.\n",
|
||||
progname, progbuf);
|
||||
pmsg_error("cannot auto detect file format when using stdin/out\n");
|
||||
imsg_error("please specify a file format and try again\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
format_detect = fileio_fmt_autodetect(fname);
|
||||
if (format_detect < 0) {
|
||||
avrdude_message(MSG_INFO, "%s: can't determine file format for %s, specify explicitly\n",
|
||||
progname, fname);
|
||||
pmsg_error("cannot determine file format for %s, specify explicitly\n", fname);
|
||||
return -1;
|
||||
}
|
||||
format = format_detect;
|
||||
|
||||
if (quell_progress < 2) {
|
||||
avrdude_message(MSG_NOTICE, "%s: %s file %s auto detected as %s\n",
|
||||
progname, fio.iodesc, fname, fileio_fmtstr(format));
|
||||
}
|
||||
if (quell_progress < 2)
|
||||
pmsg_notice("%s file %s auto detected as %s\n",
|
||||
fio.iodesc, fname, fileio_fmtstr(format));
|
||||
}
|
||||
|
||||
#if defined(WIN32)
|
||||
|
@ -1568,8 +1492,7 @@ int fileio(int oprwv, char * filename, FILEFMT format,
|
|||
if (!using_stdio) {
|
||||
f = fopen(fname, fio.mode);
|
||||
if (f == NULL) {
|
||||
avrdude_message(MSG_INFO, "%s: can't open %s file %s: %s\n",
|
||||
progname, fio.iodesc, fname, strerror(errno));
|
||||
pmsg_ext_error("cannot open %s file %s: %s\n", fio.iodesc, fname, strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
@ -1593,9 +1516,7 @@ int fileio(int oprwv, char * filename, FILEFMT format,
|
|||
#ifdef HAVE_LIBELF
|
||||
rc = fileio_elf(&fio, fname, f, mem, p, size);
|
||||
#else
|
||||
avrdude_message(MSG_INFO, "%s: can't handle ELF file %s, "
|
||||
"ELF file support was not compiled in\n",
|
||||
progname, fname);
|
||||
pmsg_error("cannot handle ELF file %s, ELF file support was not compiled in\n", fname);
|
||||
rc = -1;
|
||||
#endif
|
||||
break;
|
||||
|
@ -1612,8 +1533,7 @@ int fileio(int oprwv, char * filename, FILEFMT format,
|
|||
break;
|
||||
|
||||
default:
|
||||
avrdude_message(MSG_INFO, "%s: invalid %s file format: %d\n",
|
||||
progname, fio.iodesc, format);
|
||||
pmsg_error("invalid %s file format: %d\n", fio.iodesc, format);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
|
145
src/flip1.c
145
src/flip1.c
|
@ -234,16 +234,13 @@ int flip1_initialize(const PROGRAMMER *pgm, const AVRPART *part) {
|
|||
if (usbpid) {
|
||||
pid = *(int *)(ldata(usbpid));
|
||||
if (lnext(usbpid))
|
||||
avrdude_message(MSG_INFO, "%s: Warning: using PID 0x%04x, ignoring remaining PIDs in list\n",
|
||||
progname, pid);
|
||||
pmsg_warning("using PID 0x%04x, ignoring remaining PIDs in list\n", pid);
|
||||
} else {
|
||||
pid = part->usbpid;
|
||||
}
|
||||
if (!ovsigck && (part->prog_modes & PM_PDI)) {
|
||||
avrdude_message(MSG_INFO, "%s: \"flip1\" (FLIP protocol version 1) is for AT90USB* and ATmega*U* devices.\n"
|
||||
"%s For Xmega devices, use \"flip2\".\n"
|
||||
"%s (Use -F to bypass this check.)\n",
|
||||
progname, progbuf, progbuf);
|
||||
pmsg_error("flip1 (FLIP protocol version 1) is for AT90USB* and ATmega*U* devices\n");
|
||||
imsg_error("for Xmega devices, use flip2 (or use -F to bypass this check)\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -255,32 +252,25 @@ int flip1_initialize(const PROGRAMMER *pgm, const AVRPART *part) {
|
|||
/* Check if descriptor values are what we expect. */
|
||||
|
||||
if (dfu->dev_desc.idVendor != vid)
|
||||
avrdude_message(MSG_INFO, "%s: Warning: USB idVendor = 0x%04X (expected 0x%04X)\n",
|
||||
progname, dfu->dev_desc.idVendor, vid);
|
||||
pmsg_warning("USB idVendor = 0x%04X (expected 0x%04X)\n", dfu->dev_desc.idVendor, vid);
|
||||
|
||||
if (pid != 0 && dfu->dev_desc.idProduct != pid)
|
||||
avrdude_message(MSG_INFO, "%s: Warning: USB idProduct = 0x%04X (expected 0x%04X)\n",
|
||||
progname, dfu->dev_desc.idProduct, pid);
|
||||
pmsg_warning("USB idProduct = 0x%04X (expected 0x%04X)\n", dfu->dev_desc.idProduct, pid);
|
||||
|
||||
if (dfu->dev_desc.bNumConfigurations != 1)
|
||||
avrdude_message(MSG_INFO, "%s: Warning: USB bNumConfigurations = %d (expected 1)\n",
|
||||
progname, (int) dfu->dev_desc.bNumConfigurations);
|
||||
pmsg_warning("USB bNumConfigurations = %d (expected 1)\n", (int) dfu->dev_desc.bNumConfigurations);
|
||||
|
||||
if (dfu->conf_desc.bNumInterfaces != 1)
|
||||
avrdude_message(MSG_INFO, "%s: Warning: USB bNumInterfaces = %d (expected 1)\n",
|
||||
progname, (int) dfu->conf_desc.bNumInterfaces);
|
||||
pmsg_warning("USB bNumInterfaces = %d (expected 1)\n", (int) dfu->conf_desc.bNumInterfaces);
|
||||
|
||||
if (dfu->dev_desc.bDeviceClass != 254)
|
||||
avrdude_message(MSG_INFO, "%s: Warning: USB bDeviceClass = %d (expected 254)\n",
|
||||
progname, (int) dfu->dev_desc.bDeviceClass);
|
||||
pmsg_warning("USB bDeviceClass = %d (expected 254)\n", (int) dfu->dev_desc.bDeviceClass);
|
||||
|
||||
if (dfu->dev_desc.bDeviceSubClass != 1)
|
||||
avrdude_message(MSG_INFO, "%s: Warning: USB bDeviceSubClass = %d (expected 1)\n",
|
||||
progname, (int) dfu->dev_desc.bDeviceSubClass);
|
||||
pmsg_warning("USB bDeviceSubClass = %d (expected 1)\n", (int) dfu->dev_desc.bDeviceSubClass);
|
||||
|
||||
if (dfu->dev_desc.bDeviceProtocol != 0)
|
||||
avrdude_message(MSG_INFO, "%s: Warning: USB bDeviceProtocol = %d (expected 0)\n",
|
||||
progname, (int) dfu->dev_desc.bDeviceProtocol);
|
||||
pmsg_warning("USB bDeviceProtocol = %d (expected 0)\n", (int) dfu->dev_desc.bDeviceProtocol);
|
||||
|
||||
/*
|
||||
* doc7618 claims an interface class of FEh and a subclas 01h.
|
||||
|
@ -290,21 +280,17 @@ int flip1_initialize(const PROGRAMMER *pgm, const AVRPART *part) {
|
|||
*/
|
||||
if (0) {
|
||||
if (dfu->intf_desc.bInterfaceClass != 254)
|
||||
avrdude_message(MSG_INFO, "%s: Warning: USB bInterfaceClass = %d (expected 254)\n",
|
||||
progname, (int) dfu->intf_desc.bInterfaceClass);
|
||||
pmsg_warning("USB bInterfaceClass = %d (expected 254)\n", (int) dfu->intf_desc.bInterfaceClass);
|
||||
|
||||
if (dfu->intf_desc.bInterfaceSubClass != 1)
|
||||
avrdude_message(MSG_INFO, "%s: Warning: USB bInterfaceSubClass = %d (expected 1)\n",
|
||||
progname, (int) dfu->intf_desc.bInterfaceSubClass);
|
||||
pmsg_warning("USB bInterfaceSubClass = %d (expected 1)\n", (int) dfu->intf_desc.bInterfaceSubClass);
|
||||
|
||||
if (dfu->intf_desc.bInterfaceProtocol != 0)
|
||||
avrdude_message(MSG_INFO, "%s: Warning: USB bInterfaceSubClass = %d (expected 0)\n",
|
||||
progname, (int) dfu->intf_desc.bInterfaceProtocol);
|
||||
pmsg_warning("USB bInterfaceSubClass = %d (expected 0)\n", (int) dfu->intf_desc.bInterfaceProtocol);
|
||||
}
|
||||
|
||||
if (dfu->dev_desc.bMaxPacketSize0 != 32)
|
||||
avrdude_message(MSG_INFO, "%s: Warning: bMaxPacketSize0 (%d) != 32, things might go wrong\n",
|
||||
progname, dfu->dev_desc.bMaxPacketSize0);
|
||||
pmsg_warning("bMaxPacketSize0 (%d) != 32, things might go wrong\n", dfu->dev_desc.bMaxPacketSize0);
|
||||
|
||||
if (verbose)
|
||||
flip1_show_info(FLIP1(pgm));
|
||||
|
@ -353,7 +339,7 @@ int flip1_chip_erase(const PROGRAMMER *pgm, const AVRPART *part) {
|
|||
int aux_result;
|
||||
unsigned int default_timeout = FLIP1(pgm)->dfu->timeout;
|
||||
|
||||
avrdude_message(MSG_NOTICE2, "%s: flip_chip_erase()\n", progname);
|
||||
pmsg_notice2("flip_chip_erase()\n");
|
||||
|
||||
struct flip1_cmd cmd = {
|
||||
FLIP1_CMD_WRITE_COMMAND, { 0, 0xff }
|
||||
|
@ -368,8 +354,7 @@ int flip1_chip_erase(const PROGRAMMER *pgm, const AVRPART *part) {
|
|||
return -1;
|
||||
|
||||
if (status.bStatus != DFU_STATUS_OK) {
|
||||
avrdude_message(MSG_INFO, "%s: failed to send chip erase command: %s\n",
|
||||
progname, flip1_status_str(&status));
|
||||
pmsg_error("unable to send chip erase command: %s\n", flip1_status_str(&status));
|
||||
if (status.bState == STATE_dfuERROR)
|
||||
dfu_clrstatus(FLIP1(pgm)->dfu);
|
||||
return -1;
|
||||
|
@ -389,9 +374,8 @@ int flip1_read_byte(const PROGRAMMER *pgm, const AVRPART *part, const AVRMEM *me
|
|||
if (strcmp(mem->desc, "signature") == 0) {
|
||||
if (flip1_read_sig_bytes(pgm, part, mem) < 0)
|
||||
return -1;
|
||||
if (addr > mem->size) {
|
||||
avrdude_message(MSG_INFO, "%s: flip1_read_byte(signature): address %lu out of range\n",
|
||||
progname, addr);
|
||||
if (addr >= mem->size) {
|
||||
pmsg_error("signature address %lu out of range [0, %d]\n", addr, mem->size-1);
|
||||
return -1;
|
||||
}
|
||||
*value = mem->buf[addr];
|
||||
|
@ -401,10 +385,7 @@ int flip1_read_byte(const PROGRAMMER *pgm, const AVRPART *part, const AVRMEM *me
|
|||
mem_unit = flip1_mem_unit(mem->desc);
|
||||
|
||||
if (mem_unit == FLIP1_MEM_UNIT_UNKNOWN) {
|
||||
avrdude_message(MSG_INFO, "%s: Error: "
|
||||
"\"%s\" memory not accessible using FLIP",
|
||||
progname, mem->desc);
|
||||
avrdude_message(MSG_INFO, "\n");
|
||||
pmsg_error("%s memory not accessible using FLIP\n", mem->desc);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -426,10 +407,7 @@ int flip1_write_byte(const PROGRAMMER *pgm, const AVRPART *part, const AVRMEM *m
|
|||
mem_unit = flip1_mem_unit(mem->desc);
|
||||
|
||||
if (mem_unit == FLIP1_MEM_UNIT_UNKNOWN) {
|
||||
avrdude_message(MSG_INFO, "%s: Error: "
|
||||
"\"%s\" memory not accessible using FLIP",
|
||||
progname, mem->desc);
|
||||
avrdude_message(MSG_INFO, "\n");
|
||||
pmsg_error("%s memory not accessible using FLIP\n", mem->desc);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -447,10 +425,7 @@ int flip1_paged_load(const PROGRAMMER *pgm, const AVRPART *part, const AVRMEM *m
|
|||
mem_unit = flip1_mem_unit(mem->desc);
|
||||
|
||||
if (mem_unit == FLIP1_MEM_UNIT_UNKNOWN) {
|
||||
avrdude_message(MSG_INFO, "%s: Error: "
|
||||
"\"%s\" memory not accessible using FLIP",
|
||||
progname, mem->desc);
|
||||
avrdude_message(MSG_INFO, "\n");
|
||||
pmsg_error("%s memory not accessible using FLIP\n", mem->desc);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -473,17 +448,13 @@ int flip1_paged_write(const PROGRAMMER *pgm, const AVRPART *part, const AVRMEM *
|
|||
mem_unit = flip1_mem_unit(mem->desc);
|
||||
|
||||
if (mem_unit == FLIP1_MEM_UNIT_UNKNOWN) {
|
||||
avrdude_message(MSG_INFO, "%s: Error: "
|
||||
"\"%s\" memory not accessible using FLIP",
|
||||
progname, mem->desc);
|
||||
avrdude_message(MSG_INFO, "\n");
|
||||
pmsg_error("%s memory not accessible using FLIP\n", mem->desc);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (n_bytes > INT_MAX) {
|
||||
/* This should never happen, unless the int type is only 16 bits. */
|
||||
avrdude_message(MSG_INFO, "%s: Error: Attempting to read more than %d bytes\n",
|
||||
progname, INT_MAX);
|
||||
pmsg_error("attempting to read more than %d bytes\n", INT_MAX);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
@ -494,14 +465,13 @@ int flip1_paged_write(const PROGRAMMER *pgm, const AVRPART *part, const AVRMEM *
|
|||
}
|
||||
|
||||
int flip1_read_sig_bytes(const PROGRAMMER *pgm, const AVRPART *part, const AVRMEM *mem) {
|
||||
avrdude_message(MSG_NOTICE2, "%s: flip1_read_sig_bytes(): ", progname);
|
||||
pmsg_notice2("flip1_read_sig_bytes(): ");
|
||||
|
||||
if (FLIP1(pgm)->dfu == NULL)
|
||||
return -1;
|
||||
|
||||
if (mem->size < sizeof(FLIP1(pgm)->part_sig)) {
|
||||
avrdude_message(MSG_INFO, "%s: Error: Signature read must be at least %u bytes\n",
|
||||
progname, (unsigned int) sizeof(FLIP1(pgm)->part_sig));
|
||||
pmsg_error("signature read must be at least %u bytes\n", (unsigned int) sizeof(FLIP1(pgm)->part_sig));
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -518,7 +488,7 @@ int flip1_read_sig_bytes(const PROGRAMMER *pgm, const AVRPART *part, const AVRME
|
|||
FLIP1_CMD_READ_COMMAND, FLIP1_READ_FAMILY_CODE
|
||||
};
|
||||
|
||||
avrdude_message(MSG_NOTICE2, "from device\n");
|
||||
msg_notice2("from device\n");
|
||||
|
||||
for (i = 0; i < 3; i++)
|
||||
{
|
||||
|
@ -535,8 +505,7 @@ int flip1_read_sig_bytes(const PROGRAMMER *pgm, const AVRPART *part, const AVRME
|
|||
|
||||
if (status.bStatus != DFU_STATUS_OK)
|
||||
{
|
||||
avrdude_message(MSG_INFO, "%s: failed to send cmd for signature byte %d: %s\n",
|
||||
progname, i, flip1_status_str(&status));
|
||||
pmsg_error("unable to send cmd for signature byte %d: %s\n", i, flip1_status_str(&status));
|
||||
if (status.bState == STATE_dfuERROR)
|
||||
dfu_clrstatus(FLIP1(pgm)->dfu);
|
||||
return -1;
|
||||
|
@ -550,8 +519,7 @@ int flip1_read_sig_bytes(const PROGRAMMER *pgm, const AVRPART *part, const AVRME
|
|||
|
||||
if (status.bStatus != DFU_STATUS_OK)
|
||||
{
|
||||
avrdude_message(MSG_INFO, "%s: failed to read signature byte %d: %s\n",
|
||||
progname, i, flip1_status_str(&status));
|
||||
pmsg_error("unable to read signature byte %d: %s\n", i, flip1_status_str(&status));
|
||||
if (status.bState == STATE_dfuERROR)
|
||||
dfu_clrstatus(FLIP1(pgm)->dfu);
|
||||
return -1;
|
||||
|
@ -560,7 +528,7 @@ int flip1_read_sig_bytes(const PROGRAMMER *pgm, const AVRPART *part, const AVRME
|
|||
}
|
||||
else
|
||||
{
|
||||
avrdude_message(MSG_NOTICE2, "cached\n");
|
||||
msg_notice2("cached\n");
|
||||
}
|
||||
|
||||
memcpy(mem->buf, FLIP1(pgm)->part_sig, sizeof(FLIP1(pgm)->part_sig));
|
||||
|
@ -573,8 +541,7 @@ void flip1_setup(PROGRAMMER * pgm)
|
|||
pgm->cookie = calloc(1, sizeof(struct flip1));
|
||||
|
||||
if (pgm->cookie == NULL) {
|
||||
avrdude_message(MSG_INFO, "%s: Out of memory allocating private data structure\n",
|
||||
progname);
|
||||
pmsg_error("out of memory allocating private data structure\n");
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
@ -591,8 +558,7 @@ void flip1_teardown(PROGRAMMER * pgm)
|
|||
void flip1_show_info(struct flip1 *flip1)
|
||||
{
|
||||
dfu_show_info(flip1->dfu);
|
||||
avrdude_message(MSG_INFO, " USB max packet size : %hu\n",
|
||||
(unsigned short) flip1->dfu->dev_desc.bMaxPacketSize0);
|
||||
msg_info(" USB max packet size : %hu\n", (unsigned short) flip1->dfu->dev_desc.bMaxPacketSize0);
|
||||
}
|
||||
|
||||
int flip1_read_memory(const PROGRAMMER *pgm,
|
||||
|
@ -609,8 +575,7 @@ int flip1_read_memory(const PROGRAMMER *pgm,
|
|||
unsigned int default_timeout = dfu->timeout;
|
||||
|
||||
|
||||
avrdude_message(MSG_NOTICE2, "%s: flip_read_memory(%s, 0x%04x, %d)\n",
|
||||
progname, flip1_mem_unit_str(mem_unit), addr, size);
|
||||
pmsg_notice2("flip_read_memory(%s, 0x%04x, %d)\n", flip1_mem_unit_str(mem_unit), addr, size);
|
||||
|
||||
/*
|
||||
* As this function is called once per page, no need to handle 64
|
||||
|
@ -640,9 +605,8 @@ int flip1_read_memory(const PROGRAMMER *pgm,
|
|||
|
||||
if (status.bStatus != DFU_STATUS_OK)
|
||||
{
|
||||
avrdude_message(MSG_INFO, "%s: failed to read %u bytes of %s memory @%u: %s\n",
|
||||
progname, size, flip1_mem_unit_str(mem_unit), addr,
|
||||
flip1_status_str(&status));
|
||||
pmsg_error("unable to read %u bytes of %s memory @%u: %s\n", size,
|
||||
flip1_mem_unit_str(mem_unit), addr, flip1_status_str(&status));
|
||||
if (status.bState == STATE_dfuERROR)
|
||||
dfu_clrstatus(dfu);
|
||||
return -1;
|
||||
|
@ -653,13 +617,14 @@ int flip1_read_memory(const PROGRAMMER *pgm,
|
|||
|
||||
if (cmd_result < 0 && aux_result == 0 &&
|
||||
status.bStatus == DFU_STATUS_ERR_WRITE) {
|
||||
if (FLIP1(pgm)->security_mode_flag == 0)
|
||||
avrdude_message(MSG_INFO, "\n%s:\n"
|
||||
"%s***********************************************************************\n"
|
||||
"%sMaybe the device is in ``security mode´´, and needs a chip erase first?\n"
|
||||
"%s***********************************************************************\n"
|
||||
"\n",
|
||||
progname, progbuf, progbuf, progbuf);
|
||||
if (FLIP1(pgm)->security_mode_flag == 0) {
|
||||
msg_error("\n");
|
||||
pmsg_error("\n");
|
||||
imsg_error("***********************************************************************\n");
|
||||
imsg_error("Maybe the device is in ``security mode´´, and needs a chip erase first?\n");
|
||||
imsg_error("***********************************************************************\n");
|
||||
msg_error("\n");
|
||||
}
|
||||
FLIP1(pgm)->security_mode_flag = 1;
|
||||
}
|
||||
|
||||
|
@ -668,9 +633,8 @@ int flip1_read_memory(const PROGRAMMER *pgm,
|
|||
|
||||
if (status.bStatus != DFU_STATUS_OK)
|
||||
{
|
||||
avrdude_message(MSG_INFO, "%s: failed to read %u bytes of %s memory @%u: %s\n",
|
||||
progname, size, flip1_mem_unit_str(mem_unit), addr,
|
||||
flip1_status_str(&status));
|
||||
pmsg_error("unable to read %u bytes of %s memory @%u: %s\n", size,
|
||||
flip1_mem_unit_str(mem_unit), addr, flip1_status_str(&status));
|
||||
if (status.bState == STATE_dfuERROR)
|
||||
dfu_clrstatus(dfu);
|
||||
return -1;
|
||||
|
@ -702,14 +666,14 @@ int flip1_write_memory(struct dfu_dev *dfu,
|
|||
unsigned int default_timeout = dfu->timeout;
|
||||
unsigned char *buf;
|
||||
|
||||
avrdude_message(MSG_NOTICE2, "%s: flip_write_memory(%s, 0x%04x, %d)\n",
|
||||
progname, flip1_mem_unit_str(mem_unit), addr, size);
|
||||
pmsg_notice2("flip_write_memory(%s, 0x%04x, %d)\n",
|
||||
flip1_mem_unit_str(mem_unit), addr, size);
|
||||
|
||||
if (size < 32) {
|
||||
/* presumably single-byte updates; must be padded to USB endpoint size */
|
||||
if ((addr + size - 1) / 32 != addr / 32) {
|
||||
avrdude_message(MSG_INFO, "%s: flip_write_memory(): begin (0x%x) and end (0x%x) not within same 32-byte block\n",
|
||||
progname, addr, addr + size - 1);
|
||||
pmsg_error("begin 0x%x and end 0x%x not within same 32-byte block\n",
|
||||
addr, addr + size - 1);
|
||||
return -1;
|
||||
}
|
||||
write_size = 32;
|
||||
|
@ -720,7 +684,7 @@ int flip1_write_memory(struct dfu_dev *dfu,
|
|||
if ((buf = malloc(sizeof(struct flip1_cmd_header) +
|
||||
write_size +
|
||||
sizeof(struct flip1_prog_footer))) == 0) {
|
||||
avrdude_message(MSG_INFO, "%s: Out of memory\n", progname);
|
||||
pmsg_error("out of memory\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -769,9 +733,8 @@ int flip1_write_memory(struct dfu_dev *dfu,
|
|||
|
||||
if (status.bStatus != DFU_STATUS_OK)
|
||||
{
|
||||
avrdude_message(MSG_INFO, "%s: failed to write %u bytes of %s memory @%u: %s\n",
|
||||
progname, size, flip1_mem_unit_str(mem_unit), addr,
|
||||
flip1_status_str(&status));
|
||||
pmsg_error("unable to write %u bytes of %s memory @%u: %s\n", size,
|
||||
flip1_mem_unit_str(mem_unit), addr, flip1_status_str(&status));
|
||||
if (status.bState == STATE_dfuERROR)
|
||||
dfu_clrstatus(dfu);
|
||||
return -1;
|
||||
|
@ -800,8 +763,7 @@ int flip1_set_mem_page(struct dfu_dev *dfu,
|
|||
|
||||
if (status.bStatus != DFU_STATUS_OK)
|
||||
{
|
||||
avrdude_message(MSG_INFO, "%s: failed to set memory page: %s\n",
|
||||
progname, flip1_status_str(&status));
|
||||
pmsg_error("unable to set memory page: %s\n", flip1_status_str(&status));
|
||||
if (status.bState == STATE_dfuERROR)
|
||||
dfu_clrstatus(dfu);
|
||||
return -1;
|
||||
|
@ -855,8 +817,7 @@ enum flip1_mem_unit flip1_mem_unit(const char *name) {
|
|||
#else /* HAVE_LIBUSB */
|
||||
// Dummy functions
|
||||
int flip1_open(PROGRAMMER *pgm, const char *port_spec) {
|
||||
fprintf(stderr, "%s: Error: No USB support in this compile of avrdude\n",
|
||||
progname);
|
||||
pmsg_error("no USB support compiled for avrdude\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
|
178
src/flip2.c
178
src/flip2.c
|
@ -226,17 +226,15 @@ int flip2_initialize(const PROGRAMMER *pgm, const AVRPART *part) {
|
|||
if (usbpid) {
|
||||
pid = *(int *)(ldata(usbpid));
|
||||
if (lnext(usbpid))
|
||||
avrdude_message(MSG_INFO, "%s: Warning: using PID 0x%04x, ignoring remaining PIDs in list\n",
|
||||
progname, pid);
|
||||
pmsg_warning("using PID 0x%04x, ignoring remaining PIDs in list\n", pid);
|
||||
} else {
|
||||
pid = part->usbpid;
|
||||
}
|
||||
|
||||
if (!ovsigck && !(part->prog_modes & PM_PDI)) {
|
||||
avrdude_message(MSG_INFO, "%s: \"flip2\" (FLIP protocol version 2) is for Xmega devices.\n"
|
||||
"%s For AT90USB* or ATmega*U* devices, use \"flip1\".\n"
|
||||
"%s (Use -F to bypass this check.)\n",
|
||||
progname, progbuf, progbuf);
|
||||
pmsg_error("flip2 (FLIP protocol version 2) is for Xmega devices\n");
|
||||
imsg_error("for AT90USB* or ATmega*U* devices, use flip1\n");
|
||||
imsg_error("(or use -F to bypass this check)\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -248,44 +246,44 @@ int flip2_initialize(const PROGRAMMER *pgm, const AVRPART *part) {
|
|||
/* Check if descriptor values are what we expect. */
|
||||
|
||||
if (dfu->dev_desc.idVendor != vid)
|
||||
avrdude_message(MSG_INFO, "%s: Warning: USB idVendor = 0x%04X (expected 0x%04X)\n",
|
||||
progname, dfu->dev_desc.idVendor, vid);
|
||||
pmsg_warning("USB idVendor = 0x%04X (expected 0x%04X)\n",
|
||||
dfu->dev_desc.idVendor, vid);
|
||||
|
||||
if (pid != 0 && dfu->dev_desc.idProduct != pid)
|
||||
avrdude_message(MSG_INFO, "%s: Warning: USB idProduct = 0x%04X (expected 0x%04X)\n",
|
||||
progname, dfu->dev_desc.idProduct, pid);
|
||||
pmsg_warning("USB idProduct = 0x%04X (expected 0x%04X)\n",
|
||||
dfu->dev_desc.idProduct, pid);
|
||||
|
||||
if (dfu->dev_desc.bNumConfigurations != 1)
|
||||
avrdude_message(MSG_INFO, "%s: Warning: USB bNumConfigurations = %d (expected 1)\n",
|
||||
progname, (int) dfu->dev_desc.bNumConfigurations);
|
||||
pmsg_error("USB bNumConfigurations = %d (expected 1)\n",
|
||||
(int) dfu->dev_desc.bNumConfigurations);
|
||||
|
||||
if (dfu->conf_desc.bNumInterfaces != 1)
|
||||
avrdude_message(MSG_INFO, "%s: Warning: USB bNumInterfaces = %d (expected 1)\n",
|
||||
progname, (int) dfu->conf_desc.bNumInterfaces);
|
||||
pmsg_error("USB bNumInterfaces = %d (expected 1)\n",
|
||||
(int) dfu->conf_desc.bNumInterfaces);
|
||||
|
||||
if (dfu->dev_desc.bDeviceClass != 0)
|
||||
avrdude_message(MSG_INFO, "%s: Warning: USB bDeviceClass = %d (expected 0)\n",
|
||||
progname, (int) dfu->dev_desc.bDeviceClass);
|
||||
pmsg_error("USB bDeviceClass = %d (expected 0)\n",
|
||||
(int) dfu->dev_desc.bDeviceClass);
|
||||
|
||||
if (dfu->dev_desc.bDeviceSubClass != 0)
|
||||
avrdude_message(MSG_INFO, "%s: Warning: USB bDeviceSubClass = %d (expected 0)\n",
|
||||
progname, (int) dfu->dev_desc.bDeviceSubClass);
|
||||
pmsg_error("USB bDeviceSubClass = %d (expected 0)\n",
|
||||
(int) dfu->dev_desc.bDeviceSubClass);
|
||||
|
||||
if (dfu->dev_desc.bDeviceProtocol != 0)
|
||||
avrdude_message(MSG_INFO, "%s: Warning: USB bDeviceProtocol = %d (expected 0)\n",
|
||||
progname, (int) dfu->dev_desc.bDeviceProtocol);
|
||||
pmsg_error("USB bDeviceProtocol = %d (expected 0)\n",
|
||||
(int) dfu->dev_desc.bDeviceProtocol);
|
||||
|
||||
if (dfu->intf_desc.bInterfaceClass != 0xFF)
|
||||
avrdude_message(MSG_INFO, "%s: Warning: USB bInterfaceClass = %d (expected 255)\n",
|
||||
progname, (int) dfu->intf_desc.bInterfaceClass);
|
||||
pmsg_error("USB bInterfaceClass = %d (expected 255)\n",
|
||||
(int) dfu->intf_desc.bInterfaceClass);
|
||||
|
||||
if (dfu->intf_desc.bInterfaceSubClass != 0)
|
||||
avrdude_message(MSG_INFO, "%s: Warning: USB bInterfaceSubClass = %d (expected 0)\n",
|
||||
progname, (int) dfu->intf_desc.bInterfaceSubClass);
|
||||
pmsg_error("USB bInterfaceSubClass = %d (expected 0)\n",
|
||||
(int) dfu->intf_desc.bInterfaceSubClass);
|
||||
|
||||
if (dfu->intf_desc.bInterfaceProtocol != 0)
|
||||
avrdude_message(MSG_INFO, "%s: Warning: USB bInterfaceSubClass = %d (expected 0)\n",
|
||||
progname, (int) dfu->intf_desc.bInterfaceProtocol);
|
||||
pmsg_error("USB bInterfaceSubClass = %d (expected 0)\n",
|
||||
(int) dfu->intf_desc.bInterfaceProtocol);
|
||||
|
||||
result = flip2_read_memory(FLIP2(pgm)->dfu,
|
||||
FLIP2_MEM_UNIT_SIGNATURE, 0, FLIP2(pgm)->part_sig, 4);
|
||||
|
@ -347,7 +345,7 @@ int flip2_chip_erase(const PROGRAMMER *pgm, const AVRPART *part) {
|
|||
int cmd_result = 0;
|
||||
int aux_result;
|
||||
|
||||
avrdude_message(MSG_NOTICE2, "%s: flip_chip_erase()\n", progname);
|
||||
pmsg_notice2("flip_chip_erase()\n");
|
||||
|
||||
struct flip2_cmd cmd = {
|
||||
FLIP2_CMD_GROUP_EXEC, FLIP2_CMD_CHIP_ERASE, { 0xFF, 0, 0, 0 }
|
||||
|
@ -365,9 +363,8 @@ int flip2_chip_erase(const PROGRAMMER *pgm, const AVRPART *part) {
|
|||
status.bState == ((FLIP2_STATUS_ERASE_ONGOING >> 0) & 0xFF))
|
||||
{
|
||||
continue;
|
||||
} else
|
||||
avrdude_message(MSG_INFO, "%s: Error: DFU status %s\n", progname,
|
||||
flip2_status_str(&status));
|
||||
}
|
||||
pmsg_error("DFU status %s\n", flip2_status_str(&status));
|
||||
dfu_clrstatus(FLIP2(pgm)->dfu);
|
||||
} else
|
||||
break;
|
||||
|
@ -377,7 +374,7 @@ int flip2_chip_erase(const PROGRAMMER *pgm, const AVRPART *part) {
|
|||
}
|
||||
|
||||
int flip2_start_app(const PROGRAMMER *pgm) {
|
||||
avrdude_message(MSG_INFO, "%s: Starting application\n", progname);
|
||||
pmsg_info("starting application\n");
|
||||
|
||||
struct flip2_cmd cmd = {
|
||||
FLIP2_CMD_GROUP_EXEC, FLIP2_CMD_START_APP, { 0x00, 0, 0, 0 }
|
||||
|
@ -403,12 +400,10 @@ int flip2_read_byte(const PROGRAMMER *pgm, const AVRPART *part, const AVRMEM *me
|
|||
mem_unit = flip2_mem_unit(mem->desc);
|
||||
|
||||
if (mem_unit == FLIP2_MEM_UNIT_UNKNOWN) {
|
||||
avrdude_message(MSG_INFO, "%s: Error: "
|
||||
"\"%s\" memory not accessible using FLIP",
|
||||
progname, mem->desc);
|
||||
pmsg_error("%s memory not accessible using FLIP", mem->desc);
|
||||
if (strcmp(mem->desc, "flash") == 0)
|
||||
avrdude_message(MSG_INFO, " (did you mean \"application\"?)");
|
||||
avrdude_message(MSG_INFO, "\n");
|
||||
msg_error(" (did you mean \"application\"?)");
|
||||
msg_error("\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -426,12 +421,10 @@ int flip2_write_byte(const PROGRAMMER *pgm, const AVRPART *part, const AVRMEM *m
|
|||
mem_unit = flip2_mem_unit(mem->desc);
|
||||
|
||||
if (mem_unit == FLIP2_MEM_UNIT_UNKNOWN) {
|
||||
avrdude_message(MSG_INFO, "%s: Error: "
|
||||
"\"%s\" memory not accessible using FLIP",
|
||||
progname, mem->desc);
|
||||
pmsg_error("%s memory not accessible using FLIP", mem->desc);
|
||||
if (strcmp(mem->desc, "flash") == 0)
|
||||
avrdude_message(MSG_INFO, " (did you mean \"application\"?)");
|
||||
avrdude_message(MSG_INFO, "\n");
|
||||
msg_error(" (did you mean \"application\"?)");
|
||||
msg_error("\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -450,19 +443,16 @@ int flip2_paged_load(const PROGRAMMER *pgm, const AVRPART *part, const AVRMEM *m
|
|||
mem_unit = flip2_mem_unit(mem->desc);
|
||||
|
||||
if (mem_unit == FLIP2_MEM_UNIT_UNKNOWN) {
|
||||
avrdude_message(MSG_INFO, "%s: Error: "
|
||||
"\"%s\" memory not accessible using FLIP",
|
||||
progname, mem->desc);
|
||||
pmsg_error("%s memory not accessible using FLIP", mem->desc);
|
||||
if (strcmp(mem->desc, "flash") == 0)
|
||||
avrdude_message(MSG_INFO, " (did you mean \"application\"?)");
|
||||
avrdude_message(MSG_INFO, "\n");
|
||||
msg_error(" (did you mean \"application\"?)");
|
||||
msg_error("\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (n_bytes > INT_MAX) {
|
||||
/* This should never happen, unless the int type is only 16 bits. */
|
||||
avrdude_message(MSG_INFO, "%s: Error: Attempting to read more than %d bytes\n",
|
||||
progname, INT_MAX);
|
||||
pmsg_error("attempting to read more than %d bytes\n", INT_MAX);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
@ -484,19 +474,16 @@ int flip2_paged_write(const PROGRAMMER *pgm, const AVRPART *part, const AVRMEM *
|
|||
mem_unit = flip2_mem_unit(mem->desc);
|
||||
|
||||
if (mem_unit == FLIP2_MEM_UNIT_UNKNOWN) {
|
||||
avrdude_message(MSG_INFO, "%s: Error: "
|
||||
"\"%s\" memory not accessible using FLIP",
|
||||
progname, mem->desc);
|
||||
pmsg_error("%s memory not accessible using FLIP", mem->desc);
|
||||
if (strcmp(mem->desc, "flash") == 0)
|
||||
avrdude_message(MSG_INFO, " (did you mean \"application\"?)");
|
||||
avrdude_message(MSG_INFO, "\n");
|
||||
msg_error(" (did you mean \"application\"?)");
|
||||
msg_error("\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (n_bytes > INT_MAX) {
|
||||
/* This should never happen, unless the int type is only 16 bits. */
|
||||
avrdude_message(MSG_INFO, "%s: Error: Attempting to read more than %d bytes\n",
|
||||
progname, INT_MAX);
|
||||
pmsg_error("attempting to read more than %d bytes\n", INT_MAX);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
@ -534,8 +521,7 @@ int flip2_read_sig_bytes(const PROGRAMMER *pgm, const AVRPART *part, const AVRME
|
|||
return -1;
|
||||
|
||||
if (mem->size < sizeof(FLIP2(pgm)->part_sig)) {
|
||||
avrdude_message(MSG_INFO, "%s: Error: Signature read must be at least %u bytes\n",
|
||||
progname, (unsigned int) sizeof(FLIP2(pgm)->part_sig));
|
||||
pmsg_error("signature read must be at least %u bytes\n", (unsigned int) sizeof(FLIP2(pgm)->part_sig));
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -548,8 +534,7 @@ void flip2_setup(PROGRAMMER * pgm)
|
|||
pgm->cookie = calloc(1, sizeof(struct flip2));
|
||||
|
||||
if (pgm->cookie == NULL) {
|
||||
avrdude_message(MSG_INFO, "%s: Out of memory allocating private data structure\n",
|
||||
progname);
|
||||
pmsg_error("out of memory allocating private data structure\n");
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
@ -567,24 +552,24 @@ void flip2_show_info(struct flip2 *flip2)
|
|||
{
|
||||
dfu_show_info(flip2->dfu);
|
||||
|
||||
avrdude_message(MSG_INFO, " Part signature : 0x%02X%02X%02X\n",
|
||||
msg_info(" Part signature : 0x%02X%02X%02X\n",
|
||||
(int) flip2->part_sig[0],
|
||||
(int) flip2->part_sig[1],
|
||||
(int) flip2->part_sig[2]);
|
||||
|
||||
if (flip2->part_rev < 26)
|
||||
avrdude_message(MSG_INFO, " Part revision : %c\n",
|
||||
msg_info(" Part revision : %c\n",
|
||||
(char) (flip2->part_rev + 'A'));
|
||||
else
|
||||
avrdude_message(MSG_INFO, " Part revision : %c%c\n",
|
||||
msg_info(" Part revision : %c%c\n",
|
||||
(char) (flip2->part_rev / 26 - 1 + 'A'),
|
||||
(char) (flip2->part_rev % 26 + 'A'));
|
||||
|
||||
avrdude_message(MSG_INFO, " Bootloader version : 2.%hu.%hu\n",
|
||||
msg_info(" Bootloader version : 2.%hu.%hu\n",
|
||||
((unsigned short) flip2->boot_ver >> 4) & 0xF,
|
||||
((unsigned short) flip2->boot_ver >> 0) & 0xF);
|
||||
|
||||
avrdude_message(MSG_INFO, " USB max packet size : %hu\n",
|
||||
msg_info(" USB max packet size : %hu\n",
|
||||
(unsigned short) flip2->dfu->dev_desc.bMaxPacketSize0);
|
||||
}
|
||||
|
||||
|
@ -597,18 +582,15 @@ int flip2_read_memory(struct dfu_dev *dfu,
|
|||
int read_size;
|
||||
int result;
|
||||
|
||||
avrdude_message(MSG_NOTICE2, "%s: flip_read_memory(%s, 0x%04x, %d)\n",
|
||||
progname, flip2_mem_unit_str(mem_unit), addr, size);
|
||||
pmsg_notice2("flip_read_memory(%s, 0x%04x, %d)\n", flip2_mem_unit_str(mem_unit), addr, size);
|
||||
|
||||
result = flip2_set_mem_unit(dfu, mem_unit);
|
||||
|
||||
if (result != 0) {
|
||||
if ((mem_name = flip2_mem_unit_str(mem_unit)) != NULL)
|
||||
avrdude_message(MSG_INFO, "%s: Error: Failed to set memory unit 0x%02X (%s)\n",
|
||||
progname, (int) mem_unit, mem_name);
|
||||
pmsg_error("unable to set memory unit 0x%02X (%s)\n", (int) mem_unit, mem_name);
|
||||
else
|
||||
avrdude_message(MSG_INFO, "%s: Error: Failed to set memory unit 0x%02X\n",
|
||||
progname, (int) mem_unit);
|
||||
pmsg_error("unable to set memory unit 0x%02X\n", (int) mem_unit);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -616,8 +598,7 @@ int flip2_read_memory(struct dfu_dev *dfu,
|
|||
result = flip2_set_mem_page(dfu, page_addr);
|
||||
|
||||
if (result != 0) {
|
||||
avrdude_message(MSG_INFO, "%s: Error: Failed to set memory page 0x%04hX\n",
|
||||
progname, page_addr);
|
||||
pmsg_error("unable to set memory page 0x%04hX\n", page_addr);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -628,8 +609,7 @@ int flip2_read_memory(struct dfu_dev *dfu,
|
|||
if (page_addr != prev_page_addr) {
|
||||
result = flip2_set_mem_page(dfu, page_addr);
|
||||
if (result != 0) {
|
||||
avrdude_message(MSG_INFO, "%s: Error: Failed to set memory page 0x%04hX\n",
|
||||
progname, page_addr);
|
||||
pmsg_error("unable to set memory page 0x%04hX\n", page_addr);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
@ -638,8 +618,7 @@ int flip2_read_memory(struct dfu_dev *dfu,
|
|||
result = flip2_read_max1k(dfu, addr & 0xFFFF, ptr, read_size);
|
||||
|
||||
if (result != 0) {
|
||||
avrdude_message(MSG_INFO, "%s: Error: Failed to read 0x%04X bytes at 0x%04lX\n",
|
||||
progname, read_size, (unsigned long) addr);
|
||||
pmsg_error("unable to read 0x%04X bytes at 0x%04lX\n", read_size, (unsigned long) addr);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -660,18 +639,15 @@ int flip2_write_memory(struct dfu_dev *dfu,
|
|||
int write_size;
|
||||
int result;
|
||||
|
||||
avrdude_message(MSG_NOTICE2, "%s: flip_write_memory(%s, 0x%04x, %d)\n",
|
||||
progname, flip2_mem_unit_str(mem_unit), addr, size);
|
||||
pmsg_notice2("flip_write_memory(%s, 0x%04x, %d)\n", flip2_mem_unit_str(mem_unit), addr, size);
|
||||
|
||||
result = flip2_set_mem_unit(dfu, mem_unit);
|
||||
|
||||
if (result != 0) {
|
||||
if ((mem_name = flip2_mem_unit_str(mem_unit)) != NULL)
|
||||
avrdude_message(MSG_INFO, "%s: Error: Failed to set memory unit 0x%02X (%s)\n",
|
||||
progname, (int) mem_unit, mem_name);
|
||||
pmsg_error("unable to set memory unit 0x%02X (%s)\n", (int) mem_unit, mem_name);
|
||||
else
|
||||
avrdude_message(MSG_INFO, "%s: Error: Failed to set memory unit 0x%02X\n",
|
||||
progname, (int) mem_unit);
|
||||
pmsg_error("unable to set memory unit 0x%02X\n", (int) mem_unit);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -679,8 +655,7 @@ int flip2_write_memory(struct dfu_dev *dfu,
|
|||
result = flip2_set_mem_page(dfu, page_addr);
|
||||
|
||||
if (result != 0) {
|
||||
avrdude_message(MSG_INFO, "%s: Error: Failed to set memory page 0x%04hX\n",
|
||||
progname, page_addr);
|
||||
pmsg_error("unable to set memory page 0x%04hX\n", page_addr);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -691,8 +666,7 @@ int flip2_write_memory(struct dfu_dev *dfu,
|
|||
if (page_addr != prev_page_addr) {
|
||||
result = flip2_set_mem_page(dfu, page_addr);
|
||||
if (result != 0) {
|
||||
avrdude_message(MSG_INFO, "%s: Error: Failed to set memory page 0x%04hX\n",
|
||||
progname, page_addr);
|
||||
pmsg_error("unable to set memory page 0x%04hX\n", page_addr);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
@ -701,8 +675,7 @@ int flip2_write_memory(struct dfu_dev *dfu,
|
|||
result = flip2_write_max1k(dfu, addr & 0xFFFF, ptr, write_size);
|
||||
|
||||
if (result != 0) {
|
||||
avrdude_message(MSG_INFO, "%s: Error: Failed to write 0x%04X bytes at 0x%04lX\n",
|
||||
progname, write_size, (unsigned long) addr);
|
||||
pmsg_error("unable to write 0x%04X bytes at 0x%04lX\n", write_size, (unsigned long) addr);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -738,11 +711,9 @@ int flip2_set_mem_unit(struct dfu_dev *dfu, enum flip2_mem_unit mem_unit)
|
|||
if (status.bStatus == ((FLIP2_STATUS_OUTOFRANGE >> 8) & 0xFF) &&
|
||||
status.bState == ((FLIP2_STATUS_OUTOFRANGE >> 0) & 0xFF))
|
||||
{
|
||||
avrdude_message(MSG_INFO, "%s: Error: Unknown memory unit (0x%02x)\n",
|
||||
progname, (unsigned int) mem_unit);
|
||||
pmsg_error("unknown memory unit (0x%02x)\n", (unsigned int) mem_unit);
|
||||
} else
|
||||
avrdude_message(MSG_INFO, "%s: Error: DFU status %s\n", progname,
|
||||
flip2_status_str(&status));
|
||||
pmsg_error("DFU status %s\n", flip2_status_str(&status));
|
||||
dfu_clrstatus(dfu);
|
||||
}
|
||||
|
||||
|
@ -775,11 +746,9 @@ int flip2_set_mem_page(struct dfu_dev *dfu,
|
|||
if (status.bStatus == ((FLIP2_STATUS_OUTOFRANGE >> 8) & 0xFF) &&
|
||||
status.bState == ((FLIP2_STATUS_OUTOFRANGE >> 0) & 0xFF))
|
||||
{
|
||||
avrdude_message(MSG_INFO, "%s: Error: Page address out of range (0x%04hx)\n",
|
||||
progname, page_addr);
|
||||
pmsg_error("page address out of range (0x%04hx)\n", page_addr);
|
||||
} else
|
||||
avrdude_message(MSG_INFO, "%s: Error: DFU status %s\n", progname,
|
||||
flip2_status_str(&status));
|
||||
pmsg_error("DFU status %s\n", flip2_status_str(&status));
|
||||
dfu_clrstatus(dfu);
|
||||
}
|
||||
|
||||
|
@ -820,11 +789,9 @@ flip2_read_max1k_status:
|
|||
if (status.bStatus == ((FLIP2_STATUS_OUTOFRANGE >> 8) & 0xFF) &&
|
||||
status.bState == ((FLIP2_STATUS_OUTOFRANGE >> 0) & 0xFF))
|
||||
{
|
||||
avrdude_message(MSG_INFO, "%s: Error: Address out of range [0x%04hX,0x%04hX]\n",
|
||||
progname, offset, offset+size-1);
|
||||
pmsg_error("address out of range [0x%04hX,0x%04hX]\n", offset, offset+size-1);
|
||||
} else
|
||||
avrdude_message(MSG_INFO, "%s: Error: DFU status %s\n", progname,
|
||||
flip2_status_str(&status));
|
||||
pmsg_error("DFU status %s\n", flip2_status_str(&status));
|
||||
dfu_clrstatus(dfu);
|
||||
}
|
||||
|
||||
|
@ -850,8 +817,7 @@ int flip2_write_max1k(struct dfu_dev *dfu,
|
|||
cmd.args[3] = ((offset+size-1) >> 0) & 0xFF;
|
||||
|
||||
if (size > 0x400) {
|
||||
avrdude_message(MSG_INFO, "%s: Error: Write block too large (%hu > 1024)\n",
|
||||
progname, size);
|
||||
pmsg_error("erite block too large (%hu > 1024)\n", size);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -881,11 +847,9 @@ int flip2_write_max1k(struct dfu_dev *dfu,
|
|||
if (status.bStatus == ((FLIP2_STATUS_OUTOFRANGE >> 8) & 0xFF) &&
|
||||
status.bState == ((FLIP2_STATUS_OUTOFRANGE >> 0) & 0xFF))
|
||||
{
|
||||
avrdude_message(MSG_INFO, "%s: Error: Address out of range [0x%04hX,0x%04hX]\n",
|
||||
progname, offset, offset+size-1);
|
||||
pmsg_error("address out of range [0x%04hX,0x%04hX]\n", offset, offset+size-1);
|
||||
} else
|
||||
avrdude_message(MSG_INFO, "%s: Error: DFU status %s\n", progname,
|
||||
flip2_status_str(&status));
|
||||
pmsg_error("DFU status %s\n", flip2_status_str(&status));
|
||||
dfu_clrstatus(dfu);
|
||||
}
|
||||
|
||||
|
@ -949,7 +913,7 @@ enum flip2_mem_unit flip2_mem_unit(const char *name) {
|
|||
|
||||
// Give a proper error if we were not compiled with libusb
|
||||
static int flip2_nousb_open(PROGRAMMER* pgm, const char* name) {
|
||||
avrdude_message(MSG_INFO, "%s: error, no USB support; please compile with libusb installed\n", progname);
|
||||
pmsg_error("no USB support; please compile with libusb installed\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
|
117
src/ft245r.c
117
src/ft245r.c
|
@ -94,8 +94,7 @@
|
|||
#if defined(DO_NOT_BUILD_FT245R)
|
||||
|
||||
static int ft245r_noftdi_open(PROGRAMMER *pgm, const char *name) {
|
||||
avrdude_message(MSG_INFO, "%s: error: no libftdi or libusb support. Install libftdi1/libusb-1.0 or libftdi/libusb and run configure/make again.\n",
|
||||
progname);
|
||||
pmsg_error("no libftdi or libusb support; install libftdi1/libusb-1.0 or libftdi/libusb and run configure/make\n");
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
@ -189,8 +188,7 @@ static int ft245r_fill(const PROGRAMMER *pgm) {
|
|||
return -1;
|
||||
rx.pending -= nread;
|
||||
#if FT245R_DEBUG
|
||||
avrdude_message(MSG_INFO, "%s: read %d bytes (pending=%d)\n",
|
||||
__func__, nread, rx.pending);
|
||||
msg_info("%s: read %d bytes (pending=%d)\n", __func__, nread, rx.pending);
|
||||
#endif
|
||||
for (i = 0; i < nread; ++i)
|
||||
ft245r_rx_buf_put(pgm, raw[i]);
|
||||
|
@ -223,9 +221,7 @@ static int ft245r_flush(const PROGRAMMER *pgm) {
|
|||
if (avail <= 0) {
|
||||
avail = ft245r_fill(pgm);
|
||||
if (avail < 0) {
|
||||
avrdude_message(MSG_INFO,
|
||||
"%s: fill returned %d: %s\n",
|
||||
__func__, avail, ftdi_get_error_string(handle));
|
||||
pmsg_error("fill returned %d: %s\n", avail, ftdi_get_error_string(handle));
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
@ -233,13 +229,11 @@ static int ft245r_flush(const PROGRAMMER *pgm) {
|
|||
avail = len;
|
||||
|
||||
#if FT245R_DEBUG
|
||||
avrdude_message(MSG_INFO, "%s: writing %d bytes\n", __func__, avail);
|
||||
msg_info("%s: writing %d bytes\n", __func__, avail);
|
||||
#endif
|
||||
rv = ftdi_write_data(handle, src, avail);
|
||||
if (rv != avail) {
|
||||
avrdude_message(MSG_INFO,
|
||||
"%s: write returned %d (expected %d): %s\n",
|
||||
__func__, rv, avail, ftdi_get_error_string(handle));
|
||||
msg_error("write returned %d (expected %d): %s\n", rv, avail, ftdi_get_error_string(handle));
|
||||
return -1;
|
||||
}
|
||||
src += avail;
|
||||
|
@ -282,8 +276,7 @@ static int ft245r_recv(const PROGRAMMER *pgm, unsigned char *buf, size_t len) {
|
|||
ft245r_fill(pgm);
|
||||
|
||||
#if FT245R_DEBUG
|
||||
avrdude_message(MSG_INFO, "%s: discarding %d, consuming %zu bytes\n",
|
||||
__func__, rx.discard, len);
|
||||
msg_info("%s: discarding %d, consuming %zu bytes\n", __func__, rx.discard, len);
|
||||
#endif
|
||||
while (rx.discard > 0) {
|
||||
int result = ft245r_rx_buf_fill_and_get(pgm);
|
||||
|
@ -320,7 +313,7 @@ static int ft245r_recv(const PROGRAMMER *pgm, unsigned char *buf, size_t len) {
|
|||
static int ft245r_drain(const PROGRAMMER *pgm, int display) {
|
||||
int r;
|
||||
|
||||
// flush the buffer in the chip by changing the mode.....
|
||||
// flush the buffer in the chip by changing the mode ...
|
||||
r = ftdi_set_bitmode(handle, 0, BITMODE_RESET); // reset
|
||||
if (r) return -1;
|
||||
r = ftdi_set_bitmode(handle, ft245r_ddr, BITMODE_SYNCBB); // set Synchronuse BitBang
|
||||
|
@ -347,8 +340,7 @@ static int ft245r_chip_erase(const PROGRAMMER *pgm, const AVRPART *p) {
|
|||
return avr_tpi_chip_erase(pgm, p);
|
||||
|
||||
if (p->op[AVR_OP_CHIP_ERASE] == NULL) {
|
||||
avrdude_message(MSG_INFO, "chip erase instruction not defined for part \"%s\"\n",
|
||||
p->desc);
|
||||
msg_error("chip erase instruction not defined for part %s\n", p->desc);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -381,14 +373,12 @@ static int ft245r_set_bitclock(const PROGRAMMER *pgm) {
|
|||
ftdi_rate = rate;
|
||||
#endif
|
||||
|
||||
avrdude_message(MSG_NOTICE2,
|
||||
"%s: bitclk %d -> FTDI rate %d, baud multiplier %d\n",
|
||||
msg_notice2("%s: bitclk %d -> FTDI rate %d, baud multiplier %d\n",
|
||||
__func__, rate, ftdi_rate, baud_multiplier);
|
||||
|
||||
r = ftdi_set_baudrate(handle, ftdi_rate);
|
||||
if (r) {
|
||||
avrdude_message(MSG_INFO, "Set baudrate (%d) failed with error '%s'.\n",
|
||||
rate, ftdi_get_error_string (handle));
|
||||
msg_error("set baudrate %d failed with error '%s'\n", rate, ftdi_get_error_string (handle));
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
|
@ -402,7 +392,7 @@ static int get_pin(const PROGRAMMER *pgm, int pinname) {
|
|||
if (ftdi_read_pins(handle, &byte) != 0)
|
||||
return -1;
|
||||
if (FT245R_DEBUG)
|
||||
avrdude_message(MSG_INFO, "%s: in 0x%02x\n", __func__, byte);
|
||||
msg_info("%s: in 0x%02x\n", __func__, byte);
|
||||
return GET_BITS_0(byte, pgm, pinname) != 0;
|
||||
}
|
||||
|
||||
|
@ -506,8 +496,7 @@ static int ft245r_program_enable(const PROGRAMMER *pgm, const AVRPART *p) {
|
|||
return avr_tpi_program_enable(pgm, p, TPIPCR_GT_0b);
|
||||
|
||||
if (p->op[AVR_OP_PGM_ENABLE] == NULL) {
|
||||
avrdude_message(MSG_INFO, "%s: AVR_OP_PGM_ENABLE command not defined for %s\n",
|
||||
progname, p->desc);
|
||||
pmsg_error("AVR_OP_PGM_ENABLE command not defined for %s\n", p->desc);
|
||||
fflush(stderr);
|
||||
return -1;
|
||||
}
|
||||
|
@ -520,8 +509,7 @@ static int ft245r_program_enable(const PROGRAMMER *pgm, const AVRPART *p) {
|
|||
if (res[p->pollindex-1] == p->pollvalue) return 0;
|
||||
|
||||
if (FT245R_DEBUG) {
|
||||
avrdude_message(MSG_NOTICE, "%s: Program enable command not successful. Retrying.\n",
|
||||
progname);
|
||||
pmsg_notice("program enable command not successful, retrying\n");
|
||||
fflush(stderr);
|
||||
}
|
||||
set_pin(pgm, PIN_AVR_RESET, ON);
|
||||
|
@ -534,8 +522,7 @@ static int ft245r_program_enable(const PROGRAMMER *pgm, const AVRPART *p) {
|
|||
}
|
||||
}
|
||||
|
||||
avrdude_message(MSG_INFO, "%s: Device is not responding to program enable. Check connection.\n",
|
||||
progname);
|
||||
pmsg_error("device is not responding to program enable; check connection\n");
|
||||
fflush(stderr);
|
||||
|
||||
return -1;
|
||||
|
@ -576,20 +563,26 @@ static int ft245r_initialize(const PROGRAMMER *pgm, const AVRPART *p) {
|
|||
set_pin(pgm, PIN_AVR_MOSI, 0);
|
||||
if (get_pin(pgm, PIN_AVR_MISO) != 0) {
|
||||
io_link_ok = false;
|
||||
avrdude_message(MSG_INFO, "MOSI->MISO 0 failed\n");
|
||||
if (!ovsigck)
|
||||
if(ovsigck) {
|
||||
pmsg_warning("MOSI->MISO 0 failed\n");
|
||||
} else {
|
||||
pmsg_error("MOSI->MISO 0 failed\n");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
set_pin(pgm, PIN_AVR_MOSI, 1);
|
||||
if (get_pin(pgm, PIN_AVR_MISO) != 1) {
|
||||
io_link_ok = false;
|
||||
avrdude_message(MSG_INFO, "MOSI->MISO 1 failed\n");
|
||||
if (!ovsigck)
|
||||
if(ovsigck) {
|
||||
pmsg_warning("MOSI->MISO 1 failed\n");
|
||||
} else {
|
||||
pmsg_error("MOSI->MISO 1 failed\n");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
if (io_link_ok)
|
||||
avrdude_message(MSG_NOTICE2, "MOSI-MISO link present\n");
|
||||
msg_notice2("MOSI-MISO link present\n");
|
||||
|
||||
/* keep TPIDATA high for 16 clock cycles */
|
||||
set_pin(pgm, PIN_AVR_MOSI, 1);
|
||||
|
@ -606,7 +599,7 @@ static int ft245r_initialize(const PROGRAMMER *pgm, const AVRPART *p) {
|
|||
ft245r_tpi_tx(pgm, TPI_CMD_SLDCS | TPI_REG_TPIIR);
|
||||
ft245r_tpi_rx(pgm, &byte);
|
||||
if (byte != 0x80) {
|
||||
avrdude_message(MSG_INFO, "TPIIR 0x%02x not correct\n", byte);
|
||||
msg_error("TPIIR 0x%02x not correct\n", byte);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
@ -769,8 +762,7 @@ static int ft245r_tpi_rx(const PROGRAMMER *pgm, uint8_t *bytep) {
|
|||
while (m & res)
|
||||
m <<= 1;
|
||||
if (m >= 0x10) {
|
||||
avrdude_message(MSG_INFO, "%s: start bit missing (res=0x%04x)\n",
|
||||
__func__, res);
|
||||
pmsg_error("start bit missing (res=0x%04x)\n", res);
|
||||
return -1;
|
||||
}
|
||||
byte = parity = 0;
|
||||
|
@ -782,11 +774,11 @@ static int ft245r_tpi_rx(const PROGRAMMER *pgm, uint8_t *bytep) {
|
|||
}
|
||||
m <<= 1;
|
||||
if (((res & m) != 0) != parity) {
|
||||
avrdude_message(MSG_INFO, "%s: parity bit wrong\n", __func__);
|
||||
pmsg_error("parity bit wrong\n");
|
||||
return -1;
|
||||
}
|
||||
if (((res & (m << 1)) == 0) || ((res & (m << 2))) == 0) {
|
||||
avrdude_message(MSG_INFO, "%s: stop bits wrong\n", __func__);
|
||||
pmsg_error("stop bits wrong\n");
|
||||
return -1;
|
||||
}
|
||||
*bytep = (uint8_t) byte;
|
||||
|
@ -805,13 +797,13 @@ static int ft245r_cmd_tpi(const PROGRAMMER *pgm, const unsigned char *cmd,
|
|||
if ((ret = ft245r_tpi_rx(pgm, &res[i])) < 0)
|
||||
break;
|
||||
if (verbose >= 2) {
|
||||
avrdude_message(MSG_NOTICE2, "%s: [ ", __func__);
|
||||
msg_notice2("%s: [ ", __func__);
|
||||
for (i = 0; i < cmd_len; i++)
|
||||
avrdude_message(MSG_NOTICE2, "%02X ", cmd[i]);
|
||||
avrdude_message(MSG_NOTICE2, "] [ ");
|
||||
msg_notice2("%02X ", cmd[i]);
|
||||
msg_notice2("] [ ");
|
||||
for(i = 0; i < res_len; i++)
|
||||
avrdude_message(MSG_NOTICE2, "%02X ", res[i]);
|
||||
avrdude_message(MSG_NOTICE2, "]\n");
|
||||
msg_notice2("%02X ", res[i]);
|
||||
msg_notice2("]\n");
|
||||
}
|
||||
|
||||
pgm->pgm_led(pgm, OFF);
|
||||
|
@ -845,20 +837,12 @@ static int ft245r_open(PROGRAMMER *pgm, const char *port) {
|
|||
|
||||
// read device string cut after 8 chars (max. length of serial number)
|
||||
if ((sscanf(port, "usb:%8s", device) != 1)) {
|
||||
avrdude_message(MSG_NOTICE,
|
||||
"%s: ft245r_open(): no device identifier in portname, using default\n",
|
||||
progname);
|
||||
pmsg_notice("ft245r_open(): no device identifier in portname, using default\n");
|
||||
pgm->usbsn = cache_string("");
|
||||
devnum = 0;
|
||||
} else {
|
||||
if (strlen(device) == 8 ){ // serial number
|
||||
if (verbose >= 2) {
|
||||
avrdude_message(MSG_INFO,
|
||||
"%s: ft245r_open(): serial number parsed as: "
|
||||
"%s\n",
|
||||
progname,
|
||||
device);
|
||||
}
|
||||
pmsg_notice2("ft245r_open(): serial number parsed as: %s\n", device);
|
||||
// copy serial number to pgm struct
|
||||
pgm->usbsn = cache_string(device);
|
||||
// and use first device with matching serial (should be unique)
|
||||
|
@ -871,18 +855,13 @@ static int ft245r_open(PROGRAMMER *pgm, const char *port) {
|
|||
if ((startptr==endptr) || (*endptr != '\0')) {
|
||||
devnum = -1;
|
||||
}
|
||||
avrdude_message(MSG_INFO,
|
||||
"%s: ft245r_open(): device number parsed as: "
|
||||
"%d\n",
|
||||
progname,
|
||||
devnum);
|
||||
pmsg_notice2("ft245r_open(): device number parsed as: %d\n", devnum);
|
||||
}
|
||||
}
|
||||
|
||||
// if something went wrong before abort with helpful message
|
||||
if (devnum < 0) {
|
||||
avrdude_message(MSG_INFO, "%s: ft245r_open(): invalid portname '%s': use^ 'ft[0-9]+' or serial number\n",
|
||||
progname,port);
|
||||
pmsg_error("invalid portname '%s': use^ 'ft[0-9]+' or serial number\n", port);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -893,8 +872,7 @@ static int ft245r_open(PROGRAMMER *pgm, const char *port) {
|
|||
if (usbpid) {
|
||||
pid = *(int *)(ldata(usbpid));
|
||||
if (lnext(usbpid))
|
||||
avrdude_message(MSG_INFO, "%s: Warning: using PID 0x%04x, ignoring remaining PIDs in list\n",
|
||||
progname, pid);
|
||||
pmsg_warning("using PID 0x%04x, ignoring remaining PIDs in list\n", pid);
|
||||
} else {
|
||||
pid = USB_DEVICE_FT245;
|
||||
}
|
||||
|
@ -905,8 +883,7 @@ static int ft245r_open(PROGRAMMER *pgm, const char *port) {
|
|||
pgm->usbsn[0]?pgm->usbsn:NULL,
|
||||
devnum);
|
||||
if (rv) {
|
||||
avrdude_message(MSG_INFO, "%s: can't open ftdi device: %s\n",
|
||||
progname, ftdi_get_error_string(handle));
|
||||
pmsg_error("cannot open ftdi device: %s\n", ftdi_get_error_string(handle));
|
||||
goto cleanup_no_usb;
|
||||
}
|
||||
|
||||
|
@ -936,15 +913,13 @@ static int ft245r_open(PROGRAMMER *pgm, const char *port) {
|
|||
|
||||
rv = ftdi_set_latency_timer(handle, 1);
|
||||
if (rv) {
|
||||
avrdude_message(MSG_INFO, "%s: unable to set latency timer to 1 (%s)\n",
|
||||
progname, ftdi_get_error_string(handle));
|
||||
pmsg_error("unable to set latency timer to 1 (%s)\n", ftdi_get_error_string(handle));
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
rv = ftdi_set_bitmode(handle, ft245r_ddr, BITMODE_SYNCBB); // set Synchronous BitBang
|
||||
if (rv) {
|
||||
avrdude_message(MSG_INFO, "%s: Synchronous BitBangMode is not supported (%s)\n",
|
||||
progname, ftdi_get_error_string(handle));
|
||||
pmsg_error("synchronous BitBangMode is not supported (%s)\n", ftdi_get_error_string(handle));
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
|
@ -985,7 +960,7 @@ static void ft245r_close(PROGRAMMER * pgm) {
|
|||
}
|
||||
|
||||
static void ft245r_display(const PROGRAMMER *pgm, const char *p) {
|
||||
avrdude_message(MSG_INFO, "%sPin assignment : 0..7 = DBUS0..7\n",p);/* , 8..11 = GPIO0..3\n",p);*/
|
||||
msg_info("%sPin assignment : 0..7 = DBUS0..7\n", p); // , 8..11 = GPIO0..3\n",p);
|
||||
pgm_display_generic_mask(pgm, p, SHOW_ALL_PINS);
|
||||
}
|
||||
|
||||
|
@ -1016,7 +991,7 @@ static void put_request(int addr, int bytes, int n) {
|
|||
} else {
|
||||
p = malloc(sizeof(struct ft245r_request));
|
||||
if (!p) {
|
||||
avrdude_message(MSG_INFO, "can't alloc memory\n");
|
||||
msg_error("cannot alloc memory\n");
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
@ -1065,7 +1040,7 @@ static int ft245r_paged_write_flash(const PROGRAMMER *pgm, const AVRPART *p, con
|
|||
unsigned char cmd[4];
|
||||
|
||||
if(m->op[AVR_OP_LOADPAGE_LO] == NULL || m->op[AVR_OP_LOADPAGE_HI] == NULL) {
|
||||
avrdude_message(MSG_INFO, "AVR_OP_LOADPAGE_HI/LO command not defined for %s\n", p->desc);
|
||||
msg_error("AVR_OP_LOADPAGE_HI/LO command not defined for %s\n", p->desc);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -1163,7 +1138,7 @@ static int ft245r_paged_load_flash(const PROGRAMMER *pgm, const AVRPART *p, cons
|
|||
unsigned char cmd[4];
|
||||
|
||||
if(m->op[AVR_OP_READ_LO] == NULL || m->op[AVR_OP_READ_HI] == NULL) {
|
||||
avrdude_message(MSG_INFO, "AVR_OP_READ_HI/LO command not defined for %s\n", p->desc);
|
||||
msg_error("AVR_OP_READ_HI/LO command not defined for %s\n", p->desc);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
|
485
src/jtag3.c
485
src/jtag3.c
File diff suppressed because it is too large
Load Diff
369
src/jtagmkI.c
369
src/jtagmkI.c
|
@ -111,8 +111,7 @@ static int jtagmkI_resync(const PROGRAMMER *pgm, int maxtries, int signon);
|
|||
static void jtagmkI_setup(PROGRAMMER * pgm)
|
||||
{
|
||||
if ((pgm->cookie = malloc(sizeof(struct pdata))) == 0) {
|
||||
avrdude_message(MSG_INFO, "%s: jtagmkI_setup(): Out of memory allocating private data\n",
|
||||
progname);
|
||||
pmsg_error("out of memory allocating private data\n");
|
||||
exit(1);
|
||||
}
|
||||
memset(pgm->cookie, 0, sizeof(struct pdata));
|
||||
|
@ -143,65 +142,64 @@ static void jtagmkI_prmsg(const PROGRAMMER *pgm, unsigned char *data, size_t len
|
|||
int i;
|
||||
|
||||
if (verbose >= 4) {
|
||||
avrdude_message(MSG_TRACE, "Raw message:\n");
|
||||
msg_trace("Raw message:\n");
|
||||
|
||||
for (i = 0; i < len; i++) {
|
||||
avrdude_message(MSG_TRACE, "0x%02x ", data[i]);
|
||||
msg_trace("0x%02x ", data[i]);
|
||||
if (i % 16 == 15)
|
||||
putc('\n', stderr);
|
||||
msg_trace("\n");
|
||||
else
|
||||
putc(' ', stderr);
|
||||
msg_trace(" ");
|
||||
}
|
||||
if (i % 16 != 0)
|
||||
putc('\n', stderr);
|
||||
msg_trace("\n");
|
||||
}
|
||||
|
||||
switch (data[0]) {
|
||||
case RESP_OK:
|
||||
avrdude_message(MSG_INFO, "OK\n");
|
||||
msg_info("OK\n");
|
||||
break;
|
||||
|
||||
case RESP_FAILED:
|
||||
avrdude_message(MSG_INFO, "FAILED\n");
|
||||
msg_info("FAILED\n");
|
||||
break;
|
||||
|
||||
case RESP_BREAK:
|
||||
avrdude_message(MSG_INFO, "breakpoint hit\n");
|
||||
msg_info("breakpoint hit\n");
|
||||
break;
|
||||
|
||||
case RESP_INFO:
|
||||
avrdude_message(MSG_INFO, "IDR dirty\n");
|
||||
msg_info("IDR dirty\n");
|
||||
break;
|
||||
|
||||
case RESP_SYNC_ERROR:
|
||||
avrdude_message(MSG_INFO, "Synchronization lost\n");
|
||||
msg_info("Synchronization lost\n");
|
||||
break;
|
||||
|
||||
case RESP_SLEEP:
|
||||
avrdude_message(MSG_INFO, "sleep instruction hit\n");
|
||||
msg_info("sleep instruction hit\n");
|
||||
break;
|
||||
|
||||
case RESP_POWER:
|
||||
avrdude_message(MSG_INFO, "target power lost\n");
|
||||
msg_info("target power lost\n");
|
||||
|
||||
default:
|
||||
avrdude_message(MSG_INFO, "unknown message 0x%02x\n", data[0]);
|
||||
msg_info("unknown message 0x%02x\n", data[0]);
|
||||
}
|
||||
|
||||
putc('\n', stderr);
|
||||
msg_info("\n");
|
||||
}
|
||||
|
||||
|
||||
static int jtagmkI_send(const PROGRAMMER *pgm, unsigned char *data, size_t len) {
|
||||
unsigned char *buf;
|
||||
|
||||
avrdude_message(MSG_DEBUG, "\n%s: jtagmkI_send(): sending %u bytes\n",
|
||||
progname, (unsigned int)len);
|
||||
msg_debug("\n");
|
||||
pmsg_debug("jtagmkI_send(): sending %u bytes\n", (unsigned int) len);
|
||||
|
||||
if ((buf = malloc(len + 2)) == NULL)
|
||||
{
|
||||
avrdude_message(MSG_INFO, "%s: jtagmkI_send(): out of memory",
|
||||
progname);
|
||||
pmsg_error("out of memory");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
@ -210,8 +208,7 @@ static int jtagmkI_send(const PROGRAMMER *pgm, unsigned char *data, size_t len)
|
|||
buf[len + 1] = ' '; /* EOP */
|
||||
|
||||
if (serial_send(&pgm->fd, buf, len + 2) != 0) {
|
||||
avrdude_message(MSG_INFO, "%s: jtagmkI_send(): failed to send command to serial port\n",
|
||||
progname);
|
||||
pmsg_error("unable to send command to serial port\n");
|
||||
free(buf);
|
||||
return -1;
|
||||
}
|
||||
|
@ -223,12 +220,12 @@ static int jtagmkI_send(const PROGRAMMER *pgm, unsigned char *data, size_t len)
|
|||
|
||||
static int jtagmkI_recv(const PROGRAMMER *pgm, unsigned char *buf, size_t len) {
|
||||
if (serial_recv(&pgm->fd, buf, len) != 0) {
|
||||
avrdude_message(MSG_INFO, "\n%s: jtagmkI_recv(): failed to send command to serial port\n",
|
||||
progname);
|
||||
msg_error("\n");
|
||||
pmsg_error("unable to send command to serial port\n");
|
||||
return -1;
|
||||
}
|
||||
if (verbose >= 3) {
|
||||
putc('\n', stderr);
|
||||
msg_debug("\n");
|
||||
jtagmkI_prmsg(pgm, buf, len);
|
||||
}
|
||||
return 0;
|
||||
|
@ -247,7 +244,7 @@ static int jtagmkI_resync(const PROGRAMMER *pgm, int maxtries, int signon) {
|
|||
|
||||
serial_recv_timeout = 200;
|
||||
|
||||
avrdude_message(MSG_TRACE, "%s: jtagmkI_resync()\n", progname);
|
||||
pmsg_trace("jtagmkI_resync()\n");
|
||||
|
||||
jtagmkI_drain(pgm, 0);
|
||||
|
||||
|
@ -255,17 +252,16 @@ static int jtagmkI_resync(const PROGRAMMER *pgm, int maxtries, int signon) {
|
|||
|
||||
/* Get the sign-on information. */
|
||||
buf[0] = CMD_GET_SYNC;
|
||||
avrdude_message(MSG_NOTICE2, "%s: jtagmkI_resync(): Sending sync command: ",
|
||||
progname);
|
||||
pmsg_notice2("jtagmkI_resync(): sending sync command: ");
|
||||
|
||||
if (serial_send(&pgm->fd, buf, 1) != 0) {
|
||||
avrdude_message(MSG_INFO, "\n%s: jtagmkI_resync(): failed to send command to serial port\n",
|
||||
progname);
|
||||
msg_error("\n");
|
||||
pmsg_error("unable to send command to serial port\n");
|
||||
serial_recv_timeout = otimeout;
|
||||
return -1;
|
||||
}
|
||||
if (serial_recv(&pgm->fd, resp, 1) == 0 && resp[0] == RESP_OK) {
|
||||
avrdude_message(MSG_NOTICE2, "got RESP_OK\n");
|
||||
msg_notice2("got RESP_OK\n");
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -284,25 +280,23 @@ static int jtagmkI_resync(const PROGRAMMER *pgm, int maxtries, int signon) {
|
|||
buf[1] = 'E';
|
||||
buf[2] = ' ';
|
||||
buf[3] = ' ';
|
||||
avrdude_message(MSG_NOTICE2, "%s: jtagmkI_resync(): Sending sign-on command: ",
|
||||
progname);
|
||||
pmsg_notice2("jtagmkI_resync(): sending sign-on command: ");
|
||||
|
||||
if (serial_send(&pgm->fd, buf, 4) != 0) {
|
||||
avrdude_message(MSG_INFO, "\n%s: jtagmkI_resync(): failed to send command to serial port\n",
|
||||
progname);
|
||||
msg_error("\n");
|
||||
pmsg_error("unable to send command to serial port\n");
|
||||
serial_recv_timeout = otimeout;
|
||||
return -1;
|
||||
}
|
||||
if (serial_recv(&pgm->fd, resp, 9) == 0 && resp[0] == RESP_OK) {
|
||||
avrdude_message(MSG_NOTICE2, "got RESP_OK\n");
|
||||
msg_notice2("got RESP_OK\n");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (tries >= maxtries) {
|
||||
avrdude_message(MSG_NOTICE2, "%s: jtagmkI_resync(): "
|
||||
"timeout/error communicating with programmer\n",
|
||||
progname);
|
||||
pmsg_notice2("jtagmkI_resync(): "
|
||||
"timeout/error communicating with programmer\n");
|
||||
serial_recv_timeout = otimeout;
|
||||
return -1;
|
||||
}
|
||||
|
@ -321,17 +315,14 @@ static int jtagmkI_getsync(const PROGRAMMER *pgm) {
|
|||
|
||||
jtagmkI_drain(pgm, 0);
|
||||
|
||||
avrdude_message(MSG_NOTICE2, "%s: jtagmkI_getsync(): Sending sign-on command: ",
|
||||
progname);
|
||||
pmsg_notice2("jtagmkI_getsync(): sending sign-on command; ");
|
||||
|
||||
buf[0] = CMD_GET_SIGNON;
|
||||
jtagmkI_send(pgm, buf, 1);
|
||||
if (jtagmkI_recv(pgm, resp, 9) < 0)
|
||||
return -1;
|
||||
if (verbose >= 2) {
|
||||
resp[8] = '\0';
|
||||
avrdude_message(MSG_NOTICE2, "got %s\n", resp + 1);
|
||||
}
|
||||
msg_notice2("got %s\n", resp + 1);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -343,21 +334,16 @@ static int jtagmkI_chip_erase(const PROGRAMMER *pgm, const AVRPART *p) {
|
|||
unsigned char buf[1], resp[2];
|
||||
|
||||
buf[0] = CMD_CHIP_ERASE;
|
||||
avrdude_message(MSG_NOTICE2, "%s: jtagmkI_chip_erase(): Sending chip erase command: ",
|
||||
progname);
|
||||
pmsg_notice2("jtagmkI_chip_erase(): sending chip erase command: ");
|
||||
jtagmkI_send(pgm, buf, 1);
|
||||
if (jtagmkI_recv(pgm, resp, 2) < 0)
|
||||
return -1;
|
||||
if (resp[0] != RESP_OK) {
|
||||
if (verbose >= 2)
|
||||
putc('\n', stderr);
|
||||
avrdude_message(MSG_INFO, "%s: jtagmkI_chip_erase(): "
|
||||
"timeout/error communicating with programmer (resp %c)\n",
|
||||
progname, resp[0]);
|
||||
msg_notice2("\n");
|
||||
pmsg_error("timeout/error communicating with programmer (resp %c)\n", resp[0]);
|
||||
return -1;
|
||||
} else {
|
||||
if (verbose == 2)
|
||||
avrdude_message(MSG_NOTICE2, "OK\n");
|
||||
msg_notice2("OK\n");
|
||||
}
|
||||
|
||||
pgm->initialize(pgm, p);
|
||||
|
@ -389,22 +375,17 @@ static void jtagmkI_set_devdescr(const PROGRAMMER *pgm, const AVRPART *p) {
|
|||
}
|
||||
}
|
||||
|
||||
avrdude_message(MSG_NOTICE2, "%s: jtagmkI_set_devdescr(): "
|
||||
"Sending set device descriptor command: ",
|
||||
progname);
|
||||
pmsg_notice2("jtagmkI_set_devdescr(): "
|
||||
"Sending set device descriptor command: ");
|
||||
jtagmkI_send(pgm, (unsigned char *)&sendbuf, sizeof(sendbuf));
|
||||
|
||||
if (jtagmkI_recv(pgm, resp, 2) < 0)
|
||||
return;
|
||||
if (resp[0] != RESP_OK) {
|
||||
if (verbose >= 2)
|
||||
putc('\n', stderr);
|
||||
avrdude_message(MSG_INFO, "%s: jtagmkI_set_devdescr(): "
|
||||
"timeout/error communicating with programmer (resp %c)\n",
|
||||
progname, resp[0]);
|
||||
msg_notice2("\n");
|
||||
pmsg_error("timeout/error communicating with programmer (resp %c)\n", resp[0]);
|
||||
} else {
|
||||
if (verbose == 2)
|
||||
avrdude_message(MSG_NOTICE2, "OK\n");
|
||||
msg_notice2("OK\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -415,22 +396,17 @@ static int jtagmkI_reset(const PROGRAMMER *pgm) {
|
|||
unsigned char buf[1], resp[2];
|
||||
|
||||
buf[0] = CMD_RESET;
|
||||
avrdude_message(MSG_NOTICE2, "%s: jtagmkI_reset(): Sending reset command: ",
|
||||
progname);
|
||||
pmsg_notice2("jtagmkI_reset(): sending reset command: ");
|
||||
jtagmkI_send(pgm, buf, 1);
|
||||
|
||||
if (jtagmkI_recv(pgm, resp, 2) < 0)
|
||||
return -1;
|
||||
if (resp[0] != RESP_OK) {
|
||||
if (verbose >= 2)
|
||||
putc('\n', stderr);
|
||||
avrdude_message(MSG_INFO, "%s: jtagmkI_reset(): "
|
||||
"timeout/error communicating with programmer (resp %c)\n",
|
||||
progname, resp[0]);
|
||||
msg_notice2("\n");
|
||||
pmsg_error("timeout/error communicating with programmer (resp %c)\n", resp[0]);
|
||||
return -1;
|
||||
} else {
|
||||
if (verbose == 2)
|
||||
avrdude_message(MSG_NOTICE2, "OK\n");
|
||||
msg_notice2("OK\n");
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -448,23 +424,18 @@ static int jtagmkI_program_enable(const PROGRAMMER *pgm) {
|
|||
return 0;
|
||||
|
||||
buf[0] = CMD_ENTER_PROGMODE;
|
||||
avrdude_message(MSG_NOTICE2, "%s: jtagmkI_program_enable(): "
|
||||
"Sending enter progmode command: ",
|
||||
progname);
|
||||
pmsg_notice2("jtagmkI_program_enable(): "
|
||||
"Sending enter progmode command: ");
|
||||
jtagmkI_send(pgm, buf, 1);
|
||||
|
||||
if (jtagmkI_recv(pgm, resp, 2) < 0)
|
||||
return -1;
|
||||
if (resp[0] != RESP_OK) {
|
||||
if (verbose >= 2)
|
||||
putc('\n', stderr);
|
||||
avrdude_message(MSG_INFO, "%s: jtagmkI_program_enable(): "
|
||||
"timeout/error communicating with programmer (resp %c)\n",
|
||||
progname, resp[0]);
|
||||
msg_notice2("\n");
|
||||
pmsg_error("timeout/error communicating with programmer (resp %c)\n", resp[0]);
|
||||
return -1;
|
||||
} else {
|
||||
if (verbose == 2)
|
||||
avrdude_message(MSG_NOTICE2, "OK\n");
|
||||
msg_notice2("OK\n");
|
||||
}
|
||||
|
||||
PDATA(pgm)->prog_enabled = 1;
|
||||
|
@ -480,23 +451,17 @@ static int jtagmkI_program_disable(const PROGRAMMER *pgm) {
|
|||
|
||||
if (pgm->fd.ifd != -1) {
|
||||
buf[0] = CMD_LEAVE_PROGMODE;
|
||||
avrdude_message(MSG_NOTICE2, "%s: jtagmkI_program_disable(): "
|
||||
"Sending leave progmode command: ",
|
||||
progname);
|
||||
pmsg_notice2("jtagmkI_program_disable(): sending leave progmode command: ");
|
||||
jtagmkI_send(pgm, buf, 1);
|
||||
|
||||
if (jtagmkI_recv(pgm, resp, 2) < 0)
|
||||
return -1;
|
||||
if (resp[0] != RESP_OK) {
|
||||
if (verbose >= 2)
|
||||
putc('\n', stderr);
|
||||
avrdude_message(MSG_INFO, "%s: jtagmkI_program_disable(): "
|
||||
"timeout/error communicating with programmer (resp %c)\n",
|
||||
progname, resp[0]);
|
||||
msg_notice2("\n");
|
||||
pmsg_error("timeout/error communicating with programmer (resp %c)\n", resp[0]);
|
||||
return -1;
|
||||
} else {
|
||||
if (verbose == 2)
|
||||
avrdude_message(MSG_NOTICE2, "OK\n");
|
||||
msg_notice2("OK\n");
|
||||
}
|
||||
}
|
||||
PDATA(pgm)->prog_enabled = 0;
|
||||
|
@ -524,24 +489,20 @@ static int jtagmkI_initialize(const PROGRAMMER *pgm, const AVRPART *p) {
|
|||
unsigned char b;
|
||||
|
||||
if (!(p->prog_modes & (PM_JTAGmkI | PM_JTAG))) {
|
||||
avrdude_message(MSG_INFO, "%s: jtagmkI_initialize(): part %s has no JTAG interface\n",
|
||||
progname, p->desc);
|
||||
pmsg_error("part %s has no JTAG interface\n", p->desc);
|
||||
return -1;
|
||||
}
|
||||
if (!(p->prog_modes & PM_JTAGmkI))
|
||||
avrdude_message(MSG_INFO, "%s: jtagmkI_initialize(): warning part %s has JTAG interface, but may be too new\n",
|
||||
progname, p->desc);
|
||||
pmsg_warning("part %s has JTAG interface, but may be too new\n", p->desc);
|
||||
|
||||
jtagmkI_drain(pgm, 0);
|
||||
|
||||
if ((serdev->flags & SERDEV_FL_CANSETSPEED) && PDATA(pgm)->initial_baudrate != pgm->baudrate) {
|
||||
if ((b = jtagmkI_get_baud(pgm->baudrate)) == 0) {
|
||||
avrdude_message(MSG_INFO, "%s: jtagmkI_initialize(): unsupported baudrate %d\n",
|
||||
progname, pgm->baudrate);
|
||||
pmsg_error("unsupported baudrate %d\n", pgm->baudrate);
|
||||
} else {
|
||||
avrdude_message(MSG_NOTICE2, "%s: jtagmkI_initialize(): "
|
||||
"trying to set baudrate to %d\n",
|
||||
progname, pgm->baudrate);
|
||||
pmsg_notice2("jtagmkI_initialize(): "
|
||||
"trying to set baudrate to %d\n", pgm->baudrate);
|
||||
if (jtagmkI_setparm(pgm, PARM_BITRATE, b) == 0) {
|
||||
PDATA(pgm)->initial_baudrate = pgm->baudrate; /* don't adjust again later */
|
||||
serial_setparams(&pgm->fd, pgm->baudrate, SERIAL_8N1);
|
||||
|
@ -550,9 +511,8 @@ static int jtagmkI_initialize(const PROGRAMMER *pgm, const AVRPART *p) {
|
|||
}
|
||||
|
||||
if (pgm->bitclock != 0.0) {
|
||||
avrdude_message(MSG_NOTICE2, "%s: jtagmkI_initialize(): "
|
||||
"trying to set JTAG clock period to %.1f us\n",
|
||||
progname, pgm->bitclock);
|
||||
pmsg_notice2("jtagmkI_initialize(): "
|
||||
"trying to set JTAG clock period to %.1f us\n", pgm->bitclock);
|
||||
if (jtagmkI_set_sck_period(pgm, pgm->bitclock) != 0)
|
||||
return -1;
|
||||
}
|
||||
|
@ -562,14 +522,10 @@ static int jtagmkI_initialize(const PROGRAMMER *pgm, const AVRPART *p) {
|
|||
if (jtagmkI_recv(pgm, resp, 5) < 0)
|
||||
return -1;
|
||||
if (resp[0] != RESP_OK) {
|
||||
if (verbose >= 2)
|
||||
putc('\n', stderr);
|
||||
avrdude_message(MSG_INFO, "%s: jtagmkI_initialize(): "
|
||||
"timeout/error communicating with programmer (resp %c)\n",
|
||||
progname, resp[0]);
|
||||
msg_notice2("\n");
|
||||
pmsg_warning("timeout/error communicating with programmer (resp %c)\n", resp[0]);
|
||||
} else {
|
||||
if (verbose == 2)
|
||||
avrdude_message(MSG_NOTICE2, "OK\n");
|
||||
msg_notice2("OK\n");
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -584,13 +540,11 @@ static int jtagmkI_initialize(const PROGRAMMER *pgm, const AVRPART *p) {
|
|||
free(PDATA(pgm)->flash_pagecache);
|
||||
free(PDATA(pgm)->eeprom_pagecache);
|
||||
if ((PDATA(pgm)->flash_pagecache = malloc(PDATA(pgm)->flash_pagesize)) == NULL) {
|
||||
avrdude_message(MSG_INFO, "%s: jtagmkI_initialize(): Out of memory\n",
|
||||
progname);
|
||||
pmsg_error("out of memory\n");
|
||||
return -1;
|
||||
}
|
||||
if ((PDATA(pgm)->eeprom_pagecache = malloc(PDATA(pgm)->eeprom_pagesize)) == NULL) {
|
||||
avrdude_message(MSG_INFO, "%s: jtagmkI_initialize(): Out of memory\n",
|
||||
progname);
|
||||
pmsg_error("out of memory\n");
|
||||
free(PDATA(pgm)->flash_pagecache);
|
||||
return -1;
|
||||
}
|
||||
|
@ -603,9 +557,8 @@ static int jtagmkI_initialize(const PROGRAMMER *pgm, const AVRPART *p) {
|
|||
if (jtagmkI_read_byte(pgm, p, &hfuse, 1, &b) < 0)
|
||||
return -1;
|
||||
if ((b & OCDEN) != 0)
|
||||
avrdude_message(MSG_INFO, "%s: jtagmkI_initialize(): warning: OCDEN fuse not programmed, "
|
||||
"single-byte EEPROM updates not possible\n",
|
||||
progname);
|
||||
pmsg_warning("OCDEN fuse not programmed, "
|
||||
"single-byte EEPROM updates not possible\n");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -630,7 +583,7 @@ static int jtagmkI_open(PROGRAMMER *pgm, const char *port)
|
|||
{
|
||||
size_t i;
|
||||
|
||||
avrdude_message(MSG_NOTICE2, "%s: jtagmkI_open()\n", progname);
|
||||
pmsg_notice2("jtagmkI_open()\n");
|
||||
|
||||
strcpy(pgm->port, port);
|
||||
PDATA(pgm)->initial_baudrate = -1L;
|
||||
|
@ -639,8 +592,7 @@ static int jtagmkI_open(PROGRAMMER *pgm, const char *port)
|
|||
union pinfo pinfo;
|
||||
pinfo.serialinfo.baud = baudtab[i].baud;
|
||||
pinfo.serialinfo.cflags = SERIAL_8N1;
|
||||
avrdude_message(MSG_NOTICE2, "%s: jtagmkI_open(): trying to sync at baud rate %ld:\n",
|
||||
progname, pinfo.serialinfo.baud);
|
||||
pmsg_notice2("jtagmkI_open(): trying to sync at baud rate %ld:\n", pinfo.serialinfo.baud);
|
||||
if (serial_open(port, pinfo, &pgm->fd)==-1) {
|
||||
return -1;
|
||||
}
|
||||
|
@ -652,15 +604,14 @@ static int jtagmkI_open(PROGRAMMER *pgm, const char *port)
|
|||
|
||||
if (jtagmkI_getsync(pgm) == 0) {
|
||||
PDATA(pgm)->initial_baudrate = baudtab[i].baud;
|
||||
avrdude_message(MSG_NOTICE2, "%s: jtagmkI_open(): succeeded\n", progname);
|
||||
pmsg_notice2("jtagmkI_open(): succeeded\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
serial_close(&pgm->fd);
|
||||
}
|
||||
|
||||
avrdude_message(MSG_INFO, "%s: jtagmkI_open(): failed to synchronize to ICE\n",
|
||||
progname);
|
||||
pmsg_error("unable to synchronize to ICE\n");
|
||||
pgm->fd.ifd = -1;
|
||||
|
||||
return -1;
|
||||
|
@ -671,7 +622,7 @@ static void jtagmkI_close(PROGRAMMER * pgm)
|
|||
{
|
||||
unsigned char b;
|
||||
|
||||
avrdude_message(MSG_NOTICE2, "%s: jtagmkI_close()\n", progname);
|
||||
pmsg_notice2("jtagmkI_close()\n");
|
||||
|
||||
/*
|
||||
* Revert baud rate to what it used to be when we started. This
|
||||
|
@ -680,12 +631,10 @@ static void jtagmkI_close(PROGRAMMER * pgm)
|
|||
*/
|
||||
if ((serdev->flags & SERDEV_FL_CANSETSPEED) && PDATA(pgm)->initial_baudrate != pgm->baudrate) {
|
||||
if ((b = jtagmkI_get_baud(PDATA(pgm)->initial_baudrate)) == 0) {
|
||||
avrdude_message(MSG_INFO, "%s: jtagmkI_close(): unsupported baudrate %d\n",
|
||||
progname, PDATA(pgm)->initial_baudrate);
|
||||
pmsg_error("unsupported baudrate %d\n", PDATA(pgm)->initial_baudrate);
|
||||
} else {
|
||||
avrdude_message(MSG_NOTICE2, "%s: jtagmkI_close(): "
|
||||
"trying to set baudrate to %d\n",
|
||||
progname, PDATA(pgm)->initial_baudrate);
|
||||
pmsg_notice2("jtagmkI_close(): "
|
||||
"trying to set baudrate to %d\n", PDATA(pgm)->initial_baudrate);
|
||||
if (jtagmkI_setparm(pgm, PARM_BITRATE, b) == 0) {
|
||||
serial_setparams(&pgm->fd, pgm->baudrate, SERIAL_8N1);
|
||||
}
|
||||
|
@ -712,23 +661,21 @@ static int jtagmkI_paged_write(const PROGRAMMER *pgm, const AVRPART *p, const AV
|
|||
long otimeout = serial_recv_timeout;
|
||||
#define MAXTRIES 3
|
||||
|
||||
avrdude_message(MSG_NOTICE2, "%s: jtagmkI_paged_write(.., %s, %d, %d)\n",
|
||||
progname, m->desc, page_size, n_bytes);
|
||||
pmsg_notice2("jtagmkI_paged_write(.., %s, %d, %d)\n", m->desc, page_size, n_bytes);
|
||||
|
||||
if (jtagmkI_program_enable(pgm) < 0)
|
||||
return -1;
|
||||
|
||||
if (page_size == 0) page_size = 256;
|
||||
if (page_size == 0)
|
||||
page_size = 256;
|
||||
|
||||
if (page_size > 256) {
|
||||
avrdude_message(MSG_INFO, "%s: jtagmkI_paged_write(): page size %d too large\n",
|
||||
progname, page_size);
|
||||
pmsg_error("page size %d too large\n", page_size);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if ((datacmd = malloc(page_size + 1)) == NULL) {
|
||||
avrdude_message(MSG_INFO, "%s: jtagmkI_paged_write(): Out of memory\n",
|
||||
progname);
|
||||
pmsg_error("out of memory\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -751,8 +698,7 @@ static int jtagmkI_paged_write(const PROGRAMMER *pgm, const AVRPART *p, const AV
|
|||
again:
|
||||
|
||||
if (tries != 0 && jtagmkI_resync(pgm, 2000, 0) < 0) {
|
||||
avrdude_message(MSG_INFO, "%s: jtagmkI_paged_write(): sync loss, retries exhausted\n",
|
||||
progname);
|
||||
pmsg_error("sync loss, retries exhausted\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -760,9 +706,8 @@ static int jtagmkI_paged_write(const PROGRAMMER *pgm, const AVRPART *p, const AV
|
|||
block_size = n_bytes;
|
||||
else
|
||||
block_size = page_size;
|
||||
avrdude_message(MSG_DEBUG, "%s: jtagmkI_paged_write(): "
|
||||
"block_size at addr %d is %d\n",
|
||||
progname, addr, block_size);
|
||||
pmsg_debug("jtagmkI_paged_write(): "
|
||||
"block_size at addr %d is %d\n", addr, block_size);
|
||||
|
||||
/* We always write full pages. */
|
||||
send_size = page_size;
|
||||
|
@ -774,27 +719,22 @@ static int jtagmkI_paged_write(const PROGRAMMER *pgm, const AVRPART *p, const AV
|
|||
u32_to_b3(cmd + 3, addr);
|
||||
}
|
||||
|
||||
avrdude_message(MSG_NOTICE2, "%s: jtagmkI_paged_write(): "
|
||||
"Sending write memory command: ",
|
||||
progname);
|
||||
pmsg_notice2("jtagmkI_paged_write(): "
|
||||
"sending write memory command: ");
|
||||
|
||||
/* First part, send the write command. */
|
||||
jtagmkI_send(pgm, cmd, 6);
|
||||
if (jtagmkI_recv(pgm, resp, 1) < 0)
|
||||
return -1;
|
||||
if (resp[0] != RESP_OK) {
|
||||
if (verbose >= 2)
|
||||
putc('\n', stderr);
|
||||
avrdude_message(MSG_INFO, "%s: jtagmkI_paged_write(): "
|
||||
"timeout/error communicating with programmer (resp %c)\n",
|
||||
progname, resp[0]);
|
||||
msg_notice2("\n");
|
||||
pmsg_warning("timeout/error communicating with programmer (resp %c)\n", resp[0]);
|
||||
if (tries++ < MAXTRIES)
|
||||
goto again;
|
||||
serial_recv_timeout = otimeout;
|
||||
return -1;
|
||||
} else {
|
||||
if (verbose == 2)
|
||||
avrdude_message(MSG_NOTICE2, "OK\n");
|
||||
msg_notice2("OK\n");
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -812,18 +752,14 @@ static int jtagmkI_paged_write(const PROGRAMMER *pgm, const AVRPART *p, const AV
|
|||
if (jtagmkI_recv(pgm, resp, 2) < 0)
|
||||
return -1;
|
||||
if (resp[1] != RESP_OK) {
|
||||
if (verbose >= 2)
|
||||
putc('\n', stderr);
|
||||
avrdude_message(MSG_INFO, "%s: jtagmkI_paged_write(): "
|
||||
"timeout/error communicating with programmer (resp %c)\n",
|
||||
progname, resp[0]);
|
||||
msg_notice2("\n");
|
||||
pmsg_warning("timeout/error communicating with programmer (resp %c)\n", resp[0]);
|
||||
if (tries++ < MAXTRIES)
|
||||
goto again;
|
||||
serial_recv_timeout = otimeout;
|
||||
return -1;
|
||||
} else {
|
||||
if (verbose == 2)
|
||||
avrdude_message(MSG_NOTICE2, "OK\n");
|
||||
msg_notice2("OK\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -844,8 +780,7 @@ static int jtagmkI_paged_load(const PROGRAMMER *pgm, const AVRPART *p, const AVR
|
|||
long otimeout = serial_recv_timeout;
|
||||
#define MAXTRIES 3
|
||||
|
||||
avrdude_message(MSG_NOTICE2, "%s: jtagmkI_paged_load(.., %s, %d, %d)\n",
|
||||
progname, m->desc, page_size, n_bytes);
|
||||
pmsg_notice2("jtagmkI_paged_load(.., %s, %d, %d)\n", m->desc, page_size, n_bytes);
|
||||
|
||||
if (jtagmkI_program_enable(pgm) < 0)
|
||||
return -1;
|
||||
|
@ -861,8 +796,7 @@ static int jtagmkI_paged_load(const PROGRAMMER *pgm, const AVRPART *p, const AVR
|
|||
}
|
||||
|
||||
if (page_size > (is_flash? 512: 256)) {
|
||||
avrdude_message(MSG_INFO, "%s: jtagmkI_paged_load(): page size %d too large\n",
|
||||
progname, page_size);
|
||||
pmsg_error("page size %d too large\n", page_size);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -871,8 +805,7 @@ static int jtagmkI_paged_load(const PROGRAMMER *pgm, const AVRPART *p, const AVR
|
|||
tries = 0;
|
||||
again:
|
||||
if (tries != 0 && jtagmkI_resync(pgm, 2000, 0) < 0) {
|
||||
avrdude_message(MSG_INFO, "%s: jtagmkI_paged_load(): sync loss, retries exhausted\n",
|
||||
progname);
|
||||
pmsg_error("sync loss, retries exhausted\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -880,9 +813,8 @@ static int jtagmkI_paged_load(const PROGRAMMER *pgm, const AVRPART *p, const AVR
|
|||
block_size = n_bytes;
|
||||
else
|
||||
block_size = page_size;
|
||||
avrdude_message(MSG_DEBUG, "%s: jtagmkI_paged_load(): "
|
||||
"block_size at addr %d is %d\n",
|
||||
progname, addr, block_size);
|
||||
pmsg_debug("jtagmkI_paged_load(): "
|
||||
"block_size at addr %d is %d\n", addr, block_size);
|
||||
|
||||
if (is_flash) {
|
||||
read_size = 2 * ((block_size + 1) / 2); /* round up */
|
||||
|
@ -894,27 +826,22 @@ static int jtagmkI_paged_load(const PROGRAMMER *pgm, const AVRPART *p, const AVR
|
|||
u32_to_b3(cmd + 3, addr);
|
||||
}
|
||||
|
||||
avrdude_message(MSG_NOTICE2, "%s: jtagmkI_paged_load(): Sending read memory command: ",
|
||||
progname);
|
||||
pmsg_notice2("jtagmkI_paged_load(): sending read memory command: ");
|
||||
|
||||
jtagmkI_send(pgm, cmd, 6);
|
||||
if (jtagmkI_recv(pgm, resp, read_size + 3) < 0)
|
||||
return -1;
|
||||
|
||||
if (resp[read_size + 3 - 1] != RESP_OK) {
|
||||
if (verbose >= 2)
|
||||
putc('\n', stderr);
|
||||
avrdude_message(MSG_INFO, "%s: jtagmkI_paged_load(): "
|
||||
"timeout/error communicating with programmer (resp %c)\n",
|
||||
progname, resp[read_size + 3 - 1]);
|
||||
msg_notice2("\n");
|
||||
pmsg_warning("timeout/error communicating with programmer (resp %c)\n", resp[read_size + 3 - 1]);
|
||||
if (tries++ < MAXTRIES)
|
||||
goto again;
|
||||
|
||||
serial_recv_timeout = otimeout;
|
||||
return -1;
|
||||
} else {
|
||||
if (verbose == 2)
|
||||
avrdude_message(MSG_NOTICE2, "OK\n");
|
||||
msg_notice2("OK\n");
|
||||
}
|
||||
|
||||
memcpy(m->buf + addr, resp + 1, block_size);
|
||||
|
@ -935,8 +862,7 @@ static int jtagmkI_read_byte(const PROGRAMMER *pgm, const AVRPART *p, const AVRM
|
|||
int respsize = 3 + 1;
|
||||
int is_flash = 0;
|
||||
|
||||
avrdude_message(MSG_NOTICE2, "%s: jtagmkI_read_byte(.., %s, 0x%lx, ...)\n",
|
||||
progname, mem->desc, addr);
|
||||
pmsg_notice2("jtagmkI_read_byte(.., %s, 0x%lx, ...)\n", mem->desc, addr);
|
||||
|
||||
if (jtagmkI_program_enable(pgm) < 0)
|
||||
return -1;
|
||||
|
@ -1017,15 +943,11 @@ static int jtagmkI_read_byte(const PROGRAMMER *pgm, const AVRPART *p, const AVRM
|
|||
return -1;
|
||||
|
||||
if (resp[respsize - 1] != RESP_OK) {
|
||||
if (verbose >= 2)
|
||||
putc('\n', stderr);
|
||||
avrdude_message(MSG_INFO, "%s: jtagmkI_read_byte(): "
|
||||
"timeout/error communicating with programmer (resp %c)\n",
|
||||
progname, resp[respsize - 1]);
|
||||
msg_notice2("\n");
|
||||
pmsg_error("timeout/error communicating with programmer (resp %c)\n", resp[respsize - 1]);
|
||||
return -1;
|
||||
} else {
|
||||
if (verbose == 2)
|
||||
avrdude_message(MSG_NOTICE2, "OK\n");
|
||||
msg_notice2("OK\n");
|
||||
}
|
||||
|
||||
if (pagesize) {
|
||||
|
@ -1048,8 +970,7 @@ static int jtagmkI_write_byte(const PROGRAMMER *pgm, const AVRPART *p, const AVR
|
|||
unsigned char resp[1], writedata;
|
||||
int len, need_progmode = 1, need_dummy_read = 0;
|
||||
|
||||
avrdude_message(MSG_NOTICE2, "%s: jtagmkI_write_byte(.., %s, 0x%lx, ...)\n",
|
||||
progname, mem->desc, addr);
|
||||
pmsg_notice2("jtagmkI_write_byte(.., %s, 0x%lx, ...)\n", mem->desc, addr);
|
||||
|
||||
writedata = data;
|
||||
cmd[0] = CMD_WRITE_MEM;
|
||||
|
@ -1107,15 +1028,11 @@ static int jtagmkI_write_byte(const PROGRAMMER *pgm, const AVRPART *p, const AVR
|
|||
if (jtagmkI_recv(pgm, resp, 1) < 0)
|
||||
return -1;
|
||||
if (resp[0] != RESP_OK) {
|
||||
if (verbose >= 2)
|
||||
putc('\n', stderr);
|
||||
avrdude_message(MSG_INFO, "%s: jtagmkI_write_byte(): "
|
||||
"timeout/error communicating with programmer (resp %c)\n",
|
||||
progname, resp[0]);
|
||||
msg_notice2("\n");
|
||||
pmsg_error("timeout/error communicating with programmer (resp %c)\n", resp[0]);
|
||||
return -1;
|
||||
} else {
|
||||
if (verbose == 2)
|
||||
avrdude_message(MSG_NOTICE2, "OK\n");
|
||||
msg_notice2("OK\n");
|
||||
}
|
||||
|
||||
/* Now, send the data buffer. */
|
||||
|
@ -1137,15 +1054,11 @@ static int jtagmkI_write_byte(const PROGRAMMER *pgm, const AVRPART *p, const AVR
|
|||
if (jtagmkI_recv(pgm, resp, 1) < 0)
|
||||
return -1;
|
||||
if (resp[0] != RESP_OK) {
|
||||
if (verbose >= 2)
|
||||
putc('\n', stderr);
|
||||
avrdude_message(MSG_INFO, "%s: jtagmkI_write_byte(): "
|
||||
"timeout/error communicating with programmer (resp %c)\n",
|
||||
progname, resp[0]);
|
||||
msg_notice2("\n");
|
||||
pmsg_error("timeout/error communicating with programmer (resp %c)\n", resp[0]);
|
||||
return -1;
|
||||
} else {
|
||||
if (verbose == 2)
|
||||
avrdude_message(MSG_NOTICE2, "OK\n");
|
||||
msg_notice2("OK\n");
|
||||
}
|
||||
|
||||
if(need_dummy_read)
|
||||
|
@ -1190,35 +1103,26 @@ static int jtagmkI_getparm(const PROGRAMMER *pgm, const unsigned char parm,
|
|||
{
|
||||
unsigned char buf[2], resp[3];
|
||||
|
||||
avrdude_message(MSG_NOTICE2, "%s: jtagmkI_getparm()\n", progname);
|
||||
pmsg_notice2("jtagmkI_getparm()\n");
|
||||
|
||||
buf[0] = CMD_GET_PARAM;
|
||||
buf[1] = parm;
|
||||
if (verbose >= 2)
|
||||
avrdude_message(MSG_NOTICE2, "%s: jtagmkI_getparm(): "
|
||||
"Sending get parameter command (parm 0x%02x): ",
|
||||
progname, parm);
|
||||
pmsg_notice2("jtagmkI_getparm(): "
|
||||
"Sending get parameter command (parm 0x%02x): ", parm);
|
||||
jtagmkI_send(pgm, buf, 2);
|
||||
|
||||
if (jtagmkI_recv(pgm, resp, 3) < 0)
|
||||
return -1;
|
||||
if (resp[0] != RESP_OK) {
|
||||
if (verbose >= 2)
|
||||
putc('\n', stderr);
|
||||
avrdude_message(MSG_INFO, "%s: jtagmkI_getparm(): "
|
||||
"timeout/error communicating with programmer (resp %c)\n",
|
||||
progname, resp[0]);
|
||||
msg_notice2("\n");
|
||||
pmsg_error("timeout/error communicating with programmer (resp %c)\n", resp[0]);
|
||||
return -1;
|
||||
} else if (resp[2] != RESP_OK) {
|
||||
if (verbose >= 2)
|
||||
putc('\n', stderr);
|
||||
avrdude_message(MSG_INFO, "%s: jtagmkI_getparm(): "
|
||||
"unknown parameter 0x%02x\n",
|
||||
progname, parm);
|
||||
msg_notice2("\n");
|
||||
pmsg_error("unknown parameter 0x%02x\n", parm);
|
||||
return -1;
|
||||
} else {
|
||||
if (verbose == 2)
|
||||
avrdude_message(MSG_NOTICE2, "OK, value 0x%02x\n", resp[1]);
|
||||
msg_notice2("OK, value 0x%02x\n", resp[1]);
|
||||
}
|
||||
|
||||
*value = resp[1];
|
||||
|
@ -1234,27 +1138,22 @@ static int jtagmkI_setparm(const PROGRAMMER *pgm, unsigned char parm,
|
|||
{
|
||||
unsigned char buf[3], resp[2];
|
||||
|
||||
avrdude_message(MSG_NOTICE2, "%s: jtagmkI_setparm()\n", progname);
|
||||
pmsg_notice2("jtagmkI_setparm()\n");
|
||||
|
||||
buf[0] = CMD_SET_PARAM;
|
||||
buf[1] = parm;
|
||||
buf[2] = value;
|
||||
avrdude_message(MSG_NOTICE2, "%s: jtagmkI_setparm(): "
|
||||
"Sending set parameter command (parm 0x%02x): ",
|
||||
progname, parm);
|
||||
pmsg_notice2("jtagmkI_setparm(): "
|
||||
"Sending set parameter command (parm 0x%02x): ", parm);
|
||||
jtagmkI_send(pgm, buf, 3);
|
||||
if (jtagmkI_recv(pgm, resp, 2) < 0)
|
||||
return -1;
|
||||
if (resp[0] != RESP_OK) {
|
||||
if (verbose >= 2)
|
||||
putc('\n', stderr);
|
||||
avrdude_message(MSG_INFO, "%s: jtagmkI_setparm(): "
|
||||
"timeout/error communicating with programmer (resp %c)\n",
|
||||
progname, resp[0]);
|
||||
msg_notice2("\n");
|
||||
pmsg_error("timeout/error communicating with programmer (resp %c)\n", resp[0]);
|
||||
return -1;
|
||||
} else {
|
||||
if (verbose == 2)
|
||||
avrdude_message(MSG_NOTICE2, "OK\n");
|
||||
msg_notice2("OK\n");
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -1268,8 +1167,8 @@ static void jtagmkI_display(const PROGRAMMER *pgm, const char *p) {
|
|||
jtagmkI_getparm(pgm, PARM_SW_VERSION, &fw) < 0)
|
||||
return;
|
||||
|
||||
avrdude_message(MSG_INFO, "%sICE HW version: 0x%02x\n", p, hw);
|
||||
avrdude_message(MSG_INFO, "%sICE FW version: 0x%02x\n", p, fw);
|
||||
msg_info("%sICE HW version: 0x%02x\n", p, hw);
|
||||
msg_info("%sICE FW version: 0x%02x\n", p, fw);
|
||||
|
||||
jtagmkI_print_parms1(pgm, p);
|
||||
|
||||
|
@ -1312,10 +1211,8 @@ static void jtagmkI_print_parms1(const PROGRAMMER *pgm, const char *p) {
|
|||
clk = 1e6;
|
||||
}
|
||||
|
||||
avrdude_message(MSG_INFO, "%sVtarget : %.1f V\n", p,
|
||||
6.25 * (unsigned)vtarget / 255.0);
|
||||
avrdude_message(MSG_INFO, "%sJTAG clock : %s (%.1f us)\n", p, clkstr,
|
||||
1.0e6 / clk);
|
||||
msg_info("%sVtarget : %.1f V\n", p, 6.25 * (unsigned)vtarget / 255.0);
|
||||
msg_info("%sJTAG clock : %s (%.1f us)\n", p, clkstr, 1.0e6 / clk);
|
||||
|
||||
return;
|
||||
}
|
||||
|
|
967
src/jtagmkII.c
967
src/jtagmkII.c
File diff suppressed because it is too large
Load Diff
|
@ -33,16 +33,16 @@
|
|||
|
||||
#define ppi_claim(fd) \
|
||||
if (ioctl(fd, PPCLAIM)) { \
|
||||
avrdude_message(MSG_INFO, "%s: can't claim device \"%s\": %s\n\n", \
|
||||
progname, port, strerror(errno)); \
|
||||
pmsg_ext_error("cannot claim port %s: %s\n\n", \
|
||||
port, strerror(errno)); \
|
||||
close(fd); \
|
||||
return; \
|
||||
}
|
||||
|
||||
#define ppi_release(fd) \
|
||||
if (ioctl(fd, PPRELEASE)) { \
|
||||
avrdude_message(MSG_INFO, "%s: can't release device: %s\n\n", \
|
||||
progname, strerror(errno)); \
|
||||
pmsg_ext_error("cannot release device: %s\n\n", \
|
||||
strerror(errno)); \
|
||||
}
|
||||
|
||||
#define DO_PPI_READ(fd, reg, valp) \
|
||||
|
|
|
@ -63,7 +63,7 @@ static int linuxgpio_export(unsigned int gpio)
|
|||
|
||||
fd = open("/sys/class/gpio/export", O_WRONLY);
|
||||
if (fd < 0) {
|
||||
perror("Can't open /sys/class/gpio/export");
|
||||
pmsg_ext_error("cannot open /sys/class/gpio/export: %s\n", strerror(errno));
|
||||
return fd;
|
||||
}
|
||||
|
||||
|
@ -81,7 +81,7 @@ static int linuxgpio_unexport(unsigned int gpio)
|
|||
|
||||
fd = open("/sys/class/gpio/unexport", O_WRONLY);
|
||||
if (fd < 0) {
|
||||
perror("Can't open /sys/class/gpio/unexport");
|
||||
pmsg_ext_error("cannot open /sys/class/gpio/unexport: %s\n", strerror(errno));
|
||||
return fd;
|
||||
}
|
||||
|
||||
|
@ -109,8 +109,7 @@ static int linuxgpio_dir(unsigned int gpio, unsigned int dir)
|
|||
|
||||
fd = open(buf, O_WRONLY);
|
||||
if (fd < 0) {
|
||||
snprintf(buf, sizeof(buf), "Can't open gpio%u/direction", gpio);
|
||||
perror(buf);
|
||||
pmsg_ext_error("cannot open %s: %s\n", buf, strerror(errno));
|
||||
return fd;
|
||||
}
|
||||
|
||||
|
@ -220,7 +219,7 @@ static int linuxgpio_highpulsepin(const PROGRAMMER *pgm, int pinfunc) {
|
|||
|
||||
|
||||
static void linuxgpio_display(const PROGRAMMER *pgm, const char *p) {
|
||||
avrdude_message(MSG_INFO, "%sPin assignment : /sys/class/gpio/gpio{n}\n",p);
|
||||
msg_info("%sPin assignment : /sys/class/gpio/gpio{n}\n",p);
|
||||
pgm_display_generic_mask(pgm, p, SHOW_AVR_PINS);
|
||||
}
|
||||
|
||||
|
@ -267,7 +266,7 @@ static int linuxgpio_open(PROGRAMMER *pgm, const char *port) {
|
|||
i == PIN_AVR_MISO ) {
|
||||
pin = pgm->pinno[i] & PIN_MASK;
|
||||
if ((r=linuxgpio_export(pin)) < 0) {
|
||||
avrdude_message(MSG_INFO, "Can't export GPIO %d, already exported/busy?: %s",
|
||||
pmsg_ext_error("cannot export GPIO %d, already exported/busy?: %s",
|
||||
pin, strerror(errno));
|
||||
return r;
|
||||
}
|
||||
|
@ -306,8 +305,8 @@ static int linuxgpio_open(PROGRAMMER *pgm, const char *port) {
|
|||
}
|
||||
|
||||
if (retry_count)
|
||||
avrdude_message(MSG_NOTICE2, "%s: needed %d retr%s for linuxgpio_dir_%s(%s)\n",
|
||||
progname, retry_count, retry_count > 1? "ies": "y",
|
||||
pmsg_notice2("needed %d retr%s for linuxgpio_dir_%s(%s)\n",
|
||||
retry_count, retry_count > 1? "ies": "y",
|
||||
i == PIN_AVR_MISO? "in": "out", avr_pin_name(pin));
|
||||
|
||||
if (r < 0) {
|
||||
|
@ -379,8 +378,7 @@ const char linuxgpio_desc[] = "GPIO bitbanging using the Linux sysfs interface";
|
|||
#else /* !HAVE_LINUXGPIO */
|
||||
|
||||
void linuxgpio_initpgm(PROGRAMMER *pgm) {
|
||||
avrdude_message(MSG_INFO, "%s: Linux sysfs GPIO support not available in this configuration\n",
|
||||
progname);
|
||||
pmsg_error("Linux sysfs GPIO support not available in this configuration\n");
|
||||
}
|
||||
|
||||
const char linuxgpio_desc[] = "GPIO bitbanging using the Linux sysfs interface (not available)";
|
||||
|
|
|
@ -94,10 +94,11 @@ static int linuxspi_spi_duplex(const PROGRAMMER *pgm, const unsigned char *tx, u
|
|||
ret = ioctl(fd_spidev, SPI_IOC_MESSAGE(1), &tr);
|
||||
if (ret != len) {
|
||||
int ioctl_errno = errno;
|
||||
avrdude_message(MSG_INFO, "\n%s: unable to send SPI message", progname);
|
||||
msg_error("\n");
|
||||
pmsg_error("unable to send SPI message");
|
||||
if (ioctl_errno)
|
||||
avrdude_message(MSG_INFO, ". %s", strerror(ioctl_errno));
|
||||
avrdude_message(MSG_INFO, "\n");
|
||||
msg_error("%s", strerror(ioctl_errno));
|
||||
msg_error("\n");
|
||||
}
|
||||
|
||||
return ret == -1? -1: 0;
|
||||
|
@ -133,8 +134,7 @@ static int linuxspi_reset_mcu(const PROGRAMMER *pgm, bool active) {
|
|||
#endif
|
||||
if (ret == -1) {
|
||||
ret = -errno;
|
||||
avrdude_message(MSG_INFO, "%s: unable to set GPIO line %d value. %s\n",
|
||||
progname, pgm->pinno[PIN_AVR_RESET] & ~PIN_INVERSE, strerror(errno));
|
||||
pmsg_ext_error("unable to set GPIO line %d value: %s\n", pgm->pinno[PIN_AVR_RESET] & ~PIN_INVERSE, strerror(errno));
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -143,7 +143,7 @@ static int linuxspi_reset_mcu(const PROGRAMMER *pgm, bool active) {
|
|||
|
||||
static int linuxspi_open(PROGRAMMER *pgm, const char *pt) {
|
||||
const char *port_error =
|
||||
"%s: error, unknown port specification; "
|
||||
"unknown port specification, "
|
||||
"please use the format /dev/spidev:/dev/gpiochip[:resetno]\n";
|
||||
char port_default[] = "/dev/spidev0.0:/dev/gpiochip0";
|
||||
char *spidev, *gpiochip, *reset_pin;
|
||||
|
@ -157,13 +157,13 @@ static int linuxspi_open(PROGRAMMER *pgm, const char *pt) {
|
|||
|
||||
spidev = strtok(port, ":");
|
||||
if (!spidev) {
|
||||
avrdude_message(MSG_INFO, port_error, progname);
|
||||
pmsg_error("%s", port_error);
|
||||
return -1;
|
||||
}
|
||||
|
||||
gpiochip = strtok(NULL, ":");
|
||||
if (!gpiochip) {
|
||||
avrdude_message(MSG_INFO, port_error, progname);
|
||||
pmsg_error("%s", port_error);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -175,8 +175,7 @@ static int linuxspi_open(PROGRAMMER *pgm, const char *pt) {
|
|||
strcpy(pgm->port, port);
|
||||
fd_spidev = open(pgm->port, O_RDWR);
|
||||
if (fd_spidev < 0) {
|
||||
avrdude_message(MSG_INFO, "\n%s: unable to open the spidev device %s. %s",
|
||||
progname, pgm->port, strerror(errno));
|
||||
pmsg_ext_error("unable to open the spidev device %s: %s\n", pgm->port, strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -187,16 +186,14 @@ static int linuxspi_open(PROGRAMMER *pgm, const char *pt) {
|
|||
ret = ioctl(fd_spidev, SPI_IOC_WR_MODE32, &mode);
|
||||
if (ret == -1) {
|
||||
int ioctl_errno = errno;
|
||||
avrdude_message(MSG_INFO, "%s: unable to set SPI mode %02X on %s. %s\n",
|
||||
progname, mode, spidev, strerror(errno));
|
||||
pmsg_ext_error("unable to set SPI mode %02X on %s: %s\n", mode, spidev, strerror(errno));
|
||||
if(ioctl_errno == EINVAL && !PDATA(pgm)->disable_no_cs)
|
||||
avrdude_message(MSG_INFO, "%s: try -x disable_no_cs\n", progname);
|
||||
pmsg_error("try -x disable_no_cs\n");
|
||||
goto close_spidev;
|
||||
}
|
||||
fd_gpiochip = open(gpiochip, 0);
|
||||
if (fd_gpiochip < 0) {
|
||||
avrdude_message(MSG_INFO, "\n%s: unable to open the gpiochip %s. %s\n",
|
||||
progname, gpiochip, strerror(errno));
|
||||
pmsg_ext_error("unable to open the gpiochip %s: %s\n", gpiochip, strerror(errno));
|
||||
ret = -1;
|
||||
goto close_spidev;
|
||||
}
|
||||
|
@ -231,8 +228,7 @@ static int linuxspi_open(PROGRAMMER *pgm, const char *pt) {
|
|||
#endif
|
||||
if (ret == -1) {
|
||||
ret = -errno;
|
||||
avrdude_message(MSG_INFO, "%s: unable to get GPIO line %d. %s\n",
|
||||
progname, pgm->pinno[PIN_AVR_RESET] & ~PIN_INVERSE, strerror(errno));
|
||||
pmsg_ext_error("unable to get GPIO line %d. %s\n", pgm->pinno[PIN_AVR_RESET] & ~PIN_INVERSE, strerror(errno));
|
||||
goto close_gpiochip;
|
||||
}
|
||||
|
||||
|
@ -241,14 +237,11 @@ static int linuxspi_open(PROGRAMMER *pgm, const char *pt) {
|
|||
goto close_out;
|
||||
|
||||
if (pgm->baudrate != 0) {
|
||||
avrdude_message(MSG_INFO,
|
||||
"%s: obsolete use of -b <clock> option for bit clock; use -B <clock>\n",
|
||||
progname);
|
||||
pmsg_warning("obsolete use of -b <clock> option for bit clock; use -B <clock>\n");
|
||||
pgm->bitclock = 1.0 / pgm->baudrate;
|
||||
}
|
||||
if (pgm->bitclock == 0) {
|
||||
avrdude_message(MSG_NOTICE,
|
||||
"%s: defaulting bit clock to 200 kHz\n", progname);
|
||||
pmsg_notice("defaulting bit clock to 200 kHz\n");
|
||||
pgm->bitclock = 5E-6; // 200 kHz - 5 µs
|
||||
}
|
||||
|
||||
|
@ -296,7 +289,7 @@ static int linuxspi_initialize(const PROGRAMMER *pgm, const AVRPART *p) {
|
|||
|
||||
if (p->prog_modes & PM_TPI) {
|
||||
/* We do not support TPI. This is a dedicated SPI thing */
|
||||
avrdude_message(MSG_INFO, "%s: error, programmer " LINUXSPI " does not support TPI\n", progname);
|
||||
pmsg_error("programmer " LINUXSPI " does not support TPI\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -310,7 +303,7 @@ static int linuxspi_initialize(const PROGRAMMER *pgm, const AVRPART *p) {
|
|||
} while(tries++ < 65);
|
||||
|
||||
if (ret)
|
||||
avrdude_message(MSG_INFO, "%s: error, AVR device not responding\n", progname);
|
||||
pmsg_error("AVR device not responding\n");
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
@ -324,7 +317,7 @@ static int linuxspi_program_enable(const PROGRAMMER *pgm, const AVRPART *p) {
|
|||
unsigned char cmd[4], res[4];
|
||||
|
||||
if (!p->op[AVR_OP_PGM_ENABLE]) {
|
||||
avrdude_message(MSG_INFO, "%s: error, program enable instruction not defined for part %s\n", progname, p->desc);
|
||||
pmsg_error("program enable instruction not defined for part %s\n", p->desc);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -367,7 +360,7 @@ static int linuxspi_chip_erase(const PROGRAMMER *pgm, const AVRPART *p) {
|
|||
unsigned char cmd[4], res[4];
|
||||
|
||||
if (!p->op[AVR_OP_CHIP_ERASE]) {
|
||||
avrdude_message(MSG_INFO, "%s: error, chip erase instruction not defined for part %s\n", progname, p->desc);
|
||||
pmsg_error("chip erase instruction not defined for part %s\n", p->desc);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -415,8 +408,7 @@ static int linuxspi_parseextparams(const PROGRAMMER *pgm, const LISTID extparms)
|
|||
continue;
|
||||
}
|
||||
|
||||
avrdude_message(MSG_INFO, "%s: linuxspi_parseextparams(): "
|
||||
"invalid extended parameter '%s'\n", progname, extended_param);
|
||||
pmsg_error("invalid extended parameter '%s'\n", extended_param);
|
||||
rc = -1;
|
||||
}
|
||||
|
||||
|
@ -453,7 +445,7 @@ const char linuxspi_desc[] = "SPI using Linux spidev driver";
|
|||
#else /* !HAVE_LINUXSPI */
|
||||
|
||||
void linuxspi_initpgm(PROGRAMMER *pgm) {
|
||||
avrdude_message(MSG_INFO, "%s: Linux SPI driver not available in this configuration\n", progname);
|
||||
pmsg_error("Linux SPI driver not available in this configuration\n");
|
||||
}
|
||||
|
||||
const char linuxspi_desc[] = "SPI using Linux spidev driver (not available)";
|
||||
|
|
440
src/main.c
440
src/main.c
|
@ -48,7 +48,7 @@
|
|||
|
||||
#include "avrdude.h"
|
||||
#include "libavrdude.h"
|
||||
|
||||
#include "config.h"
|
||||
#include "term.h"
|
||||
#include "developer_opts.h"
|
||||
|
||||
|
@ -60,7 +60,7 @@ char progbuf[PATH_MAX]; /* temporary buffer of spaces the same
|
|||
length as progname; used for lining up
|
||||
multiline messages */
|
||||
|
||||
int avrdude_message(const int msglvl, const char *format, ...)
|
||||
int avrdude_message(int msglvl, const char *format, ...)
|
||||
{
|
||||
int rc = 0;
|
||||
va_list ap;
|
||||
|
@ -72,6 +72,55 @@ int avrdude_message(const int msglvl, const char *format, ...)
|
|||
return rc;
|
||||
}
|
||||
|
||||
static const char *avrdude_message_type(int msglvl) {
|
||||
switch(msglvl) {
|
||||
case MSG_EXT_ERROR: return "OS error";
|
||||
case MSG_ERROR: return "error";
|
||||
case MSG_WARNING: return "warning";
|
||||
case MSG_INFO: return "info";
|
||||
case MSG_NOTICE: return "notice";
|
||||
case MSG_NOTICE2: return "notice2";
|
||||
case MSG_DEBUG: return "debug";
|
||||
case MSG_TRACE: return "trace";
|
||||
case MSG_TRACE2: return "trace2";
|
||||
default: return "unknown msglvl";
|
||||
}
|
||||
}
|
||||
|
||||
int avrdude_message2(const char *fname, int msgmode, int msglvl, const char *format, ...) {
|
||||
int rc = 0;
|
||||
va_list ap;
|
||||
|
||||
if(msgmode & MSG2_FLUSH) {
|
||||
fflush(stdout);
|
||||
fflush(stderr);
|
||||
}
|
||||
|
||||
// Reduce effective verbosity level by number of -q above one
|
||||
if ((quell_progress < 2? verbose: verbose+1-quell_progress) >= msglvl) {
|
||||
if(msgmode & MSG2_PROGNAME) {
|
||||
fprintf(stderr, "%s", progname);
|
||||
if(verbose >= MSG_NOTICE && (msgmode & MSG2_FUNCTION))
|
||||
fprintf(stderr, " %s()", fname);
|
||||
if(msgmode & MSG2_TYPE)
|
||||
fprintf(stderr, " %s", avrdude_message_type(msglvl));
|
||||
fprintf(stderr, ": ");
|
||||
} else if(msgmode & MSG2_INDENT1) {
|
||||
fprintf(stderr, "%*s", (int) strlen(progname)+1, "");
|
||||
} else if(msgmode & MSG2_INDENT2) {
|
||||
fprintf(stderr, "%*s", (int) strlen(progname)+2, "");
|
||||
}
|
||||
va_start(ap, format);
|
||||
rc = vfprintf(stderr, format, ap);
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
if(msgmode & MSG2_FLUSH)
|
||||
fflush(stderr);
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
||||
struct list_walk_cookie
|
||||
{
|
||||
|
@ -96,40 +145,39 @@ int ovsigck; /* 1=override sig check, 0=don't */
|
|||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* usage message
|
||||
*/
|
||||
static void usage(void)
|
||||
{
|
||||
avrdude_message(MSG_INFO,
|
||||
msg_error(
|
||||
"Usage: %s [options]\n"
|
||||
"Options:\n"
|
||||
" -p <partno> Required. Specify AVR device.\n"
|
||||
" -b <baudrate> Override RS-232 baud rate.\n"
|
||||
" -B <bitclock> Specify JTAG/STK500v2 bit clock period (us).\n"
|
||||
" -C <config-file> Specify location of configuration file.\n"
|
||||
" -c <programmer> Specify programmer type.\n"
|
||||
" -A Disable trailing-0xff removal from file and AVR read.\n"
|
||||
" -D Disable auto erase for flash memory; implies -A.\n"
|
||||
" -p <partno> Specify AVR device\n"
|
||||
" -b <baudrate> Override RS-232 baud rate\n"
|
||||
" -B <bitclock> Specify JTAG/STK500v2 bit clock period (us)\n"
|
||||
" -C <config-file> Specify location of configuration file\n"
|
||||
" -c <programmer> Specify programmer type\n"
|
||||
" -A Disable trailing-0xff removal from file and AVR read\n"
|
||||
" -D Disable auto erase for flash memory; implies -A\n"
|
||||
" -i <delay> ISP Clock Delay [in microseconds]\n"
|
||||
" -P <port> Specify connection port.\n"
|
||||
" -F Override invalid signature check.\n"
|
||||
" -e Perform a chip erase.\n"
|
||||
" -O Perform RC oscillator calibration (see AVR053). \n"
|
||||
" -P <port> Specify connection port\n"
|
||||
" -F Override invalid signature check\n"
|
||||
" -e Perform a chip erase\n"
|
||||
" -O Perform RC oscillator calibration (see AVR053)\n"
|
||||
" -U <memtype>:r|w|v:<filename>[:format]\n"
|
||||
" Memory operation specification.\n"
|
||||
" Memory operation specification\n"
|
||||
" Multiple -U options are allowed, each request\n"
|
||||
" is performed in the order specified.\n"
|
||||
" -n Do not write anything to the device.\n"
|
||||
" -V Do not verify.\n"
|
||||
" -t Enter terminal mode.\n"
|
||||
" -E <exitspec>[,<exitspec>] List programmer exit specifications.\n"
|
||||
" -x <extended_param> Pass <extended_param> to programmer.\n"
|
||||
" -v Verbose output. -v -v for more.\n"
|
||||
" -q Quell progress output. -q -q for less.\n"
|
||||
" -l logfile Use logfile rather than stderr for diagnostics.\n"
|
||||
" -? Display this usage.\n"
|
||||
" is performed in the order specified\n"
|
||||
" -n Do not write anything to the device\n"
|
||||
" -V Do not verify\n"
|
||||
" -t Enter terminal mode\n"
|
||||
" -E <exitspec>[,<exitspec>] List programmer exit specifications\n"
|
||||
" -x <extended_param> Pass <extended_param> to programmer\n"
|
||||
" -v Verbose output; -v -v for more\n"
|
||||
" -q Quell progress output; -q -q for less\n"
|
||||
" -l logfile Use logfile rather than stderr for diagnostics\n"
|
||||
" -? Display this usage\n"
|
||||
"\navrdude version %s, URL: <https://github.com/avrdudes/avrdude>\n",
|
||||
progname, version);
|
||||
}
|
||||
|
@ -252,8 +300,7 @@ static void list_programmer_types_callback(const char *name, const char *desc,
|
|||
void *cookie)
|
||||
{
|
||||
struct list_walk_cookie *c = (struct list_walk_cookie *)cookie;
|
||||
fprintf(c->f, "%s%-16s = %-s\n",
|
||||
c->prefix, name, desc);
|
||||
fprintf(c->f, "%s%-16s = %-s\n", c->prefix, name, desc);
|
||||
}
|
||||
|
||||
static void list_programmer_types(FILE * f, const char *prefix)
|
||||
|
@ -279,7 +326,7 @@ static void list_parts(FILE *f, const char *prefix, LISTID avrparts, int pm) {
|
|||
p = ldata(ln1);
|
||||
// List part if pm or prog_modes uninitialised or if they are compatible otherwise
|
||||
if(!pm || !p->prog_modes || (pm & p->prog_modes)) {
|
||||
if((verbose < 2) && (p->id[0] == '.')) // hide ids starting with '.'
|
||||
if(verbose < 2 && p->id[0] == '.') // hide ids starting with '.'
|
||||
continue;
|
||||
if((len = strlen(p->id)) > maxlen)
|
||||
maxlen = len;
|
||||
|
@ -291,7 +338,7 @@ static void list_parts(FILE *f, const char *prefix, LISTID avrparts, int pm) {
|
|||
p = ldata(ln1);
|
||||
// List part if pm or prog_modes uninitialised or if they are compatible otherwise
|
||||
if(!pm || !p->prog_modes || (pm & p->prog_modes)) {
|
||||
if((verbose < 2) && (p->id[0] == '.')) // hide ids starting with '.'
|
||||
if(verbose < 2 && p->id[0] == '.') // hide ids starting with '.'
|
||||
continue;
|
||||
if(verbose)
|
||||
fprintf(f, "%s%-*s = %-18s [%s:%d]", prefix, maxlen, p->id, p->desc, p->config_file, p->lineno);
|
||||
|
@ -348,29 +395,31 @@ static int dev_opt(char *str) {
|
|||
|
||||
|
||||
static void exit_programmer_not_found(const char *programmer) {
|
||||
msg_error("\n");
|
||||
if(programmer && *programmer)
|
||||
avrdude_message(MSG_INFO, "\n%s: cannot find programmer id %s\n", progname, programmer);
|
||||
else
|
||||
avrdude_message(MSG_INFO, "\n%s: no programmer has been specified on the command line "
|
||||
"or in the\n%sconfig file; specify one using the -c option and try again\n",
|
||||
progname, progbuf);
|
||||
pmsg_error("cannot find programmer id %s\n", programmer);
|
||||
else {
|
||||
pmsg_error("no programmer has been specified on the command line or in the\n");
|
||||
imsg_error("config file(s); specify one using the -c option and try again\n");
|
||||
}
|
||||
|
||||
avrdude_message(MSG_INFO, "\nValid programmers are:\n");
|
||||
msg_error("\nValid programmers are:\n");
|
||||
list_programmers(stderr, " ", programmers, ~0);
|
||||
avrdude_message(MSG_INFO, "\n");
|
||||
msg_error("\n");
|
||||
|
||||
exit(1);
|
||||
}
|
||||
|
||||
static void exit_part_not_found(const char *partdesc) {
|
||||
msg_error("\n");
|
||||
if(partdesc && *partdesc)
|
||||
avrdude_message(MSG_INFO, "\n%s: AVR part %s not found\n", progname, partdesc);
|
||||
pmsg_error("AVR part %s not found\n", partdesc);
|
||||
else
|
||||
avrdude_message(MSG_INFO, "\n%s: no AVR part has been specified; use -p part\n", progname);
|
||||
pmsg_error("no AVR part has been specified; use -p part\n");
|
||||
|
||||
avrdude_message(MSG_INFO, "\nValid parts are:\n");
|
||||
msg_error("\nValid parts are:\n");
|
||||
list_parts(stderr, " ", part_list, ~0);
|
||||
avrdude_message(MSG_INFO, "\n");
|
||||
msg_error("\n");
|
||||
|
||||
exit(1);
|
||||
}
|
||||
|
@ -437,7 +486,8 @@ int main(int argc, char * argv [])
|
|||
|
||||
#if defined (WIN32)
|
||||
/* take care of backslash as dir sep in W32 */
|
||||
if (!progname) progname = strrchr(argv[0],'\\');
|
||||
if (!progname)
|
||||
progname = strrchr(argv[0], '\\');
|
||||
#endif /* WIN32 */
|
||||
|
||||
if (progname)
|
||||
|
@ -445,6 +495,12 @@ int main(int argc, char * argv [])
|
|||
else
|
||||
progname = argv[0];
|
||||
|
||||
// Remove trailing .exe
|
||||
if(strlen(progname) > 4 && strcmp(progname+strlen(progname)-4, ".exe") == 0) {
|
||||
progname = cfg_strdup("main()", progname); // Don't write to argv[0]
|
||||
progname[strlen(progname)-4] = 0;
|
||||
}
|
||||
|
||||
default_programmer = "";
|
||||
default_parallel = "";
|
||||
default_serial = "";
|
||||
|
@ -457,19 +513,19 @@ int main(int argc, char * argv [])
|
|||
|
||||
updates = lcreat(NULL, 0);
|
||||
if (updates == NULL) {
|
||||
avrdude_message(MSG_INFO, "%s: cannot initialize updater list\n", progname);
|
||||
pmsg_error("cannot initialize updater list\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
extended_params = lcreat(NULL, 0);
|
||||
if (extended_params == NULL) {
|
||||
avrdude_message(MSG_INFO, "%s: cannot initialize extended parameter list\n", progname);
|
||||
pmsg_error("cannot initialize extended parameter list\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
additional_config_files = lcreat(NULL, 0);
|
||||
if (additional_config_files == NULL) {
|
||||
avrdude_message(MSG_INFO, "%s: cannot initialize additional config files list\n", progname);
|
||||
pmsg_error("cannot initialize additional config files list\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
@ -514,8 +570,7 @@ int main(int argc, char * argv [])
|
|||
case 'b': /* override default programmer baud rate */
|
||||
baudrate = strtol(optarg, &e, 0);
|
||||
if ((e == optarg) || (*e != 0)) {
|
||||
avrdude_message(MSG_INFO, "%s: invalid baud rate specified '%s'\n",
|
||||
progname, optarg);
|
||||
pmsg_error("invalid baud rate specified '%s'\n", optarg);
|
||||
exit(1);
|
||||
}
|
||||
break;
|
||||
|
@ -560,12 +615,10 @@ int main(int argc, char * argv [])
|
|||
break;
|
||||
}
|
||||
if (bitclock == 0.0)
|
||||
avrdude_message(MSG_INFO, "%s: invalid bit clock unit of measure '%s'\n",
|
||||
progname, e);
|
||||
pmsg_error("invalid bit clock unit of measure '%s'\n", e);
|
||||
}
|
||||
if ((e == optarg) || bitclock == 0.0) {
|
||||
avrdude_message(MSG_INFO, "%s: invalid bit clock period specified '%s'\n",
|
||||
progname, optarg);
|
||||
pmsg_error("invalid bit clock period specified '%s'\n", optarg);
|
||||
exit(1);
|
||||
}
|
||||
break;
|
||||
|
@ -573,8 +626,7 @@ int main(int argc, char * argv [])
|
|||
case 'i': /* specify isp clock delay */
|
||||
ispdelay = strtol(optarg, &e,10);
|
||||
if ((e == optarg) || (*e != 0) || ispdelay == 0) {
|
||||
avrdude_message(MSG_INFO, "%s: invalid isp clock delay specified '%s'\n",
|
||||
progname, optarg);
|
||||
pmsg_error("invalid isp clock delay specified '%s'\n", optarg);
|
||||
exit(1);
|
||||
}
|
||||
break;
|
||||
|
@ -643,15 +695,13 @@ int main(int argc, char * argv [])
|
|||
|
||||
case 's':
|
||||
case 'u':
|
||||
avrdude_message(MSG_INFO, "%s: \"safemode\" feature no longer supported\n",
|
||||
progname);
|
||||
pmsg_error("\"safemode\" feature no longer supported\n");
|
||||
break;
|
||||
|
||||
case 'U':
|
||||
upd = parse_op(optarg);
|
||||
if (upd == NULL) {
|
||||
avrdude_message(MSG_INFO, "%s: error parsing update operation '%s'\n",
|
||||
progname, optarg);
|
||||
pmsg_error("unable to parse update operation '%s'\n", optarg);
|
||||
exit(1);
|
||||
}
|
||||
ladd(updates, upd);
|
||||
|
@ -670,13 +720,11 @@ int main(int argc, char * argv [])
|
|||
break;
|
||||
|
||||
case 'y':
|
||||
avrdude_message(MSG_INFO, "%s: erase cycle counter no longer supported\n",
|
||||
progname);
|
||||
pmsg_error("erase cycle counter no longer supported\n");
|
||||
break;
|
||||
|
||||
case 'Y':
|
||||
avrdude_message(MSG_INFO, "%s: erase cycle counter no longer supported\n",
|
||||
progname);
|
||||
pmsg_error("erase cycle counter no longer supported\n");
|
||||
break;
|
||||
|
||||
case '?': /* help */
|
||||
|
@ -685,7 +733,7 @@ int main(int argc, char * argv [])
|
|||
break;
|
||||
|
||||
default:
|
||||
avrdude_message(MSG_INFO, "%s: invalid option -%c\n\n", progname, ch);
|
||||
pmsg_error("invalid option -%c\n\n", ch);
|
||||
usage();
|
||||
exit(1);
|
||||
break;
|
||||
|
@ -697,8 +745,7 @@ int main(int argc, char * argv [])
|
|||
FILE *newstderr = freopen(logfile, "w", stderr);
|
||||
if (newstderr == NULL) {
|
||||
/* Help! There's no stderr to complain to anymore now. */
|
||||
printf("Cannot create logfile \"%s\": %s\n",
|
||||
logfile, strerror(errno));
|
||||
printf("Cannot create logfile %s: %s\n", logfile, strerror(errno));
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
@ -737,10 +784,10 @@ int main(int argc, char * argv [])
|
|||
executable_dirpath[executable_dirpath_len] = '\0';
|
||||
|
||||
// Debug output
|
||||
avrdude_message(MSG_DEBUG, "executable_abspath = %s\n", executable_abspath);
|
||||
avrdude_message(MSG_DEBUG, "executable_abspath_len = %i\n", executable_abspath_len);
|
||||
avrdude_message(MSG_DEBUG, "executable_dirpath = %s\n", executable_dirpath);
|
||||
avrdude_message(MSG_DEBUG, "executable_dirpath_len = %i\n", executable_dirpath_len);
|
||||
msg_debug("executable_abspath = %s\n", executable_abspath);
|
||||
msg_debug("executable_abspath_len = %i\n", executable_abspath_len);
|
||||
msg_debug("executable_dirpath = %s\n", executable_dirpath);
|
||||
msg_debug("executable_dirpath_len = %i\n", executable_dirpath_len);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -796,9 +843,9 @@ int main(int argc, char * argv [])
|
|||
}
|
||||
}
|
||||
// Debug output
|
||||
avrdude_message(MSG_DEBUG, "sys_config = %s\n", sys_config);
|
||||
avrdude_message(MSG_DEBUG, "sys_config_found = %s\n", sys_config_found ? "true" : "false");
|
||||
avrdude_message(MSG_DEBUG, "\n");
|
||||
msg_debug("sys_config = %s\n", sys_config);
|
||||
msg_debug("sys_config_found = %s\n", sys_config_found ? "true" : "false");
|
||||
msg_debug("\n");
|
||||
|
||||
/*
|
||||
* USER CONFIG
|
||||
|
@ -826,35 +873,36 @@ int main(int argc, char * argv [])
|
|||
* Print out an identifying string so folks can tell what version
|
||||
* they are running
|
||||
*/
|
||||
avrdude_message(MSG_NOTICE, "\n%s: Version %s\n"
|
||||
"%sCopyright (c) Brian Dean, http://www.bdmicro.com/\n"
|
||||
"%sCopyright (c) Joerg Wunsch\n\n",
|
||||
progname, version, progbuf, progbuf);
|
||||
avrdude_message(MSG_NOTICE, "%sSystem wide configuration file is \"%s\"\n",
|
||||
progbuf, sys_config);
|
||||
msg_notice("\n");
|
||||
pmsg_notice("Version %s\n", version);
|
||||
imsg_notice("Copyright (c) Brian Dean, http://www.bdmicro.com/\n");
|
||||
imsg_notice("Copyright (c) Joerg Wunsch\n\n");
|
||||
|
||||
rc = read_config(sys_config);
|
||||
if(*sys_config) {
|
||||
char *real_sys_config = realpath(sys_config, NULL);
|
||||
if(real_sys_config) {
|
||||
imsg_notice("System wide configuration file is %s\n", real_sys_config);
|
||||
} else
|
||||
pmsg_warning("cannot determine realpath() of config file %s: %s\n", sys_config, strerror(errno));
|
||||
|
||||
rc = read_config(real_sys_config);
|
||||
if (rc) {
|
||||
avrdude_message(MSG_INFO, "%s: error reading system wide configuration file \"%s\"\n",
|
||||
progname, sys_config);
|
||||
pmsg_error("unable to process system wide configuration file %s\n", real_sys_config);
|
||||
exit(1);
|
||||
}
|
||||
free(real_sys_config);
|
||||
}
|
||||
|
||||
if (usr_config[0] != 0) {
|
||||
avrdude_message(MSG_NOTICE, "%sUser configuration file is \"%s\"\n",
|
||||
progbuf, usr_config);
|
||||
imsg_notice("User configuration file is %s\n", usr_config);
|
||||
|
||||
rc = stat(usr_config, &sb);
|
||||
if ((rc < 0) || ((sb.st_mode & S_IFREG) == 0)) {
|
||||
avrdude_message(MSG_NOTICE, "%sUser configuration file does not exist or is not a "
|
||||
"regular file, skipping\n",
|
||||
progbuf);
|
||||
}
|
||||
if ((rc < 0) || ((sb.st_mode & S_IFREG) == 0))
|
||||
imsg_notice("User configuration file does not exist or is not a regular file, skipping\n");
|
||||
else {
|
||||
rc = read_config(usr_config);
|
||||
if (rc) {
|
||||
avrdude_message(MSG_INFO, "%s: error reading user configuration file \"%s\"\n",
|
||||
progname, usr_config);
|
||||
pmsg_error("unable to process user configuration file %s\n", usr_config);
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
@ -866,13 +914,11 @@ int main(int argc, char * argv [])
|
|||
|
||||
for (ln1=lfirst(additional_config_files); ln1; ln1=lnext(ln1)) {
|
||||
p = ldata(ln1);
|
||||
avrdude_message(MSG_NOTICE, "%sAdditional configuration file is \"%s\"\n",
|
||||
progbuf, p);
|
||||
imsg_notice("additional configuration file is %s\n", p);
|
||||
|
||||
rc = read_config(p);
|
||||
if (rc) {
|
||||
avrdude_message(MSG_INFO, "%s: error reading additional configuration file \"%s\"\n",
|
||||
progname, p);
|
||||
pmsg_error("unable to process additional configuration file %s\n", p);
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
@ -898,8 +944,8 @@ int main(int argc, char * argv [])
|
|||
PROGRAMMER *pgm = ldata(ln2);
|
||||
int pm = pgm->prog_modes & p->prog_modes;
|
||||
if(pm & (pm-1))
|
||||
avrdude_message(MSG_INFO, "%s warning: %s and %s share multiple modes (%s)\n",
|
||||
progname, pgm->id? ldata(lfirst(pgm->id)): "???", p->desc, via_prog_modes(pm));
|
||||
pmsg_warning("%s and %s share multiple modes (%s)\n",
|
||||
pgm->id? (char *) ldata(lfirst(pgm->id)): "???", p->desc, via_prog_modes(pm));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -909,13 +955,13 @@ int main(int argc, char * argv [])
|
|||
PROGRAMMER *pgm = locate_programmer(programmers, programmer);
|
||||
if(!pgm)
|
||||
exit_programmer_not_found(programmer);
|
||||
avrdude_message(MSG_INFO, "\nValid parts for programmer %s are:\n", programmer);
|
||||
msg_error("\nValid parts for programmer %s are:\n", programmer);
|
||||
list_parts(stderr, " ", part_list, pgm->prog_modes);
|
||||
} else {
|
||||
avrdude_message(MSG_INFO, "\nValid parts are:\n");
|
||||
msg_error("\nValid parts are:\n");
|
||||
list_parts(stderr, " ", part_list, ~0);
|
||||
}
|
||||
avrdude_message(MSG_INFO, "\n");
|
||||
msg_error("\n");
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
@ -926,25 +972,25 @@ int main(int argc, char * argv [])
|
|||
AVRPART *p = locate_part(part_list, partdesc);
|
||||
if(!p)
|
||||
exit_part_not_found(partdesc);
|
||||
avrdude_message(MSG_INFO, "\nValid programmers for part %s are:\n", p->desc);
|
||||
msg_error("\nValid programmers for part %s are:\n", p->desc);
|
||||
list_programmers(stderr, " ", programmers, p->prog_modes);
|
||||
} else {
|
||||
avrdude_message(MSG_INFO, "\nValid programmers are:\n");
|
||||
msg_error("\nValid programmers are:\n");
|
||||
list_programmers(stderr, " ", programmers, ~0);
|
||||
}
|
||||
avrdude_message(MSG_INFO, "\n");
|
||||
msg_error("\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (strcmp(programmer, "?type") == 0) {
|
||||
avrdude_message(MSG_INFO, "\nValid programmer types are:\n");
|
||||
msg_error("\nValid programmer types are:\n");
|
||||
list_programmer_types(stderr, " ");
|
||||
avrdude_message(MSG_INFO, "\n");
|
||||
msg_error("\n");
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
avrdude_message(MSG_NOTICE, "\n");
|
||||
msg_notice("\n");
|
||||
|
||||
if (!programmer || !*programmer)
|
||||
exit_programmer_not_found(NULL);
|
||||
|
@ -956,7 +1002,8 @@ int main(int argc, char * argv [])
|
|||
if (pgm->initpgm) {
|
||||
pgm->initpgm(pgm);
|
||||
} else {
|
||||
avrdude_message(MSG_INFO, "\n%s: cannot initialize the programmer\n\n", progname);
|
||||
msg_error("\n");
|
||||
pmsg_error("cannot initialize the programmer\n\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
@ -969,13 +1016,10 @@ int main(int argc, char * argv [])
|
|||
|
||||
if (lsize(extended_params) > 0) {
|
||||
if (pgm->parseextparams == NULL) {
|
||||
avrdude_message(MSG_INFO, "%s: WARNING: Programmer doesn't support extended parameters,"
|
||||
" -x option(s) ignored\n",
|
||||
progname);
|
||||
pmsg_error("programmer does not support extended parameters, -x option(s) ignored\n");
|
||||
} else {
|
||||
if (pgm->parseextparams(pgm, extended_params) < 0) {
|
||||
avrdude_message(MSG_INFO, "%s: Error parsing extended parameter list\n",
|
||||
progname);
|
||||
pmsg_error("unable to parse extended parameter list\n");
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
@ -1014,8 +1058,7 @@ int main(int argc, char * argv [])
|
|||
|
||||
if (exitspecs != NULL) {
|
||||
if (pgm->parseexitspecs == NULL) {
|
||||
avrdude_message(MSG_INFO, "%s: WARNING: -E option not supported by this programmer type\n",
|
||||
progname);
|
||||
pmsg_warning("-E option not supported by this programmer type\n");
|
||||
exitspecs = NULL;
|
||||
}
|
||||
else if (pgm->parseexitspecs(pgm, exitspecs) < 0) {
|
||||
|
@ -1025,8 +1068,8 @@ int main(int argc, char * argv [])
|
|||
}
|
||||
|
||||
if (avr_initmem(p) != 0) {
|
||||
avrdude_message(MSG_INFO, "\n%s: failed to initialize memories\n",
|
||||
progname);
|
||||
msg_error("\n");
|
||||
pmsg_error("unable to initialize memories\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
@ -1042,8 +1085,7 @@ int main(int argc, char * argv [])
|
|||
upd = ldata(ln);
|
||||
if (upd->memtype == NULL) {
|
||||
const char *mtype = p->prog_modes & PM_PDI? "application": "flash";
|
||||
avrdude_message(MSG_NOTICE2, "%s: defaulting memtype in -U %c:%s option to \"%s\"\n",
|
||||
progname,
|
||||
pmsg_notice2("defaulting memtype in -U %c:%s option to \"%s\"\n",
|
||||
(upd->op == DEVICE_READ)? 'r': (upd->op == DEVICE_WRITE)? 'w': 'v',
|
||||
upd->filename, mtype);
|
||||
upd->memtype = cfg_strdup("main()", mtype);
|
||||
|
@ -1060,44 +1102,42 @@ int main(int argc, char * argv [])
|
|||
* open the programmer
|
||||
*/
|
||||
if (port[0] == 0) {
|
||||
avrdude_message(MSG_INFO, "\n%s: no port has been specified on the command line "
|
||||
"or in the config file\n",
|
||||
progname);
|
||||
avrdude_message(MSG_INFO, "%sSpecify a port using the -P option and try again\n\n",
|
||||
progbuf);
|
||||
msg_error("\n");
|
||||
pmsg_error("no port has been specified on the command line or in the config file\n");
|
||||
imsg_error("specify a port using the -P option and try again\n\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (verbose) {
|
||||
avrdude_message(MSG_NOTICE, "%sUsing Port : %s\n", progbuf, port);
|
||||
avrdude_message(MSG_NOTICE, "%sUsing Programmer : %s\n", progbuf, programmer);
|
||||
imsg_notice("Using Port : %s\n", port);
|
||||
imsg_notice("Using Programmer : %s\n", programmer);
|
||||
if ((strcmp(pgm->type, "avr910") == 0)) {
|
||||
avrdude_message(MSG_NOTICE, "%savr910_devcode (avrdude.conf) : ", progbuf);
|
||||
if(p->avr910_devcode)avrdude_message(MSG_INFO, "0x%x\n", p->avr910_devcode);
|
||||
else avrdude_message(MSG_NOTICE, "none\n");
|
||||
imsg_notice("avr910_devcode (avrdude.conf) : ");
|
||||
if(p->avr910_devcode)
|
||||
msg_notice("0x%x\n", p->avr910_devcode);
|
||||
else
|
||||
msg_notice("none\n");
|
||||
}
|
||||
}
|
||||
|
||||
if (baudrate != 0) {
|
||||
avrdude_message(MSG_NOTICE, "%sOverriding Baud Rate : %d\n", progbuf, baudrate);
|
||||
imsg_notice("Overriding Baud Rate : %d\n", baudrate);
|
||||
pgm->baudrate = baudrate;
|
||||
}
|
||||
|
||||
if (bitclock != 0.0) {
|
||||
avrdude_message(MSG_NOTICE, "%sSetting bit clk period : %.1f\n", progbuf, bitclock);
|
||||
imsg_notice("Setting bit clk period : %.1f\n", bitclock);
|
||||
pgm->bitclock = bitclock * 1e-6;
|
||||
}
|
||||
|
||||
if (ispdelay != 0) {
|
||||
avrdude_message(MSG_NOTICE, "%sSetting isp clock delay : %3i\n", progbuf, ispdelay);
|
||||
imsg_notice("Setting isp clock delay : %3i\n", ispdelay);
|
||||
pgm->ispdelay = ispdelay;
|
||||
}
|
||||
|
||||
rc = pgm->open(pgm, port);
|
||||
if (rc < 0) {
|
||||
avrdude_message(MSG_INFO,
|
||||
"%s: opening programmer \"%s\" on port \"%s\" failed\n",
|
||||
progname, programmer, port);
|
||||
pmsg_error("unable to open programmer %s on port %s\n", programmer, port);
|
||||
exitrc = 1;
|
||||
pgm->ppidata = 0; /* clear all bits at exit */
|
||||
goto main_exit;
|
||||
|
@ -1110,29 +1150,24 @@ int main(int argc, char * argv [])
|
|||
* as outlined in appnote AVR053
|
||||
*/
|
||||
if (pgm->perform_osccal == 0) {
|
||||
avrdude_message(MSG_INFO, "%s: programmer does not support RC oscillator calibration\n",
|
||||
progname);
|
||||
pmsg_error("programmer does not support RC oscillator calibration\n");
|
||||
exitrc = 1;
|
||||
} else {
|
||||
avrdude_message(MSG_INFO, "%s: performing RC oscillator calibration\n", progname);
|
||||
pmsg_info("performing RC oscillator calibration\n");
|
||||
exitrc = pgm->perform_osccal(pgm);
|
||||
}
|
||||
if (exitrc == 0 && quell_progress < 2) {
|
||||
avrdude_message(MSG_INFO, "%s: calibration value is now stored in EEPROM at address 0\n",
|
||||
progname);
|
||||
}
|
||||
if (exitrc == 0)
|
||||
pmsg_info("calibration value is now stored in EEPROM at address 0\n");
|
||||
goto main_exit;
|
||||
}
|
||||
|
||||
if (verbose) {
|
||||
if (verbose && quell_progress < 2) {
|
||||
avr_display(stderr, p, progbuf, verbose);
|
||||
avrdude_message(MSG_NOTICE, "\n");
|
||||
msg_notice("\n");
|
||||
programmer_display(pgm, progbuf);
|
||||
}
|
||||
|
||||
if (quell_progress < 2) {
|
||||
avrdude_message(MSG_INFO, "\n");
|
||||
}
|
||||
msg_info("\n");
|
||||
|
||||
exitrc = 0;
|
||||
|
||||
|
@ -1154,12 +1189,10 @@ int main(int argc, char * argv [])
|
|||
*/
|
||||
init_ok = (rc = pgm->initialize(pgm, p)) >= 0;
|
||||
if (!init_ok) {
|
||||
avrdude_message(MSG_INFO, "%s: initialization failed, rc=%d\n", progname, rc);
|
||||
pmsg_error("initialization failed, rc=%d\n", rc);
|
||||
if (!ovsigck) {
|
||||
avrdude_message(MSG_INFO, "%sDouble check connections and try again, "
|
||||
"or use -F to override\n"
|
||||
"%sthis check.\n\n",
|
||||
progbuf, progbuf);
|
||||
imsg_error("double check connections and try again or use -F to override\n");
|
||||
imsg_error("this check\n\n");
|
||||
exitrc = 1;
|
||||
goto main_exit;
|
||||
}
|
||||
|
@ -1168,10 +1201,7 @@ int main(int argc, char * argv [])
|
|||
/* indicate ready */
|
||||
pgm->rdy_led(pgm, ON);
|
||||
|
||||
if (quell_progress < 2) {
|
||||
avrdude_message(MSG_INFO, "%s: AVR device initialized and ready to accept instructions\n",
|
||||
progname);
|
||||
}
|
||||
pmsg_info("AVR device initialized and ready to accept instructions\n");
|
||||
|
||||
/*
|
||||
* Let's read the signature bytes to make sure there is at least a
|
||||
|
@ -1194,54 +1224,46 @@ int main(int argc, char * argv [])
|
|||
// Read SIB and compare FamilyID
|
||||
char sib[AVR_SIBLEN + 1];
|
||||
pgm->read_sib(pgm, p, sib);
|
||||
avrdude_message(MSG_NOTICE, "%s: System Information Block: \"%s\"\n", progname, sib);
|
||||
if (quell_progress < 2)
|
||||
avrdude_message(MSG_INFO, "%s: Received FamilyID: \"%.*s\"\n", progname, AVR_FAMILYIDLEN, sib);
|
||||
pmsg_notice("System Information Block: %s\n", sib);
|
||||
pmsg_info("received FamilyID: \"%.*s\"\n", AVR_FAMILYIDLEN, sib);
|
||||
if (strncmp(p->family_id, sib, AVR_FAMILYIDLEN))
|
||||
avrdude_message(MSG_INFO, "%s: Expected FamilyID: \"%s\"\n", progname, p->family_id);
|
||||
pmsg_error("expected FamilyID: \"%s\"\n", p->family_id);
|
||||
}
|
||||
if(erase) {
|
||||
erase = 0;
|
||||
if (uflags & UF_NOWRITE) {
|
||||
avrdude_message(MSG_INFO, "%s: conflicting -e and -n options specified, NOT erasing chip\n",
|
||||
progname);
|
||||
pmsg_warning("conflicting -e and -n options specified, NOT erasing chip\n");
|
||||
} else {
|
||||
if (quell_progress < 2)
|
||||
avrdude_message(MSG_INFO, "%s: erasing chip\n", progname);
|
||||
pmsg_info("erasing chip\n");
|
||||
exitrc = avr_unlock(pgm, p);
|
||||
if(exitrc) goto main_exit;
|
||||
if(exitrc)
|
||||
goto main_exit;
|
||||
goto sig_again;
|
||||
}
|
||||
}
|
||||
if (!ovsigck) {
|
||||
avrdude_message(MSG_INFO, "%sDouble check chip, or use -F to override this check.\n",
|
||||
progbuf);
|
||||
imsg_error("double check chip or use -F to override this check\n");
|
||||
exitrc = 1;
|
||||
goto main_exit;
|
||||
}
|
||||
}
|
||||
avrdude_message(MSG_INFO, "%s: error reading signature data, rc=%d\n",
|
||||
progname, rc);
|
||||
pmsg_error("unable to read signature data, rc=%d\n", rc);
|
||||
exitrc = 1;
|
||||
goto main_exit;
|
||||
}
|
||||
}
|
||||
|
||||
sig = avr_locate_mem(p, "signature");
|
||||
if (sig == NULL) {
|
||||
avrdude_message(MSG_INFO, "%s: WARNING: signature data not defined for device \"%s\"\n",
|
||||
progname, p->desc);
|
||||
} else {
|
||||
if (sig == NULL)
|
||||
pmsg_warning("signature memory not defined for device %s\n", p->desc);
|
||||
|
||||
if (sig != NULL) {
|
||||
int ff, zz;
|
||||
|
||||
if (quell_progress < 2) {
|
||||
avrdude_message(MSG_INFO, "%s: Device signature = 0x", progname);
|
||||
}
|
||||
pmsg_info("device signature = 0x");
|
||||
ff = zz = 1;
|
||||
for (i=0; i<sig->size; i++) {
|
||||
if (quell_progress < 2) {
|
||||
avrdude_message(MSG_INFO, "%02x", sig->buf[i]);
|
||||
}
|
||||
msg_info("%02x", sig->buf[i]);
|
||||
if (sig->buf[i] != 0xff)
|
||||
ff = 0;
|
||||
if (sig->buf[i] != 0x00)
|
||||
|
@ -1256,46 +1278,35 @@ int main(int argc, char * argv [])
|
|||
|
||||
if (quell_progress < 2) {
|
||||
AVRPART * part;
|
||||
|
||||
part = locate_part_by_signature(part_list, sig->buf, sig->size);
|
||||
if (part) {
|
||||
avrdude_message(MSG_INFO, " (probably %s)", signature_matches ? p->id : part->id);
|
||||
}
|
||||
if((part = locate_part_by_signature(part_list, sig->buf, sig->size)))
|
||||
msg_info(" (probably %s)", signature_matches ? p->id : part->id);
|
||||
}
|
||||
if (ff || zz) {
|
||||
if (++attempt < 3) {
|
||||
waittime *= 5;
|
||||
if (quell_progress < 2) {
|
||||
avrdude_message(MSG_INFO, " (retrying)\n");
|
||||
}
|
||||
msg_info(" (retrying)\n");
|
||||
goto sig_again;
|
||||
}
|
||||
if (quell_progress < 2) {
|
||||
avrdude_message(MSG_INFO, "\n");
|
||||
}
|
||||
avrdude_message(MSG_INFO, "%s: Yikes! Invalid device signature.\n", progname);
|
||||
msg_info("\n");
|
||||
pmsg_error("Yikes! Invalid device signature.\n");
|
||||
if (!ovsigck) {
|
||||
avrdude_message(MSG_INFO, "%sDouble check connections and try again, "
|
||||
"or use -F to override\n"
|
||||
"%sthis check.\n\n",
|
||||
progbuf, progbuf);
|
||||
imsg_error("Double check connections and try again, or use -F to override\n");
|
||||
imsg_error("this check.\n\n");
|
||||
exitrc = 1;
|
||||
goto main_exit;
|
||||
}
|
||||
} else {
|
||||
if (quell_progress < 2) {
|
||||
avrdude_message(MSG_INFO, "\n");
|
||||
}
|
||||
msg_info("\n");
|
||||
}
|
||||
|
||||
if (!signature_matches) {
|
||||
avrdude_message(MSG_INFO, "%s: Expected signature for %s is %02X %02X %02X\n",
|
||||
progname, p->desc,
|
||||
if (ovsigck) {
|
||||
pmsg_warning("expected signature for %s is %02X %02X %02X\n", p->desc,
|
||||
p->signature[0], p->signature[1], p->signature[2]);
|
||||
if (!ovsigck) {
|
||||
avrdude_message(MSG_INFO, "%sDouble check chip, "
|
||||
"or use -F to override this check.\n",
|
||||
progbuf);
|
||||
} else {
|
||||
pmsg_error("expected signature for %s is %02X %02X %02X\n", p->desc,
|
||||
p->signature[0], p->signature[1], p->signature[2]);
|
||||
imsg_error("double check chip or use -F to override this check\n");
|
||||
exitrc = 1;
|
||||
goto main_exit;
|
||||
}
|
||||
|
@ -1305,12 +1316,9 @@ int main(int argc, char * argv [])
|
|||
|
||||
if (uflags & UF_AUTO_ERASE) {
|
||||
if ((p->prog_modes & PM_PDI) && pgm->page_erase && lsize(updates) > 0) {
|
||||
if (quell_progress < 2) {
|
||||
avrdude_message(MSG_INFO, "%s: NOTE: Programmer supports page erase for Xmega devices.\n"
|
||||
"%sEach page will be erased before programming it, but no chip erase is performed.\n"
|
||||
"%sTo disable page erases, specify the -D option; for a chip-erase, use the -e option.\n",
|
||||
progname, progbuf, progbuf);
|
||||
}
|
||||
pmsg_info("Note: programmer supports page erase for Xmega devices.\n");
|
||||
imsg_info("Each page will be erased before programming it, but no chip erase is performed.\n");
|
||||
imsg_info("To disable page erases, specify the -D option; for a chip-erase, use the -e option.\n");
|
||||
} else {
|
||||
AVRMEM * m;
|
||||
const char *memname = p->prog_modes & PM_PDI? "application": "flash";
|
||||
|
@ -1323,12 +1331,8 @@ int main(int argc, char * argv [])
|
|||
continue;
|
||||
if ((strcmp(m->desc, memname) == 0) && (upd->op == DEVICE_WRITE)) {
|
||||
erase = 1;
|
||||
if (quell_progress < 2) {
|
||||
avrdude_message(MSG_INFO, "%s: NOTE: \"%s\" memory has been specified, an erase cycle "
|
||||
"will be performed\n"
|
||||
"%sTo disable this feature, specify the -D option.\n",
|
||||
progname, memname, progbuf);
|
||||
}
|
||||
pmsg_info("Note: %s memory has been specified, an erase cycle will be performed.\n", memname);
|
||||
imsg_info("To disable this feature, specify the -D option.\n");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -1341,11 +1345,9 @@ int main(int argc, char * argv [])
|
|||
* before the chip can accept new programming
|
||||
*/
|
||||
if (uflags & UF_NOWRITE) {
|
||||
avrdude_message(MSG_INFO, "%s: conflicting -e and -n options specified, NOT erasing chip\n",
|
||||
progname);
|
||||
pmsg_warning("conflicting -e and -n options specified, NOT erasing chip\n");
|
||||
} else {
|
||||
if (quell_progress < 2)
|
||||
avrdude_message(MSG_INFO, "%s: erasing chip\n", progname);
|
||||
msg_info("erasing chip\n");
|
||||
exitrc = avr_chip_erase(pgm, p);
|
||||
if(exitrc) goto main_exit;
|
||||
}
|
||||
|
@ -1392,9 +1394,7 @@ main_exit:
|
|||
pgm->close(pgm);
|
||||
}
|
||||
|
||||
if (quell_progress < 2) {
|
||||
avrdude_message(MSG_INFO, "\n%s done. Thank you.\n\n", progname);
|
||||
}
|
||||
msg_info("\n%s done. Thank you.\n\n", progname);
|
||||
|
||||
return exitrc;
|
||||
}
|
||||
|
|
|
@ -164,7 +164,7 @@ static int micronucleus_reconnect(pdata_t* pdata)
|
|||
|
||||
for (int i = 0; i < 25; i++)
|
||||
{
|
||||
avrdude_message(MSG_NOTICE, "%s: Trying to reconnect...\n", progname);
|
||||
pmsg_notice("trying to reconnect ...\n");
|
||||
|
||||
pdata->usb_handle = usb_open(device);
|
||||
if (pdata->usb_handle != NULL)
|
||||
|
@ -188,14 +188,12 @@ static int micronucleus_get_bootloader_info_v1(pdata_t* pdata)
|
|||
MICRONUCLEUS_DEFAULT_TIMEOUT);
|
||||
if (result < 0)
|
||||
{
|
||||
avrdude_message(MSG_INFO, "%s: WARNING: Failed to get bootloader info block: %s\n",
|
||||
progname, usb_strerror());
|
||||
pmsg_warning("unable to get bootloader info block: %s\n", usb_strerror());
|
||||
return result;
|
||||
}
|
||||
else if (result < sizeof(buffer))
|
||||
{
|
||||
avrdude_message(MSG_INFO, "%s: WARNING: Received invalid bootloader info block size: %d\n",
|
||||
progname, result);
|
||||
pmsg_warning("received invalid bootloader info block size: %d\n", result);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -257,14 +255,12 @@ static int micronucleus_get_bootloader_info_v2(pdata_t* pdata)
|
|||
MICRONUCLEUS_DEFAULT_TIMEOUT);
|
||||
if (result < 0)
|
||||
{
|
||||
avrdude_message(MSG_INFO, "%s: WARNING: Failed to get bootloader info block: %s\n",
|
||||
progname, usb_strerror());
|
||||
pmsg_warning("unable to get bootloader info block: %s\n", usb_strerror());
|
||||
return result;
|
||||
}
|
||||
else if (result < sizeof(buffer))
|
||||
{
|
||||
avrdude_message(MSG_INFO, "%s: WARNING: Received invalid bootloader info block size: %d\n",
|
||||
progname, result);
|
||||
pmsg_warning("received invalid bootloader info block size: %d\n", result);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -302,19 +298,19 @@ static int micronucleus_get_bootloader_info(pdata_t* pdata)
|
|||
|
||||
static void micronucleus_dump_device_info(pdata_t* pdata)
|
||||
{
|
||||
avrdude_message(MSG_NOTICE, "%s: Bootloader version: %d.%d\n", progname, pdata->major_version, pdata->minor_version);
|
||||
avrdude_message(MSG_NOTICE, "%s: Available flash size: %u\n", progname, pdata->flash_size);
|
||||
avrdude_message(MSG_NOTICE, "%s: Page size: %u\n", progname, pdata->page_size);
|
||||
avrdude_message(MSG_NOTICE, "%s: Bootloader start: 0x%04X\n", progname, pdata->bootloader_start);
|
||||
avrdude_message(MSG_NOTICE, "%s: Write sleep: %ums\n", progname, pdata->write_sleep);
|
||||
avrdude_message(MSG_NOTICE, "%s: Erase sleep: %ums\n", progname, pdata->erase_sleep);
|
||||
avrdude_message(MSG_NOTICE, "%s: Signature1: 0x%02X\n", progname, pdata->signature1);
|
||||
avrdude_message(MSG_NOTICE, "%s: Signature2: 0x%02X\n", progname, pdata->signature2);
|
||||
pmsg_notice("Bootloader version: %d.%d\n", pdata->major_version, pdata->minor_version);
|
||||
imsg_notice("Available flash size: %u\n", pdata->flash_size);
|
||||
imsg_notice("Page size: %u\n", pdata->page_size);
|
||||
imsg_notice("Bootloader start: 0x%04X\n", pdata->bootloader_start);
|
||||
imsg_notice("Write sleep: %ums\n", pdata->write_sleep);
|
||||
imsg_notice("Erase sleep: %ums\n", pdata->erase_sleep);
|
||||
imsg_notice("Signature1: 0x%02X\n", pdata->signature1);
|
||||
imsg_notice("Signature2: 0x%02X\n", pdata->signature2);
|
||||
}
|
||||
|
||||
static int micronucleus_erase_device(pdata_t* pdata)
|
||||
{
|
||||
avrdude_message(MSG_DEBUG, "%s: micronucleus_erase_device()\n", progname);
|
||||
pmsg_debug("micronucleus_erase_device()\n");
|
||||
|
||||
int result = usb_control_msg(
|
||||
pdata->usb_handle,
|
||||
|
@ -329,10 +325,10 @@ static int micronucleus_erase_device(pdata_t* pdata)
|
|||
{
|
||||
case -EIO:
|
||||
case -EPIPE:
|
||||
avrdude_message(MSG_NOTICE, "%s: Ignoring last error of erase command: %s\n", progname, usb_strerror());
|
||||
pmsg_notice("ignoring last error of erase command: %s\n", usb_strerror());
|
||||
break;
|
||||
default:
|
||||
avrdude_message(MSG_INFO, "%s: WARNING: Failed is issue erase command, code %d: %s\n", progname, result, usb_strerror());
|
||||
pmsg_warning("erase command failed, code %d: %s\n", result, usb_strerror());
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
@ -342,12 +338,12 @@ static int micronucleus_erase_device(pdata_t* pdata)
|
|||
result = micronucleus_check_connection(pdata);
|
||||
if (result < 0)
|
||||
{
|
||||
avrdude_message(MSG_NOTICE, "%s: Connection dropped, trying to reconnect...\n", progname);
|
||||
pmsg_notice("connection dropped, trying to reconnect ...\n");
|
||||
|
||||
result = micronucleus_reconnect(pdata);
|
||||
if (result < 0)
|
||||
{
|
||||
avrdude_message(MSG_INFO, "%s: WARNING: Failed to reconnect USB device: %s\n", progname, usb_strerror());
|
||||
pmsg_warning("unable to reconnect USB device: %s\n", usb_strerror());
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
@ -373,7 +369,7 @@ static int micronucleus_patch_reset_vector(pdata_t* pdata, uint8_t* buffer)
|
|||
}
|
||||
else
|
||||
{
|
||||
avrdude_message(MSG_INFO, "%s: The reset vector of the user program does not contain a branch instruction.\n", progname);
|
||||
pmsg_error("the reset vector of the user program does not contain a branch instruction\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -431,7 +427,7 @@ static int micronucleus_write_page_v1(pdata_t* pdata, uint32_t address, uint8_t*
|
|||
MICRONUCLEUS_DEFAULT_TIMEOUT);
|
||||
if (result < 0)
|
||||
{
|
||||
avrdude_message(MSG_INFO, "%s: Failed to transfer page: %s\n", progname, usb_strerror());
|
||||
pmsg_error("unable to transfer page: %s\n", usb_strerror());
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -449,7 +445,7 @@ static int micronucleus_write_page_v2(pdata_t* pdata, uint32_t address, uint8_t*
|
|||
MICRONUCLEUS_DEFAULT_TIMEOUT);
|
||||
if (result < 0)
|
||||
{
|
||||
avrdude_message(MSG_INFO, "%s: Failed to transfer page: %s\n", progname, usb_strerror());
|
||||
pmsg_error("unable to transfer page: %s\n", usb_strerror());
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -466,7 +462,7 @@ static int micronucleus_write_page_v2(pdata_t* pdata, uint32_t address, uint8_t*
|
|||
MICRONUCLEUS_DEFAULT_TIMEOUT);
|
||||
if (result < 0)
|
||||
{
|
||||
avrdude_message(MSG_INFO, "%s: Failed to transfer page: %s\n", progname, usb_strerror());
|
||||
pmsg_error("unable to transfer page: %s\n", usb_strerror());
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
@ -476,7 +472,7 @@ static int micronucleus_write_page_v2(pdata_t* pdata, uint32_t address, uint8_t*
|
|||
|
||||
static int micronucleus_write_page(pdata_t* pdata, uint32_t address, uint8_t* buffer, uint32_t size)
|
||||
{
|
||||
avrdude_message(MSG_DEBUG, "%s: micronucleus_write_page(address=0x%04X, size=%d)\n", progname, address, size);
|
||||
pmsg_debug("micronucleus_write_page(address=0x%04X, size=%d)\n", address, size);
|
||||
|
||||
if (address == 0)
|
||||
{
|
||||
|
@ -528,7 +524,7 @@ static int micronucleus_write_page(pdata_t* pdata, uint32_t address, uint8_t* bu
|
|||
|
||||
static int micronucleus_start(pdata_t* pdata)
|
||||
{
|
||||
avrdude_message(MSG_DEBUG, "%s: micronucleus_start()\n", progname);
|
||||
pmsg_debug("micronucleus_start()\n");
|
||||
|
||||
int result = usb_control_msg(
|
||||
pdata->usb_handle,
|
||||
|
@ -539,7 +535,7 @@ static int micronucleus_start(pdata_t* pdata)
|
|||
MICRONUCLEUS_DEFAULT_TIMEOUT);
|
||||
if (result < 0)
|
||||
{
|
||||
avrdude_message(MSG_INFO, "%s: WARNING: Failed is issue start command: %s\n", progname, usb_strerror());
|
||||
pmsg_warning("start command failed: %s\n", usb_strerror());
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -550,11 +546,11 @@ static int micronucleus_start(pdata_t* pdata)
|
|||
|
||||
static void micronucleus_setup(PROGRAMMER* pgm)
|
||||
{
|
||||
avrdude_message(MSG_DEBUG, "%s: micronucleus_setup()\n", progname);
|
||||
pmsg_debug("micronucleus_setup()\n");
|
||||
|
||||
if ((pgm->cookie = malloc(sizeof(pdata_t))) == 0)
|
||||
{
|
||||
avrdude_message(MSG_INFO, "%s: micronucleus_setup(): Out of memory allocating private data\n", progname);
|
||||
pmsg_error("out of memory allocating private data\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
@ -563,12 +559,12 @@ static void micronucleus_setup(PROGRAMMER* pgm)
|
|||
|
||||
static void micronucleus_teardown(PROGRAMMER* pgm)
|
||||
{
|
||||
avrdude_message(MSG_DEBUG, "%s: micronucleus_teardown()\n", progname);
|
||||
pmsg_debug("micronucleus_teardown()\n");
|
||||
free(pgm->cookie);
|
||||
}
|
||||
|
||||
static int micronucleus_initialize(const PROGRAMMER *pgm, const AVRPART *p) {
|
||||
avrdude_message(MSG_DEBUG, "%s: micronucleus_initialize()\n", progname);
|
||||
pmsg_debug("micronucleus_initialize()\n");
|
||||
|
||||
pdata_t* pdata = PDATA(pgm);
|
||||
|
||||
|
@ -582,15 +578,15 @@ static int micronucleus_initialize(const PROGRAMMER *pgm, const AVRPART *p) {
|
|||
}
|
||||
|
||||
static void micronucleus_display(const PROGRAMMER *pgm, const char *prefix) {
|
||||
avrdude_message(MSG_DEBUG, "%s: micronucleus_display()\n", progname);
|
||||
pmsg_debug("micronucleus_display()\n");
|
||||
}
|
||||
|
||||
static void micronucleus_powerup(const PROGRAMMER *pgm) {
|
||||
avrdude_message(MSG_DEBUG, "%s: micronucleus_powerup()\n", progname);
|
||||
pmsg_debug("micronucleus_powerup()\n");
|
||||
}
|
||||
|
||||
static void micronucleus_powerdown(const PROGRAMMER *pgm) {
|
||||
avrdude_message(MSG_DEBUG, "%s: micronucleus_powerdown()\n", progname);
|
||||
pmsg_debug("micronucleus_powerdown()\n");
|
||||
|
||||
pdata_t* pdata = PDATA(pgm);
|
||||
if (pdata->write_last_page)
|
||||
|
@ -615,24 +611,24 @@ static void micronucleus_powerdown(const PROGRAMMER *pgm) {
|
|||
}
|
||||
|
||||
static void micronucleus_enable(PROGRAMMER *pgm, const AVRPART *p) {
|
||||
avrdude_message(MSG_DEBUG, "%s: micronucleus_enable()\n", progname);
|
||||
pmsg_debug("micronucleus_enable()\n");
|
||||
}
|
||||
|
||||
static void micronucleus_disable(const PROGRAMMER *pgm) {
|
||||
avrdude_message(MSG_DEBUG, "%s: micronucleus_disable()\n", progname);
|
||||
pmsg_debug("micronucleus_disable()\n");
|
||||
}
|
||||
|
||||
static int micronucleus_program_enable(const PROGRAMMER *pgm, const AVRPART *p) {
|
||||
avrdude_message(MSG_DEBUG, "%s: micronucleus_program_enable()\n", progname);
|
||||
pmsg_debug("micronucleus_program_enable()\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int micronucleus_read_sig_bytes(const PROGRAMMER *pgm, const AVRPART *p, const AVRMEM *mem) {
|
||||
avrdude_message(MSG_DEBUG, "%s: micronucleus_read_sig_bytes()\n", progname);
|
||||
pmsg_debug("micronucleus_read_sig_bytes()\n");
|
||||
|
||||
if (mem->size < 3)
|
||||
{
|
||||
avrdude_message(MSG_INFO, "%s: memory size too small for read_sig_bytes", progname);
|
||||
pmsg_error("memory size %d < 3 too small for read_sig_bytes", mem->size);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -644,14 +640,14 @@ static int micronucleus_read_sig_bytes(const PROGRAMMER *pgm, const AVRPART *p,
|
|||
}
|
||||
|
||||
static int micronucleus_chip_erase(const PROGRAMMER *pgm, const AVRPART *p) {
|
||||
avrdude_message(MSG_DEBUG, "%s: micronucleus_chip_erase()\n", progname);
|
||||
pmsg_debug("micronucleus_chip_erase()\n");
|
||||
|
||||
pdata_t* pdata = PDATA(pgm);
|
||||
return micronucleus_erase_device(pdata);
|
||||
}
|
||||
|
||||
static int micronucleus_open(PROGRAMMER* pgm, const char *port) {
|
||||
avrdude_message(MSG_DEBUG, "%s: micronucleus_open(\"%s\")\n", progname, port);
|
||||
pmsg_debug("micronucleus_open(\"%s\")\n", port);
|
||||
|
||||
pdata_t* pdata = PDATA(pgm);
|
||||
const char *bus_name = NULL;
|
||||
|
@ -679,8 +675,8 @@ static int micronucleus_open(PROGRAMMER* pgm, const char *port) {
|
|||
|
||||
if (port != NULL && dev_name == NULL)
|
||||
{
|
||||
avrdude_message(MSG_INFO, "%s: ERROR: Invalid -P value: '%s'\n", progname, port);
|
||||
avrdude_message(MSG_INFO, "%sUse -P usb:bus:device\n", progbuf);
|
||||
pmsg_error("invalid -P value %s\n", port);
|
||||
imsg_error("use -P usb:bus:device\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -694,8 +690,7 @@ static int micronucleus_open(PROGRAMMER* pgm, const char *port) {
|
|||
pid = *(int*)(ldata(usbpid));
|
||||
if (lnext(usbpid))
|
||||
{
|
||||
avrdude_message(MSG_INFO, "%s: WARNING: using PID 0x%04x, ignoring remaining PIDs in list\n",
|
||||
progname, pid);
|
||||
pmsg_warning("using PID 0x%04x, ignoring remaining PIDs in list\n", pid);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -728,8 +723,7 @@ static int micronucleus_open(PROGRAMMER* pgm, const char *port) {
|
|||
{
|
||||
if (show_unresponsive_device_message)
|
||||
{
|
||||
avrdude_message(MSG_INFO, "%s: WARNING: Unresponsive Micronucleus device detected, please reconnect...\n",
|
||||
progname);
|
||||
pmsg_warning("unresponsive Micronucleus device detected, please reconnect ...\n");
|
||||
|
||||
show_unresponsive_device_message = false;
|
||||
}
|
||||
|
@ -737,8 +731,7 @@ static int micronucleus_open(PROGRAMMER* pgm, const char *port) {
|
|||
continue;
|
||||
}
|
||||
|
||||
avrdude_message(MSG_NOTICE, "%s: Found device with Micronucleus V%d.%d, bus:device: %s:%s\n",
|
||||
progname,
|
||||
pmsg_notice("found device with Micronucleus V%d.%d, bus:device: %s:%s\n",
|
||||
pdata->major_version, pdata->minor_version,
|
||||
bus->dirname, device->filename);
|
||||
|
||||
|
@ -753,8 +746,7 @@ static int micronucleus_open(PROGRAMMER* pgm, const char *port) {
|
|||
|
||||
if (pdata->major_version > MICRONUCLEUS_MAX_MAJOR_VERSION)
|
||||
{
|
||||
avrdude_message(MSG_INFO, "%s: WARNING: device with unsupported version (V%d.%d) of Micronucleus detected.\n",
|
||||
progname,
|
||||
pmsg_warning("device with unsupported Micronucleus version V%d.%d\n",
|
||||
pdata->major_version, pdata->minor_version);
|
||||
continue;
|
||||
}
|
||||
|
@ -762,7 +754,7 @@ static int micronucleus_open(PROGRAMMER* pgm, const char *port) {
|
|||
pdata->usb_handle = usb_open(device);
|
||||
if (pdata->usb_handle == NULL)
|
||||
{
|
||||
avrdude_message(MSG_INFO, "%s: ERROR: Failed to open USB device: %s\n", progname, usb_strerror());
|
||||
pmsg_error("unable to open USB device: %s\n", usb_strerror());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -774,16 +766,15 @@ static int micronucleus_open(PROGRAMMER* pgm, const char *port) {
|
|||
{
|
||||
if (pdata->wait_timout < 0)
|
||||
{
|
||||
avrdude_message(MSG_INFO, "%s: No device found, waiting for device to be plugged in...\n", progname);
|
||||
pmsg_error("no device found, waiting for device to be plugged in ...\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
avrdude_message(MSG_INFO, "%s: No device found, waiting %d seconds for device to be plugged in...\n",
|
||||
progname,
|
||||
pmsg_error("no device found, waiting %d seconds for device to be plugged in ...\n",
|
||||
pdata->wait_timout);
|
||||
}
|
||||
|
||||
avrdude_message(MSG_INFO, "%s: Press CTRL-C to terminate.\n", progname);
|
||||
pmsg_error("press CTRL-C to terminate\n");
|
||||
show_retry_message = false;
|
||||
}
|
||||
|
||||
|
@ -799,8 +790,7 @@ static int micronucleus_open(PROGRAMMER* pgm, const char *port) {
|
|||
|
||||
if (!pdata->usb_handle)
|
||||
{
|
||||
avrdude_message(MSG_INFO, "%s: ERROR: Could not find device with Micronucleus bootloader (%04X:%04X)\n",
|
||||
progname, vid, pid);
|
||||
pmsg_error("cannot find device with Micronucleus bootloader (%04X:%04X)\n", vid, pid);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -809,7 +799,7 @@ static int micronucleus_open(PROGRAMMER* pgm, const char *port) {
|
|||
|
||||
static void micronucleus_close(PROGRAMMER* pgm)
|
||||
{
|
||||
avrdude_message(MSG_DEBUG, "%s: micronucleus_close()\n", progname);
|
||||
pmsg_debug("micronucleus_close()\n");
|
||||
|
||||
pdata_t* pdata = PDATA(pgm);
|
||||
if (pdata->usb_handle != NULL)
|
||||
|
@ -822,8 +812,7 @@ static void micronucleus_close(PROGRAMMER* pgm)
|
|||
static int micronucleus_read_byte(const PROGRAMMER *pgm, const AVRPART *p, const AVRMEM *mem,
|
||||
unsigned long addr, unsigned char* value)
|
||||
{
|
||||
avrdude_message(MSG_DEBUG, "%s: micronucleus_read_byte(desc=%s, addr=0x%0X)\n",
|
||||
progname, mem->desc, addr);
|
||||
pmsg_debug("micronucleus_read_byte(desc=%s, addr=0x%04lX)\n", mem->desc, addr);
|
||||
|
||||
if (strcmp(mem->desc, "lfuse") == 0 ||
|
||||
strcmp(mem->desc, "hfuse") == 0 ||
|
||||
|
@ -835,7 +824,7 @@ static int micronucleus_read_byte(const PROGRAMMER *pgm, const AVRPART *p, const
|
|||
}
|
||||
else
|
||||
{
|
||||
avrdude_message(MSG_INFO, "%s: Unsupported memory type: %s\n", progname, mem->desc);
|
||||
pmsg_error("unsupported memory type %s\n", mem->desc);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
@ -843,8 +832,7 @@ static int micronucleus_read_byte(const PROGRAMMER *pgm, const AVRPART *p, const
|
|||
static int micronucleus_write_byte(const PROGRAMMER *pgm, const AVRPART *p, const AVRMEM *mem,
|
||||
unsigned long addr, unsigned char value)
|
||||
{
|
||||
avrdude_message(MSG_DEBUG, "%s: micronucleus_write_byte(desc=%s, addr=0x%0X)\n",
|
||||
progname, mem->desc, addr);
|
||||
pmsg_debug("micronucleus_write_byte(desc=%s, addr=0x%04lX)\n", mem->desc, addr);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -852,8 +840,7 @@ static int micronucleus_paged_load(const PROGRAMMER *pgm, const AVRPART *p, cons
|
|||
unsigned int page_size,
|
||||
unsigned int addr, unsigned int n_bytes)
|
||||
{
|
||||
avrdude_message(MSG_DEBUG, "%s: micronucleus_paged_load(page_size=0x%X, addr=0x%X, n_bytes=0x%X)\n",
|
||||
progname, page_size, addr, n_bytes);
|
||||
pmsg_debug("micronucleus_paged_load(page_size=0x%X, addr=0x%X, n_bytes=0x%X)\n", page_size, addr, n_bytes);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -861,8 +848,7 @@ static int micronucleus_paged_write(const PROGRAMMER *pgm, const AVRPART *p, con
|
|||
unsigned int page_size,
|
||||
unsigned int addr, unsigned int n_bytes)
|
||||
{
|
||||
avrdude_message(MSG_DEBUG, "%s: micronucleus_paged_write(page_size=0x%X, addr=0x%X, n_bytes=0x%X)\n",
|
||||
progname, page_size, addr, n_bytes);
|
||||
pmsg_debug("micronucleus_paged_write(page_size=0x%X, addr=0x%X, n_bytes=0x%X)\n", page_size, addr, n_bytes);
|
||||
|
||||
if (strcmp(mem->desc, "flash") == 0)
|
||||
{
|
||||
|
@ -870,20 +856,20 @@ static int micronucleus_paged_write(const PROGRAMMER *pgm, const AVRPART *p, con
|
|||
|
||||
if (n_bytes > page_size)
|
||||
{
|
||||
avrdude_message(MSG_INFO, "%s: Buffer size (%u) exceeds page size (%u)\n", progname, n_bytes, page_size);
|
||||
pmsg_error("buffer size %u exceeds page size %u\n", n_bytes, page_size);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (addr + n_bytes > pdata->flash_size)
|
||||
{
|
||||
avrdude_message(MSG_INFO, "%s: Program size (%u) exceeds flash size (%u)\n", progname, addr + n_bytes, pdata->flash_size);
|
||||
pmsg_error("program size %u exceeds flash size %u\n", addr + n_bytes, pdata->flash_size);
|
||||
return -1;
|
||||
}
|
||||
|
||||
uint8_t* page_buffer = (uint8_t*)malloc(pdata->page_size);
|
||||
if (page_buffer == NULL)
|
||||
{
|
||||
avrdude_message(MSG_INFO, "%s: Failed to allocate memory\n", progname);
|
||||
pmsg_error("unable to allocate memory\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -911,13 +897,13 @@ static int micronucleus_paged_write(const PROGRAMMER *pgm, const AVRPART *p, con
|
|||
}
|
||||
else
|
||||
{
|
||||
avrdude_message(MSG_INFO, "%s: Unsupported memory type: %s\n", progname, mem->desc);
|
||||
pmsg_error("unsupported memory type: %s\n", mem->desc);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
static int micronucleus_parseextparams(const PROGRAMMER *pgm, const LISTID xparams) {
|
||||
avrdude_message(MSG_DEBUG, "%s: micronucleus_parseextparams()\n", progname);
|
||||
pmsg_debug("micronucleus_parseextparams()\n");
|
||||
|
||||
pdata_t* pdata = PDATA(pgm);
|
||||
for (LNODEID node = lfirst(xparams); node != NULL; node = lnext(node))
|
||||
|
@ -936,7 +922,7 @@ static int micronucleus_parseextparams(const PROGRAMMER *pgm, const LISTID xpara
|
|||
}
|
||||
else
|
||||
{
|
||||
avrdude_message(MSG_INFO, "%s: Invalid extended parameter '%s'\n", progname, param);
|
||||
pmsg_error("invalid extended parameter '%s'\n", param);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
@ -972,7 +958,7 @@ void micronucleus_initpgm(PROGRAMMER *pgm) {
|
|||
|
||||
// Give a proper error if we were not compiled with libusb
|
||||
static int micronucleus_nousb_open(PROGRAMMER* pgm, const char* name) {
|
||||
avrdude_message(MSG_INFO, "%s: error: No usb support. Please compile again with libusb installed.\n", progname);
|
||||
pmsg_error("no usb support; please compile again with libusb installed\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
|
|
@ -231,8 +231,7 @@ static int par_open(PROGRAMMER *pgm, const char *port) {
|
|||
|
||||
ppi_open(port, &pgm->fd);
|
||||
if (pgm->fd.ifd < 0) {
|
||||
avrdude_message(MSG_INFO, "%s: failed to open parallel port \"%s\"\n\n",
|
||||
progname, port);
|
||||
pmsg_error("unable to open parallel port %s\n\n", port);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -241,14 +240,14 @@ static int par_open(PROGRAMMER *pgm, const char *port) {
|
|||
*/
|
||||
rc = ppi_getall(&pgm->fd, PPIDATA);
|
||||
if (rc < 0) {
|
||||
avrdude_message(MSG_INFO, "%s: error reading status of ppi data port\n", progname);
|
||||
pmsg_error("unable to read status of ppi data port\n");
|
||||
return -1;
|
||||
}
|
||||
pgm->ppidata = rc;
|
||||
|
||||
rc = ppi_getall(&pgm->fd, PPICTRL);
|
||||
if (rc < 0) {
|
||||
avrdude_message(MSG_INFO, "%s: error reading status of ppi ctrl port\n", progname);
|
||||
pmsg_error("unable to read status of ppi ctrl port\n");
|
||||
return -1;
|
||||
}
|
||||
pgm->ppictrl = rc;
|
||||
|
@ -391,7 +390,7 @@ void par_initpgm(PROGRAMMER *pgm) {
|
|||
#else /* !HAVE_PARPORT */
|
||||
|
||||
void par_initpgm(PROGRAMMER *pgm) {
|
||||
avrdude_message(MSG_INFO, "%s: parallel port access not available in this configuration\n", progname);
|
||||
pmsg_error("parallel port access not available in this configuration\n");
|
||||
}
|
||||
|
||||
#endif /* HAVE_PARPORT */
|
||||
|
|
28
src/pgm.c
28
src/pgm.c
|
@ -39,7 +39,7 @@ static void pgm_default_6(const PROGRAMMER *, const char *);
|
|||
|
||||
|
||||
static int pgm_default_open(PROGRAMMER *pgm, const char *name) {
|
||||
avrdude_message(MSG_INFO, "\n%s: programmer does not support open()", progname);
|
||||
pmsg_error("programmer does not support open()");
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -220,7 +220,7 @@ PROGRAMMER *pgm_dup(const PROGRAMMER *src) {
|
|||
|
||||
|
||||
static void pgm_default(void) {
|
||||
avrdude_message(MSG_INFO, "%s: programmer operation not supported\n", progname);
|
||||
pmsg_error("programmer operation not supported\n");
|
||||
}
|
||||
|
||||
|
||||
|
@ -251,8 +251,8 @@ static void pgm_default_6 (const PROGRAMMER *pgm, const char *p) {
|
|||
|
||||
|
||||
void programmer_display(PROGRAMMER *pgm, const char * p) {
|
||||
avrdude_message(MSG_INFO, "%sProgrammer Type : %s\n", p, pgm->type);
|
||||
avrdude_message(MSG_INFO, "%sDescription : %s\n", p, pgm->desc);
|
||||
msg_info("%sProgrammer Type : %s\n", p, pgm->type);
|
||||
msg_info("%sDescription : %s\n", p, pgm->desc);
|
||||
|
||||
pgm->display(pgm, p);
|
||||
}
|
||||
|
@ -260,25 +260,25 @@ void programmer_display(PROGRAMMER *pgm, const char * p) {
|
|||
|
||||
void pgm_display_generic_mask(const PROGRAMMER *pgm, const char *p, unsigned int show) {
|
||||
if(show & (1<<PPI_AVR_VCC))
|
||||
avrdude_message(MSG_INFO, "%s VCC = %s\n", p, pins_to_str(&pgm->pin[PPI_AVR_VCC]));
|
||||
msg_info("%s VCC = %s\n", p, pins_to_str(&pgm->pin[PPI_AVR_VCC]));
|
||||
if(show & (1<<PPI_AVR_BUFF))
|
||||
avrdude_message(MSG_INFO, "%s BUFF = %s\n", p, pins_to_str(&pgm->pin[PPI_AVR_BUFF]));
|
||||
msg_info("%s BUFF = %s\n", p, pins_to_str(&pgm->pin[PPI_AVR_BUFF]));
|
||||
if(show & (1<<PIN_AVR_RESET))
|
||||
avrdude_message(MSG_INFO, "%s RESET = %s\n", p, pins_to_str(&pgm->pin[PIN_AVR_RESET]));
|
||||
msg_info("%s RESET = %s\n", p, pins_to_str(&pgm->pin[PIN_AVR_RESET]));
|
||||
if(show & (1<<PIN_AVR_SCK))
|
||||
avrdude_message(MSG_INFO, "%s SCK = %s\n", p, pins_to_str(&pgm->pin[PIN_AVR_SCK]));
|
||||
msg_info("%s SCK = %s\n", p, pins_to_str(&pgm->pin[PIN_AVR_SCK]));
|
||||
if(show & (1<<PIN_AVR_MOSI))
|
||||
avrdude_message(MSG_INFO, "%s MOSI = %s\n", p, pins_to_str(&pgm->pin[PIN_AVR_MOSI]));
|
||||
msg_info("%s MOSI = %s\n", p, pins_to_str(&pgm->pin[PIN_AVR_MOSI]));
|
||||
if(show & (1<<PIN_AVR_MISO))
|
||||
avrdude_message(MSG_INFO, "%s MISO = %s\n", p, pins_to_str(&pgm->pin[PIN_AVR_MISO]));
|
||||
msg_info("%s MISO = %s\n", p, pins_to_str(&pgm->pin[PIN_AVR_MISO]));
|
||||
if(show & (1<<PIN_LED_ERR))
|
||||
avrdude_message(MSG_INFO, "%s ERR LED = %s\n", p, pins_to_str(&pgm->pin[PIN_LED_ERR]));
|
||||
msg_info("%s ERR LED = %s\n", p, pins_to_str(&pgm->pin[PIN_LED_ERR]));
|
||||
if(show & (1<<PIN_LED_RDY))
|
||||
avrdude_message(MSG_INFO, "%s RDY LED = %s\n", p, pins_to_str(&pgm->pin[PIN_LED_RDY]));
|
||||
msg_info("%s RDY LED = %s\n", p, pins_to_str(&pgm->pin[PIN_LED_RDY]));
|
||||
if(show & (1<<PIN_LED_PGM))
|
||||
avrdude_message(MSG_INFO, "%s PGM LED = %s\n", p, pins_to_str(&pgm->pin[PIN_LED_PGM]));
|
||||
msg_info("%s PGM LED = %s\n", p, pins_to_str(&pgm->pin[PIN_LED_PGM]));
|
||||
if(show & (1<<PIN_LED_VFY))
|
||||
avrdude_message(MSG_INFO, "%s VFY LED = %s\n", p, pins_to_str(&pgm->pin[PIN_LED_VFY]));
|
||||
msg_info("%s VFY LED = %s\n", p, pins_to_str(&pgm->pin[PIN_LED_VFY]));
|
||||
}
|
||||
|
||||
void pgm_display_generic(const PROGRAMMER *pgm, const char *p) {
|
||||
|
|
|
@ -72,13 +72,13 @@
|
|||
#endif
|
||||
|
||||
#if 0
|
||||
#define DEBUG(...) do { avrdude_message(MSG_DEBUG, __VA_ARGS__); } while(0)
|
||||
#define DEBUG(...) do { msg_debug(__VA_ARGS__); } while(0)
|
||||
#else
|
||||
#define DEBUG(...) ((void)0)
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
#define DEBUGRECV(...) do { avrdude_message(MSG_DEBUG, __VA_ARGS__); } while(0)
|
||||
#define DEBUGRECV(...) do { msg_debug(__VA_ARGS__); } while(0)
|
||||
#else
|
||||
#define DEBUGRECV(...) ((void)0)
|
||||
#endif
|
||||
|
@ -164,8 +164,7 @@ static void pickit2_setup(PROGRAMMER * pgm)
|
|||
{
|
||||
if ((pgm->cookie = malloc(sizeof(struct pdata))) == 0)
|
||||
{
|
||||
avrdude_message(MSG_INFO, "%s: pickit2_setup(): Out of memory allocating private data\n",
|
||||
progname);
|
||||
pmsg_error("out of memory allocating private data\n");
|
||||
exit(1);
|
||||
}
|
||||
memset(pgm->cookie, 0, sizeof(struct pdata));
|
||||
|
@ -186,8 +185,7 @@ static int pickit2_open(PROGRAMMER *pgm, const char *port) {
|
|||
if (PDATA(pgm)->usb_handle == INVALID_HANDLE_VALUE)
|
||||
{
|
||||
/* no PICkit2 found */
|
||||
avrdude_message(MSG_INFO, "%s: error: could not find PICkit2 with vid=0x%x pid=0x%x\n",
|
||||
progname, PICKIT2_VID, PICKIT2_PID);
|
||||
pmsg_error("cannot find PICkit2 with vid=0x%x pid=0x%x\n", PICKIT2_VID, PICKIT2_PID);
|
||||
return -1;
|
||||
}
|
||||
else
|
||||
|
@ -209,8 +207,7 @@ static int pickit2_open(PROGRAMMER *pgm, const char *port) {
|
|||
if (usb_open_device(&(PDATA(pgm)->usb_handle), PICKIT2_VID, PICKIT2_PID) < 0)
|
||||
{
|
||||
/* no PICkit2 found */
|
||||
avrdude_message(MSG_INFO, "%s: error: could not find PICkit2 with vid=0x%x pid=0x%x\n",
|
||||
progname, PICKIT2_VID, PICKIT2_PID);
|
||||
pmsg_error("cannot find PICkit2 with vid=0x%x pid=0x%x\n", PICKIT2_VID, PICKIT2_PID);
|
||||
return -1;
|
||||
}
|
||||
#endif
|
||||
|
@ -258,7 +255,7 @@ static int pickit2_initialize(const PROGRAMMER *pgm, const AVRPART *p) {
|
|||
//memset(report, 0, sizeof(report));
|
||||
if ((errorCode = pickit2_read_report(pgm, report)) >= 4)
|
||||
{
|
||||
avrdude_message(MSG_NOTICE, "%s: %s firmware version %d.%d.%d\n", progname, pgm->desc, (int)report[1], (int)report[2], (int)report[3]);
|
||||
pmsg_notice("%s firmware version %d.%d.%d\n", pgm->desc, (int)report[1], (int)report[2], (int)report[3]);
|
||||
|
||||
// set the pins, apply reset,
|
||||
// TO DO: apply vtarget (if requested though -x option)
|
||||
|
@ -293,19 +290,19 @@ static int pickit2_initialize(const PROGRAMMER *pgm, const AVRPART *p) {
|
|||
|
||||
if (pickit2_write_report(pgm, report) < 0)
|
||||
{
|
||||
avrdude_message(MSG_INFO, "pickit2_read_report failed (ec %d). %s\n", errorCode, usb_strerror());
|
||||
pmsg_error("pickit2_read_report failed (ec %d). %s\n", errorCode, usb_strerror());
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
avrdude_message(MSG_INFO, "pickit2_read_report failed (ec %d). %s\n", errorCode, usb_strerror());
|
||||
pmsg_error("pickit2_read_report failed (ec %d). %s\n", errorCode, usb_strerror());
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
avrdude_message(MSG_INFO, "pickit2_write_report failed (ec %d). %s\n", errorCode, usb_strerror());
|
||||
pmsg_error("pickit2_write_report failed (ec %d). %s\n", errorCode, usb_strerror());
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -341,7 +338,7 @@ static void pickit2_enable(PROGRAMMER *pgm, const AVRPART *p) {
|
|||
}
|
||||
|
||||
static void pickit2_display(const PROGRAMMER *pgm, const char *p) {
|
||||
DEBUG( "%s: Found \"%s\" version %d.%d.%d\n", progname, p, 1, 1, 1);
|
||||
DEBUG("%s: found %s version %d.%d.%d\n", progname, p, 1, 1, 1);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -408,8 +405,7 @@ static int pickit2_program_enable(const PROGRAMMER *pgm, const AVRPART *p) {
|
|||
|
||||
if (p->op[AVR_OP_PGM_ENABLE] == NULL)
|
||||
{
|
||||
avrdude_message(MSG_INFO, "program enable instruction not defined for part \"%s\"\n",
|
||||
p->desc);
|
||||
pmsg_error("program enable instruction not defined for part %s\n", p->desc);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -419,13 +415,13 @@ static int pickit2_program_enable(const PROGRAMMER *pgm, const AVRPART *p) {
|
|||
|
||||
{
|
||||
int i;
|
||||
avrdude_message(MSG_DEBUG, "program_enable(): sending command. Resp = ");
|
||||
msg_debug("program_enable(): sending command. Resp = ");
|
||||
|
||||
for (i = 0; i < 4; i++)
|
||||
{
|
||||
avrdude_message(MSG_DEBUG, "%x ", (int)res[i]);
|
||||
msg_debug("%x ", (int)res[i]);
|
||||
}
|
||||
avrdude_message(MSG_DEBUG, "\n");
|
||||
msg_debug("\n");
|
||||
}
|
||||
|
||||
// check for sync character
|
||||
|
@ -441,8 +437,7 @@ static int pickit2_chip_erase(const PROGRAMMER *pgm, const AVRPART *p) {
|
|||
|
||||
if (p->op[AVR_OP_CHIP_ERASE] == NULL)
|
||||
{
|
||||
avrdude_message(MSG_INFO, "chip erase instruction not defined for part \"%s\"\n",
|
||||
p->desc);
|
||||
pmsg_error("chip erase instruction not defined for part %s\n", p->desc);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -515,7 +510,7 @@ static int pickit2_paged_load(const PROGRAMMER *pgm, const AVRPART *p, const AVR
|
|||
}
|
||||
else
|
||||
{
|
||||
avrdude_message(MSG_INFO, "no read command specified\n");
|
||||
pmsg_error("no read command specified\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -527,7 +522,7 @@ static int pickit2_paged_load(const PROGRAMMER *pgm, const AVRPART *p, const AVR
|
|||
|
||||
if (bytes_read < 0)
|
||||
{
|
||||
avrdude_message(MSG_INFO, "Failed @ pgm->spi()\n");
|
||||
pmsg_error("failed @ pgm->spi()\n");
|
||||
pgm->err_led(pgm, ON);
|
||||
return -1;
|
||||
}
|
||||
|
@ -561,8 +556,7 @@ static int pickit2_commit_page(const PROGRAMMER *pgm, const AVRPART *p, const AV
|
|||
wp = mem->op[AVR_OP_WRITEPAGE];
|
||||
if (wp == NULL)
|
||||
{
|
||||
avrdude_message(MSG_INFO, "pickit2_commit_page(): memory \"%s\" not configured for page writes\n",
|
||||
mem->desc);
|
||||
pmsg_error("memory %s not configured for page writes\n", mem->desc);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -609,7 +603,7 @@ static int pickit2_paged_write(const PROGRAMMER *pgm, const AVRPART *p, const A
|
|||
// only paged write for flash implemented
|
||||
if (strcmp(mem->desc, "flash") != 0 && strcmp(mem->desc, "eeprom") != 0)
|
||||
{
|
||||
avrdude_message(MSG_INFO, "Part does not support %d paged write of %s\n", page_size, mem->desc);
|
||||
pmsg_error("part does not support %d paged write of %s\n", page_size, mem->desc);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -666,7 +660,7 @@ static int pickit2_paged_write(const PROGRAMMER *pgm, const AVRPART *p, const A
|
|||
writeop = mem->op[AVR_OP_WRITE_LO];
|
||||
caddr = addr; // maybe this should divide by 2 & use the write_high opcode also
|
||||
|
||||
avrdude_message(MSG_INFO, "Error AVR_OP_WRITE_LO defined only (where's the HIGH command?)\n");
|
||||
pmsg_error("%s AVR_OP_WRITE_LO defined only (where is the HIGH command?)\n", mem->desc);
|
||||
return -1;
|
||||
}
|
||||
else
|
||||
|
@ -691,7 +685,7 @@ static int pickit2_paged_write(const PROGRAMMER *pgm, const AVRPART *p, const A
|
|||
|
||||
if (bytes_read < 0)
|
||||
{
|
||||
avrdude_message(MSG_INFO, "Failed @ pgm->spi()\n");
|
||||
pmsg_error("failed @ pgm->spi()\n");
|
||||
pgm->err_led(pgm, ON);
|
||||
return -1;
|
||||
}
|
||||
|
@ -1129,25 +1123,27 @@ static int usb_open_device(struct usb_dev_handle **device, int vendor, int produ
|
|||
if (handle == NULL)
|
||||
{
|
||||
errorCode = USB_ERROR_ACCESS;
|
||||
avrdude_message(MSG_INFO, "%s: Warning: cannot open USB device: %s\n", progname, usb_strerror());
|
||||
pmsg_warning("cannot open USB device: %s\n", usb_strerror());
|
||||
continue;
|
||||
}
|
||||
|
||||
// return with opened device handle
|
||||
else
|
||||
{
|
||||
avrdude_message(MSG_NOTICE, "Device %p seemed to open OK.\n", handle);
|
||||
msg_notice("device %p seemed to open OK\n", handle);
|
||||
|
||||
if ((errorCode = usb_set_configuration(handle, 1)) < 0)
|
||||
{
|
||||
avrdude_message(MSG_INFO, "Could not set configuration. Error code %d, %s.\n"
|
||||
"You may need to run avrdude as root or set up correct usb port permissions.", errorCode, usb_strerror());
|
||||
pmsg_ext_error("cannot set configuration, error code %d, %s\n"
|
||||
"you may need to run avrdude as root or set up correct usb port permissions",
|
||||
errorCode, usb_strerror());
|
||||
}
|
||||
|
||||
if ((errorCode = usb_claim_interface(handle, 0)) < 0)
|
||||
{
|
||||
avrdude_message(MSG_INFO, "Could not claim interface. Error code %d, %s\n"
|
||||
"You may need to run avrdude as root or set up correct usb port permissions.", errorCode, usb_strerror());
|
||||
pmsg_ext_error("cannot 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());
|
||||
}
|
||||
|
||||
errorCode = 0;
|
||||
|
@ -1186,8 +1182,7 @@ static int pickit2_parseextparams(const PROGRAMMER *pgm, const LISTID extparms)
|
|||
int clock_rate;
|
||||
if (sscanf(extended_param, "clockrate=%i", &clock_rate) != 1 || clock_rate <= 0)
|
||||
{
|
||||
avrdude_message(MSG_INFO, "%s: pickit2_parseextparms(): invalid clockrate '%s'\n",
|
||||
progname, extended_param);
|
||||
pmsg_error("invalid clockrate '%s'\n", extended_param);
|
||||
rv = -1;
|
||||
continue;
|
||||
}
|
||||
|
@ -1195,8 +1190,7 @@ static int pickit2_parseextparams(const PROGRAMMER *pgm, const LISTID extparms)
|
|||
int clock_period = MIN(1000000 / clock_rate, 255); // max period is 255
|
||||
clock_rate = (int)(1000000 / (clock_period + 5e-7)); // assume highest speed is 2MHz - should probably check this
|
||||
|
||||
avrdude_message(MSG_NOTICE2, "%s: pickit2_parseextparms(): clockrate set to 0x%02x\n",
|
||||
progname, clock_rate);
|
||||
pmsg_notice2("pickit2_parseextparms(): clockrate set to 0x%02x\n", clock_rate);
|
||||
PDATA(pgm)->clock_period = clock_period;
|
||||
|
||||
continue;
|
||||
|
@ -1207,21 +1201,18 @@ static int pickit2_parseextparams(const PROGRAMMER *pgm, const LISTID extparms)
|
|||
int timeout;
|
||||
if (sscanf(extended_param, "timeout=%i", &timeout) != 1 || timeout <= 0)
|
||||
{
|
||||
avrdude_message(MSG_INFO, "%s: pickit2_parseextparms(): invalid timeout '%s'\n",
|
||||
progname, extended_param);
|
||||
pmsg_error("invalid timeout '%s'\n", extended_param);
|
||||
rv = -1;
|
||||
continue;
|
||||
}
|
||||
|
||||
avrdude_message(MSG_NOTICE2, "%s: pickit2_parseextparms(): usb timeout set to 0x%02x\n",
|
||||
progname, timeout);
|
||||
pmsg_notice2("pickit2_parseextparms(): usb timeout set to 0x%02x\n", timeout);
|
||||
PDATA(pgm)->transaction_timeout = timeout;
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
avrdude_message(MSG_INFO, "%s: pickit2_parseextparms(): invalid extended parameter '%s'\n",
|
||||
progname, extended_param);
|
||||
pmsg_error("invalid extended parameter '%s'\n", extended_param);
|
||||
rv = -1;
|
||||
}
|
||||
|
||||
|
@ -1285,13 +1276,13 @@ void pickit2_initpgm(PROGRAMMER *pgm) {
|
|||
}
|
||||
#else
|
||||
static int pickit2_nousb_open(PROGRAMMER *pgm, const char *name) {
|
||||
avrdude_message(MSG_INFO,
|
||||
pmsg_error(
|
||||
#ifdef WIN32
|
||||
"%s: error: no usb or hid support. Please compile again with libusb or HID support from Win32 DDK installed.\n",
|
||||
"no usb or hid support; please compile again with libusb or HID support from Win32 DDK installed\n"
|
||||
#else
|
||||
"%s: error: no usb support. Please compile again with libusb installed.\n",
|
||||
"no usb support; please compile again with libusb installed\n"
|
||||
#endif
|
||||
progname);
|
||||
);
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
|
|
@ -64,7 +64,7 @@ static int pin_fill_old_pinno(const struct pindef_t * const pindef, unsigned int
|
|||
for(i = 0; i < PIN_MAX; i++) {
|
||||
if(pindef->mask[i / PIN_FIELD_ELEMENT_SIZE] & (1 << (i % PIN_FIELD_ELEMENT_SIZE))) {
|
||||
if(found) {
|
||||
avrdude_message(MSG_INFO, "Multiple pins found\n"); //TODO
|
||||
pmsg_error("multiple pins found\n"); // TODO
|
||||
return -1;
|
||||
}
|
||||
found = true;
|
||||
|
@ -89,7 +89,7 @@ static int pin_fill_old_pinlist(const struct pindef_t * const pindef, unsigned i
|
|||
for(i = 0; i < PIN_FIELD_SIZE; i++) {
|
||||
if(i == 0) {
|
||||
if((pindef->mask[i] & ~PIN_MASK) != 0) {
|
||||
avrdude_message(MSG_INFO, "Pins of higher index than max field size for old pinno found\n");
|
||||
pmsg_error("pins of higher index than max field size for old pinno found\n");
|
||||
return -1;
|
||||
}
|
||||
if (pindef->mask[i] == 0) {
|
||||
|
@ -101,11 +101,11 @@ static int pin_fill_old_pinlist(const struct pindef_t * const pindef, unsigned i
|
|||
} else if(pindef->mask[i] == ((~pindef->inverse[i]) & pindef->mask[i])) { /* all set bits in mask are cleared in inverse */
|
||||
*pinno = pindef->mask[i];
|
||||
} else {
|
||||
avrdude_message(MSG_INFO, "pins have different polarity set\n");
|
||||
pmsg_error("pins have different polarity set\n");
|
||||
return -1;
|
||||
}
|
||||
} else if(pindef->mask[i] != 0) {
|
||||
avrdude_message(MSG_INFO, "Pins have higher number than fit in old format\n");
|
||||
pmsg_error("pins have higher number than fit in old format\n");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
@ -271,41 +271,39 @@ int pins_check(const PROGRAMMER *const pgm, const struct pin_checklist_t *const
|
|||
}
|
||||
if(invalid) {
|
||||
if(output) {
|
||||
avrdude_message(MSG_INFO, "%s: %s: Following pins are not valid pins for this function: %s\n",
|
||||
progname, avr_pin_name(pinname), pinmask_to_str(invalid_used));
|
||||
avrdude_message(MSG_NOTICE2, "%s: %s: Valid pins for this function are: %s\n",
|
||||
progname, avr_pin_name(pinname), pinmask_to_str(valid_pins->mask));
|
||||
pmsg_error("%s: these pins are not valid pins for this function: %s\n",
|
||||
avr_pin_name(pinname), pinmask_to_str(invalid_used));
|
||||
pmsg_notice("%s: valid pins for this function are: %s\n",
|
||||
avr_pin_name(pinname), pinmask_to_str(valid_pins->mask));
|
||||
}
|
||||
is_ok = false;
|
||||
}
|
||||
if(inverse) {
|
||||
if(output) {
|
||||
avrdude_message(MSG_INFO, "%s: %s: Following pins are not usable as inverse pins for this function: %s\n",
|
||||
progname, avr_pin_name(pinname), pinmask_to_str(inverse_used));
|
||||
avrdude_message(MSG_NOTICE2, "%s: %s: Valid inverse pins for this function are: %s\n",
|
||||
progname, avr_pin_name(pinname), pinmask_to_str(valid_pins->inverse));
|
||||
pmsg_error("%s: these pins are not usable as inverse pins for this function: %s\n",
|
||||
avr_pin_name(pinname), pinmask_to_str(inverse_used));
|
||||
pmsg_notice("%s: valid inverse pins for this function are: %s\n",
|
||||
avr_pin_name(pinname), pinmask_to_str(valid_pins->inverse));
|
||||
}
|
||||
is_ok = false;
|
||||
}
|
||||
if(used) {
|
||||
if(output) {
|
||||
avrdude_message(MSG_INFO, "%s: %s: Following pins are set for other functions too: %s\n",
|
||||
progname, avr_pin_name(pinname), pinmask_to_str(already_used));
|
||||
pmsg_error("%s: these pins are set for other functions too: %s\n",
|
||||
avr_pin_name(pinname), pinmask_to_str(already_used));
|
||||
is_ok = false;
|
||||
}
|
||||
}
|
||||
if(!mandatory_used && is_mandatory && !invalid) {
|
||||
if(output) {
|
||||
avrdude_message(MSG_INFO, "%s: %s: Mandatory pin is not defined.\n",
|
||||
progname, avr_pin_name(pinname));
|
||||
pmsg_error("%s: mandatory pin is not defined\n", avr_pin_name(pinname));
|
||||
}
|
||||
is_ok = false;
|
||||
}
|
||||
if(!is_ok) {
|
||||
rv = -1;
|
||||
} else if(output) {
|
||||
avrdude_message(MSG_DEBUG, "%s: %s: Pin is ok.\n",
|
||||
progname, avr_pin_name(pinname));
|
||||
pmsg_debug("%s: pin is OK\n", avr_pin_name(pinname));
|
||||
}
|
||||
}
|
||||
return rv;
|
||||
|
|
|
@ -68,8 +68,7 @@ static int ppi_shadow_access(const union filedescriptor *fdp, int reg,
|
|||
shadow_num = 2;
|
||||
break;
|
||||
default:
|
||||
avrdude_message(MSG_INFO, "%s: avr_set(): invalid register=%d\n",
|
||||
progname, reg);
|
||||
pmsg_error("invalid register=%d\n", reg);
|
||||
return -1;
|
||||
break;
|
||||
}
|
||||
|
@ -198,8 +197,7 @@ void ppi_open(const char *port, union filedescriptor *fdp) {
|
|||
|
||||
fd = open(port, O_RDWR);
|
||||
if (fd < 0) {
|
||||
avrdude_message(MSG_INFO, "%s: can't open device \"%s\": %s\n",
|
||||
progname, port, strerror(errno));
|
||||
pmsg_ext_error("cannot open port %s: %s\n", port, strerror(errno));
|
||||
fdp->ifd = -1;
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -92,7 +92,7 @@ void ppi_open(const char *port, union filedescriptor *fdp) {
|
|||
|
||||
if(fd < 0)
|
||||
{
|
||||
avrdude_message(MSG_INFO, "%s: can't open device \"giveio\"\n\n", progname);
|
||||
pmsg_ext_error("cannot open device \"giveio\"\n\n"); // giveio?!? FIXME!
|
||||
fdp->ifd = -1;
|
||||
return;
|
||||
}
|
||||
|
@ -120,14 +120,13 @@ void ppi_open(const char *port, union filedescriptor *fdp) {
|
|||
fd = strtol(port, &cp, 0);
|
||||
if(*port == '\0' || *cp != '\0')
|
||||
{
|
||||
avrdude_message(MSG_INFO, "%s: port name \"%s\" is neither lpt1/2/3 nor valid number\n",
|
||||
progname, port);
|
||||
pmsg_error("port %s is neither lpt1/2/3 nor valid number\n", port);
|
||||
fd = -1;
|
||||
}
|
||||
}
|
||||
if(fd < 0)
|
||||
{
|
||||
avrdude_message(MSG_INFO, "%s: can't open device \"%s\"\n\n", progname, port);
|
||||
pmsg_ext_error("cannot open port %s\n\n", port);
|
||||
fdp->ifd = -1;
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -73,8 +73,7 @@ static int usbOpenDevice(union filedescriptor *fdp, int vendor, const char *vend
|
|||
dev = hid_open(vendor, product, NULL);
|
||||
if (dev == NULL)
|
||||
{
|
||||
avrdude_message(MSG_INFO, "%s: usbOpenDevice(): No device found\n",
|
||||
progname);
|
||||
pmsg_ext_error("no device found\n");
|
||||
return USB_ERROR_NOTFOUND;
|
||||
}
|
||||
fdp->usb.handle = dev;
|
||||
|
@ -113,7 +112,7 @@ static int usbSetReport(const union filedescriptor *fdp, int reportType, char *b
|
|||
|
||||
if(bytesSent != len){
|
||||
if(bytesSent < 0)
|
||||
avrdude_message(MSG_INFO, "Error sending message: %s\n", hid_error(udev));
|
||||
pmsg_error("unable to send message: %ls\n", hid_error(udev));
|
||||
return USB_ERROR_IO;
|
||||
}
|
||||
return USB_ERROR_NONE;
|
||||
|
@ -138,7 +137,7 @@ static int usbGetReport(const union filedescriptor *fdp, int reportType, int rep
|
|||
break;
|
||||
}
|
||||
if(bytesReceived < 0){
|
||||
avrdude_message(MSG_INFO, "Error sending message: %s\n", hid_error(udev));
|
||||
pmsg_error("unable to send message: %ls\n", hid_error(udev));
|
||||
return USB_ERROR_IO;
|
||||
}
|
||||
*len = bytesReceived;
|
||||
|
@ -160,42 +159,30 @@ static void dumpBlock(const char *prefix, const unsigned char *buf, int len)
|
|||
int i;
|
||||
|
||||
if(len <= 8){ /* more compact format for short blocks */
|
||||
avrdude_message(MSG_INFO, "%s: %d bytes: ", prefix, len);
|
||||
msg_info("%s: %d bytes: ", prefix, len);
|
||||
for(i = 0; i < len; i++){
|
||||
avrdude_message(MSG_INFO, "%02x ", buf[i]);
|
||||
msg_info("%02x ", buf[i]);
|
||||
}
|
||||
avrdude_message(MSG_INFO, " \"");
|
||||
for(i = 0; i < len; i++){
|
||||
if(buf[i] >= 0x20 && buf[i] < 0x7f){
|
||||
fputc(buf[i], stderr);
|
||||
msg_info(" \"");
|
||||
for(i = 0; i < len; i++)
|
||||
msg_info("%c", buf[i] >= 0x20 && buf[i] < 0x7f? buf[i]: '.');
|
||||
msg_info("\"\n");
|
||||
}else{
|
||||
fputc('.', stderr);
|
||||
}
|
||||
}
|
||||
avrdude_message(MSG_INFO, "\"\n");
|
||||
}else{
|
||||
avrdude_message(MSG_INFO, "%s: %d bytes:\n", prefix, len);
|
||||
msg_info("%s: %d bytes:\n", prefix, len);
|
||||
while(len > 0){
|
||||
for(i = 0; i < 16; i++){
|
||||
if(i < len){
|
||||
avrdude_message(MSG_INFO, "%02x ", buf[i]);
|
||||
msg_info("%02x ", buf[i]);
|
||||
}else{
|
||||
avrdude_message(MSG_INFO, " ");
|
||||
msg_info(" ");
|
||||
}
|
||||
if(i == 7)
|
||||
fputc(' ', stderr);
|
||||
msg_info(" ");
|
||||
}
|
||||
avrdude_message(MSG_INFO, " \"");
|
||||
for(i = 0; i < 16; i++){
|
||||
if(i < len){
|
||||
if(buf[i] >= 0x20 && buf[i] < 0x7f){
|
||||
fputc(buf[i], stderr);
|
||||
}else{
|
||||
fputc('.', stderr);
|
||||
}
|
||||
}
|
||||
}
|
||||
avrdude_message(MSG_INFO, "\"\n");
|
||||
msg_info(" \"");
|
||||
for(i = 0; i < 16 && i < len; i++)
|
||||
msg_info("%c", buf[i] >= 0x20 && buf[i] < 0x7f? buf[i]: '.');
|
||||
msg_info("\"\n");
|
||||
buf += 16;
|
||||
len -= 16;
|
||||
}
|
||||
|
@ -207,13 +194,13 @@ static char *usbErrorText(int usbErrno)
|
|||
static char buffer[32];
|
||||
|
||||
switch(usbErrno){
|
||||
case USB_ERROR_NONE: return "Success.";
|
||||
case USB_ERROR_ACCESS: return "Access denied.";
|
||||
case USB_ERROR_NOTFOUND:return "Device not found.";
|
||||
case USB_ERROR_BUSY: return "Device is busy.";
|
||||
case USB_ERROR_IO: return "I/O Error.";
|
||||
case USB_ERROR_NONE: return "Success";
|
||||
case USB_ERROR_ACCESS: return "Access denied";
|
||||
case USB_ERROR_NOTFOUND:return "Device not found";
|
||||
case USB_ERROR_BUSY: return "Device is busy";
|
||||
case USB_ERROR_IO: return "I/O Error";
|
||||
default:
|
||||
sprintf(buffer, "Unknown error %d.", usbErrno);
|
||||
sprintf(buffer, "Unknown error %d", usbErrno);
|
||||
return buffer;
|
||||
}
|
||||
}
|
||||
|
@ -228,7 +215,7 @@ static int avrdoper_open(const char *port, union pinfo pinfo, union filedescript
|
|||
|
||||
rval = usbOpenDevice(fdp, USB_VENDOR_ID, vname, USB_PRODUCT_ID, devname, 1);
|
||||
if(rval != 0){
|
||||
avrdude_message(MSG_INFO, "%s: avrdoper_open(): %s\n", progname, usbErrorText(rval));
|
||||
pmsg_ext_error("%s\n", usbErrorText(rval));
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
|
@ -266,11 +253,11 @@ static int avrdoper_send(const union filedescriptor *fdp, const unsigned char *b
|
|||
buffer[0] = lenIndex + 1; /* report ID */
|
||||
buffer[1] = thisLen;
|
||||
memcpy(buffer + 2, buf, thisLen);
|
||||
avrdude_message(MSG_TRACE, "Sending %d bytes data chunk\n", thisLen);
|
||||
msg_trace("Sending %d bytes data chunk\n", thisLen);
|
||||
rval = usbSetReport(fdp, USB_HID_REPORT_TYPE_FEATURE, (char *)buffer,
|
||||
reportDataSizes[lenIndex] + 2);
|
||||
if(rval != 0){
|
||||
avrdude_message(MSG_INFO, "%s: avrdoper_send(): %s\n", progname, usbErrorText(rval));
|
||||
pmsg_error("%s\n", usbErrorText(rval));
|
||||
return -1;
|
||||
}
|
||||
buflen -= thisLen;
|
||||
|
@ -295,17 +282,16 @@ static int avrdoperFillBuffer(const union filedescriptor *fdp) {
|
|||
usbErr = usbGetReport(fdp, USB_HID_REPORT_TYPE_FEATURE, lenIndex + 1,
|
||||
(char *)buffer, &len);
|
||||
if(usbErr != 0){
|
||||
avrdude_message(MSG_INFO, "%s: avrdoperFillBuffer(): %s\n", progname, usbErrorText(usbErr));
|
||||
pmsg_error("%s\n", usbErrorText(usbErr));
|
||||
return -1;
|
||||
}
|
||||
avrdude_message(MSG_TRACE, "Received %d bytes data chunk of total %d\n", len - 2, buffer[1]);
|
||||
msg_trace("Received %d bytes data chunk of total %d\n", len - 2, buffer[1]);
|
||||
len -= 2; /* compensate for report ID and length byte */
|
||||
bytesPending = buffer[1] - len; /* amount still buffered */
|
||||
if(len > buffer[1]) /* cut away padding */
|
||||
len = buffer[1];
|
||||
if(avrdoperRxLength + len > sizeof(avrdoperRxBuffer)){
|
||||
avrdude_message(MSG_INFO, "%s: avrdoperFillBuffer(): internal error: buffer overflow\n",
|
||||
progname);
|
||||
pmsg_error("buffer overflow\n");
|
||||
return -1;
|
||||
}
|
||||
memcpy(avrdoperRxBuffer + avrdoperRxLength, buffer + 2, len);
|
||||
|
@ -352,7 +338,7 @@ static int avrdoper_drain(const union filedescriptor *fdp, int display)
|
|||
|
||||
static int avrdoper_set_dtr_rts(const union filedescriptor *fdp, int is_on)
|
||||
{
|
||||
avrdude_message(MSG_INFO, "%s: AVR-Doper doesn't support DTR/RTS setting\n", progname);
|
||||
pmsg_error("AVR-Doper does not support DTR/RTS setting\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
|
|
@ -137,8 +137,7 @@ static speed_t serial_baud_lookup(long baud, bool *nonstandard) {
|
|||
* If a non-standard BAUD rate is used, issue
|
||||
* a warning (if we are verbose) and return the raw rate
|
||||
*/
|
||||
avrdude_message(MSG_NOTICE, "%s: serial_baud_lookup(): Using non-standard baud rate: %ld\n",
|
||||
progname, baud);
|
||||
pmsg_notice("serial_baud_lookup(): using non-standard baud rate: %ld\n", baud);
|
||||
|
||||
*nonstandard = true;
|
||||
|
||||
|
@ -159,9 +158,9 @@ static int ser_setparams(const union filedescriptor *fd, long baud, unsigned lon
|
|||
*/
|
||||
rc = tcgetattr(fd->ifd, &termios);
|
||||
if (rc < 0) {
|
||||
avrdude_message(MSG_INFO, "%s: ser_setparams(): tcgetattr() failed",
|
||||
progname);
|
||||
return -errno;
|
||||
int ret = -errno;
|
||||
pmsg_ext_error("tcgetattr() failed\n");
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -254,18 +253,18 @@ static int ser_setparams(const union filedescriptor *fd, long baud, unsigned lon
|
|||
|
||||
rc = tcsetattr(fd->ifd, TCSANOW, &termios);
|
||||
if (rc < 0) {
|
||||
avrdude_message(MSG_INFO, "%s: ser_setparams(): tcsetattr() failed\n",
|
||||
progname);
|
||||
return -errno;
|
||||
int ret = -errno;
|
||||
pmsg_ext_error("tcsetattr() failed\n");
|
||||
return ret;
|
||||
}
|
||||
|
||||
#ifdef __APPLE__
|
||||
// handle nonstandard speed values the MacOS way
|
||||
if (nonstandard) {
|
||||
if (ioctl(fd->ifd, IOSSIOSPEED, &speed) < 0) {
|
||||
avrdude_message(MSG_INFO, "%s: ser_setparams(): ioctrl(IOSSIOSPEED) failed\n",
|
||||
progname);
|
||||
return -errno;
|
||||
int ret = -errno;
|
||||
pmsg_ext_error("ioctrl(IOSSIOSPEED) failed\n");
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
#endif // __APPLE__
|
||||
|
@ -288,8 +287,7 @@ static int net_open(const char *port, union filedescriptor *fdp) {
|
|||
struct addrinfo *result, *rp;
|
||||
|
||||
if ((hstr = hp = strdup(port)) == NULL) {
|
||||
avrdude_message(MSG_INFO, "%s: net_open(): Out of memory!\n",
|
||||
progname);
|
||||
pmsg_error("out of memory\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -299,8 +297,7 @@ static int net_open(const char *port, union filedescriptor *fdp) {
|
|||
* service name from the host or IP address.
|
||||
*/
|
||||
if (((pstr = strrchr(hstr, ':')) == NULL) || (pstr == hstr)) {
|
||||
avrdude_message(MSG_INFO, "%s: net_open(): Mangled host:port string \"%s\"\n",
|
||||
progname, hstr);
|
||||
pmsg_error("mangled host:port string %s\n", hstr);
|
||||
goto error;
|
||||
}
|
||||
|
||||
|
@ -323,10 +320,8 @@ static int net_open(const char *port, union filedescriptor *fdp) {
|
|||
s = getaddrinfo(hstr, pstr, &hints, &result);
|
||||
|
||||
if (s != 0) {
|
||||
avrdude_message(MSG_INFO,
|
||||
"%s: net_open(): Cannot resolve "
|
||||
"host=\"%s\", port=\"%s\": %s\n",
|
||||
progname, hstr, pstr, gai_strerror(s));
|
||||
pmsg_ext_error("cannot resolve host=\"%s\", port=\"%s\": %s\n",
|
||||
hstr, pstr, gai_strerror(s));
|
||||
goto error;
|
||||
}
|
||||
for (rp = result; rp != NULL; rp = rp->ai_next) {
|
||||
|
@ -342,8 +337,7 @@ static int net_open(const char *port, union filedescriptor *fdp) {
|
|||
close(fd);
|
||||
}
|
||||
if (rp == NULL) {
|
||||
avrdude_message(MSG_INFO, "%s: net_open(): Cannot connect: %s\n",
|
||||
progname, strerror(errno));
|
||||
pmsg_ext_error("cannot connect: %s\n", strerror(errno));
|
||||
}
|
||||
else {
|
||||
fdp->ifd = fd;
|
||||
|
@ -363,7 +357,7 @@ static int ser_set_dtr_rts(const union filedescriptor *fdp, int is_on) {
|
|||
|
||||
r = ioctl(fdp->ifd, TIOCMGET, &ctl);
|
||||
if (r < 0) {
|
||||
perror("ioctl(\"TIOCMGET\")");
|
||||
pmsg_ext_error("ioctl(\"TIOCMGET\"): %s\n", strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -378,7 +372,7 @@ static int ser_set_dtr_rts(const union filedescriptor *fdp, int is_on) {
|
|||
|
||||
r = ioctl(fdp->ifd, TIOCMSET, &ctl);
|
||||
if (r < 0) {
|
||||
perror("ioctl(\"TIOCMSET\")");
|
||||
pmsg_ext_error("ioctl(\"TIOCMSET\"): %s\n", strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -402,8 +396,7 @@ static int ser_open(const char *port, union pinfo pinfo, union filedescriptor *f
|
|||
*/
|
||||
fd = open(port, O_RDWR | O_NOCTTY | O_NONBLOCK);
|
||||
if (fd < 0) {
|
||||
avrdude_message(MSG_INFO, "%s: ser_open(): can't open device \"%s\": %s\n",
|
||||
progname, port, strerror(errno));
|
||||
pmsg_ext_error("cannot open port %s: %s\n", port, strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -414,8 +407,7 @@ static int ser_open(const char *port, union pinfo pinfo, union filedescriptor *f
|
|||
*/
|
||||
rc = ser_setparams(fdp, pinfo.serialinfo.baud, pinfo.serialinfo.cflags);
|
||||
if (rc) {
|
||||
avrdude_message(MSG_INFO, "%s: ser_open(): can't set attributes for device \"%s\": %s\n",
|
||||
progname, port, strerror(-rc));
|
||||
pmsg_ext_error("cannot set attributes for port %s: %s\n", port, strerror(-rc));
|
||||
close(fd);
|
||||
return -1;
|
||||
}
|
||||
|
@ -429,8 +421,7 @@ static void ser_close(union filedescriptor *fd) {
|
|||
if (saved_original_termios) {
|
||||
int rc = tcsetattr(fd->ifd, TCSANOW | TCSADRAIN, &original_termios);
|
||||
if (rc) {
|
||||
avrdude_message(MSG_INFO, "%s: ser_close(): can't reset attributes for device: %s\n",
|
||||
progname, strerror(errno));
|
||||
pmsg_ext_error("cannot reset attributes for device: %s\n", strerror(errno));
|
||||
}
|
||||
saved_original_termios = 0;
|
||||
}
|
||||
|
@ -449,30 +440,29 @@ static int ser_send(const union filedescriptor *fd, const unsigned char * buf, s
|
|||
|
||||
if (verbose > 3)
|
||||
{
|
||||
avrdude_message(MSG_TRACE, "%s: Send: ", progname);
|
||||
pmsg_trace("send: ");
|
||||
|
||||
while (buflen) {
|
||||
unsigned char c = *buf;
|
||||
if (isprint(c)) {
|
||||
avrdude_message(MSG_TRACE, "%c ", c);
|
||||
msg_trace("%c ", c);
|
||||
}
|
||||
else {
|
||||
avrdude_message(MSG_TRACE, ". ");
|
||||
msg_trace(". ");
|
||||
}
|
||||
avrdude_message(MSG_TRACE, "[%02x] ", c);
|
||||
msg_trace("[%02x] ", c);
|
||||
|
||||
buf++;
|
||||
buflen--;
|
||||
}
|
||||
|
||||
avrdude_message(MSG_TRACE, "\n");
|
||||
msg_trace("\n");
|
||||
}
|
||||
|
||||
while (len) {
|
||||
rc = write(fd->ifd, p, (len > 1024) ? 1024 : len);
|
||||
if (rc < 0) {
|
||||
avrdude_message(MSG_INFO, "%s: ser_send(): write error: %s\n",
|
||||
progname, strerror(errno));
|
||||
pmsg_ext_error("unable to write: %s\n", strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
p += rc;
|
||||
|
@ -502,27 +492,23 @@ static int ser_recv(const union filedescriptor *fd, unsigned char * buf, size_t
|
|||
|
||||
nfds = select(fd->ifd + 1, &rfds, NULL, NULL, &to2);
|
||||
if (nfds == 0) {
|
||||
avrdude_message(MSG_NOTICE2, "%s: ser_recv(): programmer is not responding\n",
|
||||
progname);
|
||||
pmsg_notice2("ser_recv(): programmer is not responding\n");
|
||||
return -1;
|
||||
}
|
||||
else if (nfds == -1) {
|
||||
if (errno == EINTR || errno == EAGAIN) {
|
||||
avrdude_message(MSG_INFO, "%s: ser_recv(): programmer is not responding,reselecting\n",
|
||||
progname);
|
||||
pmsg_warning("programmer is not responding, reselecting\n");
|
||||
goto reselect;
|
||||
}
|
||||
else {
|
||||
avrdude_message(MSG_INFO, "%s: ser_recv(): select(): %s\n",
|
||||
progname, strerror(errno));
|
||||
pmsg_ext_error("select(): %s\n", strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
rc = read(fd->ifd, p, (buflen - len > 1024) ? 1024 : buflen - len);
|
||||
if (rc < 0) {
|
||||
avrdude_message(MSG_INFO, "%s: ser_recv(): read error: %s\n",
|
||||
progname, strerror(errno));
|
||||
pmsg_ext_error("unable to read: %s\n", strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
p += rc;
|
||||
|
@ -533,22 +519,22 @@ static int ser_recv(const union filedescriptor *fd, unsigned char * buf, size_t
|
|||
|
||||
if (verbose > 3)
|
||||
{
|
||||
avrdude_message(MSG_TRACE, "%s: Recv: ", progname);
|
||||
pmsg_trace("recv: ");
|
||||
|
||||
while (len) {
|
||||
unsigned char c = *p;
|
||||
if (isprint(c)) {
|
||||
avrdude_message(MSG_TRACE, "%c ", c);
|
||||
msg_trace("%c ", c);
|
||||
}
|
||||
else {
|
||||
avrdude_message(MSG_TRACE, ". ");
|
||||
msg_trace(". ");
|
||||
}
|
||||
avrdude_message(MSG_TRACE, "[%02x] ", c);
|
||||
msg_trace("[%02x] ", c);
|
||||
|
||||
p++;
|
||||
len--;
|
||||
}
|
||||
avrdude_message(MSG_TRACE, "\n");
|
||||
msg_trace("\n");
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -566,7 +552,7 @@ static int ser_drain(const union filedescriptor *fd, int display) {
|
|||
timeout.tv_usec = 250000;
|
||||
|
||||
if (display) {
|
||||
avrdude_message(MSG_INFO, "drain>");
|
||||
msg_info("drain>");
|
||||
}
|
||||
|
||||
while (1) {
|
||||
|
@ -577,7 +563,7 @@ static int ser_drain(const union filedescriptor *fd, int display) {
|
|||
nfds = select(fd->ifd + 1, &rfds, NULL, NULL, &timeout);
|
||||
if (nfds == 0) {
|
||||
if (display) {
|
||||
avrdude_message(MSG_INFO, "<drain\n");
|
||||
msg_info("<drain\n");
|
||||
}
|
||||
|
||||
break;
|
||||
|
@ -587,20 +573,18 @@ static int ser_drain(const union filedescriptor *fd, int display) {
|
|||
goto reselect;
|
||||
}
|
||||
else {
|
||||
avrdude_message(MSG_INFO, "%s: ser_drain(): select(): %s\n",
|
||||
progname, strerror(errno));
|
||||
pmsg_ext_error("select(): %s\n", strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
rc = read(fd->ifd, &buf, 1);
|
||||
if (rc < 0) {
|
||||
avrdude_message(MSG_INFO, "%s: ser_drain(): read error: %s\n",
|
||||
progname, strerror(errno));
|
||||
pmsg_ext_error("unable to read: %s\n", strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
if (display) {
|
||||
avrdude_message(MSG_INFO, "%02x ", buf);
|
||||
msg_info("%02x ", buf);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
132
src/ser_win32.c
132
src/ser_win32.c
|
@ -77,8 +77,7 @@ static DWORD serial_baud_lookup(long baud)
|
|||
* If a non-standard BAUD rate is used, issue
|
||||
* a warning (if we are verbose) and return the raw rate
|
||||
*/
|
||||
avrdude_message(MSG_NOTICE, "%s: serial_baud_lookup(): Using non-standard baud rate: %ld",
|
||||
progname, baud);
|
||||
pmsg_notice("serial_baud_lookup(): using non-standard baud rate: %ld", baud);
|
||||
|
||||
return baud;
|
||||
}
|
||||
|
@ -160,17 +159,17 @@ static int net_open(const char *port, union filedescriptor *fdp) {
|
|||
struct hostent *hp;
|
||||
|
||||
if (WSAStartup(MAKEWORD(2, 0), &wsaData) != 0) {
|
||||
avrdude_message(MSG_INFO, "%s: net_open(): WSAStartup() failed\n", progname);
|
||||
pmsg_error("WSAStartup() failed\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if ((hstr = strdup(port)) == NULL) {
|
||||
avrdude_message(MSG_INFO, "%s: net_open(): Out of memory!\n", progname);
|
||||
pmsg_error("out of memory\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (((pstr = strchr(hstr, ':')) == NULL) || (pstr == hstr)) {
|
||||
avrdude_message(MSG_INFO, "%s: net_open(): Mangled host:port string \"%s\"\n", progname, hstr);
|
||||
pmsg_error("mangled host:port string %s\n", hstr);
|
||||
free(hstr);
|
||||
return -1;
|
||||
}
|
||||
|
@ -183,13 +182,13 @@ static int net_open(const char *port, union filedescriptor *fdp) {
|
|||
pnum = strtoul(pstr, &end, 10);
|
||||
|
||||
if ((*pstr == '\0') || (*end != '\0') || (pnum == 0) || (pnum > 65535)) {
|
||||
avrdude_message(MSG_INFO, "%s: net_open(): Bad port number \"%s\"\n", progname, pstr);
|
||||
pmsg_error("bad port number %s\n", pstr);
|
||||
free(hstr);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if ((hp = gethostbyname(hstr)) == NULL) {
|
||||
avrdude_message(MSG_INFO, "%s: net_open(): unknown host \"%s\"\n", progname, hstr);
|
||||
pmsg_error("unknown host %s\n", hstr);
|
||||
free(hstr);
|
||||
return -1;
|
||||
}
|
||||
|
@ -207,7 +206,7 @@ static int net_open(const char *port, union filedescriptor *fdp) {
|
|||
(LPTSTR)&lpMsgBuf,
|
||||
0,
|
||||
NULL);
|
||||
avrdude_message(MSG_INFO, "%s: net_open(): Cannot open socket: %s\n", progname, (char *)lpMsgBuf);
|
||||
pmsg_error("cannot open socket: %s\n", (char *) lpMsgBuf);
|
||||
LocalFree(lpMsgBuf);
|
||||
return -1;
|
||||
}
|
||||
|
@ -228,7 +227,7 @@ static int net_open(const char *port, union filedescriptor *fdp) {
|
|||
(LPTSTR)&lpMsgBuf,
|
||||
0,
|
||||
NULL);
|
||||
avrdude_message(MSG_INFO, "%s: net_open(): Connect failed: %s\n", progname, (char *)lpMsgBuf);
|
||||
pmsg_error("connect failed: %s\n", (char *) lpMsgBuf);
|
||||
LocalFree(lpMsgBuf);
|
||||
return -1;
|
||||
}
|
||||
|
@ -259,8 +258,7 @@ static int ser_open(const char *port, union pinfo pinfo, union filedescriptor *f
|
|||
newname = malloc(strlen("\\\\.\\") + strlen(port) + 1);
|
||||
|
||||
if (newname == 0) {
|
||||
avrdude_message(MSG_INFO, "%s: ser_open(): out of memory\n",
|
||||
progname);
|
||||
pmsg_error("out of memory\n");
|
||||
exit(1);
|
||||
}
|
||||
strcpy(newname, "\\\\.\\");
|
||||
|
@ -283,8 +281,7 @@ static int ser_open(const char *port, union pinfo pinfo, union filedescriptor *f
|
|||
(LPTSTR) &lpMsgBuf,
|
||||
0,
|
||||
NULL);
|
||||
avrdude_message(MSG_INFO, "%s: ser_open(): can't open device \"%s\": %s\n",
|
||||
progname, port, (char*)lpMsgBuf);
|
||||
pmsg_error("cannot open port %s: %s\n", port, (char*) lpMsgBuf);
|
||||
LocalFree( lpMsgBuf );
|
||||
return -1;
|
||||
}
|
||||
|
@ -292,8 +289,7 @@ static int ser_open(const char *port, union pinfo pinfo, union filedescriptor *f
|
|||
if (!SetupComm(hComPort, W32SERBUFSIZE, W32SERBUFSIZE))
|
||||
{
|
||||
CloseHandle(hComPort);
|
||||
avrdude_message(MSG_INFO, "%s: ser_open(): can't set buffers for \"%s\"\n",
|
||||
progname, port);
|
||||
pmsg_error("cannot set buffers for %s\n", port);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -301,16 +297,14 @@ static int ser_open(const char *port, union pinfo pinfo, union filedescriptor *f
|
|||
if (ser_setparams(fdp, pinfo.serialinfo.baud, pinfo.serialinfo.cflags) != 0)
|
||||
{
|
||||
CloseHandle(hComPort);
|
||||
avrdude_message(MSG_INFO, "%s: ser_open(): can't set com-state for \"%s\"\n",
|
||||
progname, port);
|
||||
pmsg_error("cannot set com-state for %s\n", port);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!serial_w32SetTimeOut(hComPort,0))
|
||||
{
|
||||
CloseHandle(hComPort);
|
||||
avrdude_message(MSG_INFO, "%s: ser_open(): can't set initial timeout for \"%s\"\n",
|
||||
progname, port);
|
||||
pmsg_error("cannot set initial timeout for %s\n", port);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -358,7 +352,7 @@ static int net_send(const union filedescriptor *fd, const unsigned char * buf, s
|
|||
size_t len = buflen;
|
||||
|
||||
if (fd->ifd < 0) {
|
||||
avrdude_message(MSG_NOTICE, "%s: net_send(): connection not open\n", progname);
|
||||
pmsg_notice("net_send(): connection not open\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
@ -367,22 +361,22 @@ static int net_send(const union filedescriptor *fd, const unsigned char * buf, s
|
|||
}
|
||||
|
||||
if (verbose > 3) {
|
||||
avrdude_message(MSG_TRACE, "%s: Send: ", progname);
|
||||
pmsg_trace("send: ");
|
||||
|
||||
while (buflen) {
|
||||
unsigned char c = *buf;
|
||||
if (isprint(c)) {
|
||||
avrdude_message(MSG_TRACE, "%c ", c);
|
||||
msg_trace("%c ", c);
|
||||
} else {
|
||||
avrdude_message(MSG_TRACE, ". ");
|
||||
msg_trace(". ");
|
||||
}
|
||||
avrdude_message(MSG_TRACE, "[%02x] ", c);
|
||||
msg_trace("[%02x] ", c);
|
||||
|
||||
buf++;
|
||||
buflen--;
|
||||
}
|
||||
|
||||
avrdude_message(MSG_TRACE, "\n");
|
||||
msg_trace("\n");
|
||||
}
|
||||
|
||||
while (len) {
|
||||
|
@ -398,7 +392,7 @@ static int net_send(const union filedescriptor *fd, const unsigned char * buf, s
|
|||
(LPTSTR)&lpMsgBuf,
|
||||
0,
|
||||
NULL);
|
||||
avrdude_message(MSG_INFO, "%s: net_send(): send error: %s\n", progname, (char *)lpMsgBuf);
|
||||
pmsg_error("unable to send: %s\n", (char *) lpMsgBuf);
|
||||
LocalFree(lpMsgBuf);
|
||||
exit(1);
|
||||
}
|
||||
|
@ -423,8 +417,7 @@ static int ser_send(const union filedescriptor *fd, const unsigned char * buf, s
|
|||
HANDLE hComPort=(HANDLE)fd->pfd;
|
||||
|
||||
if (hComPort == INVALID_HANDLE_VALUE) {
|
||||
avrdude_message(MSG_INFO, "%s: ser_send(): port not open\n",
|
||||
progname);
|
||||
pmsg_error("port not open\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -433,34 +426,32 @@ static int ser_send(const union filedescriptor *fd, const unsigned char * buf, s
|
|||
|
||||
if (verbose > 3)
|
||||
{
|
||||
avrdude_message(MSG_TRACE, "%s: Send: ", progname);
|
||||
pmsg_trace("send: ");
|
||||
|
||||
while (len) {
|
||||
c = *b;
|
||||
if (isprint(c)) {
|
||||
avrdude_message(MSG_TRACE, "%c ", c);
|
||||
msg_trace("%c ", c);
|
||||
}
|
||||
else {
|
||||
avrdude_message(MSG_TRACE, ". ");
|
||||
msg_trace(". ");
|
||||
}
|
||||
avrdude_message(MSG_TRACE, "[%02x] ", c);
|
||||
msg_trace("[%02x] ", c);
|
||||
b++;
|
||||
len--;
|
||||
}
|
||||
avrdude_message(MSG_INFO, "\n");
|
||||
msg_trace("\n");
|
||||
}
|
||||
|
||||
serial_w32SetTimeOut(hComPort,500);
|
||||
|
||||
if (!WriteFile (hComPort, buf, buflen, &written, NULL)) {
|
||||
avrdude_message(MSG_INFO, "%s: ser_send(): write error: %s\n",
|
||||
progname, "sorry no info avail"); // TODO
|
||||
pmsg_error("unable to write: %s\n", "sorry no info avail"); // TODO
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (written != buflen) {
|
||||
avrdude_message(MSG_INFO, "%s: ser_send(): size/send mismatch\n",
|
||||
progname);
|
||||
pmsg_error("size/send mismatch\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -478,7 +469,7 @@ static int net_recv(const union filedescriptor *fd, unsigned char * buf, size_t
|
|||
size_t len = 0;
|
||||
|
||||
if (fd->ifd < 0) {
|
||||
avrdude_message(MSG_INFO, "%s: net_recv(): connection not open\n", progname);
|
||||
pmsg_error("connection not open\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
@ -494,12 +485,12 @@ reselect:
|
|||
nfds = select(fd->ifd + 1, &rfds, NULL, NULL, &to2);
|
||||
if (nfds == 0) {
|
||||
if (verbose > 1) {
|
||||
avrdude_message(MSG_NOTICE, "%s: ser_recv(): programmer is not responding\n", progname);
|
||||
pmsg_notice("ser_recv(): programmer is not responding\n");
|
||||
}
|
||||
return -1;
|
||||
} else if (nfds == -1) {
|
||||
if (WSAGetLastError() == WSAEINTR || WSAGetLastError() == WSAEINPROGRESS) {
|
||||
avrdude_message(MSG_NOTICE, "%s: ser_recv(): programmer is not responding, reselecting\n", progname);
|
||||
pmsg_notice("ser_recv(): programmer is not responding, reselecting\n");
|
||||
goto reselect;
|
||||
} else {
|
||||
FormatMessage(
|
||||
|
@ -512,7 +503,7 @@ reselect:
|
|||
(LPTSTR)&lpMsgBuf,
|
||||
0,
|
||||
NULL);
|
||||
avrdude_message(MSG_INFO, "%s: ser_recv(): select(): %s\n", progname, (char *)lpMsgBuf);
|
||||
pmsg_error("select(): %s\n", (char *) lpMsgBuf);
|
||||
LocalFree(lpMsgBuf);
|
||||
exit(1);
|
||||
}
|
||||
|
@ -530,7 +521,7 @@ reselect:
|
|||
(LPTSTR)&lpMsgBuf,
|
||||
0,
|
||||
NULL);
|
||||
avrdude_message(MSG_INFO, "%s: ser_recv(): read error: %s\n", progname, (char *)lpMsgBuf);
|
||||
pmsg_error("unable to read: %s\n", (char *) lpMsgBuf);
|
||||
LocalFree(lpMsgBuf);
|
||||
exit(1);
|
||||
}
|
||||
|
@ -541,21 +532,21 @@ reselect:
|
|||
p = buf;
|
||||
|
||||
if (verbose > 3) {
|
||||
avrdude_message(MSG_TRACE, "%s: Recv: ", progname);
|
||||
pmsg_trace("Recv: ");
|
||||
|
||||
while (len) {
|
||||
unsigned char c = *p;
|
||||
if (isprint(c)) {
|
||||
avrdude_message(MSG_TRACE, "%c ", c);
|
||||
msg_trace("%c ", c);
|
||||
} else {
|
||||
avrdude_message(MSG_TRACE, ". ");
|
||||
msg_trace(". ");
|
||||
}
|
||||
avrdude_message(MSG_TRACE, "[%02x] ", c);
|
||||
msg_trace("[%02x] ", c);
|
||||
|
||||
p++;
|
||||
len--;
|
||||
}
|
||||
avrdude_message(MSG_TRACE, "\n");
|
||||
msg_trace("\n");
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -573,8 +564,7 @@ static int ser_recv(const union filedescriptor *fd, unsigned char * buf, size_t
|
|||
HANDLE hComPort=(HANDLE)fd->pfd;
|
||||
|
||||
if (hComPort == INVALID_HANDLE_VALUE) {
|
||||
avrdude_message(MSG_INFO, "%s: ser_read(): port not open\n",
|
||||
progname);
|
||||
pmsg_error("port not open\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -592,16 +582,14 @@ static int ser_recv(const union filedescriptor *fd, unsigned char * buf, size_t
|
|||
(LPTSTR) &lpMsgBuf,
|
||||
0,
|
||||
NULL );
|
||||
avrdude_message(MSG_INFO, "%s: ser_recv(): read error: %s\n",
|
||||
progname, (char*)lpMsgBuf);
|
||||
pmsg_error("unable to read: %s\n", (char*) lpMsgBuf);
|
||||
LocalFree( lpMsgBuf );
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* time out detected */
|
||||
if (read == 0) {
|
||||
avrdude_message(MSG_NOTICE2, "%s: ser_recv(): programmer is not responding\n",
|
||||
progname);
|
||||
pmsg_notice2("ser_recv(): programmer is not responding\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -609,22 +597,22 @@ static int ser_recv(const union filedescriptor *fd, unsigned char * buf, size_t
|
|||
|
||||
if (verbose > 3)
|
||||
{
|
||||
avrdude_message(MSG_TRACE, "%s: Recv: ", progname);
|
||||
pmsg_trace("recv: ");
|
||||
|
||||
while (read) {
|
||||
c = *p;
|
||||
if (isprint(c)) {
|
||||
avrdude_message(MSG_TRACE, "%c ", c);
|
||||
msg_trace("%c ", c);
|
||||
}
|
||||
else {
|
||||
avrdude_message(MSG_TRACE, ". ");
|
||||
msg_trace(". ");
|
||||
}
|
||||
avrdude_message(MSG_TRACE, "[%02x] ", c);
|
||||
msg_trace("[%02x] ", c);
|
||||
|
||||
p++;
|
||||
read--;
|
||||
}
|
||||
avrdude_message(MSG_INFO, "\n");
|
||||
msg_trace("\n");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -638,12 +626,12 @@ static int net_drain(const union filedescriptor *fd, int display) {
|
|||
int rc;
|
||||
|
||||
if (fd->ifd < 0) {
|
||||
avrdude_message(MSG_INFO, "%s: ser_drain(): connection not open\n", progname);
|
||||
pmsg_error("connection not open\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (display) {
|
||||
avrdude_message(MSG_INFO, "drain>");
|
||||
msg_info("drain>");
|
||||
}
|
||||
|
||||
timeout.tv_sec = 0;
|
||||
|
@ -657,13 +645,13 @@ static int net_drain(const union filedescriptor *fd, int display) {
|
|||
nfds = select(fd->ifd + 1, &rfds, NULL, NULL, &timeout);
|
||||
if (nfds == 0) {
|
||||
if (display) {
|
||||
avrdude_message(MSG_INFO, "<drain\n");
|
||||
msg_info("<drain\n");
|
||||
}
|
||||
break;
|
||||
}
|
||||
else if (nfds == -1) {
|
||||
if (WSAGetLastError() == WSAEINTR || WSAGetLastError() == WSAEINPROGRESS) {
|
||||
avrdude_message(MSG_NOTICE, "%s: ser_drain(): programmer is not responding, reselecting\n", progname);
|
||||
pmsg_notice("ser_drain(): programmer is not responding, reselecting\n");
|
||||
goto reselect;
|
||||
} else {
|
||||
FormatMessage(
|
||||
|
@ -676,7 +664,7 @@ static int net_drain(const union filedescriptor *fd, int display) {
|
|||
(LPTSTR)&lpMsgBuf,
|
||||
0,
|
||||
NULL);
|
||||
avrdude_message(MSG_INFO, "%s: ser_drain(): select(): %s\n", progname, (char *)lpMsgBuf);
|
||||
pmsg_error("select(): %s\n", (char *) lpMsgBuf);
|
||||
LocalFree(lpMsgBuf);
|
||||
exit(1);
|
||||
}
|
||||
|
@ -694,13 +682,13 @@ static int net_drain(const union filedescriptor *fd, int display) {
|
|||
(LPTSTR)&lpMsgBuf,
|
||||
0,
|
||||
NULL);
|
||||
avrdude_message(MSG_INFO, "%s: ser_drain(): read error: %s\n", progname, (char *)lpMsgBuf);
|
||||
pmsg_error("unable to read: %s\n", (char *) lpMsgBuf);
|
||||
LocalFree(lpMsgBuf);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (display) {
|
||||
avrdude_message(MSG_INFO, "%02x ", buf);
|
||||
msg_info("%02x ", buf);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -720,15 +708,14 @@ static int ser_drain(const union filedescriptor *fd, int display) {
|
|||
HANDLE hComPort=(HANDLE)fd->pfd;
|
||||
|
||||
if (hComPort == INVALID_HANDLE_VALUE) {
|
||||
avrdude_message(MSG_INFO, "%s: ser_drain(): port not open\n",
|
||||
progname);
|
||||
pmsg_error("port not open\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
serial_w32SetTimeOut(hComPort,250);
|
||||
|
||||
if (display) {
|
||||
avrdude_message(MSG_INFO, "drain>");
|
||||
msg_info("drain>");
|
||||
}
|
||||
|
||||
while (1) {
|
||||
|
@ -745,17 +732,18 @@ static int ser_drain(const union filedescriptor *fd, int display) {
|
|||
(LPTSTR) &lpMsgBuf,
|
||||
0,
|
||||
NULL );
|
||||
avrdude_message(MSG_INFO, "%s: ser_drain(): read error: %s\n",
|
||||
progname, (char*)lpMsgBuf);
|
||||
pmsg_error("unable to read: %s\n", (char*) lpMsgBuf);
|
||||
LocalFree( lpMsgBuf );
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (read) { // data avail
|
||||
if (display) avrdude_message(MSG_INFO, "%02x ", buf[0]);
|
||||
if (display)
|
||||
msg_info("%02x ", buf[0]);
|
||||
}
|
||||
else { // no more data
|
||||
if (display) avrdude_message(MSG_INFO, "<drain\n");
|
||||
if (display)
|
||||
msg_info("<drain\n");
|
||||
break;
|
||||
}
|
||||
} // while
|
||||
|
|
|
@ -85,7 +85,7 @@ static int serbb_setpin(const PROGRAMMER *pgm, int pinfunc, int value) {
|
|||
return -1;
|
||||
|
||||
#ifdef DEBUG
|
||||
printf("%s to %d\n",serpins[pin],value);
|
||||
msg_info("%s to %d\n", serpins[pin], value);
|
||||
#endif
|
||||
|
||||
switch ( pin )
|
||||
|
@ -93,7 +93,7 @@ static int serbb_setpin(const PROGRAMMER *pgm, int pinfunc, int value) {
|
|||
case 3: /* txd */
|
||||
r = ioctl(pgm->fd.ifd, value ? TIOCSBRK : TIOCCBRK, 0);
|
||||
if (r < 0) {
|
||||
perror("ioctl(\"TIOCxBRK\")");
|
||||
pmsg_ext_error("ioctl(\"TIOCxBRK\"): %s\n", strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
break;
|
||||
|
@ -102,7 +102,7 @@ static int serbb_setpin(const PROGRAMMER *pgm, int pinfunc, int value) {
|
|||
case 7: /* rts */
|
||||
r = ioctl(pgm->fd.ifd, TIOCMGET, &ctl);
|
||||
if (r < 0) {
|
||||
perror("ioctl(\"TIOCMGET\")");
|
||||
pmsg_ext_error("ioctl(\"TIOCMGET\"): %s\n", strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
if (value)
|
||||
|
@ -111,7 +111,7 @@ static int serbb_setpin(const PROGRAMMER *pgm, int pinfunc, int value) {
|
|||
ctl &= ~(serregbits[pin]);
|
||||
r = ioctl(pgm->fd.ifd, TIOCMSET, &ctl);
|
||||
if (r < 0) {
|
||||
perror("ioctl(\"TIOCMSET\")");
|
||||
pmsg_ext_error("ioctl(\"TIOCMSET\"): %s\n", strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
break;
|
||||
|
@ -153,22 +153,22 @@ static int serbb_getpin(const PROGRAMMER *pgm, int pinfunc) {
|
|||
case 9: /* ri */
|
||||
r = ioctl(pgm->fd.ifd, TIOCMGET, &ctl);
|
||||
if (r < 0) {
|
||||
perror("ioctl(\"TIOCMGET\")");
|
||||
pmsg_ext_error("ioctl(\"TIOCMGET\"): %s\n", strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
if ( !invert )
|
||||
{
|
||||
#ifdef DEBUG
|
||||
printf("%s is %d\n",serpins[pin],(ctl & serregbits[pin]) ? 1 : 0 );
|
||||
msg_info("%s is %d\n", serpins[pin], ctl & serregbits[pin]? 1: 0);
|
||||
#endif
|
||||
return ( (ctl & serregbits[pin]) ? 1 : 0 );
|
||||
return ctl & serregbits[pin]? 1: 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifdef DEBUG
|
||||
printf("%s is %d (~)\n",serpins[pin],(ctl & serregbits[pin]) ? 0 : 1 );
|
||||
msg_info("%s is %d (~)\n", serpins[pin], ctl & serregbits[pin]? 0: 1);
|
||||
#endif
|
||||
return (( ctl & serregbits[pin]) ? 0 : 1 );
|
||||
return ctl & serregbits[pin]? 0: 1;
|
||||
}
|
||||
|
||||
default: /* impossible */
|
||||
|
@ -223,14 +223,13 @@ static int serbb_open(PROGRAMMER *pgm, const char *port) {
|
|||
pgm->fd.ifd = open(port, O_RDWR | O_NOCTTY | O_NONBLOCK);
|
||||
|
||||
if (pgm->fd.ifd < 0) {
|
||||
perror(port);
|
||||
pmsg_ext_error("%s: %s\n", port, strerror(errno));
|
||||
return(-1);
|
||||
}
|
||||
|
||||
r = tcgetattr(pgm->fd.ifd, &mode);
|
||||
if (r < 0) {
|
||||
avrdude_message(MSG_INFO, "%s: ", port);
|
||||
perror("tcgetattr");
|
||||
pmsg_ext_error("%s, tcgetattr(): %s\n", port, strerror(errno));
|
||||
return(-1);
|
||||
}
|
||||
oldmode = mode;
|
||||
|
@ -243,8 +242,7 @@ static int serbb_open(PROGRAMMER *pgm, const char *port) {
|
|||
|
||||
r = tcsetattr(pgm->fd.ifd, TCSANOW, &mode);
|
||||
if (r < 0) {
|
||||
avrdude_message(MSG_INFO, "%s: ", port);
|
||||
perror("tcsetattr");
|
||||
pmsg_ext_error("%s, tcsetattr(): %s", port, strerror(errno));
|
||||
return(-1);
|
||||
}
|
||||
|
||||
|
@ -252,15 +250,13 @@ static int serbb_open(PROGRAMMER *pgm, const char *port) {
|
|||
flags = fcntl(pgm->fd.ifd, F_GETFL, 0);
|
||||
if (flags == -1)
|
||||
{
|
||||
avrdude_message(MSG_INFO, "%s: Can not get flags: %s\n",
|
||||
progname, strerror(errno));
|
||||
pmsg_ext_error("cannot get flags: %s\n", strerror(errno));
|
||||
return(-1);
|
||||
}
|
||||
flags &= ~O_NONBLOCK;
|
||||
if (fcntl(pgm->fd.ifd, F_SETFL, flags) == -1)
|
||||
{
|
||||
avrdude_message(MSG_INFO, "%s: Can not clear nonblock flag: %s\n",
|
||||
progname, strerror(errno));
|
||||
pmsg_ext_error("cannot clear nonblock flag: %s\n", strerror(errno));
|
||||
return(-1);
|
||||
}
|
||||
|
||||
|
|
|
@ -97,12 +97,10 @@ static int serbb_setpin(const PROGRAMMER *pgm, int pinfunc, int value) {
|
|||
break;
|
||||
|
||||
default:
|
||||
avrdude_message(MSG_NOTICE, "%s: serbb_setpin(): unknown pin %d\n",
|
||||
progname, pin + 1);
|
||||
pmsg_notice("serbb_setpin(): unknown pin %d\n", pin + 1);
|
||||
return -1;
|
||||
}
|
||||
avrdude_message(MSG_TRACE2, "%s: serbb_setpin(): EscapeCommFunction(%s)\n",
|
||||
progname, name);
|
||||
pmsg_trace2("serbb_setpin(): EscapeCommFunction(%s)\n", name);
|
||||
if (!EscapeCommFunction(hComPort, dwFunc))
|
||||
{
|
||||
FormatMessage(
|
||||
|
@ -115,8 +113,7 @@ static int serbb_setpin(const PROGRAMMER *pgm, int pinfunc, int value) {
|
|||
(LPTSTR) &lpMsgBuf,
|
||||
0,
|
||||
NULL);
|
||||
avrdude_message(MSG_INFO, "%s: serbb_setpin(): SetCommState() failed: %s\n",
|
||||
progname, (char *)lpMsgBuf);
|
||||
pmsg_error("SetCommState() failed: %s\n", (char *) lpMsgBuf);
|
||||
CloseHandle(hComPort);
|
||||
LocalFree(lpMsgBuf);
|
||||
return -1;
|
||||
|
@ -160,14 +157,12 @@ static int serbb_getpin(const PROGRAMMER *pgm, int pinfunc) {
|
|||
(LPTSTR) &lpMsgBuf,
|
||||
0,
|
||||
NULL);
|
||||
avrdude_message(MSG_INFO, "%s: serbb_setpin(): GetCommModemStatus() failed: %s\n",
|
||||
progname, (char *)lpMsgBuf);
|
||||
pmsg_error("GetCommModemStatus() failed: %s\n", (char *) lpMsgBuf);
|
||||
CloseHandle(hComPort);
|
||||
LocalFree(lpMsgBuf);
|
||||
return -1;
|
||||
}
|
||||
avrdude_message(MSG_TRACE2, "%s: serbb_getpin(): GetCommState() => 0x%lx\n",
|
||||
progname, modemstate);
|
||||
pmsg_trace2("serbb_getpin(): GetCommState() => 0x%lx\n", modemstate);
|
||||
switch (pin)
|
||||
{
|
||||
case 1:
|
||||
|
@ -202,12 +197,10 @@ static int serbb_getpin(const PROGRAMMER *pgm, int pinfunc) {
|
|||
name = "RTS";
|
||||
break;
|
||||
default:
|
||||
avrdude_message(MSG_NOTICE, "%s: serbb_getpin(): unknown pin %d\n",
|
||||
progname, pin + 1);
|
||||
pmsg_notice("serbb_getpin(): unknown pin %d\n", pin + 1);
|
||||
return -1;
|
||||
}
|
||||
avrdude_message(MSG_TRACE2, "%s: serbb_getpin(): return cached state for %s\n",
|
||||
progname, name);
|
||||
pmsg_trace2("serbb_getpin(): return cached state for %s\n", name);
|
||||
if (invert)
|
||||
rv = !rv;
|
||||
|
||||
|
@ -268,8 +261,7 @@ static int serbb_open(PROGRAMMER *pgm, const char *port) {
|
|||
(LPTSTR) &lpMsgBuf,
|
||||
0,
|
||||
NULL);
|
||||
avrdude_message(MSG_INFO, "%s: ser_open(): can't open device \"%s\": %s\n",
|
||||
progname, port, (char*)lpMsgBuf);
|
||||
pmsg_error("cannot open port %s: %s\n", port, (char*) lpMsgBuf);
|
||||
LocalFree(lpMsgBuf);
|
||||
return -1;
|
||||
}
|
||||
|
@ -277,8 +269,7 @@ static int serbb_open(PROGRAMMER *pgm, const char *port) {
|
|||
if (!SetupComm(hComPort, W32SERBUFSIZE, W32SERBUFSIZE))
|
||||
{
|
||||
CloseHandle(hComPort);
|
||||
avrdude_message(MSG_INFO, "%s: ser_open(): can't set buffers for \"%s\"\n",
|
||||
progname, port);
|
||||
pmsg_error("cannot set buffers for %s\n", port);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -296,12 +287,10 @@ static int serbb_open(PROGRAMMER *pgm, const char *port) {
|
|||
if (!SetCommState(hComPort, &dcb))
|
||||
{
|
||||
CloseHandle(hComPort);
|
||||
avrdude_message(MSG_INFO, "%s: ser_open(): can't set com-state for \"%s\"\n",
|
||||
progname, port);
|
||||
pmsg_error("cannot set com-state for %s\n", port);
|
||||
return -1;
|
||||
}
|
||||
avrdude_message(MSG_DEBUG, "%s: ser_open(): opened comm port \"%s\", handle 0x%zx\n",
|
||||
progname, port, (INT_PTR)hComPort);
|
||||
pmsg_debug("ser_open(): opened comm port %s, handle 0x%zx\n", port, (INT_PTR) hComPort);
|
||||
|
||||
pgm->fd.pfd = (void *)hComPort;
|
||||
|
||||
|
@ -317,8 +306,7 @@ static void serbb_close(PROGRAMMER *pgm) {
|
|||
pgm->setpin(pgm, PIN_AVR_RESET, 1);
|
||||
CloseHandle (hComPort);
|
||||
}
|
||||
avrdude_message(MSG_DEBUG, "%s: ser_close(): closed comm port handle 0x%zx\n",
|
||||
progname, (INT_PTR)hComPort);
|
||||
pmsg_debug("ser_close(): closed comm port handle 0x%zx\n", (INT_PTR) hComPort);
|
||||
|
||||
hComPort = INVALID_HANDLE_VALUE;
|
||||
}
|
||||
|
|
186
src/serialupdi.c
186
src/serialupdi.c
|
@ -49,9 +49,7 @@ static int serialupdi_leave_progmode(const PROGRAMMER *pgm);
|
|||
static void serialupdi_setup(PROGRAMMER * pgm)
|
||||
{
|
||||
if ((pgm->cookie = malloc(sizeof(updi_state))) == 0) {
|
||||
avrdude_message(MSG_INFO,
|
||||
"%s: serialupdi_setup(): Out of memory allocating private data\n",
|
||||
progname);
|
||||
pmsg_error("out of memory allocating private data\n");
|
||||
exit(1);
|
||||
}
|
||||
memset(pgm->cookie, 0, sizeof(updi_state));
|
||||
|
@ -91,10 +89,10 @@ static int serialupdi_reset(const PROGRAMMER *pgm, reset_mode mode) {
|
|||
*/
|
||||
switch (mode) {
|
||||
case APPLY_RESET:
|
||||
avrdude_message(MSG_DEBUG, "%s: Sending reset request\n", progname);
|
||||
pmsg_debug("sending reset request\n");
|
||||
return updi_write_cs(pgm, UPDI_ASI_RESET_REQ, UPDI_RESET_REQ_VALUE);
|
||||
case RELEASE_RESET:
|
||||
avrdude_message(MSG_DEBUG, "%s: Sending release reset request\n", progname);
|
||||
pmsg_debug("sending release reset request\n");
|
||||
return updi_write_cs(pgm, UPDI_ASI_RESET_REQ, 0x00);
|
||||
}
|
||||
return -1;
|
||||
|
@ -102,12 +100,12 @@ static int serialupdi_reset(const PROGRAMMER *pgm, reset_mode mode) {
|
|||
|
||||
static int serialupdi_reset_connection(const PROGRAMMER *pgm) {
|
||||
if (serialupdi_reset(pgm, APPLY_RESET) < 0) {
|
||||
avrdude_message(MSG_INFO, "%s: Apply reset operation failed\n", progname);
|
||||
pmsg_error("apply reset operation failed\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (serialupdi_reset(pgm, RELEASE_RESET) < 0) {
|
||||
avrdude_message(MSG_INFO, "%s: Release reset operation failed\n", progname);
|
||||
pmsg_error("release reset operation failed\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -118,7 +116,7 @@ static int serialupdi_decode_sib(const PROGRAMMER *pgm, updi_sib_info *sib_info)
|
|||
char * str_ptr;
|
||||
|
||||
sib_info->sib_string[SIB_INFO_STRING_LENGTH]=0;
|
||||
avrdude_message(MSG_DEBUG, "%s: Received SIB: [%s]\n", progname, sib_info->sib_string);
|
||||
pmsg_debug("received SIB: [%s]\n", sib_info->sib_string);
|
||||
memset(sib_info->family_string, 0, SIB_INFO_FAMILY_LENGTH+1);
|
||||
memset(sib_info->nvm_string, 0, SIB_INFO_NVM_LENGTH+1);
|
||||
memset(sib_info->debug_string, 0, SIB_INFO_DEBUG_LENGTH+1);
|
||||
|
@ -134,41 +132,41 @@ static int serialupdi_decode_sib(const PROGRAMMER *pgm, updi_sib_info *sib_info)
|
|||
|
||||
str_ptr = strstr(sib_info->nvm_string, ":");
|
||||
if (!str_ptr) {
|
||||
avrdude_message(MSG_INFO, "%s: Incorrect format of NVM string\n", progname);
|
||||
pmsg_error("incorrect format of NVM string\n");
|
||||
return -1;
|
||||
}
|
||||
sib_info->nvm_version = *(str_ptr+1);
|
||||
|
||||
str_ptr = strstr(sib_info->debug_string, ":");
|
||||
if (!str_ptr) {
|
||||
avrdude_message(MSG_INFO, "%s: Incorrect format of DEBUG string\n", progname);
|
||||
pmsg_error("incorrect format of DEBUG string\n");
|
||||
return -1;
|
||||
}
|
||||
sib_info->debug_version = *(str_ptr+1);
|
||||
|
||||
avrdude_message(MSG_DEBUG, "%s: Device family ID: %s\n", progname, sib_info->family_string);
|
||||
avrdude_message(MSG_DEBUG, "%s: NVM interface: %s\n", progname, sib_info->nvm_string);
|
||||
avrdude_message(MSG_DEBUG, "%s: Debug interface: %s\n", progname, sib_info->debug_string);
|
||||
avrdude_message(MSG_DEBUG, "%s: PDI oscillator: %s\n", progname, sib_info->pdi_string);
|
||||
avrdude_message(MSG_DEBUG, "%s: Extra information: %s\n", progname, sib_info->extra_string);
|
||||
pmsg_debug("Device family ID: %s\n", sib_info->family_string);
|
||||
pmsg_debug("NVM interface: %s\n", sib_info->nvm_string);
|
||||
pmsg_debug("Debug interface: %s\n", sib_info->debug_string);
|
||||
pmsg_debug("PDI oscillator: %s\n", sib_info->pdi_string);
|
||||
pmsg_debug("Extra information: %s\n", sib_info->extra_string);
|
||||
switch (sib_info->nvm_version) {
|
||||
case '0':
|
||||
avrdude_message(MSG_INFO, "%s: NVM type 0: 16-bit, page oriented write\n", progname);
|
||||
pmsg_notice("NVM type 0: 16-bit, page oriented write\n");
|
||||
updi_set_nvm_mode(pgm, UPDI_NVM_MODE_V0);
|
||||
updi_set_datalink_mode(pgm, UPDI_LINK_MODE_16BIT);
|
||||
break;
|
||||
case '2':
|
||||
avrdude_message(MSG_INFO, "%s: NVM type 2: 24-bit, word oriented write\n", progname);
|
||||
pmsg_notice("NVM type 2: 24-bit, word oriented write\n");
|
||||
updi_set_nvm_mode(pgm, UPDI_NVM_MODE_V2);
|
||||
updi_set_datalink_mode(pgm, UPDI_LINK_MODE_24BIT);
|
||||
break;
|
||||
case '3':
|
||||
avrdude_message(MSG_INFO, "%s: NVM type 3: 16-bit, page oriented\n", progname);
|
||||
pmsg_notice("NVM type 3: 16-bit, page oriented\n");
|
||||
updi_set_nvm_mode(pgm, UPDI_NVM_MODE_V3);
|
||||
updi_set_datalink_mode(pgm, UPDI_LINK_MODE_16BIT);
|
||||
break;
|
||||
default:
|
||||
avrdude_message(MSG_INFO, "%s: Unsupported NVM type: %c, please update software\n", progname, sib_info->nvm_version);
|
||||
pmsg_warning("unsupported NVM type: %c, please update software\n", sib_info->nvm_version);
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
|
@ -176,13 +174,13 @@ static int serialupdi_decode_sib(const PROGRAMMER *pgm, updi_sib_info *sib_info)
|
|||
|
||||
static void serialupdi_close(PROGRAMMER * pgm)
|
||||
{
|
||||
avrdude_message(MSG_INFO, "%s: Leaving NVM programming mode\n", progname);
|
||||
pmsg_notice("leaving NVM programming mode\n");
|
||||
|
||||
if (serialupdi_leave_progmode(pgm) < 0) {
|
||||
avrdude_message(MSG_INFO, "%s: Unable to leave NVM programming mode\n", progname);
|
||||
pmsg_error("unable to leave NVM programming mode\n");
|
||||
}
|
||||
if (updi_get_rts_mode(pgm) != RTS_MODE_DEFAULT) {
|
||||
avrdude_message(MSG_INFO, "%s: Releasing DTR/RTS handshake lines\n", progname);
|
||||
pmsg_warning("releasing DTR/RTS handshake lines\n");
|
||||
}
|
||||
|
||||
updi_link_close(pgm);
|
||||
|
@ -223,7 +221,7 @@ static int serialupdi_wait_for_unlock(const PROGRAMMER *pgm, unsigned int ms) {
|
|||
current_time = (tv.tv_sec * 1000000) + tv.tv_usec;
|
||||
} while ((current_time - start_time) < (ms * 1000));
|
||||
|
||||
avrdude_message(MSG_INFO, "%s: Timeout waiting for device to unlock\n", progname);
|
||||
pmsg_error("timeout waiting for device to unlock\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -278,7 +276,7 @@ static int serialupdi_wait_for_urow(const PROGRAMMER *pgm, unsigned int ms, urow
|
|||
current_time = (tv.tv_sec * 1000000) + tv.tv_usec;
|
||||
} while ((current_time - start_time) < (ms * 1000));
|
||||
|
||||
avrdude_message(MSG_INFO, "%s: Timeout waiting for device to complete UROW WRITE\n", progname);
|
||||
pmsg_error("timeout waiting for device to complete UROW WRITE\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -298,7 +296,7 @@ static int serialupdi_in_prog_mode(const PROGRAMMER *pgm, uint8_t *in_prog_mode)
|
|||
rc = updi_read_cs(pgm, UPDI_ASI_SYS_STATUS, &value);
|
||||
|
||||
if (rc < 0) {
|
||||
avrdude_message(MSG_INFO, "%s: Read CS operation failed\n", progname);
|
||||
pmsg_error("read CS operation failed\n");
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
@ -354,57 +352,57 @@ def enter_progmode(self):
|
|||
uint8_t key_status;
|
||||
|
||||
if (serialupdi_in_prog_mode(pgm, &in_prog_mode) < 0) {
|
||||
avrdude_message(MSG_INFO, "%s: Checking UPDI NVM prog mode failed\n", progname);
|
||||
pmsg_error("checking UPDI NVM prog mode failed\n");
|
||||
return -1;
|
||||
}
|
||||
if (in_prog_mode) {
|
||||
avrdude_message(MSG_DEBUG, "%s: Already in prog mode\n", progname);
|
||||
pmsg_debug("already in prog mode\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
memcpy(buffer, UPDI_KEY_NVM, sizeof(buffer));
|
||||
if (updi_write_key(pgm, buffer, UPDI_KEY_64, sizeof(buffer)) < 0) {
|
||||
avrdude_message(MSG_INFO, "%s: Writing NVM KEY failed\n", progname);
|
||||
pmsg_error("writing NVM KEY failed\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (updi_read_cs(pgm, UPDI_ASI_KEY_STATUS, &key_status) < 0) {
|
||||
avrdude_message(MSG_INFO, "%s: Checking KEY status failed\n", progname);
|
||||
pmsg_error("checking KEY status failed\n");
|
||||
return -1;
|
||||
}
|
||||
avrdude_message(MSG_DEBUG, "%s: Key status: 0x%02X\n", progname, key_status);
|
||||
pmsg_debug("key status: 0x%02X\n", key_status);
|
||||
|
||||
if (!(key_status & (1 << UPDI_ASI_KEY_STATUS_NVMPROG))) {
|
||||
avrdude_message(MSG_INFO, "%s: Key was not accepted\n", progname);
|
||||
pmsg_error("key was not accepted\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (serialupdi_reset(pgm, APPLY_RESET) < 0) {
|
||||
avrdude_message(MSG_INFO, "%s: Apply reset operation failed\n", progname);
|
||||
pmsg_error("apply reset operation failed\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (serialupdi_reset(pgm, RELEASE_RESET) < 0) {
|
||||
avrdude_message(MSG_INFO, "%s: Release reset operation failed\n", progname);
|
||||
pmsg_error("release reset operation failed\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (serialupdi_wait_for_unlock(pgm, 100) < 0) {
|
||||
avrdude_message(MSG_INFO, "%s: Failed to enter NVM programming mode: device is locked\n", progname);
|
||||
pmsg_error("unable to enter NVM programming mode: device is locked\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (serialupdi_in_prog_mode(pgm, &in_prog_mode) < 0) {
|
||||
avrdude_message(MSG_INFO, "%s: Checking UPDI NVM prog mode failed\n", progname);
|
||||
pmsg_error("checking UPDI NVM prog mode failed\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!in_prog_mode) {
|
||||
avrdude_message(MSG_INFO, "%s: Failed to enter NVM programming mode\n", progname);
|
||||
pmsg_error("unable to enter NVM programming mode\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
avrdude_message(MSG_DEBUG, "%s: Entered NVM programming mode\n", progname);
|
||||
pmsg_debug("entered NVM programming mode\n");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -422,12 +420,12 @@ static int serialupdi_leave_progmode(const PROGRAMMER *pgm) {
|
|||
(1 << constants.UPDI_CTRLB_UPDIDIS_BIT) | (1 << constants.UPDI_CTRLB_CCDETDIS_BIT))
|
||||
*/
|
||||
if (serialupdi_reset(pgm, APPLY_RESET) < 0) {
|
||||
avrdude_message(MSG_INFO, "%s: Apply reset operation failed\n", progname);
|
||||
pmsg_error("apply reset operation failed\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (serialupdi_reset(pgm, RELEASE_RESET) < 0) {
|
||||
avrdude_message(MSG_INFO, "%s: Release reset operation failed\n", progname);
|
||||
pmsg_error("release reset operation failed\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -491,74 +489,74 @@ static int serialupdi_write_userrow(const PROGRAMMER *pgm, const AVRPART *p, con
|
|||
|
||||
memcpy(buffer, UPDI_KEY_UROW, sizeof(buffer));
|
||||
if (updi_write_key(pgm, buffer, UPDI_KEY_64, sizeof(buffer)) < 0) {
|
||||
avrdude_message(MSG_INFO, "%s: Writing USERROW KEY failed\n", progname);
|
||||
pmsg_error("writing USERROW KEY failed\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (updi_read_cs(pgm, UPDI_ASI_KEY_STATUS, &key_status) < 0) {
|
||||
avrdude_message(MSG_INFO, "%s: Checking KEY status failed\n", progname);
|
||||
pmsg_error("checking KEY status failed\n");
|
||||
return -1;
|
||||
}
|
||||
avrdude_message(MSG_DEBUG, "%s: Key status: 0x%02X\n", progname, key_status);
|
||||
pmsg_debug("key status: 0x%02X\n", key_status);
|
||||
|
||||
if (!(key_status & (1 << UPDI_ASI_KEY_STATUS_UROWWRITE))) {
|
||||
avrdude_message(MSG_INFO, "%s: Key was not accepted\n", progname);
|
||||
pmsg_error("key was not accepted\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (serialupdi_reset(pgm, APPLY_RESET) < 0) {
|
||||
avrdude_message(MSG_INFO, "%s: Apply reset operation failed\n", progname);
|
||||
pmsg_error("apply reset operation failed\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (serialupdi_reset(pgm, RELEASE_RESET) < 0) {
|
||||
avrdude_message(MSG_INFO, "%s: Release reset operation failed\n", progname);
|
||||
pmsg_error("release reset operation failed\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (serialupdi_wait_for_urow(pgm, 500, WAIT_FOR_UROW_HIGH) < 0) {
|
||||
avrdude_message(MSG_INFO, "%s: Failed to enter USERROW programming mode\n", progname);
|
||||
pmsg_error("unable to enter USERROW programming mode\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (updi_write_data(pgm, m->offset+addr, m->buf + addr, n_bytes) < 0) {
|
||||
avrdude_message(MSG_INFO, "%s: Writing USER ROW failed\n", progname);
|
||||
pmsg_error("writing USER ROW failed\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (updi_write_cs(pgm, UPDI_ASI_SYS_CTRLA, (1 << UPDI_ASI_SYS_CTRLA_UROW_FINAL) |
|
||||
(1 << UPDI_CTRLB_CCDETDIS_BIT)) < 0) {
|
||||
avrdude_message(MSG_INFO, "%s: Failed trying to commit user row write\n", progname);
|
||||
pmsg_error("unable to commit user row write\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (serialupdi_wait_for_urow(pgm, 500, WAIT_FOR_UROW_LOW) < 0) {
|
||||
avrdude_message(MSG_DEBUG, "%s: Failed to exit USERROW programming mode\n", progname);
|
||||
pmsg_debug("unable to exit USERROW programming mode\n");
|
||||
|
||||
if (serialupdi_reset(pgm, APPLY_RESET) < 0) {
|
||||
avrdude_message(MSG_INFO, "%s: Apply reset operation failed\n", progname);
|
||||
pmsg_error("apply reset operation failed\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (serialupdi_reset(pgm, RELEASE_RESET) < 0) {
|
||||
avrdude_message(MSG_INFO, "%s: Release reset operation failed\n", progname);
|
||||
pmsg_error("release reset operation failed\n");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
if (updi_write_cs(pgm, UPDI_ASI_KEY_STATUS, (1 << UPDI_ASI_KEY_STATUS_UROWWRITE) |
|
||||
(1 << UPDI_CTRLB_CCDETDIS_BIT)) < 0) {
|
||||
avrdude_message(MSG_INFO, "%s: Failed trying to complete user row write\n", progname);
|
||||
pmsg_error("unable to complete user row write\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (serialupdi_reset(pgm, APPLY_RESET) < 0) {
|
||||
avrdude_message(MSG_INFO, "%s: Apply reset operation failed\n", progname);
|
||||
pmsg_error("apply reset operation failed\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (serialupdi_reset(pgm, RELEASE_RESET) < 0) {
|
||||
avrdude_message(MSG_INFO, "%s: Release reset operation failed\n", progname);
|
||||
pmsg_error("release reset operation failed\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -574,13 +572,13 @@ static int serialupdi_initialize(const PROGRAMMER *pgm, const AVRPART *p) {
|
|||
uint8_t reset_link_required=0;
|
||||
|
||||
if (updi_link_init(pgm) < 0) {
|
||||
avrdude_message(MSG_INFO, "%s: UPDI link initialization failed\n", progname);
|
||||
pmsg_error("UPDI link initialization failed\n");
|
||||
return -1;
|
||||
}
|
||||
avrdude_message(MSG_INFO, "%s: UPDI link initialization OK\n", progname);
|
||||
pmsg_notice2("UPDI link initialization OK\n");
|
||||
|
||||
if (updi_get_rts_mode(pgm) != RTS_MODE_DEFAULT) {
|
||||
avrdude_message(MSG_INFO, "%s: Forcing serial DTR/RTS handshake lines %s\n", progname, updi_get_rts_mode(pgm) == RTS_MODE_LOW ? "LOW" : "HIGH");
|
||||
pmsg_warning("forcing serial DTR/RTS handshake lines %s\n", updi_get_rts_mode(pgm) == RTS_MODE_LOW ? "LOW" : "HIGH");
|
||||
}
|
||||
|
||||
if (updi_read_cs(pgm, UPDI_ASI_SYS_STATUS, &value)<0) {
|
||||
|
@ -591,33 +589,33 @@ static int serialupdi_initialize(const PROGRAMMER *pgm, const AVRPART *p) {
|
|||
}
|
||||
|
||||
if (updi_read_cs(pgm, UPDI_ASI_SYS_STATUS, &value)<0) {
|
||||
avrdude_message(MSG_INFO, "%s: Read CS operation during initialization failed\n", progname);
|
||||
pmsg_error("read CS operation during initialization failed\n");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
if (value & (1 << UPDI_ASI_SYS_STATUS_LOCKSTATUS)) {
|
||||
avrdude_message(MSG_INFO, "%s: Device is locked\n", progname);
|
||||
pmsg_notice("device is locked\n");
|
||||
}
|
||||
if (value & (1 << UPDI_ASI_SYS_STATUS_UROWPROG)) {
|
||||
avrdude_message(MSG_INFO, "%s: Device in USER ROW programming state, leaving programming mode\n", progname);
|
||||
pmsg_notice("device in USER ROW programming state, leaving programming mode\n");
|
||||
reset_link_required = 1;
|
||||
}
|
||||
if (value & (1 << UPDI_ASI_SYS_STATUS_NVMPROG)) {
|
||||
avrdude_message(MSG_INFO, "%s: Device in NVM programming state, leaving programming mode\n", progname);
|
||||
pmsg_notice("device in NVM programming state, leaving programming mode\n");
|
||||
reset_link_required = 1;
|
||||
}
|
||||
if (value & (1 << UPDI_ASI_SYS_STATUS_INSLEEP)) {
|
||||
avrdude_message(MSG_INFO, "%s: Device is in SLEEP mode\n", progname);
|
||||
pmsg_notice("device is in SLEEP mode\n");
|
||||
}
|
||||
if (value & (1 << UPDI_ASI_SYS_STATUS_RSTSYS)) {
|
||||
avrdude_message(MSG_INFO, "%s: Device in reset status, trying to release it\n", progname);
|
||||
pmsg_notice("device in reset status, trying to release it\n");
|
||||
if (serialupdi_reset(pgm, RELEASE_RESET) < 0) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
if (reset_link_required) {
|
||||
if (serialupdi_reset_connection(pgm) < 0) {
|
||||
avrdude_message(MSG_INFO, "%s: UPDI link reset failed\n", progname);
|
||||
pmsg_error("UPDI link reset failed\n");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
@ -627,25 +625,25 @@ static int serialupdi_initialize(const PROGRAMMER *pgm, const AVRPART *p) {
|
|||
if (updi_read_sib(pgm, sib_info->sib_string, 32) < 0) {
|
||||
/* this should never happen, let's try to reset connection and try again */
|
||||
if (serialupdi_reset_connection(pgm) < 0) {
|
||||
avrdude_message(MSG_INFO, "%s: SerialUPDI reset connection failed\n", progname);
|
||||
pmsg_error("SerialUPDI reset connection failed\n");
|
||||
return -1;
|
||||
}
|
||||
if (updi_read_sib(pgm, sib_info->sib_string, 32) < 0) {
|
||||
avrdude_message(MSG_INFO, "%s: Read SIB operation failed\n", progname);
|
||||
pmsg_error("read SIB operation failed\n");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
if (serialupdi_decode_sib(pgm, sib_info) < 0) {
|
||||
avrdude_message(MSG_INFO, "%s: Decode SIB_INFO failed\n", progname);
|
||||
pmsg_error("decode SIB_INFO failed\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (updi_link_init(pgm) < 0) {
|
||||
avrdude_message(MSG_INFO, "%s: UPDI link initialization failed\n", progname);
|
||||
pmsg_error("UPDI link initialization failed\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
avrdude_message(MSG_INFO, "%s: Entering NVM programming mode\n", progname);
|
||||
pmsg_notice("entering NVM programming mode\n");
|
||||
/* try, but ignore failure */
|
||||
serialupdi_enter_progmode(pgm);
|
||||
|
||||
|
@ -671,14 +669,12 @@ static void serialupdi_display(const PROGRAMMER *pgm, const char *p) {
|
|||
static int serialupdi_cmd(const PROGRAMMER *pgm, const unsigned char *cmd,
|
||||
unsigned char * res)
|
||||
{
|
||||
avrdude_message(MSG_INFO, "%s: error: cmd %s[%s] not implemented yet\n",
|
||||
progname, cmd, res);
|
||||
pmsg_error("cmd %s[%s] not implemented yet\n", cmd, res);
|
||||
return -1;
|
||||
}
|
||||
|
||||
static int serialupdi_program_enable(const PROGRAMMER *pgm, const AVRPART *p) {
|
||||
avrdude_message(MSG_INFO, "%s: error: program enable not implemented yet\n",
|
||||
progname);
|
||||
pmsg_error("program enable not implemented yet\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -724,7 +720,7 @@ static int serialupdi_paged_load(const PROGRAMMER *pgm, const AVRPART *p, const
|
|||
rc = updi_read_data(pgm, m->offset + read_offset, m->buf + read_offset,
|
||||
remaining_bytes > m->readsize ? m->readsize : remaining_bytes);
|
||||
if (rc < 0) {
|
||||
avrdude_message(MSG_INFO, "%s: Paged load operation failed\n", progname);
|
||||
pmsg_error("paged load operation failed\n");
|
||||
return rc;
|
||||
} else {
|
||||
read_bytes+=rc;
|
||||
|
@ -759,15 +755,15 @@ static int serialupdi_paged_write(const PROGRAMMER *pgm, const AVRPART *p, const
|
|||
rc = serialupdi_write_userrow(pgm, p, m, page_size, write_offset,
|
||||
remaining_bytes > m->page_size ? m->page_size : remaining_bytes);
|
||||
} else if (strcmp(m->desc, "fuses")==0) {
|
||||
avrdude_message(MSG_DEBUG, "%s: Page write operation requested for fuses, falling back to byte-level write\n", progname);
|
||||
pmsg_debug("page write operation requested for fuses, falling back to byte-level write\n");
|
||||
return -1;
|
||||
} else {
|
||||
avrdude_message(MSG_INFO, "%s: Invalid memory type: <%s:%d>, 0x%06X, %d (0x%04X)\n", progname, m->desc, page_size, addr, n_bytes, n_bytes);
|
||||
pmsg_error("invalid memory type: <%s:%d>, 0x%06X, %d (0x%04X)\n", m->desc, page_size, addr, n_bytes, n_bytes);
|
||||
rc = -1;
|
||||
}
|
||||
|
||||
if (rc < 0) {
|
||||
avrdude_message(MSG_INFO, "%s: Paged write operation failed\n", progname);
|
||||
pmsg_error("paged write operation failed\n");
|
||||
return rc;
|
||||
} else {
|
||||
write_bytes+=rc;
|
||||
|
@ -784,10 +780,10 @@ static int serialupdi_paged_write(const PROGRAMMER *pgm, const AVRPART *p, const
|
|||
} else if (strcmp(m->desc, "userrow")==0) {
|
||||
rc = serialupdi_write_userrow(pgm, p, m, page_size, addr, n_bytes);
|
||||
} else if (strcmp(m->desc, "fuses")==0) {
|
||||
avrdude_message(MSG_DEBUG, "%s: Page write operation requested for fuses, falling back to byte-level write\n", progname);
|
||||
pmsg_debug("page write operation requested for fuses, falling back to byte-level write\n");
|
||||
rc = -1;
|
||||
} else {
|
||||
avrdude_message(MSG_INFO, "%s: Invalid memory type: <%s:%d>, 0x%06X, %d (0x%04X)\n", progname, m->desc, page_size, addr, n_bytes, n_bytes);
|
||||
pmsg_error("invalid memory type: <%s:%d>, 0x%06X, %d (0x%04X)\n", m->desc, page_size, addr, n_bytes, n_bytes);
|
||||
rc = -1;
|
||||
}
|
||||
return rc;
|
||||
|
@ -824,38 +820,38 @@ static int serialupdi_unlock(const PROGRAMMER *pgm, const AVRPART *p) {
|
|||
memcpy(buffer, UPDI_KEY_CHIPERASE, sizeof(buffer));
|
||||
|
||||
if (updi_write_key(pgm, buffer, UPDI_KEY_64, sizeof(buffer)) < 0) {
|
||||
avrdude_message(MSG_INFO, "%s: Writing NVM KEY failed\n", progname);
|
||||
pmsg_error("writing NVM KEY failed\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (updi_read_cs(pgm, UPDI_ASI_KEY_STATUS, &key_status) < 0) {
|
||||
avrdude_message(MSG_INFO, "%s: Checking KEY status failed\n", progname);
|
||||
pmsg_error("checking KEY status failed\n");
|
||||
return -1;
|
||||
}
|
||||
avrdude_message(MSG_DEBUG, "%s: Key status: 0x%02X\n", progname, key_status);
|
||||
pmsg_debug("key status: 0x%02X\n", key_status);
|
||||
|
||||
if (!(key_status & (1 << UPDI_ASI_KEY_STATUS_CHIPERASE))) {
|
||||
avrdude_message(MSG_INFO, "%s: Key not accepted\n", progname);
|
||||
pmsg_error("key not accepted\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (serialupdi_reset(pgm, APPLY_RESET) < 0) {
|
||||
avrdude_message(MSG_INFO, "%s: Apply reset operation failed\n", progname);
|
||||
pmsg_error("apply reset operation failed\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (serialupdi_reset(pgm, RELEASE_RESET) < 0) {
|
||||
avrdude_message(MSG_INFO, "%s: Release reset operation failed\n", progname);
|
||||
pmsg_error("release reset operation failed\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (serialupdi_wait_for_unlock(pgm, 500) < 0) {
|
||||
avrdude_message(MSG_INFO, "%s: Waiting for unlock failed\n", progname);
|
||||
pmsg_error("waiting for unlock failed\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (updi_link_init(pgm) < 0) {
|
||||
avrdude_message(MSG_INFO, "%s: UPDI link reinitialization failed\n", progname);
|
||||
pmsg_error("UPDI link reinitialization failed\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -866,14 +862,14 @@ static int serialupdi_chip_erase(const PROGRAMMER *pgm, const AVRPART *p) {
|
|||
uint8_t value;
|
||||
|
||||
if (updi_read_cs(pgm, UPDI_ASI_SYS_STATUS, &value)<0) {
|
||||
avrdude_message(MSG_INFO, "%s: Read CS operation during chip erase failed\n", progname);
|
||||
pmsg_error("read CS operation during chip erase failed\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (value & (1 << UPDI_ASI_SYS_STATUS_LOCKSTATUS)) {
|
||||
avrdude_message(MSG_INFO, "%s: Device is locked\n", progname);
|
||||
pmsg_warning("device is locked\n");
|
||||
if (ovsigck) {
|
||||
avrdude_message(MSG_INFO, "%s: Attempting device erase\n", progname);
|
||||
pmsg_warning("attempting device erase\n");
|
||||
return serialupdi_unlock(pgm, p);
|
||||
}
|
||||
} else {
|
||||
|
@ -885,8 +881,7 @@ static int serialupdi_chip_erase(const PROGRAMMER *pgm, const AVRPART *p) {
|
|||
static int serialupdi_page_erase(const PROGRAMMER *pgm, const AVRPART *p, const AVRMEM *m,
|
||||
unsigned int baseaddr)
|
||||
{
|
||||
avrdude_message(MSG_INFO, "%s: error: page erase not implemented yet\n",
|
||||
progname);
|
||||
pmsg_error("page erase not implemented yet\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -895,7 +890,7 @@ static int serialupdi_read_signature(const PROGRAMMER *pgm, const AVRPART *p, co
|
|||
uint8_t value;
|
||||
|
||||
if (updi_read_cs(pgm, UPDI_ASI_SYS_STATUS, &value)<0) {
|
||||
avrdude_message(MSG_INFO, "%s: Read CS operation during signature read failed\n", progname);
|
||||
pmsg_error("read CS operation during signature read failed\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -937,14 +932,13 @@ static int serialupdi_parseextparms(const PROGRAMMER *pgm, const LISTID extparms
|
|||
} else if (strcasecmp(rts_mode, "high") == 0) {
|
||||
updi_set_rts_mode(pgm, RTS_MODE_HIGH);
|
||||
} else {
|
||||
avrdude_message(MSG_INFO, "%s: RTS/DTR mode must be LOW or HIGH\n", progname);
|
||||
pmsg_error("RTS/DTR mode must be LOW or HIGH\n");
|
||||
return -1;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
avrdude_message(MSG_INFO, "%s: serialupdi_parseextparms(): invalid extended parameter '%s'\n",
|
||||
progname, extended_param);
|
||||
pmsg_error("invalid extended parameter '%s'\n", extended_param);
|
||||
rv = -1;
|
||||
}
|
||||
|
||||
|
|
251
src/stk500.c
251
src/stk500.c
|
@ -60,8 +60,7 @@ static int stk500_recv(const PROGRAMMER *pgm, unsigned char *buf, size_t len) {
|
|||
|
||||
rv = serial_recv(&pgm->fd, buf, len);
|
||||
if (rv < 0) {
|
||||
avrdude_message(MSG_INFO, "%s: stk500_recv(): programmer is not responding\n",
|
||||
progname);
|
||||
pmsg_error("programmer is not responding\n");
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
|
@ -110,8 +109,7 @@ int stk500_getsync(const PROGRAMMER *pgm) {
|
|||
if(stk500_recv(pgm, resp, 1) >= 0 && resp[0] == Resp_STK_INSYNC)
|
||||
break;
|
||||
|
||||
avrdude_message(MSG_INFO, "%s: stk500_getsync() attempt %d of %d: not in sync: resp=0x%02x\n",
|
||||
progname, attempt + 1, max_sync_attempts, resp[0]);
|
||||
pmsg_warning("attempt %d of %d: not in sync: resp=0x%02x\n", attempt + 1, max_sync_attempts, resp[0]);
|
||||
}
|
||||
if (attempt == max_sync_attempts) {
|
||||
stk500_drain(pgm, 0);
|
||||
|
@ -121,9 +119,7 @@ int stk500_getsync(const PROGRAMMER *pgm) {
|
|||
if (stk500_recv(pgm, resp, 1) < 0)
|
||||
return -1;
|
||||
if (resp[0] != Resp_STK_OK) {
|
||||
avrdude_message(MSG_INFO, "%s: stk500_getsync(): can't communicate with device: "
|
||||
"resp=0x%02x\n",
|
||||
progname, resp[0]);
|
||||
pmsg_error("cannot communicate with device: resp=0x%02x\n", resp[0]);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -152,7 +148,7 @@ static int stk500_cmd(const PROGRAMMER *pgm, const unsigned char *cmd,
|
|||
if (stk500_recv(pgm, buf, 1) < 0)
|
||||
return -1;
|
||||
if (buf[0] != Resp_STK_INSYNC) {
|
||||
avrdude_message(MSG_INFO, "%s: stk500_cmd(): programmer is out of sync\n", progname);
|
||||
pmsg_error("programmer is out of sync\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -165,7 +161,7 @@ static int stk500_cmd(const PROGRAMMER *pgm, const unsigned char *cmd,
|
|||
if (stk500_recv(pgm, buf, 1) < 0)
|
||||
return -1;
|
||||
if (buf[0] != Resp_STK_OK) {
|
||||
avrdude_message(MSG_INFO, "%s: stk500_cmd(): protocol error\n", progname);
|
||||
pmsg_error("protocol expects OK byte 0x%02x but got 0x%02x\n", Resp_STK_OK, buf[0]);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -182,15 +178,13 @@ static int stk500_chip_erase(const PROGRAMMER *pgm, const AVRPART *p) {
|
|||
unsigned char res[4];
|
||||
|
||||
if (pgm->cmd == NULL) {
|
||||
avrdude_message(MSG_INFO, "%s: Error: %s programmer uses stk500_chip_erase() but does not\n"
|
||||
"provide a cmd() method.\n",
|
||||
progname, pgm->type);
|
||||
pmsg_error("%s programmer uses stk500_chip_erase() but does not\n", pgm->type);
|
||||
imsg_error("provide a cmd() method\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (p->op[AVR_OP_CHIP_ERASE] == NULL) {
|
||||
avrdude_message(MSG_INFO, "%s: chip erase instruction not defined for part \"%s\"\n",
|
||||
progname, p->desc);
|
||||
pmsg_error("chip erase instruction not defined for part %s\n", p->desc);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -226,8 +220,7 @@ static int stk500_program_enable(const PROGRAMMER *pgm, const AVRPART *p) {
|
|||
return -1;
|
||||
if (buf[0] == Resp_STK_NOSYNC) {
|
||||
if (tries > 33) {
|
||||
avrdude_message(MSG_INFO, "%s: stk500_program_enable(): can't get into sync\n",
|
||||
progname);
|
||||
pmsg_error("cannot get into sync\n");
|
||||
return -1;
|
||||
}
|
||||
if (stk500_getsync(pgm) < 0)
|
||||
|
@ -235,9 +228,7 @@ static int stk500_program_enable(const PROGRAMMER *pgm, const AVRPART *p) {
|
|||
goto retry;
|
||||
}
|
||||
else if (buf[0] != Resp_STK_INSYNC) {
|
||||
avrdude_message(MSG_INFO, "%s: stk500_program_enable(): protocol error, "
|
||||
"expect=0x%02x, resp=0x%02x\n",
|
||||
progname, Resp_STK_INSYNC, buf[0]);
|
||||
pmsg_error("protocol expects sync byte 0x%02x but got 0x%02x\n", Resp_STK_INSYNC, buf[0]);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -247,21 +238,18 @@ static int stk500_program_enable(const PROGRAMMER *pgm, const AVRPART *p) {
|
|||
return 0;
|
||||
}
|
||||
else if (buf[0] == Resp_STK_NODEVICE) {
|
||||
avrdude_message(MSG_INFO, "%s: stk500_program_enable(): no device\n",
|
||||
progname);
|
||||
pmsg_error("no device\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if(buf[0] == Resp_STK_FAILED)
|
||||
{
|
||||
avrdude_message(MSG_INFO, "%s: stk500_program_enable(): failed to enter programming mode\n",
|
||||
progname);
|
||||
pmsg_error("unable to enter programming mode\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
avrdude_message(MSG_INFO, "%s: stk500_program_enable(): unknown response=0x%02x\n",
|
||||
progname, buf[0]);
|
||||
pmsg_error("unknown response=0x%02x\n", buf[0]);
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
@ -291,8 +279,7 @@ static int stk500_set_extended_parms(const PROGRAMMER *pgm, int n,
|
|||
return -1;
|
||||
if (buf[0] == Resp_STK_NOSYNC) {
|
||||
if (tries > 33) {
|
||||
avrdude_message(MSG_INFO, "%s: stk500_set_extended_parms(): can't get into sync\n",
|
||||
progname);
|
||||
pmsg_error("cannot get into sync\n");
|
||||
return -1;
|
||||
}
|
||||
if (stk500_getsync(pgm) < 0)
|
||||
|
@ -300,9 +287,7 @@ static int stk500_set_extended_parms(const PROGRAMMER *pgm, int n,
|
|||
goto retry;
|
||||
}
|
||||
else if (buf[0] != Resp_STK_INSYNC) {
|
||||
avrdude_message(MSG_INFO, "%s: stk500_set_extended_parms(): protocol error, "
|
||||
"expect=0x%02x, resp=0x%02x\n",
|
||||
progname, Resp_STK_INSYNC, buf[0]);
|
||||
pmsg_error("protocol expects sync byte 0x%02x but got 0x%02x\n", Resp_STK_INSYNC, buf[0]);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -312,22 +297,16 @@ static int stk500_set_extended_parms(const PROGRAMMER *pgm, int n,
|
|||
return 0;
|
||||
}
|
||||
else if (buf[0] == Resp_STK_NODEVICE) {
|
||||
avrdude_message(MSG_INFO, "%s: stk500_set_extended_parms(): no device\n",
|
||||
progname);
|
||||
pmsg_error("no device\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if(buf[0] == Resp_STK_FAILED)
|
||||
{
|
||||
avrdude_message(MSG_INFO, "%s: stk500_set_extended_parms(): failed to set extended "
|
||||
"device programming parameters\n",
|
||||
progname);
|
||||
if(buf[0] == Resp_STK_FAILED) {
|
||||
pmsg_error("unable to set extended device programming parameters\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
avrdude_message(MSG_INFO, "%s: stk500_set_extended_parms(): unknown response=0x%02x\n",
|
||||
progname, buf[0]);
|
||||
pmsg_error("unknown response=0x%02x\n", buf[0]);
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
@ -360,8 +339,7 @@ static int mib510_isp(const PROGRAMMER *pgm, unsigned char cmd) {
|
|||
return -1;
|
||||
if (buf[0] == Resp_STK_NOSYNC) {
|
||||
if (tries > 33) {
|
||||
avrdude_message(MSG_INFO, "%s: mib510_isp(): can't get into sync\n",
|
||||
progname);
|
||||
pmsg_error("cannot get into sync\n");
|
||||
return -1;
|
||||
}
|
||||
if (stk500_getsync(pgm) < 0)
|
||||
|
@ -369,9 +347,7 @@ static int mib510_isp(const PROGRAMMER *pgm, unsigned char cmd) {
|
|||
goto retry;
|
||||
}
|
||||
else if (buf[0] != Resp_STK_INSYNC) {
|
||||
avrdude_message(MSG_INFO, "%s: mib510_isp(): protocol error, "
|
||||
"expect=0x%02x, resp=0x%02x\n",
|
||||
progname, Resp_STK_INSYNC, buf[0]);
|
||||
pmsg_error("protocol expects sync byte 0x%02x but got 0x%02x\n", Resp_STK_INSYNC, buf[0]);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -381,21 +357,18 @@ static int mib510_isp(const PROGRAMMER *pgm, unsigned char cmd) {
|
|||
return 0;
|
||||
}
|
||||
else if (buf[0] == Resp_STK_NODEVICE) {
|
||||
avrdude_message(MSG_INFO, "%s: mib510_isp(): no device\n",
|
||||
progname);
|
||||
pmsg_error("no device\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (buf[0] == Resp_STK_FAILED)
|
||||
{
|
||||
avrdude_message(MSG_INFO, "%s: mib510_isp(): command %d failed\n",
|
||||
progname, cmd);
|
||||
pmsg_error("command %d failed\n", cmd);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
avrdude_message(MSG_INFO, "%s: mib510_isp(): unknown response=0x%02x\n",
|
||||
progname, buf[0]);
|
||||
pmsg_error("unknown response=0x%02x\n", buf[0]);
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
@ -454,8 +427,7 @@ static int stk500_initialize(const PROGRAMMER *pgm, const AVRPART *p) {
|
|||
}
|
||||
|
||||
#if 0
|
||||
avrdude_message(MSG_INFO, "%s: stk500_initialize(): n_extparms = %d\n",
|
||||
progname, n_extparms);
|
||||
pmsg_info("stk500_initialize(): n_extparms = %d\n", n_extparms);
|
||||
#endif
|
||||
|
||||
buf[5] = 1; /* polling supported - XXX need this in config file */
|
||||
|
@ -528,8 +500,7 @@ static int stk500_initialize(const PROGRAMMER *pgm, const AVRPART *p) {
|
|||
if (stk500_recv(pgm, buf, 1) < 0)
|
||||
return -1;
|
||||
if (buf[0] == Resp_STK_NOSYNC) {
|
||||
avrdude_message(MSG_INFO, "%s: stk500_initialize(): programmer not in sync, resp=0x%02x\n",
|
||||
progname, buf[0]);
|
||||
pmsg_warning("programmer not in sync, resp=0x%02x\n", buf[0]);
|
||||
if (tries > 33)
|
||||
return -1;
|
||||
if (stk500_getsync(pgm) < 0)
|
||||
|
@ -537,26 +508,21 @@ static int stk500_initialize(const PROGRAMMER *pgm, const AVRPART *p) {
|
|||
goto retry;
|
||||
}
|
||||
else if (buf[0] != Resp_STK_INSYNC) {
|
||||
avrdude_message(MSG_INFO, "%s: stk500_initialize(): (a) protocol error, "
|
||||
"expect=0x%02x, resp=0x%02x\n",
|
||||
progname, Resp_STK_INSYNC, buf[0]);
|
||||
pmsg_error("protocol expects sync byte 0x%02x but got 0x%02x\n", Resp_STK_INSYNC, buf[0]);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (stk500_recv(pgm, buf, 1) < 0)
|
||||
return -1;
|
||||
if (buf[0] != Resp_STK_OK) {
|
||||
avrdude_message(MSG_INFO, "%s: stk500_initialize(): (b) protocol error, "
|
||||
"expect=0x%02x, resp=0x%02x\n",
|
||||
progname, Resp_STK_OK, buf[0]);
|
||||
pmsg_error("protocol expects OK byte 0x%02x but got 0x%02x\n", Resp_STK_OK, buf[0]);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (n_extparms) {
|
||||
if ((p->pagel == 0) || (p->bs2 == 0)) {
|
||||
avrdude_message(MSG_NOTICE2, "%s: PAGEL and BS2 signals not defined in the configuration "
|
||||
"file for part %s, using dummy values\n",
|
||||
progname, p->desc);
|
||||
pmsg_notice2("PAGEL and BS2 signals not defined in the configuration "
|
||||
"file for part %s, using dummy values\n", p->desc);
|
||||
buf[2] = 0xD7; /* they look somehow possible, */
|
||||
buf[3] = 0xA0; /* don't they? ;) */
|
||||
}
|
||||
|
@ -584,7 +550,7 @@ static int stk500_initialize(const PROGRAMMER *pgm, const AVRPART *p) {
|
|||
|
||||
rc = stk500_set_extended_parms(pgm, n_extparms+1, buf);
|
||||
if (rc) {
|
||||
avrdude_message(MSG_INFO, "%s: stk500_initialize(): failed\n", progname);
|
||||
pmsg_error("failed to initialise programmer\n");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
@ -604,13 +570,11 @@ static int stk500_parseextparms(const PROGRAMMER *pgm, const LISTID extparms)
|
|||
|
||||
if (sscanf(extended_param, "attempts=%2d", &attempts) == 1) {
|
||||
PDATA(pgm)->retry_attempts = attempts;
|
||||
avrdude_message(MSG_INFO, "%s: Setting number of retry attempts to %d\n",
|
||||
progname, attempts);
|
||||
pmsg_info("setting number of retry attempts to %d\n", attempts);
|
||||
continue;
|
||||
}
|
||||
|
||||
avrdude_message(MSG_INFO, "%s: stk500_parseextparms(): invalid extended parameter '%s'\n",
|
||||
progname, extended_param);
|
||||
pmsg_error("invalid extended parameter '%s'\n", extended_param);
|
||||
rv = -1;
|
||||
}
|
||||
|
||||
|
@ -633,8 +597,7 @@ static void stk500_disable(const PROGRAMMER *pgm) {
|
|||
return;
|
||||
if (buf[0] == Resp_STK_NOSYNC) {
|
||||
if (tries > 33) {
|
||||
avrdude_message(MSG_INFO, "%s: stk500_disable(): can't get into sync\n",
|
||||
progname);
|
||||
pmsg_error("cannot get into sync\n");
|
||||
return;
|
||||
}
|
||||
if (stk500_getsync(pgm) < 0)
|
||||
|
@ -642,9 +605,7 @@ static void stk500_disable(const PROGRAMMER *pgm) {
|
|||
goto retry;
|
||||
}
|
||||
else if (buf[0] != Resp_STK_INSYNC) {
|
||||
avrdude_message(MSG_INFO, "%s: stk500_disable(): protocol error, expect=0x%02x, "
|
||||
"resp=0x%02x\n",
|
||||
progname, Resp_STK_INSYNC, buf[0]);
|
||||
pmsg_error("protocol expects sync byte 0x%02x but got 0x%02x\n", Resp_STK_INSYNC, buf[0]);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -654,13 +615,11 @@ static void stk500_disable(const PROGRAMMER *pgm) {
|
|||
return;
|
||||
}
|
||||
else if (buf[0] == Resp_STK_NODEVICE) {
|
||||
avrdude_message(MSG_INFO, "%s: stk500_disable(): no device\n",
|
||||
progname);
|
||||
pmsg_error("no device\n");
|
||||
return;
|
||||
}
|
||||
|
||||
avrdude_message(MSG_INFO, "%s: stk500_disable(): unknown response=0x%02x\n",
|
||||
progname, buf[0]);
|
||||
pmsg_error("unknown response=0x%02x\n", buf[0]);
|
||||
|
||||
return;
|
||||
}
|
||||
|
@ -742,8 +701,7 @@ static int stk500_loadaddr(const PROGRAMMER *pgm, const AVRMEM *mem, const unsig
|
|||
return -1;
|
||||
if (buf[0] == Resp_STK_NOSYNC) {
|
||||
if (tries > 33) {
|
||||
avrdude_message(MSG_INFO, "%s: stk500_loadaddr(): can't get into sync\n",
|
||||
progname);
|
||||
pmsg_error("cannot get into sync\n");
|
||||
return -1;
|
||||
}
|
||||
if (stk500_getsync(pgm) < 0)
|
||||
|
@ -751,9 +709,7 @@ static int stk500_loadaddr(const PROGRAMMER *pgm, const AVRMEM *mem, const unsig
|
|||
goto retry;
|
||||
}
|
||||
else if (buf[0] != Resp_STK_INSYNC) {
|
||||
avrdude_message(MSG_INFO, "%s: stk500_loadaddr(): (a) protocol error, "
|
||||
"expect=0x%02x, resp=0x%02x\n",
|
||||
progname, Resp_STK_INSYNC, buf[0]);
|
||||
pmsg_error("protocol expects sync byte 0x%02x but got 0x%02x\n", Resp_STK_INSYNC, buf[0]);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -762,9 +718,7 @@ static int stk500_loadaddr(const PROGRAMMER *pgm, const AVRMEM *mem, const unsig
|
|||
if (buf[0] == Resp_STK_OK)
|
||||
return 0;
|
||||
|
||||
avrdude_message(MSG_INFO, "%s: stk500_loadaddr(): (b) protocol error, "
|
||||
"expect=0x%02x, resp=0x%02x\n",
|
||||
progname, Resp_STK_OK, buf[0]);
|
||||
pmsg_error("protocol expects OK byte 0x%02x but got 0x%02x\n", Resp_STK_OK, buf[0]);
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
@ -800,7 +754,8 @@ static int stk500_paged_write(const PROGRAMMER *pgm, const AVRPART *p, const AVR
|
|||
|
||||
n = addr + n_bytes;
|
||||
#if 0
|
||||
avrdude_message(MSG_INFO, "n_bytes = %d\n"
|
||||
msg_info(
|
||||
"n_bytes = %d\n"
|
||||
"n = %u\n"
|
||||
"a_div = %d\n"
|
||||
"page_size = %d\n",
|
||||
|
@ -838,8 +793,8 @@ static int stk500_paged_write(const PROGRAMMER *pgm, const AVRPART *p, const AVR
|
|||
return -1;
|
||||
if (buf[0] == Resp_STK_NOSYNC) {
|
||||
if (tries > 33) {
|
||||
avrdude_message(MSG_INFO, "\n%s: stk500_paged_write(): can't get into sync\n",
|
||||
progname);
|
||||
msg_error("\n");
|
||||
pmsg_error("cannot get into sync\n");
|
||||
return -3;
|
||||
}
|
||||
if (stk500_getsync(pgm) < 0)
|
||||
|
@ -847,18 +802,16 @@ static int stk500_paged_write(const PROGRAMMER *pgm, const AVRPART *p, const AVR
|
|||
goto retry;
|
||||
}
|
||||
else if (buf[0] != Resp_STK_INSYNC) {
|
||||
avrdude_message(MSG_INFO, "\n%s: stk500_paged_write(): (a) protocol error, "
|
||||
"expect=0x%02x, resp=0x%02x\n",
|
||||
progname, Resp_STK_INSYNC, buf[0]);
|
||||
msg_error("\n");
|
||||
pmsg_error("protocol expects sync byte 0x%02x but got 0x%02x\n", Resp_STK_INSYNC, buf[0]);
|
||||
return -4;
|
||||
}
|
||||
|
||||
if (stk500_recv(pgm, buf, 1) < 0)
|
||||
return -1;
|
||||
if (buf[0] != Resp_STK_OK) {
|
||||
avrdude_message(MSG_INFO, "\n%s: stk500_paged_write(): (b) protocol error, "
|
||||
"expect=0x%02x, resp=0x%02x\n",
|
||||
progname, Resp_STK_OK, buf[0]);
|
||||
msg_error("\n");
|
||||
pmsg_error("protocol expects OK byte 0x%02x but got 0x%02x\n", Resp_STK_OK, buf[0]);
|
||||
return -5;
|
||||
}
|
||||
}
|
||||
|
@ -920,8 +873,8 @@ static int stk500_paged_load(const PROGRAMMER *pgm, const AVRPART *p, const AVRM
|
|||
return -1;
|
||||
if (buf[0] == Resp_STK_NOSYNC) {
|
||||
if (tries > 33) {
|
||||
avrdude_message(MSG_INFO, "\n%s: stk500_paged_load(): can't get into sync\n",
|
||||
progname);
|
||||
msg_error("\n");
|
||||
pmsg_error("cannot get into sync\n");
|
||||
return -3;
|
||||
}
|
||||
if (stk500_getsync(pgm) < 0)
|
||||
|
@ -929,9 +882,8 @@ static int stk500_paged_load(const PROGRAMMER *pgm, const AVRPART *p, const AVRM
|
|||
goto retry;
|
||||
}
|
||||
else if (buf[0] != Resp_STK_INSYNC) {
|
||||
avrdude_message(MSG_INFO, "\n%s: stk500_paged_load(): (a) protocol error, "
|
||||
"expect=0x%02x, resp=0x%02x\n",
|
||||
progname, Resp_STK_INSYNC, buf[0]);
|
||||
msg_error("\n");
|
||||
pmsg_error("protocol expects sync byte 0x%02x but got 0x%02x\n", Resp_STK_INSYNC, buf[0]);
|
||||
return -4;
|
||||
}
|
||||
|
||||
|
@ -943,17 +895,15 @@ static int stk500_paged_load(const PROGRAMMER *pgm, const AVRPART *p, const AVRM
|
|||
|
||||
if(strcmp(ldata(lfirst(pgm->id)), "mib510") == 0) {
|
||||
if (buf[0] != Resp_STK_INSYNC) {
|
||||
avrdude_message(MSG_INFO, "\n%s: stk500_paged_load(): (a) protocol error, "
|
||||
"expect=0x%02x, resp=0x%02x\n",
|
||||
progname, Resp_STK_INSYNC, buf[0]);
|
||||
msg_error("\n");
|
||||
pmsg_error("protocol expects sync byte 0x%02x but got 0x%02x\n", Resp_STK_INSYNC, buf[0]);
|
||||
return -5;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (buf[0] != Resp_STK_OK) {
|
||||
avrdude_message(MSG_INFO, "\n%s: stk500_paged_load(): (b) protocol error, "
|
||||
"expect=0x%02x, resp=0x%02x\n",
|
||||
progname, Resp_STK_OK, buf[0]);
|
||||
msg_error("\n");
|
||||
pmsg_error("protocol expects OK byte 0x%02x but got 0x%02x\n", Resp_STK_OK, buf[0]);
|
||||
return -5;
|
||||
}
|
||||
}
|
||||
|
@ -969,16 +919,13 @@ static int stk500_set_vtarget(const PROGRAMMER *pgm, double v) {
|
|||
utarg = (unsigned)((v + 0.049) * 10);
|
||||
|
||||
if (stk500_getparm(pgm, Parm_STK_VADJUST, &uaref) != 0) {
|
||||
avrdude_message(MSG_INFO, "%s: stk500_set_vtarget(): cannot obtain V[aref]\n",
|
||||
progname);
|
||||
pmsg_error("cannot obtain V[aref]\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (uaref > utarg) {
|
||||
avrdude_message(MSG_INFO, "%s: stk500_set_vtarget(): reducing V[aref] from %.1f to %.1f\n",
|
||||
progname, uaref / 10.0, v);
|
||||
if (stk500_setparm(pgm, Parm_STK_VADJUST, utarg)
|
||||
!= 0)
|
||||
pmsg_error("reducing V[aref] from %.1f to %.1f\n", uaref / 10.0, v);
|
||||
if (stk500_setparm(pgm, Parm_STK_VADJUST, utarg) != 0)
|
||||
return -1;
|
||||
}
|
||||
return stk500_setparm(pgm, Parm_STK_VTARGET, utarg);
|
||||
|
@ -993,15 +940,13 @@ static int stk500_set_varef(const PROGRAMMER *pgm, unsigned int chan /* unused *
|
|||
uaref = (unsigned)((v + 0.049) * 10);
|
||||
|
||||
if (stk500_getparm(pgm, Parm_STK_VTARGET, &utarg) != 0) {
|
||||
avrdude_message(MSG_INFO, "%s: stk500_set_varef(): cannot obtain V[target]\n",
|
||||
progname);
|
||||
pmsg_error("cannot obtain V[target]\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (uaref > utarg) {
|
||||
avrdude_message(MSG_INFO, "%s: stk500_set_varef(): V[aref] must not be greater than "
|
||||
"V[target] = %.1f\n",
|
||||
progname, utarg / 10.0);
|
||||
pmsg_error("V[aref] must not be greater than "
|
||||
"V[target] = %.1f\n", utarg/10.0);
|
||||
return -1;
|
||||
}
|
||||
return stk500_setparm(pgm, Parm_STK_VADJUST, uaref);
|
||||
|
@ -1028,8 +973,7 @@ static int stk500_set_fosc(const PROGRAMMER *pgm, double v) {
|
|||
unit = "kHz";
|
||||
} else
|
||||
unit = "Hz";
|
||||
avrdude_message(MSG_INFO, "%s: stk500_set_fosc(): f = %.3f %s too high, using %.3f MHz\n",
|
||||
progname, v, unit, STK500_XTAL / 2e6);
|
||||
pmsg_warning("f = %.3f %s too high, using %.3f MHz\n", v, unit, STK500_XTAL/2e6);
|
||||
fosc = STK500_XTAL / 2;
|
||||
} else
|
||||
fosc = (unsigned) v;
|
||||
|
@ -1043,8 +987,7 @@ static int stk500_set_fosc(const PROGRAMMER *pgm, double v) {
|
|||
}
|
||||
}
|
||||
if (idx == sizeof(ps) / sizeof(ps[0])) {
|
||||
avrdude_message(MSG_INFO, "%s: stk500_set_fosc(): f = %u Hz too low, %u Hz min\n",
|
||||
progname, fosc, STK500_XTAL / (256 * 1024 * 2));
|
||||
pmsg_warning("f = %u Hz too low, %u Hz min\n", fosc, STK500_XTAL / (256 * 1024 * 2));
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
@ -1074,12 +1017,12 @@ static int stk500_set_sck_period(const PROGRAMMER *pgm, double v) {
|
|||
|
||||
if (v < min) {
|
||||
dur = 1;
|
||||
avrdude_message(MSG_INFO, "%s: stk500_set_sck_period(): p = %.1f us too small, using %.1f us\n",
|
||||
progname, v / 1e-6, dur * min / 1e-6);
|
||||
pmsg_warning("p = %.1f us too small, using %.1f us\n",
|
||||
v/1e-6, dur*min/1e-6);
|
||||
} else if (v > max) {
|
||||
dur = 255;
|
||||
avrdude_message(MSG_INFO, "%s: stk500_set_sck_period(): p = %.1f us too large, using %.1f us\n",
|
||||
progname, v / 1e-6, dur * min / 1e-6);
|
||||
pmsg_warning("p = %.1f us too large, using %.1f us\n",
|
||||
v/1e-6, dur*min/1e-6);
|
||||
}
|
||||
|
||||
return stk500_setparm(pgm, Parm_STK_SCK_DURATION, dur);
|
||||
|
@ -1103,8 +1046,8 @@ static int stk500_getparm(const PROGRAMMER *pgm, unsigned parm, unsigned *value)
|
|||
return -1;
|
||||
if (buf[0] == Resp_STK_NOSYNC) {
|
||||
if (tries > 33) {
|
||||
avrdude_message(MSG_INFO, "\n%s: stk500_getparm(): can't get into sync\n",
|
||||
progname);
|
||||
msg_error("\n");
|
||||
pmsg_error("cannot get into sync\n");
|
||||
return -1;
|
||||
}
|
||||
if (stk500_getsync(pgm) < 0)
|
||||
|
@ -1112,9 +1055,8 @@ static int stk500_getparm(const PROGRAMMER *pgm, unsigned parm, unsigned *value)
|
|||
goto retry;
|
||||
}
|
||||
else if (buf[0] != Resp_STK_INSYNC) {
|
||||
avrdude_message(MSG_INFO, "\n%s: stk500_getparm(): (a) protocol error, "
|
||||
"expect=0x%02x, resp=0x%02x\n",
|
||||
progname, Resp_STK_INSYNC, buf[0]);
|
||||
msg_error("\n");
|
||||
pmsg_error("protocol expects sync byte 0x%02x but got 0x%02x\n", Resp_STK_INSYNC, buf[0]);
|
||||
return -2;
|
||||
}
|
||||
|
||||
|
@ -1125,14 +1067,13 @@ static int stk500_getparm(const PROGRAMMER *pgm, unsigned parm, unsigned *value)
|
|||
if (stk500_recv(pgm, buf, 1) < 0)
|
||||
return -1;
|
||||
if (buf[0] == Resp_STK_FAILED) {
|
||||
avrdude_message(MSG_INFO, "\n%s: stk500_getparm(): parameter 0x%02x failed\n",
|
||||
progname, v);
|
||||
msg_error("\n");
|
||||
pmsg_error("parameter 0x%02x failed\n", v);
|
||||
return -3;
|
||||
}
|
||||
else if (buf[0] != Resp_STK_OK) {
|
||||
avrdude_message(MSG_INFO, "\n%s: stk500_getparm(): (b) protocol error, "
|
||||
"expect=0x%02x, resp=0x%02x\n",
|
||||
progname, Resp_STK_OK, buf[0]);
|
||||
msg_error("\n");
|
||||
pmsg_error("protocol expects OK byte 0x%02x but got 0x%02x\n", Resp_STK_OK, buf[0]);
|
||||
return -3;
|
||||
}
|
||||
|
||||
|
@ -1159,8 +1100,8 @@ static int stk500_setparm(const PROGRAMMER *pgm, unsigned parm, unsigned value)
|
|||
return -1;
|
||||
if (buf[0] == Resp_STK_NOSYNC) {
|
||||
if (tries > 33) {
|
||||
avrdude_message(MSG_INFO, "\n%s: stk500_setparm(): can't get into sync\n",
|
||||
progname);
|
||||
msg_error("\n");
|
||||
pmsg_error("cannot get into sync\n");
|
||||
return -1;
|
||||
}
|
||||
if (stk500_getsync(pgm) < 0)
|
||||
|
@ -1168,9 +1109,8 @@ static int stk500_setparm(const PROGRAMMER *pgm, unsigned parm, unsigned value)
|
|||
goto retry;
|
||||
}
|
||||
else if (buf[0] != Resp_STK_INSYNC) {
|
||||
avrdude_message(MSG_INFO, "\n%s: stk500_setparm(): (a) protocol error, "
|
||||
"expect=0x%02x, resp=0x%02x\n",
|
||||
progname, Resp_STK_INSYNC, buf[0]);
|
||||
msg_error("\n");
|
||||
pmsg_error("protocol expects sync byte 0x%02x but got 0x%02x\n", Resp_STK_INSYNC, buf[0]);
|
||||
return -2;
|
||||
}
|
||||
|
||||
|
@ -1183,14 +1123,13 @@ static int stk500_setparm(const PROGRAMMER *pgm, unsigned parm, unsigned value)
|
|||
if (stk500_recv(pgm, buf, 1) < 0)
|
||||
return -1;
|
||||
if (buf[0] == Resp_STK_FAILED) {
|
||||
avrdude_message(MSG_INFO, "\n%s: stk500_setparm(): parameter 0x%02x failed\n",
|
||||
progname, parm);
|
||||
msg_error("\n");
|
||||
pmsg_error("parameter 0x%02x failed\n", parm);
|
||||
return -3;
|
||||
}
|
||||
else {
|
||||
avrdude_message(MSG_INFO, "\n%s: stk500_setparm(): (b) protocol error, "
|
||||
"expect=0x%02x, resp=0x%02x\n",
|
||||
progname, Resp_STK_OK, buf[0]);
|
||||
msg_error("\n");
|
||||
pmsg_error("protocol expects OK byte 0x%02x but got 0x%02x\n", Resp_STK_OK, buf[0]);
|
||||
return -3;
|
||||
}
|
||||
}
|
||||
|
@ -1204,8 +1143,8 @@ static void stk500_display(const PROGRAMMER *pgm, const char *p) {
|
|||
stk500_getparm(pgm, Parm_STK_SW_MINOR, &min);
|
||||
stk500_getparm(pgm, Param_STK500_TOPCARD_DETECT, &topcard);
|
||||
|
||||
avrdude_message(MSG_INFO, "%sHardware Version: %d\n", p, hdw);
|
||||
avrdude_message(MSG_INFO, "%sFirmware Version: %d.%d\n", p, maj, min);
|
||||
msg_info("%sHardware Version: %d\n", p, hdw);
|
||||
msg_info("%sFirmware Version: %d.%d\n", p, maj, min);
|
||||
if (topcard < 3) {
|
||||
const char *n = "Unknown";
|
||||
|
||||
|
@ -1218,7 +1157,7 @@ static void stk500_display(const PROGRAMMER *pgm, const char *p) {
|
|||
n = "STK501";
|
||||
break;
|
||||
}
|
||||
avrdude_message(MSG_INFO, "%sTopcard : %s\n", p, n);
|
||||
msg_info("%sTopcard : %s\n", p, n);
|
||||
}
|
||||
if(strcmp(pgm->type, "Arduino") != 0)
|
||||
stk500_print_parms1(pgm, p);
|
||||
|
@ -1236,11 +1175,11 @@ static void stk500_print_parms1(const PROGRAMMER *pgm, const char *p) {
|
|||
stk500_getparm(pgm, Parm_STK_OSC_CMATCH, &osc_cmatch);
|
||||
stk500_getparm(pgm, Parm_STK_SCK_DURATION, &sck_duration);
|
||||
|
||||
avrdude_message(MSG_INFO, "%sVtarget : %.1f V\n", p, vtarget / 10.0);
|
||||
avrdude_message(MSG_INFO, "%sVaref : %.1f V\n", p, vadjust / 10.0);
|
||||
avrdude_message(MSG_INFO, "%sOscillator : ", p);
|
||||
msg_info("%sVtarget : %.1f V\n", p, vtarget / 10.0);
|
||||
msg_info("%sVaref : %.1f V\n", p, vadjust / 10.0);
|
||||
msg_info("%sOscillator : ", p);
|
||||
if (osc_pscale == 0)
|
||||
avrdude_message(MSG_INFO, "Off\n");
|
||||
msg_info("Off\n");
|
||||
else {
|
||||
int prescale = 1;
|
||||
double f = STK500_XTAL / 2;
|
||||
|
@ -1264,10 +1203,9 @@ static void stk500_print_parms1(const PROGRAMMER *pgm, const char *p) {
|
|||
unit = "kHz";
|
||||
} else
|
||||
unit = "Hz";
|
||||
avrdude_message(MSG_INFO, "%.3f %s\n", f, unit);
|
||||
msg_info("%.3f %s\n", f, unit);
|
||||
}
|
||||
avrdude_message(MSG_INFO, "%sSCK period : %.1f us\n", p,
|
||||
sck_duration * 8.0e6 / STK500_XTAL + 0.05);
|
||||
msg_info("%sSCK period : %.1f us\n", p, sck_duration * 8.0e6 / STK500_XTAL + 0.05);
|
||||
|
||||
return;
|
||||
}
|
||||
|
@ -1280,8 +1218,7 @@ static void stk500_print_parms(const PROGRAMMER *pgm) {
|
|||
static void stk500_setup(PROGRAMMER * pgm)
|
||||
{
|
||||
if ((pgm->cookie = malloc(sizeof(struct pdata))) == 0) {
|
||||
avrdude_message(MSG_INFO, "%s: stk500_setup(): Out of memory allocating private data\n",
|
||||
progname);
|
||||
pmsg_error("out of memory allocating private data\n");
|
||||
return;
|
||||
}
|
||||
memset(pgm->cookie, 0, sizeof(struct pdata));
|
||||
|
|
|
@ -42,8 +42,7 @@ static int stk500generic_open(PROGRAMMER *pgm, const char *port) {
|
|||
stk500_initpgm(pgm);
|
||||
if (pgm->open(pgm, port) >= 0)
|
||||
{
|
||||
avrdude_message(MSG_INFO, "%s: successfully opened stk500v1 device -- please use -c stk500v1\n",
|
||||
progname);
|
||||
pmsg_info("successfully opened stk500v1 device -- please use -c stk500v1\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -52,13 +51,11 @@ static int stk500generic_open(PROGRAMMER *pgm, const char *port) {
|
|||
stk500v2_initpgm(pgm);
|
||||
if (pgm->open(pgm, port) >= 0)
|
||||
{
|
||||
avrdude_message(MSG_INFO, "%s: successfully opened stk500v2 device -- please use -c stk500v2\n",
|
||||
progname);
|
||||
pmsg_info("successfully opened stk500v2 device -- please use -c stk500v2\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
avrdude_message(MSG_INFO, "%s: cannot open either stk500v1 or stk500v2 programmer\n",
|
||||
progname);
|
||||
pmsg_error("cannot open either stk500v1 or stk500v2 programmer\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
|
536
src/stk500v2.c
536
src/stk500v2.c
File diff suppressed because it is too large
Load Diff
107
src/teensy.c
107
src/teensy.c
|
@ -127,12 +127,12 @@ static int teensy_get_bootloader_info(pdata_t* pdata, const AVRPART* p) {
|
|||
// On Linux, libhidapi does not seem to return the HID usage from the report descriptor.
|
||||
// We try to infer the board from the part information, until somebody fixes libhidapi.
|
||||
// To use this workaround, the -F option is required.
|
||||
avrdude_message(MSG_INFO, "%s: WARNING: Cannot detect board type (HID usage is 0)\n", progname);
|
||||
pmsg_error("cannot detect board type (HID usage is 0)\n");
|
||||
|
||||
AVRMEM* mem = avr_locate_mem(p, "flash");
|
||||
if (mem == NULL)
|
||||
{
|
||||
avrdude_message(MSG_INFO, "No flash memory for part %s\n", p->desc);
|
||||
pmsg_error("no flash memory defined for part %s\n", p->desc);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -147,8 +147,7 @@ static int teensy_get_bootloader_info(pdata_t* pdata, const AVRPART* p) {
|
|||
}
|
||||
else
|
||||
{
|
||||
avrdude_message(MSG_INFO, "%s: ERROR: Teensy board not supported (HID usage 0x%02X)\n",
|
||||
progname, pdata->hid_usage);
|
||||
pmsg_error("Teensy board not supported (HID usage 0x%02X)\n", pdata->hid_usage);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
@ -158,21 +157,21 @@ static int teensy_get_bootloader_info(pdata_t* pdata, const AVRPART* p) {
|
|||
|
||||
static void teensy_dump_device_info(pdata_t* pdata)
|
||||
{
|
||||
avrdude_message(MSG_NOTICE, "%s: HID usage: 0x%02X\n", progname, pdata->hid_usage);
|
||||
avrdude_message(MSG_NOTICE, "%s: Board: %s\n", progname, pdata->board);
|
||||
avrdude_message(MSG_NOTICE, "%s: Available flash size: %u\n", progname, pdata->flash_size);
|
||||
avrdude_message(MSG_NOTICE, "%s: Page size: %u\n", progname, pdata->page_size);
|
||||
avrdude_message(MSG_NOTICE, "%s: Signature: 0x%02X%02X%02X\n", progname,
|
||||
pmsg_notice("HID usage: 0x%02X\n", pdata->hid_usage);
|
||||
pmsg_notice("Board: %s\n", pdata->board);
|
||||
pmsg_notice("Available flash size: %u\n", pdata->flash_size);
|
||||
pmsg_notice("Page size: %u\n", pdata->page_size);
|
||||
pmsg_notice("Signature: 0x%02X%02X%02X\n",
|
||||
pdata->sig_bytes[0], pdata->sig_bytes[1], pdata->sig_bytes[2]);
|
||||
}
|
||||
|
||||
static int teensy_write_page(pdata_t* pdata, uint32_t address, const uint8_t* buffer, uint32_t size, bool suppress_warning)
|
||||
{
|
||||
avrdude_message(MSG_DEBUG, "%s: teensy_write_page(address=0x%06X, size=%d)\n", progname, address, size);
|
||||
pmsg_debug("teensy_write_page(address=0x%06X, size=%d)\n", address, size);
|
||||
|
||||
if (size > pdata->page_size)
|
||||
{
|
||||
avrdude_message(MSG_INFO, "%s: ERROR: Invalid page size: %u\n", progname, pdata->page_size);
|
||||
pmsg_error("invalid page size: %u\n", pdata->page_size);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -180,7 +179,7 @@ static int teensy_write_page(pdata_t* pdata, uint32_t address, const uint8_t* bu
|
|||
uint8_t* report = (uint8_t*)malloc(report_size);
|
||||
if (report == NULL)
|
||||
{
|
||||
avrdude_message(MSG_INFO, "%s: ERROR: Failed to allocate memory\n", progname);
|
||||
pmsg_error("unable to allocate memory\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -208,10 +207,7 @@ static int teensy_write_page(pdata_t* pdata, uint32_t address, const uint8_t* bu
|
|||
if (result < 0)
|
||||
{
|
||||
if (!suppress_warning)
|
||||
{
|
||||
avrdude_message(MSG_INFO, "%s: WARNING: Failed to write page: %ls\n",
|
||||
progname, hid_error(pdata->hid_handle));
|
||||
}
|
||||
pmsg_error("unable to write page: %ls\n", hid_error(pdata->hid_handle));
|
||||
|
||||
return result;
|
||||
}
|
||||
|
@ -221,7 +217,7 @@ static int teensy_write_page(pdata_t* pdata, uint32_t address, const uint8_t* bu
|
|||
|
||||
static int teensy_erase_flash(pdata_t* pdata)
|
||||
{
|
||||
avrdude_message(MSG_DEBUG, "%s: teensy_erase_flash()\n", progname);
|
||||
pmsg_debug("teensy_erase_flash()\n");
|
||||
|
||||
// Write a dummy page at address 0 to explicitly erase the flash.
|
||||
return teensy_write_page(pdata, 0, NULL, 0, false);
|
||||
|
@ -229,7 +225,7 @@ static int teensy_erase_flash(pdata_t* pdata)
|
|||
|
||||
static int teensy_reboot(pdata_t* pdata)
|
||||
{
|
||||
avrdude_message(MSG_DEBUG, "%s: teensy_reboot()\n", progname);
|
||||
pmsg_debug("teensy_reboot()\n");
|
||||
|
||||
// Write a dummy page at address -1 to reboot the Teensy.
|
||||
return teensy_write_page(pdata, 0xFFFFFFFF, NULL, 0, true);
|
||||
|
@ -239,11 +235,11 @@ static int teensy_reboot(pdata_t* pdata)
|
|||
|
||||
static void teensy_setup(PROGRAMMER* pgm)
|
||||
{
|
||||
avrdude_message(MSG_DEBUG, "%s: teensy_setup()\n", progname);
|
||||
pmsg_debug("teensy_setup()\n");
|
||||
|
||||
if ((pgm->cookie = malloc(sizeof(pdata_t))) == NULL)
|
||||
{
|
||||
avrdude_message(MSG_INFO, "%s: ERROR: Failed to allocate memory\n", progname);
|
||||
pmsg_error("unable to allocate memory\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
@ -252,12 +248,12 @@ static void teensy_setup(PROGRAMMER* pgm)
|
|||
|
||||
static void teensy_teardown(PROGRAMMER* pgm)
|
||||
{
|
||||
avrdude_message(MSG_DEBUG, "%s: teensy_teardown()\n", progname);
|
||||
pmsg_debug("teensy_teardown()\n");
|
||||
free(pgm->cookie);
|
||||
}
|
||||
|
||||
static int teensy_initialize(const PROGRAMMER *pgm, const AVRPART *p) {
|
||||
avrdude_message(MSG_DEBUG, "%s: teensy_initialize()\n", progname);
|
||||
pmsg_debug("teensy_initialize()\n");
|
||||
|
||||
pdata_t* pdata = PDATA(pgm);
|
||||
|
||||
|
@ -271,15 +267,15 @@ static int teensy_initialize(const PROGRAMMER *pgm, const AVRPART *p) {
|
|||
}
|
||||
|
||||
static void teensy_display(const PROGRAMMER *pgm, const char *prefix) {
|
||||
avrdude_message(MSG_DEBUG, "%s: teensy_display()\n", progname);
|
||||
pmsg_debug("teensy_display()\n");
|
||||
}
|
||||
|
||||
static void teensy_powerup(const PROGRAMMER *pgm) {
|
||||
avrdude_message(MSG_DEBUG, "%s: teensy_powerup()\n", progname);
|
||||
pmsg_debug("teensy_powerup()\n");
|
||||
}
|
||||
|
||||
static void teensy_powerdown(const PROGRAMMER *pgm) {
|
||||
avrdude_message(MSG_DEBUG, "%s: teensy_powerdown()\n", progname);
|
||||
pmsg_debug("teensy_powerdown()\n");
|
||||
|
||||
pdata_t* pdata = PDATA(pgm);
|
||||
|
||||
|
@ -297,24 +293,24 @@ static void teensy_powerdown(const PROGRAMMER *pgm) {
|
|||
}
|
||||
|
||||
static void teensy_enable(PROGRAMMER* pgm, const AVRPART *p) {
|
||||
avrdude_message(MSG_DEBUG, "%s: teensy_enable()\n", progname);
|
||||
pmsg_debug("teensy_enable()\n");
|
||||
}
|
||||
|
||||
static void teensy_disable(const PROGRAMMER *pgm) {
|
||||
avrdude_message(MSG_DEBUG, "%s: teensy_disable()\n", progname);
|
||||
pmsg_debug("teensy_disable()\n");
|
||||
}
|
||||
|
||||
static int teensy_program_enable(const PROGRAMMER *pgm, const AVRPART *p) {
|
||||
avrdude_message(MSG_DEBUG, "%s: teensy_program_enable()\n", progname);
|
||||
pmsg_debug("teensy_program_enable()\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int teensy_read_sig_bytes(const PROGRAMMER *pgm, const AVRPART *p, const AVRMEM *mem) {
|
||||
avrdude_message(MSG_DEBUG, "%s: teensy_read_sig_bytes()\n", progname);
|
||||
pmsg_debug("teensy_read_sig_bytes()\n");
|
||||
|
||||
if (mem->size < 3)
|
||||
{
|
||||
avrdude_message(MSG_INFO, "%s: memory size too small for read_sig_bytes\n", progname);
|
||||
pmsg_error("memory size too small for read_sig_bytes\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -325,7 +321,7 @@ static int teensy_read_sig_bytes(const PROGRAMMER *pgm, const AVRPART *p, const
|
|||
}
|
||||
|
||||
static int teensy_chip_erase(const PROGRAMMER *pgm, const AVRPART *p) {
|
||||
avrdude_message(MSG_DEBUG, "%s: teensy_chip_erase()\n", progname);
|
||||
pmsg_debug("teensy_chip_erase()\n");
|
||||
|
||||
pdata_t* pdata = PDATA(pgm);
|
||||
|
||||
|
@ -336,7 +332,7 @@ static int teensy_chip_erase(const PROGRAMMER *pgm, const AVRPART *p) {
|
|||
}
|
||||
|
||||
static int teensy_open(PROGRAMMER *pgm, const char *port) {
|
||||
avrdude_message(MSG_DEBUG, "%s: teensy_open(\"%s\")\n", progname, port);
|
||||
pmsg_debug("teensy_open(\"%s\")\n", port);
|
||||
|
||||
pdata_t* pdata = PDATA(pgm);
|
||||
const char *bus_name = NULL;
|
||||
|
@ -364,8 +360,8 @@ static int teensy_open(PROGRAMMER *pgm, const char *port) {
|
|||
|
||||
if (port != NULL && dev_name == NULL)
|
||||
{
|
||||
avrdude_message(MSG_INFO, "%s: ERROR: Invalid -P value: '%s'\n", progname, port);
|
||||
avrdude_message(MSG_INFO, "%sUse -P usb:bus:device\n", progbuf);
|
||||
pmsg_error("invalid -P value: '%s'\n", port);
|
||||
imsg_error("Use -P usb:bus:device\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -379,8 +375,7 @@ static int teensy_open(PROGRAMMER *pgm, const char *port) {
|
|||
pid = *(int*)(ldata(usbpid));
|
||||
if (lnext(usbpid))
|
||||
{
|
||||
avrdude_message(MSG_INFO, "%s: WARNING: using PID 0x%04x, ignoring remaining PIDs in list\n",
|
||||
progname, pid);
|
||||
pmsg_error("using PID 0x%04x, ignoring remaining PIDs in list\n", pid);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -400,7 +395,7 @@ static int teensy_open(PROGRAMMER *pgm, const char *port) {
|
|||
pdata->hid_handle = hid_open_path(device->path);
|
||||
if (pdata->hid_handle == NULL)
|
||||
{
|
||||
avrdude_message(MSG_INFO, "%s: ERROR: Found HID device, but hid_open_path() failed.\n", progname);
|
||||
pmsg_error("found HID device, but hid_open_path() failed\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -420,16 +415,15 @@ static int teensy_open(PROGRAMMER *pgm, const char *port) {
|
|||
{
|
||||
if (pdata->wait_timout < 0)
|
||||
{
|
||||
avrdude_message(MSG_INFO, "%s: No device found, waiting for device to be plugged in...\n", progname);
|
||||
pmsg_error("no device found, waiting for device to be plugged in ...\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
avrdude_message(MSG_INFO, "%s: No device found, waiting %d seconds for device to be plugged in...\n",
|
||||
progname,
|
||||
pmsg_error("no device found, waiting %d seconds for device to be plugged in ...\n",
|
||||
pdata->wait_timout);
|
||||
}
|
||||
|
||||
avrdude_message(MSG_INFO, "%s: Press CTRL-C to terminate.\n", progname);
|
||||
pmsg_error("press CTRL-C to terminate\n");
|
||||
show_retry_message = false;
|
||||
}
|
||||
|
||||
|
@ -445,8 +439,7 @@ static int teensy_open(PROGRAMMER *pgm, const char *port) {
|
|||
|
||||
if (!pdata->hid_handle)
|
||||
{
|
||||
avrdude_message(MSG_INFO, "%s: ERROR: Could not find device with Teensy bootloader (%04X:%04X)\n",
|
||||
progname, vid, pid);
|
||||
pmsg_error("cannot find device with Teensy bootloader (%04X:%04X)\n", vid, pid);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -455,7 +448,7 @@ static int teensy_open(PROGRAMMER *pgm, const char *port) {
|
|||
|
||||
static void teensy_close(PROGRAMMER* pgm)
|
||||
{
|
||||
avrdude_message(MSG_DEBUG, "%s: teensy_close()\n", progname);
|
||||
pmsg_debug("teensy_close()\n");
|
||||
|
||||
pdata_t* pdata = PDATA(pgm);
|
||||
if (pdata->hid_handle != NULL)
|
||||
|
@ -468,8 +461,7 @@ static void teensy_close(PROGRAMMER* pgm)
|
|||
static int teensy_read_byte(const PROGRAMMER *pgm, const AVRPART *p, const AVRMEM *mem,
|
||||
unsigned long addr, unsigned char* value)
|
||||
{
|
||||
avrdude_message(MSG_DEBUG, "%s: teensy_read_byte(desc=%s, addr=0x%0X)\n",
|
||||
progname, mem->desc, addr);
|
||||
pmsg_debug("teensy_read_byte(desc=%s, addr=0x%04lX)\n", mem->desc, addr);
|
||||
|
||||
if (strcmp(mem->desc, "lfuse") == 0 ||
|
||||
strcmp(mem->desc, "hfuse") == 0 ||
|
||||
|
@ -481,7 +473,7 @@ static int teensy_read_byte(const PROGRAMMER *pgm, const AVRPART *p, const AVRME
|
|||
}
|
||||
else
|
||||
{
|
||||
avrdude_message(MSG_INFO, "%s: Unsupported memory type: %s\n", progname, mem->desc);
|
||||
pmsg_error("unsupported memory type: %s\n", mem->desc);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
@ -489,8 +481,7 @@ static int teensy_read_byte(const PROGRAMMER *pgm, const AVRPART *p, const AVRME
|
|||
static int teensy_write_byte(const PROGRAMMER *pgm, const AVRPART *p, const AVRMEM *mem,
|
||||
unsigned long addr, unsigned char value)
|
||||
{
|
||||
avrdude_message(MSG_DEBUG, "%s: teensy_write_byte(desc=%s, addr=0x%0X)\n",
|
||||
progname, mem->desc, addr);
|
||||
pmsg_debug("teensy_write_byte(desc=%s, addr=0x%04lX)\n", mem->desc, addr);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -498,8 +489,7 @@ static int teensy_paged_load(const PROGRAMMER *pgm, const AVRPART *p, const AVRM
|
|||
unsigned int page_size,
|
||||
unsigned int addr, unsigned int n_bytes)
|
||||
{
|
||||
avrdude_message(MSG_DEBUG, "%s: teensy_paged_load(page_size=0x%X, addr=0x%X, n_bytes=0x%X)\n",
|
||||
progname, page_size, addr, n_bytes);
|
||||
pmsg_debug("teensy_paged_load(page_size=0x%X, addr=0x%X, n_bytes=0x%X)\n", page_size, addr, n_bytes);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -507,8 +497,7 @@ static int teensy_paged_write(const PROGRAMMER *pgm, const AVRPART *p, const AVR
|
|||
unsigned int page_size,
|
||||
unsigned int addr, unsigned int n_bytes)
|
||||
{
|
||||
avrdude_message(MSG_DEBUG, "%s: teensy_paged_write(page_size=0x%X, addr=0x%X, n_bytes=0x%X)\n",
|
||||
progname, page_size, addr, n_bytes);
|
||||
pmsg_debug("teensy_paged_write(page_size=0x%X, addr=0x%X, n_bytes=0x%X)\n", page_size, addr, n_bytes);
|
||||
|
||||
if (strcmp(mem->desc, "flash") == 0)
|
||||
{
|
||||
|
@ -516,13 +505,13 @@ static int teensy_paged_write(const PROGRAMMER *pgm, const AVRPART *p, const AVR
|
|||
|
||||
if (n_bytes > page_size)
|
||||
{
|
||||
avrdude_message(MSG_INFO, "%s: Buffer size (%u) exceeds page size (%u)\n", progname, n_bytes, page_size);
|
||||
pmsg_error("buffer size %u exceeds page size %u\n", n_bytes, page_size);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (addr + n_bytes > pdata->flash_size)
|
||||
{
|
||||
avrdude_message(MSG_INFO, "%s: Program size (%u) exceeds flash size (%u)\n", progname, addr + n_bytes, pdata->flash_size);
|
||||
pmsg_error("program size %u exceeds flash size %u\n", addr + n_bytes, pdata->flash_size);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -555,13 +544,13 @@ static int teensy_paged_write(const PROGRAMMER *pgm, const AVRPART *p, const AVR
|
|||
}
|
||||
else
|
||||
{
|
||||
avrdude_message(MSG_INFO, "%s: Unsupported memory type: %s\n", progname, mem->desc);
|
||||
pmsg_error("unsupported memory type: %s\n", mem->desc);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
static int teensy_parseextparams(const PROGRAMMER *pgm, const LISTID xparams) {
|
||||
avrdude_message(MSG_DEBUG, "%s: teensy_parseextparams()\n", progname);
|
||||
pmsg_debug("teensy_parseextparams()\n");
|
||||
|
||||
pdata_t* pdata = PDATA(pgm);
|
||||
for (LNODEID node = lfirst(xparams); node != NULL; node = lnext(node))
|
||||
|
@ -580,7 +569,7 @@ static int teensy_parseextparams(const PROGRAMMER *pgm, const LISTID xparams) {
|
|||
}
|
||||
else
|
||||
{
|
||||
avrdude_message(MSG_INFO, "%s: Invalid extended parameter '%s'\n", progname, param);
|
||||
pmsg_error("invalid extended parameter '%s'\n", param);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
@ -616,7 +605,7 @@ void teensy_initpgm(PROGRAMMER *pgm) {
|
|||
|
||||
// Give a proper error if we were not compiled with libhidapi
|
||||
static int teensy_nousb_open(PROGRAMMER *pgm, const char *name) {
|
||||
avrdude_message(MSG_INFO, "%s: error: No HID support. Please compile again with libhidapi installed.\n", progname);
|
||||
pmsg_error("no HID support; please compile again with libhidapi installed\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
|
29
src/term.c
29
src/term.c
|
@ -202,7 +202,7 @@ static int hexdump_buf(FILE *f, int startaddr, unsigned char *buf, int len) {
|
|||
n = len;
|
||||
hexdump_line(dst1, p, n, 48);
|
||||
chardump_line(dst2, p, n, 16);
|
||||
fprintf(stdout, "%04x %s |%s|\n", addr, dst1, dst2);
|
||||
fprintf(f, "%04x %s |%s|\n", addr, dst1, dst2);
|
||||
len -= n;
|
||||
addr += n;
|
||||
p += n;
|
||||
|
@ -806,7 +806,7 @@ static int cmd_pgerase(PROGRAMMER *pgm, AVRPART *p, int argc, char *argv[]) {
|
|||
|
||||
// terminal_message(MSG_INFO, "%s: %s page erase 0x%05x\n", progname, mem->desc, addr & ~(mem->page_size-1));
|
||||
if(pgm->page_erase_cached(pgm, p, mem, (unsigned int) addr) < 0) {
|
||||
terminal_message(MSG_INFO, "%s (pgerase): %s page at 0x%05x could not be erased\n",
|
||||
terminal_message(MSG_INFO, "%s (pgerase): unable to erase %s page at 0x%05x\n",
|
||||
progname, mem->desc, addr);
|
||||
return -1;
|
||||
}
|
||||
|
@ -883,7 +883,7 @@ static int cmd_vtarg(PROGRAMMER *pgm, AVRPART *p, int argc, char *argv[]) {
|
|||
return -1;
|
||||
}
|
||||
if ((rc = pgm->set_vtarget(pgm, v)) != 0) {
|
||||
terminal_message(MSG_INFO, "%s (vtarg): failed to set V[target] (rc = %d)\n",
|
||||
terminal_message(MSG_INFO, "%s (vtarg): unable to set V[target] (rc = %d)\n",
|
||||
progname, rc);
|
||||
return -3;
|
||||
}
|
||||
|
@ -915,7 +915,7 @@ static int cmd_fosc(PROGRAMMER *pgm, AVRPART *p, int argc, char *argv[]) {
|
|||
else if (*endp == 'k' || *endp == 'K')
|
||||
v *= 1e3;
|
||||
if ((rc = pgm->set_fosc(pgm, v)) != 0) {
|
||||
terminal_message(MSG_INFO, "%s (fosc): failed to set oscillator frequency (rc = %d)\n",
|
||||
terminal_message(MSG_INFO, "%s (fosc): unable to set oscillator frequency (rc = %d)\n",
|
||||
progname, rc);
|
||||
return -3;
|
||||
}
|
||||
|
@ -940,7 +940,7 @@ static int cmd_sck(PROGRAMMER *pgm, AVRPART *p, int argc, char *argv[]) {
|
|||
}
|
||||
v *= 1e-6; /* Convert from microseconds to seconds. */
|
||||
if ((rc = pgm->set_sck_period(pgm, v)) != 0) {
|
||||
terminal_message(MSG_INFO, "%s (sck): failed to set SCK period (rc = %d)\n",
|
||||
terminal_message(MSG_INFO, "%s (sck): unable to set SCK period (rc = %d)\n",
|
||||
progname, rc);
|
||||
return -3;
|
||||
}
|
||||
|
@ -981,7 +981,7 @@ static int cmd_varef(PROGRAMMER *pgm, AVRPART *p, int argc, char *argv[]) {
|
|||
}
|
||||
}
|
||||
if ((rc = pgm->set_varef(pgm, chan, v)) != 0) {
|
||||
terminal_message(MSG_INFO, "%s (varef): failed to set V[aref] (rc = %d)\n",
|
||||
terminal_message(MSG_INFO, "%s (varef): unable to set V[aref] (rc = %d)\n",
|
||||
progname, rc);
|
||||
return -3;
|
||||
}
|
||||
|
@ -1223,7 +1223,7 @@ char *terminal_get_input(const char *prompt) {
|
|||
return input;
|
||||
#else
|
||||
char input[256];
|
||||
printf("%s", prompt);
|
||||
fprintf(stdout, "%s", prompt);
|
||||
if (fgets(input, sizeof(input), stdin))
|
||||
{
|
||||
/* FIXME: readline strips the '\n', should this too? */
|
||||
|
@ -1309,7 +1309,7 @@ static void update_progress_tty(int percent, double etime, const char *hdr, int
|
|||
setvbuf(stderr, (char *) NULL, _IONBF, 0);
|
||||
|
||||
if(hdr) {
|
||||
avrdude_message(MSG_INFO, "\n");
|
||||
msg_info("\n");
|
||||
last = done = 0;
|
||||
if(header)
|
||||
free(header);
|
||||
|
@ -1330,11 +1330,10 @@ static void update_progress_tty(int percent, double etime, const char *hdr, int
|
|||
hashes[i/2] = '#';
|
||||
hashes[50] = 0;
|
||||
|
||||
avrdude_message(MSG_INFO, "\r%s | %s | %d%% %0.2fs",
|
||||
header, hashes, showperc, etime);
|
||||
msg_info("\r%s | %s | %d%% %0.2fs", header, hashes, showperc, etime);
|
||||
if(percent == 100) {
|
||||
if(finish)
|
||||
avrdude_message(MSG_INFO, "\n\n");
|
||||
msg_info("\n\n");
|
||||
done = 1;
|
||||
}
|
||||
}
|
||||
|
@ -1351,18 +1350,18 @@ static void update_progress_no_tty(int percent, double etime, const char *hdr, i
|
|||
percent = percent > 100? 100: percent < 0? 0: percent;
|
||||
|
||||
if(hdr) {
|
||||
avrdude_message(MSG_INFO, "\n%s | ", hdr);
|
||||
msg_info("\n%s | ", hdr);
|
||||
last = done = 0;
|
||||
}
|
||||
|
||||
if(!done) {
|
||||
for(int cnt = percent/2; cnt > last/2; cnt--)
|
||||
avrdude_message(MSG_INFO, finish >= 0? "#": "-");
|
||||
msg_info(finish >= 0? "#": "-");
|
||||
|
||||
if(percent == 100) {
|
||||
avrdude_message(MSG_INFO, " | %d%% %0.2fs", etime, finish >= 0? 100: last);
|
||||
msg_info(" | %d%% %0.2fs", finish >= 0? 100: last, etime);
|
||||
if(finish)
|
||||
avrdude_message(MSG_INFO, "\n\n");
|
||||
msg_info("\n\n");
|
||||
done = 1;
|
||||
}
|
||||
}
|
||||
|
|
150
src/update.c
150
src/update.c
|
@ -69,9 +69,8 @@ UPDATE * parse_op(char * s)
|
|||
upd->op = DEVICE_VERIFY;
|
||||
}
|
||||
else {
|
||||
avrdude_message(MSG_INFO, "%s: invalid I/O mode '%c' in update specification\n",
|
||||
progname, *p);
|
||||
avrdude_message(MSG_INFO, " allowed values are:\n"
|
||||
pmsg_error("invalid I/O mode '%c' in update specification\n", *p);
|
||||
msg_error(" allowed values are:\n"
|
||||
" r = read device\n"
|
||||
" w = write device\n"
|
||||
" v = verify device\n");
|
||||
|
@ -83,7 +82,7 @@ UPDATE * parse_op(char * s)
|
|||
p++;
|
||||
|
||||
if (*p != ':') {
|
||||
avrdude_message(MSG_INFO, "%s: invalid update specification\n", progname);
|
||||
pmsg_error("invalid update specification\n");
|
||||
free(upd->memtype);
|
||||
free(upd);
|
||||
return NULL;
|
||||
|
@ -128,8 +127,7 @@ UPDATE * parse_op(char * s)
|
|||
case 'h': upd->format = FMT_HEX; break;
|
||||
case 'o': upd->format = FMT_OCT; break;
|
||||
default:
|
||||
avrdude_message(MSG_INFO, "%s: invalid file format '%s' in update specifier\n",
|
||||
progname, p);
|
||||
pmsg_error("invalid file format '%s' in update specifier\n", p);
|
||||
free(upd->memtype);
|
||||
free(upd);
|
||||
return NULL;
|
||||
|
@ -195,14 +193,12 @@ int memstats(struct avrpart *p, char *memtype, int size, Filestats *fsp) {
|
|||
AVRMEM *mem = avr_locate_mem(p, memtype);
|
||||
|
||||
if(!mem) {
|
||||
avrdude_message(MSG_INFO, "%s: %s %s undefined\n",
|
||||
progname, p->desc, memtype);
|
||||
pmsg_error("%s %s undefined\n", p->desc, memtype);
|
||||
return LIBAVRDUDE_GENERAL_FAILURE;
|
||||
}
|
||||
|
||||
if(!mem->buf || !mem->tags) {
|
||||
avrdude_message(MSG_INFO, "%s: %s %s is not set\n",
|
||||
progname, p->desc, memtype);
|
||||
pmsg_error("%s %s is not set\n", p->desc, memtype);
|
||||
return LIBAVRDUDE_GENERAL_FAILURE;
|
||||
}
|
||||
|
||||
|
@ -211,8 +207,7 @@ int memstats(struct avrpart *p, char *memtype, int size, Filestats *fsp) {
|
|||
pgsize = 1;
|
||||
|
||||
if(size < 0 || size > mem->size) {
|
||||
avrdude_message(MSG_INFO, "%s: memstats() size %d at odds with %s %s size %d\n",
|
||||
progname, size, p->desc, memtype, mem->size);
|
||||
pmsg_error("size %d at odds with %s %s size %d\n", size, p->desc, memtype, mem->size);
|
||||
return LIBAVRDUDE_GENERAL_FAILURE;
|
||||
}
|
||||
|
||||
|
@ -338,13 +333,14 @@ int update_is_readable(const char *fn) {
|
|||
|
||||
|
||||
static void ioerror(const char *iotype, UPDATE *upd) {
|
||||
avrdude_message(MSG_INFO, "%s: file %s is not %s",
|
||||
progname, update_outname(upd->filename), iotype);
|
||||
if(errno)
|
||||
avrdude_message(MSG_INFO, ". %s", strerror(errno));
|
||||
int errnocp = errno;
|
||||
|
||||
pmsg_ext_error("file %s is not %s", update_outname(upd->filename), iotype);
|
||||
if(errnocp)
|
||||
msg_ext_error("memstats(): %s", strerror(errnocp));
|
||||
else if(upd->filename && *upd->filename)
|
||||
avrdude_message(MSG_INFO, " (not a regular or character file?)");
|
||||
avrdude_message(MSG_INFO, "\n");
|
||||
msg_ext_error(" (not a regular or character file?)");
|
||||
msg_ext_error("\n");
|
||||
}
|
||||
|
||||
// Basic checks to reveal serious failure before programming
|
||||
|
@ -359,7 +355,7 @@ int update_dryrun(struct avrpart *p, UPDATE *upd) {
|
|||
* but accept when the specific part does not have it (allow unifying i/faces)
|
||||
*/
|
||||
if(!avr_mem_might_be_known(upd->memtype)) {
|
||||
avrdude_message(MSG_INFO, "%s: unknown memory type %s\n", progname, upd->memtype);
|
||||
pmsg_error("unknown memory type %s\n", upd->memtype);
|
||||
ret = LIBAVRDUDE_GENERAL_FAILURE;
|
||||
} else if(p && !avr_locate_mem(p, upd->memtype))
|
||||
ret = LIBAVRDUDE_SOFTFAIL;
|
||||
|
@ -384,19 +380,18 @@ int update_dryrun(struct avrpart *p, UPDATE *upd) {
|
|||
|
||||
if(!known && upd->format == FMT_AUTO) {
|
||||
if(!strcmp(upd->filename, "-")) {
|
||||
avrdude_message(MSG_INFO, "%s: can't auto detect file format for stdin/out, "
|
||||
"specify explicitly\n", progname);
|
||||
pmsg_error("cannot auto detect file format for stdin/out, "
|
||||
"specify explicitly\n");
|
||||
ret = LIBAVRDUDE_GENERAL_FAILURE;
|
||||
} else if((format_detect = fileio_fmt_autodetect(upd->filename)) < 0) {
|
||||
avrdude_message(MSG_INFO, "%s: can't determine file format for %s, specify explicitly\n",
|
||||
progname, upd->filename);
|
||||
pmsg_error("cannot determine file format for %s, specify explicitly\n", upd->filename);
|
||||
ret = LIBAVRDUDE_GENERAL_FAILURE;
|
||||
} else {
|
||||
// Set format now, no need to repeat auto detection later
|
||||
upd->format = format_detect;
|
||||
if(quell_progress < 2)
|
||||
avrdude_message(MSG_NOTICE, "%s: %s file %s auto detected as %s\n",
|
||||
progname, upd->op == DEVICE_READ? "output": "input", upd->filename,
|
||||
pmsg_notice("%s file %s auto detected as %s\n",
|
||||
upd->op == DEVICE_READ? "output": "input", upd->filename,
|
||||
fileio_fmtstr(upd->format));
|
||||
}
|
||||
}
|
||||
|
@ -404,8 +399,7 @@ int update_dryrun(struct avrpart *p, UPDATE *upd) {
|
|||
switch(upd->op) {
|
||||
case DEVICE_READ:
|
||||
if(upd->format == FMT_IMM) {
|
||||
avrdude_message(MSG_INFO,
|
||||
"%s: invalid file format 'immediate' for output\n", progname);
|
||||
pmsg_error("invalid file format 'immediate' for output\n");
|
||||
ret = LIBAVRDUDE_GENERAL_FAILURE;
|
||||
} else {
|
||||
errno = 0;
|
||||
|
@ -424,8 +418,7 @@ int update_dryrun(struct avrpart *p, UPDATE *upd) {
|
|||
break;
|
||||
|
||||
default:
|
||||
avrdude_message(MSG_INFO, "%s: invalid update operation (%d) requested\n",
|
||||
progname, upd->op);
|
||||
pmsg_error("invalid update operation (%d) requested\n", upd->op);
|
||||
ret = LIBAVRDUDE_GENERAL_FAILURE;
|
||||
}
|
||||
|
||||
|
@ -443,8 +436,7 @@ int do_op(PROGRAMMER * pgm, struct avrpart * p, UPDATE * upd, enum updateflags f
|
|||
|
||||
mem = avr_locate_mem(p, upd->memtype);
|
||||
if (mem == NULL) {
|
||||
avrdude_message(MSG_INFO, "%s: skipping -U %s:... as memory not defined for part %s\n",
|
||||
progname, upd->memtype, p->desc);
|
||||
pmsg_warning("skipping -U %s:... as memory not defined for part %s\n", upd->memtype, p->desc);
|
||||
return LIBAVRDUDE_SOFTFAIL;
|
||||
}
|
||||
|
||||
|
@ -459,36 +451,28 @@ int do_op(PROGRAMMER * pgm, struct avrpart * p, UPDATE * upd, enum updateflags f
|
|||
case DEVICE_READ:
|
||||
// Read out the specified device memory and write it to a file
|
||||
if (upd->format == FMT_IMM) {
|
||||
avrdude_message(MSG_INFO,
|
||||
"%s: invalid file format 'immediate' for output\n", progname);
|
||||
pmsg_error("invalid file format 'immediate' for output\n");
|
||||
return LIBAVRDUDE_GENERAL_FAILURE;
|
||||
}
|
||||
if (quell_progress < 2)
|
||||
avrdude_message(MSG_INFO, "%s: reading %s%s memory ...\n",
|
||||
progname, mem->desc, alias_mem_desc);
|
||||
pmsg_info("reading %s%s memory ...\n", mem->desc, alias_mem_desc);
|
||||
|
||||
report_progress(0, 1, "Reading");
|
||||
|
||||
rc = avr_read(pgm, p, upd->memtype, 0);
|
||||
report_progress(1, 1, NULL);
|
||||
if (rc < 0) {
|
||||
avrdude_message(MSG_INFO, "%s: failed to read all of %s%s memory, rc=%d\n",
|
||||
progname, mem->desc, alias_mem_desc, rc);
|
||||
pmsg_error("unable to read all of %s%s memory, rc=%d\n", mem->desc, alias_mem_desc, rc);
|
||||
return LIBAVRDUDE_GENERAL_FAILURE;
|
||||
}
|
||||
size = rc;
|
||||
|
||||
if (quell_progress < 2) {
|
||||
if (rc == 0)
|
||||
avrdude_message(MSG_INFO, "%s: flash is empty, resulting file has no contents\n",
|
||||
progname);
|
||||
avrdude_message(MSG_INFO, "%s: writing output file %s\n",
|
||||
progname, update_outname(upd->filename));
|
||||
}
|
||||
pmsg_notice("flash is empty, resulting file has no contents\n");
|
||||
pmsg_info("writing output file %s\n", update_outname(upd->filename));
|
||||
|
||||
rc = fileio(FIO_WRITE, upd->filename, upd->format, p, upd->memtype, size);
|
||||
if (rc < 0) {
|
||||
avrdude_message(MSG_INFO, "%s: write to file %s failed\n",
|
||||
progname, update_outname(upd->filename));
|
||||
pmsg_error("write to file %s failed\n", update_outname(upd->filename));
|
||||
return LIBAVRDUDE_GENERAL_FAILURE;
|
||||
}
|
||||
break;
|
||||
|
@ -498,42 +482,33 @@ int do_op(PROGRAMMER * pgm, struct avrpart * p, UPDATE * upd, enum updateflags f
|
|||
|
||||
rc = fileio(FIO_READ, upd->filename, upd->format, p, upd->memtype, -1);
|
||||
if (rc < 0) {
|
||||
avrdude_message(MSG_INFO, "%s: read from file %s failed\n",
|
||||
progname, update_inname(upd->filename));
|
||||
pmsg_error("read from file %s failed\n", update_inname(upd->filename));
|
||||
return LIBAVRDUDE_GENERAL_FAILURE;
|
||||
}
|
||||
size = rc;
|
||||
if (quell_progress < 2)
|
||||
avrdude_message(MSG_INFO, "%s: reading input file %s for %s%s\n",
|
||||
progname, update_inname(upd->filename), mem->desc, alias_mem_desc);
|
||||
pmsg_info("reading input file %s for %s%s\n",
|
||||
update_inname(upd->filename), mem->desc, alias_mem_desc);
|
||||
|
||||
if(memstats(p, upd->memtype, size, &fs) < 0)
|
||||
return LIBAVRDUDE_GENERAL_FAILURE;
|
||||
|
||||
if(quell_progress < 2) {
|
||||
int level = fs.nsections > 1 || fs.firstaddr > 0 || fs.ntrailing? MSG_INFO: MSG_NOTICE;
|
||||
|
||||
avrdude_message(level, "%*s with %d byte%s in %d section%s within %s\n",
|
||||
(int) strlen(progname)+1, "",
|
||||
imsg_info("with %d byte%s in %d section%s within %s\n",
|
||||
fs.nbytes, update_plural(fs.nbytes),
|
||||
fs.nsections, update_plural(fs.nsections),
|
||||
update_interval(fs.firstaddr, fs.lastaddr));
|
||||
if(mem->page_size > 1) {
|
||||
avrdude_message(level, "%*s using %d page%s and %d pad byte%s",
|
||||
(int) strlen(progname)+1, "",
|
||||
imsg_info("using %d page%s and %d pad byte%s",
|
||||
fs.npages, update_plural(fs.npages),
|
||||
fs.nfill, update_plural(fs.nfill));
|
||||
if(fs.ntrailing)
|
||||
avrdude_message(level, ", cutting off %d trailing 0xff byte%s",
|
||||
msg_info(", cutting off %d trailing 0xff byte%s",
|
||||
fs.ntrailing, update_plural(fs.ntrailing));
|
||||
avrdude_message(level, "\n");
|
||||
}
|
||||
msg_info("\n");
|
||||
}
|
||||
|
||||
// Write the buffer contents to the selected memory type
|
||||
if (quell_progress < 2)
|
||||
avrdude_message(MSG_INFO, "%s: writing %d byte%s %s%s ...\n",
|
||||
progname, fs.nbytes, update_plural(fs.nbytes), mem->desc, alias_mem_desc);
|
||||
pmsg_info("writing %d byte%s %s%s ...\n", fs.nbytes,
|
||||
update_plural(fs.nbytes), mem->desc, alias_mem_desc);
|
||||
|
||||
if (!(flags & UF_NOWRITE)) {
|
||||
report_progress(0, 1, "Writing");
|
||||
|
@ -545,14 +520,12 @@ int do_op(PROGRAMMER * pgm, struct avrpart * p, UPDATE * upd, enum updateflags f
|
|||
}
|
||||
|
||||
if (rc < 0) {
|
||||
avrdude_message(MSG_INFO, "%s: failed to write %s%s memory, rc=%d\n",
|
||||
progname, mem->desc, alias_mem_desc, rc);
|
||||
pmsg_error("unable to write %s%s memory, rc=%d\n", mem->desc, alias_mem_desc, rc);
|
||||
return LIBAVRDUDE_GENERAL_FAILURE;
|
||||
}
|
||||
|
||||
if (quell_progress < 2)
|
||||
avrdude_message(MSG_INFO, "%s: %d byte%s of %s%s written\n",
|
||||
progname, fs.nbytes, update_plural(fs.nbytes), mem->desc, alias_mem_desc);
|
||||
pmsg_info("%d byte%s of %s%s written\n", fs.nbytes,
|
||||
update_plural(fs.nbytes), mem->desc, alias_mem_desc);
|
||||
|
||||
// Fall through for (default) auto verify, ie, unless -V was specified
|
||||
if (!(flags & UF_VERIFY))
|
||||
|
@ -564,22 +537,18 @@ int do_op(PROGRAMMER * pgm, struct avrpart * p, UPDATE * upd, enum updateflags f
|
|||
|
||||
int userverify = upd->op == DEVICE_VERIFY; // Explicit -U :v by user
|
||||
|
||||
if (quell_progress < 2) {
|
||||
avrdude_message(MSG_INFO, "%s: verifying %s%s memory against %s\n",
|
||||
progname, mem->desc, alias_mem_desc, update_inname(upd->filename));
|
||||
|
||||
if (userverify)
|
||||
avrdude_message(MSG_NOTICE, "%s: load %s%s data from input file %s\n",
|
||||
progname, mem->desc, alias_mem_desc, update_inname(upd->filename));
|
||||
}
|
||||
pmsg_info("verifying %s%s memory against %s\n", mem->desc,
|
||||
alias_mem_desc, update_inname(upd->filename));
|
||||
|
||||
// No need to read file when fallen through from DEVICE_WRITE
|
||||
if (userverify) {
|
||||
pmsg_notice("load %s%s data from input file %s\n", mem->desc,
|
||||
alias_mem_desc, update_inname(upd->filename));
|
||||
|
||||
rc = fileio(FIO_READ_FOR_VERIFY, upd->filename, upd->format, p, upd->memtype, -1);
|
||||
|
||||
if (rc < 0) {
|
||||
avrdude_message(MSG_INFO, "%s: read from file %s failed\n",
|
||||
progname, update_inname(upd->filename));
|
||||
pmsg_error("read from file %s failed\n", update_inname(upd->filename));
|
||||
return LIBAVRDUDE_GENERAL_FAILURE;
|
||||
}
|
||||
size = rc;
|
||||
|
@ -595,48 +564,41 @@ int do_op(PROGRAMMER * pgm, struct avrpart * p, UPDATE * upd, enum updateflags f
|
|||
|
||||
if (quell_progress < 2) {
|
||||
if (userverify)
|
||||
avrdude_message(MSG_NOTICE, "%s: input file %s contains %d byte%s\n",
|
||||
progname, update_inname(upd->filename), fs.nbytes, update_plural(fs.nbytes));
|
||||
avrdude_message(MSG_NOTICE2, "%s: reading on-chip %s%s data ...\n",
|
||||
progname, mem->desc, alias_mem_desc);
|
||||
pmsg_notice("input file %s contains %d byte%s\n",
|
||||
update_inname(upd->filename), fs.nbytes, update_plural(fs.nbytes));
|
||||
pmsg_notice2("reading on-chip %s%s data ...\n", mem->desc, alias_mem_desc);
|
||||
}
|
||||
|
||||
report_progress (0,1,"Reading");
|
||||
rc = avr_read(pgm, p, upd->memtype, v);
|
||||
report_progress (1,1,NULL);
|
||||
if (rc < 0) {
|
||||
avrdude_message(MSG_INFO, "%s: failed to read all of %s%s memory, rc=%d\n",
|
||||
progname, mem->desc, alias_mem_desc, rc);
|
||||
pmsg_error("unable to read all of %s%s memory, rc=%d\n", mem->desc, alias_mem_desc, rc);
|
||||
pgm->err_led(pgm, ON);
|
||||
avr_free_part(v);
|
||||
return LIBAVRDUDE_GENERAL_FAILURE;
|
||||
}
|
||||
|
||||
if (quell_progress < 2)
|
||||
avrdude_message(MSG_NOTICE2, "%s: verifying ...\n", progname);
|
||||
pmsg_notice2("verifying ...\n");
|
||||
|
||||
rc = avr_verify(p, v, upd->memtype, size);
|
||||
if (rc < 0) {
|
||||
avrdude_message(MSG_INFO, "%s: verification error; content mismatch\n",
|
||||
progname);
|
||||
pmsg_error("verification mismatch\n");
|
||||
pgm->err_led(pgm, ON);
|
||||
avr_free_part(v);
|
||||
return LIBAVRDUDE_GENERAL_FAILURE;
|
||||
}
|
||||
|
||||
if (quell_progress < 2) {
|
||||
int verified = fs.nbytes+fs.ntrailing;
|
||||
avrdude_message(MSG_INFO, "%s: %d byte%s of %s%s verified\n",
|
||||
progname, verified, update_plural(verified), mem->desc, alias_mem_desc);
|
||||
}
|
||||
pmsg_info("%d byte%s of %s%s verified\n", verified, update_plural(verified), mem->desc, alias_mem_desc);
|
||||
|
||||
pgm->vfy_led(pgm, OFF);
|
||||
avr_free_part(v);
|
||||
break;
|
||||
|
||||
default:
|
||||
avrdude_message(MSG_INFO, "%s: invalid update operation (%d) requested\n",
|
||||
progname, upd->op);
|
||||
pmsg_error("invalid update operation (%d) requested\n", upd->op);
|
||||
return LIBAVRDUDE_GENERAL_FAILURE;
|
||||
}
|
||||
|
||||
|
|
138
src/updi_link.c
138
src/updi_link.c
|
@ -58,11 +58,11 @@ static int updi_physical_open(PROGRAMMER* pgm, int baudrate, unsigned long cflag
|
|||
pinfo.serialinfo.baud = baudrate;
|
||||
pinfo.serialinfo.cflags = cflags;
|
||||
|
||||
avrdude_message(MSG_DEBUG, "%s: Opening serial port...\n", progname);
|
||||
pmsg_debug("opening serial port ...\n");
|
||||
|
||||
if (serial_open(pgm->port, pinfo, &pgm->fd)==-1) {
|
||||
|
||||
avrdude_message(MSG_DEBUG, "%s: Serial port open failed!\n", progname);
|
||||
pmsg_debug("serial port open failed!\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -90,14 +90,14 @@ static int updi_physical_send(const PROGRAMMER *pgm, unsigned char *buf, size_t
|
|||
size_t i;
|
||||
int rv;
|
||||
|
||||
avrdude_message(MSG_DEBUG, "%s: Sending %lu bytes [", progname, len);
|
||||
pmsg_debug("sending %lu bytes [", len);
|
||||
for (i=0; i<len; i++) {
|
||||
avrdude_message(MSG_DEBUG, "0x%02x", buf[i]);
|
||||
msg_debug("0x%02x", buf[i]);
|
||||
if (i<len-1) {
|
||||
avrdude_message(MSG_DEBUG, ", ");
|
||||
msg_debug(", ");
|
||||
}
|
||||
}
|
||||
avrdude_message(MSG_DEBUG, "]\n");
|
||||
msg_debug("]\n");
|
||||
|
||||
rv = serial_send(&pgm->fd, buf, len);
|
||||
serial_recv(&pgm->fd, buf, len);
|
||||
|
@ -110,20 +110,18 @@ static int updi_physical_recv(const PROGRAMMER *pgm, unsigned char *buf, size_t
|
|||
|
||||
rv = serial_recv(&pgm->fd, buf, len);
|
||||
if (rv < 0) {
|
||||
avrdude_message(MSG_DEBUG,
|
||||
"%s: serialupdi_recv(): programmer is not responding\n",
|
||||
progname);
|
||||
pmsg_debug("serialupdi_recv(): programmer is not responding\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
avrdude_message(MSG_DEBUG, "%s: Received %lu bytes [", progname, len);
|
||||
pmsg_debug("received %lu bytes [", len);
|
||||
for (i=0; i<len; i++) {
|
||||
avrdude_message(MSG_DEBUG, "0x%02x", buf[i]);
|
||||
msg_debug("0x%02x", buf[i]);
|
||||
if (i<len-1) {
|
||||
avrdude_message(MSG_DEBUG, ", ");
|
||||
msg_debug(", ");
|
||||
}
|
||||
}
|
||||
avrdude_message(MSG_DEBUG, "]\n");
|
||||
msg_debug("]\n");
|
||||
|
||||
return len;
|
||||
}
|
||||
|
@ -131,7 +129,7 @@ static int updi_physical_recv(const PROGRAMMER *pgm, unsigned char *buf, size_t
|
|||
static int updi_physical_send_double_break(const PROGRAMMER *pgm) {
|
||||
unsigned char buffer[1];
|
||||
|
||||
avrdude_message(MSG_DEBUG, "%s: Sending double break\n", progname);
|
||||
pmsg_debug("sending double break\n");
|
||||
|
||||
if (serial_setparams(&pgm->fd, 300, SERIAL_8E1) < 0) {
|
||||
return -1;
|
||||
|
@ -184,7 +182,7 @@ int updi_physical_sib(const PROGRAMMER *pgm, unsigned char *buffer, uint8_t size
|
|||
send_buffer[1] = UPDI_KEY | UPDI_KEY_SIB | UPDI_SIB_32BYTES;
|
||||
|
||||
if (updi_physical_send(pgm, send_buffer, 2) < 0) {
|
||||
avrdude_message(MSG_DEBUG, "%s: SIB request send failed\n", progname);
|
||||
pmsg_debug("SIB request send failed\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -246,14 +244,14 @@ static int updi_link_check(const PROGRAMMER *pgm) {
|
|||
uint8_t value;
|
||||
result = updi_link_ldcs(pgm, UPDI_CS_STATUSA, &value);
|
||||
if (result < 0) {
|
||||
avrdude_message(MSG_DEBUG, "%s: Check failed\n", progname);
|
||||
pmsg_debug("check failed\n");
|
||||
return -1;
|
||||
} else {
|
||||
if (value > 0) {
|
||||
avrdude_message(MSG_DEBUG, "%s: UDPI init OK\n", progname);
|
||||
pmsg_debug("UDPI init OK\n");
|
||||
return 0;
|
||||
} else {
|
||||
avrdude_message(MSG_DEBUG, "%s: UDPI not OK - reinitialisation required\n", progname);
|
||||
pmsg_debug("UDPI not OK - reinitialisation required\n");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
@ -276,22 +274,22 @@ int updi_link_init(const PROGRAMMER *pgm) {
|
|||
raise PymcuprogError("UPDI initialisation failed")
|
||||
*/
|
||||
if (updi_link_init_session_parameters(pgm) < 0) {
|
||||
avrdude_message(MSG_DEBUG, "%s: Session initialisation failed\n", progname);
|
||||
pmsg_debug("session initialisation failed\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (updi_link_check(pgm) < 0) {
|
||||
avrdude_message(MSG_DEBUG, "%s: Datalink not active, resetting...\n", progname);
|
||||
pmsg_debug("datalink not active, resetting ...\n");
|
||||
if (updi_physical_send_double_break(pgm) < 0) {
|
||||
avrdude_message(MSG_DEBUG, "%s: Datalink initialisation failed\n", progname);
|
||||
pmsg_debug("datalink initialisation failed\n");
|
||||
return -1;
|
||||
}
|
||||
if (updi_link_init_session_parameters(pgm) < 0) {
|
||||
avrdude_message(MSG_DEBUG, "%s: Session initialisation failed\n", progname);
|
||||
pmsg_debug("session initialisation failed\n");
|
||||
return -1;
|
||||
}
|
||||
if (updi_link_check(pgm) < 0) {
|
||||
avrdude_message(MSG_DEBUG, "%s: Restoring datalink failed\n", progname);
|
||||
pmsg_debug("restoring datalink failed\n");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
@ -318,17 +316,17 @@ int updi_link_ldcs(const PROGRAMMER *pgm, uint8_t address, uint8_t *value) {
|
|||
*/
|
||||
unsigned char buffer[2];
|
||||
int result;
|
||||
avrdude_message(MSG_DEBUG, "%s: LDCS from 0x%02X\n", progname, address);
|
||||
pmsg_debug("LDCS from 0x%02X\n", address);
|
||||
buffer[0]=UPDI_PHY_SYNC;
|
||||
buffer[1]=UPDI_LDCS | (address & 0x0F);
|
||||
if (updi_physical_send(pgm, buffer, 2) < 0) {
|
||||
avrdude_message(MSG_DEBUG, "%s: LDCS send operation failed\n", progname);
|
||||
pmsg_debug("LDCS send operation failed\n");
|
||||
return -1;
|
||||
}
|
||||
result = updi_physical_recv(pgm, buffer, 1);
|
||||
if (result != 1) {
|
||||
if (result >= 0) {
|
||||
avrdude_message(MSG_DEBUG, "%s: Incorrect response size, received %d instead of %d bytes\n", progname, result, 1);
|
||||
pmsg_debug("incorrect response size, received %d instead of %d bytes\n", result, 1);
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
@ -349,7 +347,7 @@ int updi_link_stcs(const PROGRAMMER *pgm, uint8_t address, uint8_t value) {
|
|||
self.updi_phy.send([constants.UPDI_PHY_SYNC, constants.UPDI_STCS | (address & 0x0F), value])
|
||||
*/
|
||||
unsigned char buffer[3];
|
||||
avrdude_message(MSG_DEBUG, "%s: STCS 0x%02X to address 0x%02X\n", progname, value, address);
|
||||
pmsg_debug("STCS 0x%02X to address 0x%02X\n", value, address);
|
||||
buffer[0] = UPDI_PHY_SYNC;
|
||||
buffer[1] = UPDI_STCS | (address & 0x0F);
|
||||
buffer[2] = value;
|
||||
|
@ -371,11 +369,11 @@ int updi_link_ld_ptr_inc(const PROGRAMMER *pgm, unsigned char *buffer, uint16_t
|
|||
return self.updi_phy.receive(size)
|
||||
*/
|
||||
unsigned char send_buffer[2];
|
||||
avrdude_message(MSG_DEBUG, "%s: LD8 from ptr++\n", progname);
|
||||
pmsg_debug("LD8 from ptr++\n");
|
||||
send_buffer[0] = UPDI_PHY_SYNC;
|
||||
send_buffer[1] = UPDI_LD | UPDI_PTR_INC | UPDI_DATA_8;
|
||||
if (updi_physical_send(pgm, send_buffer, 2) < 0) {
|
||||
avrdude_message(MSG_DEBUG, "%s: LD_PTR_INC send operation failed\n", progname);
|
||||
pmsg_debug("LD_PTR_INC send operation failed\n");
|
||||
return -1;
|
||||
}
|
||||
return updi_physical_recv(pgm, buffer, size);
|
||||
|
@ -396,11 +394,11 @@ int updi_link_ld_ptr_inc16(const PROGRAMMER *pgm, unsigned char *buffer, uint16_
|
|||
return self.updi_phy.receive(words << 1)
|
||||
*/
|
||||
unsigned char send_buffer[2];
|
||||
avrdude_message(MSG_DEBUG, "%s: LD16 from ptr++\n", progname);
|
||||
pmsg_debug("LD16 from ptr++\n");
|
||||
send_buffer[0] = UPDI_PHY_SYNC;
|
||||
send_buffer[1] = UPDI_LD | UPDI_PTR_INC | UPDI_DATA_16;
|
||||
if (updi_physical_send(pgm, send_buffer, 2) < 0) {
|
||||
avrdude_message(MSG_DEBUG, "%s: LD_PTR_INC send operation failed\n", progname);
|
||||
pmsg_debug("LD_PTR_INC send operation failed\n");
|
||||
return -1;
|
||||
}
|
||||
return updi_physical_recv(pgm, buffer, words << 2);
|
||||
|
@ -435,32 +433,32 @@ int updi_link_st_ptr_inc(const PROGRAMMER *pgm, unsigned char *buffer, uint16_t
|
|||
unsigned char recv_buffer[1];
|
||||
int response;
|
||||
int num = 1;
|
||||
avrdude_message(MSG_DEBUG, "%s: ST8 to *ptr++\n", progname);
|
||||
pmsg_debug("ST8 to *ptr++\n");
|
||||
send_buffer[0] = UPDI_PHY_SYNC;
|
||||
send_buffer[1] = UPDI_ST | UPDI_PTR_INC | UPDI_DATA_8;
|
||||
send_buffer[2] = buffer[0];
|
||||
if (updi_physical_send(pgm, send_buffer, 3) < 0) {
|
||||
avrdude_message(MSG_DEBUG, "%s: ST_PTR_INC send operation failed\n", progname);
|
||||
pmsg_debug("ST_PTR_INC send operation failed\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
response = updi_physical_recv(pgm, recv_buffer, 1);
|
||||
|
||||
if (response != 1 || recv_buffer[0] != UPDI_PHY_ACK) {
|
||||
avrdude_message(MSG_DEBUG, "%s: ACK was expected but not received\n", progname);
|
||||
pmsg_debug("ACK was expected but not received\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
while (num < size) {
|
||||
send_buffer[0]=buffer[num];
|
||||
if (updi_physical_send(pgm, send_buffer, 1) < 0) {
|
||||
avrdude_message(MSG_DEBUG, "%s: ST_PTR_INC data send operation failed\n", progname);
|
||||
pmsg_debug("ST_PTR_INC data send operation failed\n");
|
||||
return -1;
|
||||
}
|
||||
response = updi_physical_recv(pgm, recv_buffer, 1);
|
||||
|
||||
if (response != 1 || recv_buffer[0] != UPDI_PHY_ACK) {
|
||||
avrdude_message(MSG_DEBUG, "%s: Data ACK was expected but not received\n", progname);
|
||||
pmsg_debug("data ACK was expected but not received\n");
|
||||
return -1;
|
||||
}
|
||||
num++;
|
||||
|
@ -498,20 +496,20 @@ int updi_link_st_ptr_inc16(const PROGRAMMER *pgm, unsigned char *buffer, uint16_
|
|||
unsigned char recv_buffer[1];
|
||||
int response;
|
||||
int num = 2;
|
||||
avrdude_message(MSG_DEBUG, "%s: ST16 to *ptr++\n", progname);
|
||||
pmsg_debug("ST16 to *ptr++\n");
|
||||
send_buffer[0] = UPDI_PHY_SYNC;
|
||||
send_buffer[1] = UPDI_ST | UPDI_PTR_INC | UPDI_DATA_16;
|
||||
send_buffer[2] = buffer[0];
|
||||
send_buffer[3] = buffer[1];
|
||||
if (updi_physical_send(pgm, send_buffer, 4) < 0) {
|
||||
avrdude_message(MSG_DEBUG, "%s: ST_PTR_INC16 send operation failed\n", progname);
|
||||
pmsg_debug("ST_PTR_INC16 send operation failed\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
response = updi_physical_recv(pgm, recv_buffer, 1);
|
||||
|
||||
if (response != 1 || recv_buffer[0] != UPDI_PHY_ACK) {
|
||||
avrdude_message(MSG_DEBUG, "%s: ACK was expected but not received\n", progname);
|
||||
pmsg_debug("ACK was expected but not received\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -519,13 +517,13 @@ int updi_link_st_ptr_inc16(const PROGRAMMER *pgm, unsigned char *buffer, uint16_
|
|||
send_buffer[0]=buffer[num];
|
||||
send_buffer[1]=buffer[num+1];
|
||||
if (updi_physical_send(pgm, send_buffer, 2) < 0) {
|
||||
avrdude_message(MSG_DEBUG, "%s: ST_PTR_INC data send operation failed\n", progname);
|
||||
pmsg_debug("ST_PTR_INC data send operation failed\n");
|
||||
return -1;
|
||||
}
|
||||
response = updi_physical_recv(pgm, recv_buffer, 1);
|
||||
|
||||
if (response != 1 || recv_buffer[0] != UPDI_PHY_ACK) {
|
||||
avrdude_message(MSG_DEBUG, "%s: Data ACK was expected but not received\n", progname);
|
||||
pmsg_debug("data ACK was expected but not received\n");
|
||||
return -1;
|
||||
}
|
||||
num+=2;
|
||||
|
@ -548,7 +546,7 @@ int updi_link_st_ptr_inc16_RSD(const PROGRAMMER *pgm, unsigned char *buffer, uin
|
|||
"""
|
||||
self.logger.debug("ST16 to *ptr++ with RSD, data length: 0x%03X in blocks of: %d", len(data), blocksize)
|
||||
|
||||
#for performance we glob everything together into one USB transfer....
|
||||
#for performance we glob everything together into one USB transfer ...
|
||||
repnumber= ((len(data) >> 1) -1)
|
||||
data = [*data, *[constants.UPDI_PHY_SYNC, constants.UPDI_STCS | constants.UPDI_CS_CTRLA, 0x06]]
|
||||
|
||||
|
@ -577,14 +575,14 @@ int updi_link_st_ptr_inc16_RSD(const PROGRAMMER *pgm, unsigned char *buffer, uin
|
|||
self.updi_phy.send(data_slice)
|
||||
num += len(data_slice)
|
||||
*/
|
||||
avrdude_message(MSG_DEBUG, "%s: ST16 to *ptr++ with RSD, data length: 0x%03X in blocks of: %d\n", progname, words * 2, blocksize);
|
||||
pmsg_debug("ST16 to *ptr++ with RSD, data length: 0x%03X in blocks of: %d\n", words * 2, blocksize);
|
||||
|
||||
unsigned int temp_buffer_size = 3 + 3 + 2 + (words * 2) + 3;
|
||||
unsigned int num=0;
|
||||
unsigned char* temp_buffer = malloc(temp_buffer_size);
|
||||
|
||||
if (temp_buffer == 0) {
|
||||
avrdude_message(MSG_DEBUG, "%s: Allocating temporary buffer failed\n", progname);
|
||||
pmsg_debug("allocating temporary buffer failed\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -609,7 +607,7 @@ int updi_link_st_ptr_inc16_RSD(const PROGRAMMER *pgm, unsigned char *buffer, uin
|
|||
|
||||
if (blocksize < 10) {
|
||||
if (updi_physical_send(pgm, temp_buffer, 6) < 0) {
|
||||
avrdude_message(MSG_DEBUG, "%s: Failed to send first package\n", progname);
|
||||
pmsg_debug("unable to send first package\n");
|
||||
free(temp_buffer);
|
||||
return -1;
|
||||
}
|
||||
|
@ -626,7 +624,7 @@ int updi_link_st_ptr_inc16_RSD(const PROGRAMMER *pgm, unsigned char *buffer, uin
|
|||
}
|
||||
|
||||
if (updi_physical_send(pgm, temp_buffer + num, next_package_size) < 0) {
|
||||
avrdude_message(MSG_DEBUG, "%s: Failed to send package\n", progname);
|
||||
pmsg_debug("unable to send package\n");
|
||||
free(temp_buffer);
|
||||
return -1;
|
||||
}
|
||||
|
@ -654,9 +652,9 @@ int updi_link_repeat(const PROGRAMMER *pgm, uint16_t repeats) {
|
|||
repeats & 0xFF])
|
||||
*/
|
||||
unsigned char buffer[3];
|
||||
avrdude_message(MSG_DEBUG, "%s: Repeat %d\n", progname, repeats);
|
||||
pmsg_debug("repeat %d\n", repeats);
|
||||
if ((repeats - 1) > UPDI_MAX_REPEAT_SIZE) {
|
||||
avrdude_message(MSG_DEBUG, "%s: Invalid repeat count of %d\n", progname, repeats);
|
||||
pmsg_debug("invalid repeat count of %d\n", repeats);
|
||||
return -1;
|
||||
}
|
||||
repeats-=1;
|
||||
|
@ -695,15 +693,15 @@ int updi_link_key(const PROGRAMMER *pgm, unsigned char *buffer, uint8_t size_typ
|
|||
unsigned char send_buffer[2];
|
||||
unsigned char reversed_key[256];
|
||||
int index;
|
||||
avrdude_message(MSG_DEBUG, "%s: UPDI writing key\n", progname);
|
||||
pmsg_debug("UPDI writing key\n");
|
||||
if (size != (8 << size_type)) {
|
||||
avrdude_message(MSG_DEBUG, "%s: Invalid key length\n", progname);
|
||||
pmsg_debug("invalid key length\n");
|
||||
return -1;
|
||||
}
|
||||
send_buffer[0] = UPDI_PHY_SYNC;
|
||||
send_buffer[1] = UPDI_KEY | UPDI_KEY_KEY | size_type;
|
||||
if (updi_physical_send(pgm, send_buffer, 2) < 0) {
|
||||
avrdude_message(MSG_DEBUG, "%s: UPDI key send message failed\n", progname);
|
||||
pmsg_debug("UPDI key send message failed\n");
|
||||
return -1;
|
||||
}
|
||||
/* reverse key contents */
|
||||
|
@ -730,18 +728,18 @@ int updi_link_ld(const PROGRAMMER *pgm, uint32_t address, uint8_t *value) {
|
|||
*/
|
||||
unsigned char send_buffer[5];
|
||||
unsigned char recv_buffer[1];
|
||||
avrdude_message(MSG_DEBUG, "%s: LD from 0x%06X\n", progname, address);
|
||||
pmsg_debug("LD from 0x%06X\n", address);
|
||||
send_buffer[0] = UPDI_PHY_SYNC;
|
||||
send_buffer[1] = UPDI_LDS | UPDI_DATA_8 | (updi_get_datalink_mode(pgm) == UPDI_LINK_MODE_24BIT ? UPDI_ADDRESS_24 : UPDI_ADDRESS_16);
|
||||
send_buffer[2] = address & 0xFF;
|
||||
send_buffer[3] = (address >> 8) & 0xFF;
|
||||
send_buffer[4] = (address >> 16) & 0xFF;
|
||||
if (updi_physical_send(pgm, send_buffer, updi_get_datalink_mode(pgm) == UPDI_LINK_MODE_24BIT ? 5 : 4) < 0) {
|
||||
avrdude_message(MSG_DEBUG, "%s: LD operation send failed\n", progname);
|
||||
pmsg_debug("LD operation send failed\n");
|
||||
return -1;
|
||||
}
|
||||
if (updi_physical_recv(pgm, recv_buffer, 1) < 0) {
|
||||
avrdude_message(MSG_DEBUG, "%s: LD operation recv failed\n", progname);
|
||||
pmsg_debug("LD operation recv failed\n");
|
||||
return -1;
|
||||
}
|
||||
* value = recv_buffer[0];
|
||||
|
@ -765,18 +763,18 @@ int updi_link_ld16(const PROGRAMMER *pgm, uint32_t address, uint16_t *value) {
|
|||
*/
|
||||
unsigned char send_buffer[5];
|
||||
unsigned char recv_buffer[2];
|
||||
avrdude_message(MSG_DEBUG, "%s: LD16 from 0x%06X\n", progname, address);
|
||||
pmsg_debug("LD16 from 0x%06X\n", address);
|
||||
send_buffer[0] = UPDI_PHY_SYNC;
|
||||
send_buffer[1] = UPDI_LDS | UPDI_DATA_16 | (updi_get_datalink_mode(pgm) == UPDI_LINK_MODE_24BIT ? UPDI_ADDRESS_24 : UPDI_ADDRESS_16);
|
||||
send_buffer[2] = address & 0xFF;
|
||||
send_buffer[3] = (address >> 8) & 0xFF;
|
||||
send_buffer[4] = (address >> 16) & 0xFF;
|
||||
if (updi_physical_send(pgm, send_buffer, updi_get_datalink_mode(pgm) == UPDI_LINK_MODE_24BIT ? 5 : 4) < 0) {
|
||||
avrdude_message(MSG_DEBUG, "%s: LD16 operation send failed\n", progname);
|
||||
pmsg_debug("LD16 operation send failed\n");
|
||||
return -1;
|
||||
}
|
||||
if (updi_physical_recv(pgm, recv_buffer, 2) < 0) {
|
||||
avrdude_message(MSG_DEBUG, "%s: LD16 operation recv failed\n", progname);
|
||||
pmsg_debug("LD16 operation recv failed\n");
|
||||
return -1;
|
||||
}
|
||||
* value = (recv_buffer[0] << 8 | recv_buffer[1]);
|
||||
|
@ -804,23 +802,23 @@ static int updi_link_st_data_phase(const PROGRAMMER *pgm, unsigned char *buffer,
|
|||
*/
|
||||
unsigned char recv_buffer[1];
|
||||
if (updi_physical_recv(pgm, recv_buffer, 1) < 0) {
|
||||
avrdude_message(MSG_DEBUG, "%s: UPDI data phase recv failed on first ACK\n", progname);
|
||||
pmsg_debug("UPDI data phase recv failed on first ACK\n");
|
||||
return -1;
|
||||
}
|
||||
if (recv_buffer[0] != UPDI_PHY_ACK) {
|
||||
avrdude_message(MSG_DEBUG, "%s: UPDI data phase expected first ACK\n", progname);
|
||||
pmsg_debug("UPDI data phase expected first ACK\n");
|
||||
return -1;
|
||||
}
|
||||
if (updi_physical_send(pgm, buffer, size) < 0) {
|
||||
avrdude_message(MSG_DEBUG, "%s: UPDI data phase send failed\n", progname);
|
||||
pmsg_debug("UPDI data phase send failed\n");
|
||||
return -1;
|
||||
}
|
||||
if (updi_physical_recv(pgm, recv_buffer, 1) < 0) {
|
||||
avrdude_message(MSG_DEBUG, "%s: UPDI data phase recv failed on second ACK\n", progname);
|
||||
pmsg_debug("UPDI data phase recv failed on second ACK\n");
|
||||
return -1;
|
||||
}
|
||||
if (recv_buffer[0] != UPDI_PHY_ACK) {
|
||||
avrdude_message(MSG_DEBUG, "%s: UPDI data phase expected second ACK\n", progname);
|
||||
pmsg_debug("UPDI data phase expected second ACK\n");
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
|
@ -842,14 +840,14 @@ int updi_link_st(const PROGRAMMER *pgm, uint32_t address, uint8_t value) {
|
|||
return self._st_data_phase([value & 0xFF])
|
||||
*/
|
||||
unsigned char send_buffer[5];
|
||||
avrdude_message(MSG_DEBUG, "%s: ST to 0x%06X\n", progname, address);
|
||||
pmsg_debug("ST to 0x%06X\n", address);
|
||||
send_buffer[0] = UPDI_PHY_SYNC;
|
||||
send_buffer[1] = UPDI_STS | UPDI_DATA_8 | (updi_get_datalink_mode(pgm) == UPDI_LINK_MODE_24BIT ? UPDI_ADDRESS_24 : UPDI_ADDRESS_16);
|
||||
send_buffer[2] = address & 0xFF;
|
||||
send_buffer[3] = (address >> 8) & 0xFF;
|
||||
send_buffer[4] = (address >> 16) & 0xFF;
|
||||
if (updi_physical_send(pgm, send_buffer, updi_get_datalink_mode(pgm) == UPDI_LINK_MODE_24BIT ? 5 : 4) < 0) {
|
||||
avrdude_message(MSG_DEBUG, "%s: ST operation send failed\n", progname);
|
||||
pmsg_debug("ST operation send failed\n");
|
||||
return -1;
|
||||
}
|
||||
send_buffer[0] = value;
|
||||
|
@ -872,14 +870,14 @@ int updi_link_st16(const PROGRAMMER *pgm, uint32_t address, uint16_t value) {
|
|||
return self._st_data_phase([value & 0xFF, (value >> 8) & 0xFF])
|
||||
*/
|
||||
unsigned char send_buffer[5];
|
||||
avrdude_message(MSG_DEBUG, "%s: ST16 to 0x%06X\n", progname, address);
|
||||
pmsg_debug("ST16 to 0x%06X\n", address);
|
||||
send_buffer[0] = UPDI_PHY_SYNC;
|
||||
send_buffer[1] = UPDI_STS | UPDI_DATA_16 | (updi_get_datalink_mode(pgm) == UPDI_LINK_MODE_24BIT ? UPDI_ADDRESS_24 : UPDI_ADDRESS_16);
|
||||
send_buffer[2] = address & 0xFF;
|
||||
send_buffer[3] = (address >> 8) & 0xFF;
|
||||
send_buffer[4] = (address >> 16) & 0xFF;
|
||||
if (updi_physical_send(pgm, send_buffer, updi_get_datalink_mode(pgm) == UPDI_LINK_MODE_24BIT ? 5 : 4) < 0) {
|
||||
avrdude_message(MSG_DEBUG, "%s: ST16 operation send failed\n", progname);
|
||||
pmsg_debug("ST16 operation send failed\n");
|
||||
return -1;
|
||||
}
|
||||
send_buffer[0] = value & 0xFF;
|
||||
|
@ -905,22 +903,22 @@ int updi_link_st_ptr(const PROGRAMMER *pgm, uint32_t address) {
|
|||
*/
|
||||
unsigned char send_buffer[5];
|
||||
unsigned char recv_buffer[1];
|
||||
avrdude_message(MSG_DEBUG, "%s: ST_PTR to 0x%06X\n", progname, address);
|
||||
pmsg_debug("ST_PTR to 0x%06X\n", address);
|
||||
send_buffer[0] = UPDI_PHY_SYNC;
|
||||
send_buffer[1] = UPDI_STS | UPDI_ST | UPDI_PTR_ADDRESS | (updi_get_datalink_mode(pgm) == UPDI_LINK_MODE_24BIT ? UPDI_DATA_24 : UPDI_DATA_16);
|
||||
send_buffer[2] = address & 0xFF;
|
||||
send_buffer[3] = (address >> 8) & 0xFF;
|
||||
send_buffer[4] = (address >> 16) & 0xFF;
|
||||
if (updi_physical_send(pgm, send_buffer, updi_get_datalink_mode(pgm) == UPDI_LINK_MODE_24BIT ? 5 : 4) < 0) {
|
||||
avrdude_message(MSG_DEBUG, "%s: ST_PTR operation send failed\n", progname);
|
||||
pmsg_debug("ST_PTR operation send failed\n");
|
||||
return -1;
|
||||
}
|
||||
if (updi_physical_recv(pgm, recv_buffer, 1) < 0) {
|
||||
avrdude_message(MSG_DEBUG, "%s: UPDI ST_PTR recv failed on ACK\n", progname);
|
||||
pmsg_debug("UPDI ST_PTR recv failed on ACK\n");
|
||||
return -1;
|
||||
}
|
||||
if (recv_buffer[0] != UPDI_PHY_ACK) {
|
||||
avrdude_message(MSG_DEBUG, "%s: UPDI ST_PTR expected ACK\n", progname);
|
||||
pmsg_debug("UPDI ST_PTR expected ACK\n");
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
|
|
206
src/updi_nvm.c
206
src/updi_nvm.c
|
@ -71,17 +71,17 @@ static int nvm_chip_erase_V0(const PROGRAMMER *pgm, const AVRPART *p) {
|
|||
|
||||
return True
|
||||
*/
|
||||
avrdude_message(MSG_DEBUG, "%s: Chip erase using NVM CTRL\n", progname);
|
||||
pmsg_debug("Chip erase using NVM CTRL\n");
|
||||
if (updi_nvm_wait_ready(pgm, p) < 0) {
|
||||
avrdude_message(MSG_INFO, "%s: Wait for ready chip failed\n", progname);
|
||||
pmsg_error("updi_nvm_wait_ready() failed\n");
|
||||
return -1;
|
||||
}
|
||||
if (updi_nvm_command(pgm, p, UPDI_V0_NVMCTRL_CTRLA_CHIP_ERASE) < 0) {
|
||||
avrdude_message(MSG_INFO, "%s: Chip erase command failed\n", progname);
|
||||
pmsg_error("UPDI chip erase command failed\n");
|
||||
return -1;
|
||||
}
|
||||
if (updi_nvm_wait_ready(pgm, p) < 0) {
|
||||
avrdude_message(MSG_INFO, "%s: Wait for ready chip failed\n", progname);
|
||||
pmsg_error("updi_nvm_wait_ready() failed\n");
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
|
@ -113,22 +113,22 @@ static int nvm_erase_flash_page_V0(const PROGRAMMER *pgm, const AVRPART *p, uint
|
|||
raise IOError("Timeout waiting for NVM controller to be ready after flash page erase")
|
||||
*/
|
||||
unsigned char data[1];
|
||||
avrdude_message(MSG_DEBUG, "%s: Erase flash page at address 0x%06X\n", progname, address);
|
||||
pmsg_debug("erase flash page at address 0x%06X\n", address);
|
||||
if (updi_nvm_wait_ready(pgm, p) < 0) {
|
||||
avrdude_message(MSG_INFO, "%s: Wait for ready chip failed\n", progname);
|
||||
pmsg_error("updi_nvm_wait_ready() failed\n");
|
||||
return -1;
|
||||
}
|
||||
data[0] = 0xFF;
|
||||
if (updi_write_data(pgm, address, data, 1) < 0) {
|
||||
avrdude_message(MSG_INFO, "%s: Dummy write operation failed\n", progname);
|
||||
pmsg_error("dummy write operation failed\n");
|
||||
return -1;
|
||||
}
|
||||
if (updi_nvm_command(pgm, p, UPDI_V0_NVMCTRL_CTRLA_ERASE_PAGE) < 0) {
|
||||
avrdude_message(MSG_INFO, "%s: Flash page erase command failed\n", progname);
|
||||
pmsg_error("UPDI flash page erase command failed\n");
|
||||
return -1;
|
||||
}
|
||||
if (updi_nvm_wait_ready(pgm, p) < 0) {
|
||||
avrdude_message(MSG_INFO, "%s: Wait for ready chip failed\n", progname);
|
||||
pmsg_error("updi_nvm_wait_ready() failed\n");
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
|
@ -153,17 +153,17 @@ static int nvm_erase_eeprom_V0(const PROGRAMMER *pgm, const AVRPART *p) {
|
|||
if not self.wait_nvm_ready():
|
||||
raise IOError("Timeout waiting for NVM controller to be ready after EEPROM erase")
|
||||
*/
|
||||
avrdude_message(MSG_DEBUG, "%s: Erase EEPROM\n", progname);
|
||||
pmsg_debug("erase EEPROM\n");
|
||||
if (updi_nvm_wait_ready(pgm, p) < 0) {
|
||||
avrdude_message(MSG_INFO, "%s: Wait for ready chip failed\n", progname);
|
||||
pmsg_error("updi_nvm_wait_ready() failed\n");
|
||||
return -1;
|
||||
}
|
||||
if (updi_nvm_command(pgm, p, UPDI_V0_NVMCTRL_CTRLA_ERASE_EEPROM) < 0) {
|
||||
avrdude_message(MSG_INFO, "%s: EEPROM erase command failed\n", progname);
|
||||
pmsg_error("UPDI EEPROM erase command failed\n");
|
||||
return -1;
|
||||
}
|
||||
if (updi_nvm_wait_ready(pgm, p) < 0) {
|
||||
avrdude_message(MSG_INFO, "%s: Wait for ready chip failed\n", progname);
|
||||
pmsg_error("updi_nvm_wait_ready() failed\n");
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
|
@ -198,25 +198,25 @@ static int nvm_erase_user_row_V0(const PROGRAMMER *pgm, const AVRPART *p, uint32
|
|||
*/
|
||||
uint16_t offset;
|
||||
unsigned char data[1];
|
||||
avrdude_message(MSG_DEBUG, "%s: Erase user row\n", progname);
|
||||
pmsg_debug("erase user row\n");
|
||||
if (updi_nvm_wait_ready(pgm, p) < 0) {
|
||||
avrdude_message(MSG_INFO, "%s: Wait for ready chip failed\n", progname);
|
||||
pmsg_error("updi_nvm_wait_ready() failed\n");
|
||||
return -1;
|
||||
}
|
||||
data[0]=0xFF;
|
||||
for (offset = 0; offset<size; offset++)
|
||||
{
|
||||
if (updi_write_data(pgm, address+offset, data, 1) < 0) {
|
||||
avrdude_message(MSG_INFO, "%s: Write data operation failed at offset 0x%04x\n", progname, offset);
|
||||
pmsg_error("write data operation failed at offset 0x%04x\n", offset);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
if (updi_nvm_command(pgm, p, UPDI_V0_NVMCTRL_CTRLA_ERASE_PAGE) < 0) {
|
||||
avrdude_message(MSG_INFO, "%s: Erase page operation failed\n", progname);
|
||||
pmsg_error("erase page operation failed\n");
|
||||
return -1;
|
||||
}
|
||||
if (updi_nvm_wait_ready(pgm, p) < 0) {
|
||||
avrdude_message(MSG_INFO, "%s: Wait for ready chip failed\n", progname);
|
||||
pmsg_error("updi_nvm_wait_ready() failed\n");
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
|
@ -303,30 +303,30 @@ static int nvm_write_fuse_V0(const PROGRAMMER *pgm, const AVRPART *p, uint32_t a
|
|||
raise PymcuprogError("Timeout waiting for NVM controller to be ready after fuse write")
|
||||
*/
|
||||
if (updi_nvm_wait_ready(pgm, p) < 0) {
|
||||
avrdude_message(MSG_INFO, "%s: Wait for ready chip failed\n", progname);
|
||||
pmsg_error("updi_nvm_wait_ready() failed\n");
|
||||
return -1;
|
||||
}
|
||||
avrdude_message(MSG_DEBUG, "%s: Load NVM address\n", progname);
|
||||
pmsg_debug("load NVM address\n");
|
||||
if (updi_write_byte(pgm, p->nvm_base + UPDI_NVMCTRL_ADDRL, address & 0xFF) < 0) {
|
||||
avrdude_message(MSG_INFO, "%s: Write ADDRL operation failed\n", progname);
|
||||
pmsg_error("UPDI write ADDRL operation failed\n");
|
||||
return -1;
|
||||
}
|
||||
if (updi_write_byte(pgm, p->nvm_base + UPDI_NVMCTRL_ADDRH, (address >> 8) & 0xFF) < 0) {
|
||||
avrdude_message(MSG_INFO, "%s: Write ADDRH operation failed\n", progname);
|
||||
pmsg_error("write ADDRH operation failed\n");
|
||||
return -1;
|
||||
}
|
||||
avrdude_message(MSG_DEBUG, "%s: Load fuse data\n", progname);
|
||||
pmsg_debug("load fuse data\n");
|
||||
if (updi_write_byte(pgm, p->nvm_base + UPDI_NVMCTRL_DATAL, value & 0xFF) < 0) {
|
||||
avrdude_message(MSG_INFO, "%s: Write DATAL operation failed\n", progname);
|
||||
pmsg_error("write DATAL operation failed\n");
|
||||
return -1;
|
||||
}
|
||||
avrdude_message(MSG_DEBUG, "%s: Execute fuse write\n", progname);
|
||||
pmsg_debug("execute fuse write\n");
|
||||
if (updi_nvm_command(pgm, p, UPDI_V0_NVMCTRL_CTRLA_WRITE_FUSE) < 0) {
|
||||
avrdude_message(MSG_INFO, "%s: Write fuse operation failed\n", progname);
|
||||
pmsg_error("write fuse operation failed\n");
|
||||
return -1;
|
||||
}
|
||||
if (updi_nvm_wait_ready(pgm, p) < 0) {
|
||||
avrdude_message(MSG_INFO, "%s: Wait for ready chip failed\n", progname);
|
||||
pmsg_error("updi_nvm_wait_ready() failed\n");
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
|
@ -377,39 +377,39 @@ static int nvm_write_V0(const PROGRAMMER *pgm, const AVRPART *p, uint32_t addres
|
|||
raise PymcuprogError("Timeout waiting for NVM controller to be ready after page write")
|
||||
*/
|
||||
if (updi_nvm_wait_ready(pgm, p) < 0) {
|
||||
avrdude_message(MSG_INFO, "%s: Wait for ready chip failed\n", progname);
|
||||
pmsg_error("updi_nvm_wait_ready() failed\n");
|
||||
return -1;
|
||||
}
|
||||
avrdude_message(MSG_DEBUG, "%s: Clear page buffer\n", progname);
|
||||
pmsg_debug("clear page buffer\n");
|
||||
if (updi_nvm_command(pgm, p, UPDI_V0_NVMCTRL_CTRLA_PAGE_BUFFER_CLR) < 0) {
|
||||
avrdude_message(MSG_INFO, "%s: Clear page operation failed\n", progname);
|
||||
pmsg_error("clear page operation failed\n");
|
||||
return -1;
|
||||
}
|
||||
if (updi_nvm_wait_ready(pgm, p) < 0) {
|
||||
avrdude_message(MSG_INFO, "%s: Wait for ready chip failed\n", progname);
|
||||
pmsg_error("updi_nvm_wait_ready() failed\n");
|
||||
return -1;
|
||||
}
|
||||
if (mode == USE_WORD_ACCESS) {
|
||||
if (updi_write_data_words(pgm, address, buffer, size) < 0) {
|
||||
avrdude_message(MSG_INFO, "%s: Write data words operation failed\n", progname);
|
||||
pmsg_error("write data words operation failed\n");
|
||||
return -1;
|
||||
}
|
||||
} else {
|
||||
if (updi_write_data(pgm, address, buffer, size) < 0) {
|
||||
avrdude_message(MSG_INFO, "%s: Write data operation failed\n", progname);
|
||||
pmsg_error("write data operation failed\n");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
avrdude_message(MSG_DEBUG, "%s: Committing data\n", progname);
|
||||
pmsg_debug("committing data\n");
|
||||
if (nvm_command == USE_DEFAULT_COMMAND) {
|
||||
nvm_command = UPDI_V0_NVMCTRL_CTRLA_WRITE_PAGE;
|
||||
}
|
||||
if (updi_nvm_command(pgm, p, nvm_command) < 0) {
|
||||
avrdude_message(MSG_INFO, "%s: Commit data command failed\n", progname);
|
||||
pmsg_error("commit data command failed\n");
|
||||
return -1;
|
||||
}
|
||||
if (updi_nvm_wait_ready(pgm, p) < 0) {
|
||||
avrdude_message(MSG_INFO, "%s: Wait for ready chip failed\n", progname);
|
||||
pmsg_error("updi_nvm_wait_ready() failed\n");
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
|
@ -438,17 +438,17 @@ static int nvm_chip_erase_V2(const PROGRAMMER *pgm, const AVRPART *p) {
|
|||
|
||||
return True
|
||||
*/
|
||||
avrdude_message(MSG_DEBUG, "%s: Chip erase using NVM CTRL\n", progname);
|
||||
pmsg_debug("chip erase using NVM CTRL\n");
|
||||
if (updi_nvm_wait_ready(pgm, p) < 0) {
|
||||
avrdude_message(MSG_INFO, "%s: Wait for ready chip failed\n", progname);
|
||||
pmsg_error("updi_nvm_wait_ready() failed\n");
|
||||
return -1;
|
||||
}
|
||||
if (updi_nvm_command(pgm, p, UPDI_V2_NVMCTRL_CTRLA_CHIP_ERASE) < 0) {
|
||||
avrdude_message(MSG_INFO, "%s: Chip erase command failed\n", progname);
|
||||
pmsg_error("chip erase command failed\n");
|
||||
return -1;
|
||||
}
|
||||
if (updi_nvm_wait_ready(pgm, p) < 0) {
|
||||
avrdude_message(MSG_INFO, "%s: Wait for ready chip failed\n", progname);
|
||||
pmsg_error("updi_nvm_wait_ready() failed\n");
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
|
@ -484,22 +484,22 @@ static int nvm_erase_flash_page_V2(const PROGRAMMER *pgm, const AVRPART *p, uint
|
|||
self.execute_nvm_command(constants.UPDI_V2_NVMCTRL_CTRLA_NOCMD)
|
||||
*/
|
||||
unsigned char data[1];
|
||||
avrdude_message(MSG_DEBUG, "%s: Erase flash page at address 0x%06X\n", progname, address);
|
||||
pmsg_debug("erase flash page at address 0x%06X\n", address);
|
||||
if (updi_nvm_wait_ready(pgm, p) < 0) {
|
||||
avrdude_message(MSG_INFO, "%s: Wait for ready chip failed\n", progname);
|
||||
pmsg_error("updi_nvm_wait_ready() failed\n");
|
||||
return -1;
|
||||
}
|
||||
data[0] = 0xFF;
|
||||
if (updi_write_data(pgm, address, data, 1) < 0) {
|
||||
avrdude_message(MSG_INFO, "%s: Dummy write operation failed\n", progname);
|
||||
pmsg_error("dummy write operation failed\n");
|
||||
return -1;
|
||||
}
|
||||
if (updi_nvm_command(pgm, p, UPDI_V2_NVMCTRL_CTRLA_FLASH_PAGE_ERASE) < 0) {
|
||||
avrdude_message(MSG_INFO, "%s: Flash page erase command failed\n", progname);
|
||||
pmsg_error("flash page erase command failed\n");
|
||||
return -1;
|
||||
}
|
||||
if (updi_nvm_wait_ready(pgm, p) < 0) {
|
||||
avrdude_message(MSG_INFO, "%s: Wait for ready chip failed\n", progname);
|
||||
pmsg_error("updi_nvm_wait_ready() failed\n");
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
|
@ -528,22 +528,22 @@ static int nvm_erase_eeprom_V2(const PROGRAMMER *pgm, const AVRPART *p) {
|
|||
self.logger.debug("Clear NVM command")
|
||||
self.execute_nvm_command(constants.UPDI_V2_NVMCTRL_CTRLA_NOCMD)
|
||||
*/
|
||||
avrdude_message(MSG_DEBUG, "%s: Erase EEPROM\n", progname);
|
||||
pmsg_debug("erase EEPROM\n");
|
||||
if (updi_nvm_wait_ready(pgm, p) < 0) {
|
||||
avrdude_message(MSG_INFO, "%s: Wait for ready chip failed\n", progname);
|
||||
pmsg_error("updi_nvm_wait_ready() failed\n");
|
||||
return -1;
|
||||
}
|
||||
if (updi_nvm_command(pgm, p, UPDI_V2_NVMCTRL_CTRLA_EEPROM_ERASE) < 0) {
|
||||
avrdude_message(MSG_INFO, "%s: EEPROM erase command failed\n", progname);
|
||||
pmsg_error("EEPROM erase command failed\n");
|
||||
return -1;
|
||||
}
|
||||
if (updi_nvm_wait_ready(pgm, p) < 0) {
|
||||
avrdude_message(MSG_INFO, "%s: Wait for ready chip failed\n", progname);
|
||||
pmsg_error("updi_nvm_wait_ready() failed\n");
|
||||
return -1;
|
||||
}
|
||||
avrdude_message(MSG_DEBUG, "%s: Clear NVM command\n", progname);
|
||||
pmsg_debug("clear NVM command\n");
|
||||
if (updi_nvm_command(pgm, p, UPDI_V2_NVMCTRL_CTRLA_NOCMD) < 0) {
|
||||
avrdude_message(MSG_INFO, "%s: Sending empty command failed\n", progname);
|
||||
pmsg_error("sending empty command failed\n");
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
|
@ -629,25 +629,25 @@ static int nvm_write_eeprom_V2(const PROGRAMMER *pgm, const AVRPART *p, uint32_t
|
|||
self.execute_nvm_command(constants.UPDI_V2_NVMCTRL_CTRLA_NOCMD)
|
||||
*/
|
||||
if (updi_nvm_wait_ready(pgm, p) < 0) {
|
||||
avrdude_message(MSG_INFO, "%s: Wait for ready chip failed\n", progname);
|
||||
pmsg_error("updi_nvm_wait_ready() failed\n");
|
||||
return -1;
|
||||
}
|
||||
avrdude_message(MSG_DEBUG, "%s: NVM EEPROM erase/write command\n", progname);
|
||||
pmsg_debug("NVM EEPROM erase/write command\n");
|
||||
if (updi_nvm_command(pgm, p, UPDI_V2_NVMCTRL_CTRLA_EEPROM_ERASE_WRITE) < 0) {
|
||||
avrdude_message(MSG_INFO, "%s: EEPROM erase command failed\n", progname);
|
||||
pmsg_error("EEPROM erase command failed\n");
|
||||
return -1;
|
||||
}
|
||||
if (updi_write_data(pgm, address, buffer, size) < 0) {
|
||||
avrdude_message(MSG_INFO, "%s: Write data operation failed\n", progname);
|
||||
pmsg_error("write data operation failed\n");
|
||||
return -1;
|
||||
}
|
||||
if (updi_nvm_wait_ready(pgm, p) < 0) {
|
||||
avrdude_message(MSG_INFO, "%s: Wait for ready chip failed\n", progname);
|
||||
pmsg_error("updi_nvm_wait_ready() failed\n");
|
||||
return -1;
|
||||
}
|
||||
avrdude_message(MSG_DEBUG, "%s: Clear NVM command\n", progname);
|
||||
pmsg_debug("clear NVM command\n");
|
||||
if (updi_nvm_command(pgm, p, UPDI_V2_NVMCTRL_CTRLA_NOCMD) < 0) {
|
||||
avrdude_message(MSG_INFO, "%s: Clear NVM command failed\n", progname);
|
||||
pmsg_error("clear NVM command failed\n");
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
|
@ -708,32 +708,32 @@ static int nvm_write_V2(const PROGRAMMER *pgm, const AVRPART *p, uint32_t addres
|
|||
self.execute_nvm_command(constants.UPDI_V2_NVMCTRL_CTRLA_NOCMD)
|
||||
*/
|
||||
if (updi_nvm_wait_ready(pgm, p) < 0) {
|
||||
avrdude_message(MSG_INFO, "%s: Wait for ready chip failed\n", progname);
|
||||
pmsg_error("updi_nvm_wait_ready() failed\n");
|
||||
return -1;
|
||||
}
|
||||
avrdude_message(MSG_DEBUG, "%s: NVM write command\n", progname);
|
||||
pmsg_debug("NVM write command\n");
|
||||
if (updi_nvm_command(pgm, p, UPDI_V2_NVMCTRL_CTRLA_FLASH_WRITE) < 0) {
|
||||
avrdude_message(MSG_INFO, "%s: Clear page operation failed\n", progname);
|
||||
pmsg_error("clear page operation failed\n");
|
||||
return -1;
|
||||
}
|
||||
if (mode == USE_WORD_ACCESS) {
|
||||
if (updi_write_data_words(pgm, address, buffer, size) < 0) {
|
||||
avrdude_message(MSG_INFO, "%s: Write data words operation failed\n", progname);
|
||||
pmsg_error("write data words operation failed\n");
|
||||
return -1;
|
||||
}
|
||||
} else {
|
||||
if (updi_write_data(pgm, address, buffer, size) < 0) {
|
||||
avrdude_message(MSG_INFO, "%s: Write data operation failed\n", progname);
|
||||
pmsg_error("write data operation failed\n");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
if (updi_nvm_wait_ready(pgm, p) < 0) {
|
||||
avrdude_message(MSG_INFO, "%s: Wait for ready chip failed\n", progname);
|
||||
pmsg_error("wait for ready chip failed\n");
|
||||
return -1;
|
||||
}
|
||||
avrdude_message(MSG_DEBUG, "%s: Clear NVM command\n", progname);
|
||||
pmsg_debug("clear NVM command\n");
|
||||
if (updi_nvm_command(pgm, p, UPDI_V2_NVMCTRL_CTRLA_NOCMD) < 0) {
|
||||
avrdude_message(MSG_INFO, "%s: Clear NVM command failed\n", progname);
|
||||
pmsg_error("clear NVM command failed\n");
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
|
@ -768,21 +768,21 @@ static int nvm_chip_erase_V3(const PROGRAMMER *pgm, const AVRPART *p) {
|
|||
|
||||
return True
|
||||
*/
|
||||
avrdude_message(MSG_DEBUG, "%s: Chip erase using NVM CTRL\n", progname);
|
||||
pmsg_debug("Chip erase using NVM CTRL\n");
|
||||
if (updi_nvm_wait_ready(pgm, p) < 0) {
|
||||
avrdude_message(MSG_INFO, "%s: Wait for ready chip failed\n", progname);
|
||||
pmsg_error("updi_nvm_wait_ready() failed\n");
|
||||
return -1;
|
||||
}
|
||||
if (updi_nvm_command(pgm, p, UPDI_V3_NVMCTRL_CTRLA_CHIP_ERASE) < 0) {
|
||||
avrdude_message(MSG_INFO, "%s: Chip erase command failed\n", progname);
|
||||
pmsg_error("chip erase command failed\n");
|
||||
return -1;
|
||||
}
|
||||
if (updi_nvm_wait_ready(pgm, p) < 0) {
|
||||
avrdude_message(MSG_INFO, "%s: Wait for ready chip failed\n", progname);
|
||||
pmsg_error("updi_nvm_wait_ready() failed\n");
|
||||
return -1;
|
||||
}
|
||||
if (updi_nvm_command(pgm, p, UPDI_V3_NVMCTRL_CTRLA_NOCMD) < 0) {
|
||||
avrdude_message(MSG_INFO, "%s: Sending empty command failed\n", progname);
|
||||
pmsg_error("sending empty command failed\n");
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
|
@ -819,22 +819,22 @@ static int nvm_erase_flash_page_V3(const PROGRAMMER *pgm, const AVRPART *p, uint
|
|||
raise IOError("Timeout waiting for NVM controller to be ready after flash page erase")
|
||||
*/
|
||||
unsigned char data[1];
|
||||
avrdude_message(MSG_DEBUG, "%s: Erase flash page at address 0x%06X\n", progname, address);
|
||||
pmsg_debug("erase flash page at address 0x%06X\n", address);
|
||||
if (updi_nvm_wait_ready(pgm, p) < 0) {
|
||||
avrdude_message(MSG_INFO, "%s: Wait for ready chip failed\n", progname);
|
||||
pmsg_error("updi_nvm_wait_ready() failed\n");
|
||||
return -1;
|
||||
}
|
||||
data[0] = 0xFF;
|
||||
if (updi_write_data(pgm, address, data, 1) < 0) {
|
||||
avrdude_message(MSG_INFO, "%s: Dummy write operation failed\n", progname);
|
||||
pmsg_error("dummy write operation failed\n");
|
||||
return -1;
|
||||
}
|
||||
if (updi_nvm_command(pgm, p, UPDI_V3_NVMCTRL_CTRLA_FLASH_PAGE_ERASE) < 0) {
|
||||
avrdude_message(MSG_INFO, "%s: Flash page erase command failed\n", progname);
|
||||
pmsg_error("flash page erase command failed\n");
|
||||
return -1;
|
||||
}
|
||||
if (updi_nvm_wait_ready(pgm, p) < 0) {
|
||||
avrdude_message(MSG_INFO, "%s: Wait for ready chip failed\n", progname);
|
||||
pmsg_error("updi_nvm_wait_ready() failed\n");
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
|
@ -864,21 +864,21 @@ static int nvm_erase_eeprom_V3(const PROGRAMMER *pgm, const AVRPART *p) {
|
|||
if not status:
|
||||
raise IOError("Timeout waiting for NVM controller to be ready after EEPROM erase")
|
||||
*/
|
||||
avrdude_message(MSG_DEBUG, "%s: Erase EEPROM\n", progname);
|
||||
pmsg_debug("erase EEPROM\n");
|
||||
if (updi_nvm_wait_ready(pgm, p) < 0) {
|
||||
avrdude_message(MSG_INFO, "%s: Wait for ready chip failed\n", progname);
|
||||
pmsg_error("updi_nvm_wait_ready() failed\n");
|
||||
return -1;
|
||||
}
|
||||
if (updi_nvm_command(pgm, p, UPDI_V3_NVMCTRL_CTRLA_EEPROM_ERASE) < 0) {
|
||||
avrdude_message(MSG_INFO, "%s: EEPROM erase command failed\n", progname);
|
||||
pmsg_error("EEPROM erase command failed\n");
|
||||
return -1;
|
||||
}
|
||||
if (updi_nvm_wait_ready(pgm, p) < 0) {
|
||||
avrdude_message(MSG_INFO, "%s: Wait for ready chip failed\n", progname);
|
||||
pmsg_error("updi_nvm_wait_ready() failed\n");
|
||||
return -1;
|
||||
}
|
||||
if (updi_nvm_command(pgm, p, UPDI_V3_NVMCTRL_CTRLA_NOCMD) < 0) {
|
||||
avrdude_message(MSG_INFO, "%s: Sending empty command failed\n", progname);
|
||||
pmsg_error("sending empty command failed\n");
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
|
@ -898,7 +898,7 @@ static int nvm_erase_user_row_V3(const PROGRAMMER *pgm, const AVRPART *p, uint32
|
|||
# On this NVM version user row is implemented as FLASH
|
||||
return self.erase_flash_page(self, address)
|
||||
*/
|
||||
avrdude_message(MSG_DEBUG, "%s: Erase user row at address 0x%06X\n", progname, address);
|
||||
pmsg_debug("erase user row at address 0x%06X\n", address);
|
||||
|
||||
return nvm_erase_flash_page_V3(pgm, p, address);
|
||||
}
|
||||
|
@ -1014,43 +1014,43 @@ static int nvm_write_V3(const PROGRAMMER *pgm, const AVRPART *p, uint32_t addres
|
|||
self.execute_nvm_command(constants.UPDI_V3_NVMCTRL_CTRLA_NOCMD)
|
||||
*/
|
||||
if (updi_nvm_wait_ready(pgm, p) < 0) {
|
||||
avrdude_message(MSG_INFO, "%s: Wait for ready chip failed\n", progname);
|
||||
pmsg_error("updi_nvm_wait_ready() failed\n");
|
||||
return -1;
|
||||
}
|
||||
avrdude_message(MSG_DEBUG, "%s: Clear page buffer\n", progname);
|
||||
pmsg_debug("clear page buffer\n");
|
||||
if (updi_nvm_command(pgm, p, UPDI_V3_NVMCTRL_CTRLA_FLASH_PAGE_BUFFER_CLEAR) < 0) {
|
||||
avrdude_message(MSG_INFO, "%s: Clear page operation failed\n", progname);
|
||||
pmsg_error("clear page operation failed\n");
|
||||
return -1;
|
||||
}
|
||||
if (updi_nvm_wait_ready(pgm, p) < 0) {
|
||||
avrdude_message(MSG_INFO, "%s: Wait for ready chip failed\n", progname);
|
||||
pmsg_error("updi_nvm_wait_ready() failed\n");
|
||||
return -1;
|
||||
}
|
||||
if (mode == USE_WORD_ACCESS) {
|
||||
if (updi_write_data_words(pgm, address, buffer, size) < 0) {
|
||||
avrdude_message(MSG_INFO, "%s: Write data words operation failed\n", progname);
|
||||
pmsg_error("write data words operation failed\n");
|
||||
return -1;
|
||||
}
|
||||
} else {
|
||||
if (updi_write_data(pgm, address, buffer, size) < 0) {
|
||||
avrdude_message(MSG_INFO, "%s: Write data operation failed\n", progname);
|
||||
pmsg_error("write data operation failed\n");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
avrdude_message(MSG_DEBUG, "%s: Committing data\n", progname);
|
||||
pmsg_debug("committing data\n");
|
||||
if (nvm_command == USE_DEFAULT_COMMAND) {
|
||||
nvm_command = UPDI_V3_NVMCTRL_CTRLA_FLASH_PAGE_WRITE;
|
||||
}
|
||||
if (updi_nvm_command(pgm, p, nvm_command) < 0) {
|
||||
avrdude_message(MSG_INFO, "%s: Commit data command failed\n", progname);
|
||||
pmsg_error("commit data command failed\n");
|
||||
return -1;
|
||||
}
|
||||
if (updi_nvm_wait_ready(pgm, p) < 0) {
|
||||
avrdude_message(MSG_INFO, "%s: Wait for ready chip failed\n", progname);
|
||||
pmsg_error("updi_nvm_wait_ready() failed\n");
|
||||
return -1;
|
||||
}
|
||||
if (updi_nvm_command(pgm, p, UPDI_V3_NVMCTRL_CTRLA_NOCMD) < 0) {
|
||||
avrdude_message(MSG_INFO, "%s: Sending empty command failed\n", progname);
|
||||
pmsg_error("sending empty command failed\n");
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
|
@ -1067,7 +1067,7 @@ int updi_nvm_chip_erase(const PROGRAMMER *pgm, const AVRPART *p) {
|
|||
case UPDI_NVM_MODE_V3:
|
||||
return nvm_chip_erase_V3(pgm, p);
|
||||
default:
|
||||
avrdude_message(MSG_INFO, "%s: Invalid NVM Mode %d\n", progname, updi_get_nvm_mode(pgm));
|
||||
pmsg_error("invalid NVM Mode %d\n", updi_get_nvm_mode(pgm));
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
@ -1082,7 +1082,7 @@ int updi_nvm_erase_flash_page(const PROGRAMMER *pgm, const AVRPART *p, uint32_t
|
|||
case UPDI_NVM_MODE_V3:
|
||||
return nvm_erase_flash_page_V3(pgm, p, address);
|
||||
default:
|
||||
avrdude_message(MSG_INFO, "%s: Invalid NVM Mode %d\n", progname, updi_get_nvm_mode(pgm));
|
||||
pmsg_error("invalid NVM Mode %d\n", updi_get_nvm_mode(pgm));
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
@ -1097,7 +1097,7 @@ int updi_nvm_erase_eeprom(const PROGRAMMER *pgm, const AVRPART *p) {
|
|||
case UPDI_NVM_MODE_V3:
|
||||
return nvm_erase_eeprom_V3(pgm, p);
|
||||
default:
|
||||
avrdude_message(MSG_INFO, "%s: Invalid NVM Mode %d\n", progname, updi_get_nvm_mode(pgm));
|
||||
pmsg_error("invalid NVM Mode %d\n", updi_get_nvm_mode(pgm));
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
@ -1112,7 +1112,7 @@ int updi_nvm_erase_user_row(const PROGRAMMER *pgm, const AVRPART *p, uint32_t ad
|
|||
case UPDI_NVM_MODE_V3:
|
||||
return nvm_erase_user_row_V3(pgm, p, address, size);
|
||||
default:
|
||||
avrdude_message(MSG_INFO, "%s: Invalid NVM Mode %d\n", progname, updi_get_nvm_mode(pgm));
|
||||
pmsg_error("invalid NVM Mode %d\n", updi_get_nvm_mode(pgm));
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
@ -1127,7 +1127,7 @@ int updi_nvm_write_flash(const PROGRAMMER *pgm, const AVRPART *p, uint32_t addre
|
|||
case UPDI_NVM_MODE_V3:
|
||||
return nvm_write_flash_V3(pgm, p, address, buffer, size);
|
||||
default:
|
||||
avrdude_message(MSG_INFO, "%s: Invalid NVM Mode %d\n", progname, updi_get_nvm_mode(pgm));
|
||||
pmsg_error("invalid NVM Mode %d\n", updi_get_nvm_mode(pgm));
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
@ -1142,7 +1142,7 @@ int updi_nvm_write_user_row(const PROGRAMMER *pgm, const AVRPART *p, uint32_t ad
|
|||
case UPDI_NVM_MODE_V3:
|
||||
return nvm_write_user_row_V3(pgm, p, address, buffer, size);
|
||||
default:
|
||||
avrdude_message(MSG_INFO, "%s: Invalid NVM Mode %d\n", progname, updi_get_nvm_mode(pgm));
|
||||
pmsg_error("invalid NVM Mode %d\n", updi_get_nvm_mode(pgm));
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
@ -1157,7 +1157,7 @@ int updi_nvm_write_eeprom(const PROGRAMMER *pgm, const AVRPART *p, uint32_t addr
|
|||
case UPDI_NVM_MODE_V3:
|
||||
return nvm_write_eeprom_V3(pgm, p, address, buffer, size);
|
||||
default:
|
||||
avrdude_message(MSG_INFO, "%s: Invalid NVM Mode %d\n", progname, updi_get_nvm_mode(pgm));
|
||||
pmsg_error("invalid NVM Mode %d\n", updi_get_nvm_mode(pgm));
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
@ -1172,7 +1172,7 @@ int updi_nvm_write_fuse(const PROGRAMMER *pgm, const AVRPART *p, uint32_t addres
|
|||
case UPDI_NVM_MODE_V3:
|
||||
return nvm_write_fuse_V3(pgm, p, address, value);
|
||||
default:
|
||||
avrdude_message(MSG_INFO, "%s: Invalid NVM Mode %d\n", progname, updi_get_nvm_mode(pgm));
|
||||
pmsg_error("invalid NVM Mode %d\n", updi_get_nvm_mode(pgm));
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
@ -1208,7 +1208,7 @@ int updi_nvm_wait_ready(const PROGRAMMER *pgm, const AVRPART *p) {
|
|||
do {
|
||||
if (updi_read_byte(pgm, p->nvm_base + UPDI_NVMCTRL_STATUS, &status) >= 0) {
|
||||
if (status & (1 << UPDI_NVM_STATUS_WRITE_ERROR)) {
|
||||
avrdude_message(MSG_INFO, "%s: NVM error\n", progname);
|
||||
pmsg_error("unable to write NVM status\n");
|
||||
return -1;
|
||||
}
|
||||
if (!(status & ((1 << UPDI_NVM_STATUS_EEPROM_BUSY) |
|
||||
|
@ -1220,7 +1220,7 @@ int updi_nvm_wait_ready(const PROGRAMMER *pgm, const AVRPART *p) {
|
|||
current_time = (tv.tv_sec * 1000000) + tv.tv_usec;
|
||||
} while ((current_time - start_time) < 10000000);
|
||||
|
||||
avrdude_message(MSG_INFO, "%s: Wait NVM ready timed out\n", progname);
|
||||
pmsg_error("wait NVM ready timed out\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -1235,7 +1235,7 @@ int updi_nvm_command(const PROGRAMMER *pgm, const AVRPART *p, uint8_t command) {
|
|||
self.logger.debug("NVMCMD %d executing", command)
|
||||
return self.readwrite.write_byte(self.device.nvmctrl_address + constants.UPDI_NVMCTRL_CTRLA, command)
|
||||
*/
|
||||
avrdude_message(MSG_DEBUG, "%s: NVMCMD %d executing\n", progname, command);
|
||||
pmsg_debug("NVMCMD %d executing\n", command);
|
||||
|
||||
return updi_write_byte(pgm, p->nvm_base + UPDI_NVMCTRL_CTRLA, command);
|
||||
}
|
||||
|
|
|
@ -146,21 +146,21 @@ int updi_read_data(const PROGRAMMER *pgm, uint32_t address, uint8_t *buffer, uin
|
|||
# Do the read(s)
|
||||
return self.datalink.ld_ptr_inc(size)
|
||||
*/
|
||||
avrdude_message(MSG_DEBUG, "%s: Reading %d bytes from 0x%06X\n", progname, size, address);
|
||||
pmsg_debug("reading %d bytes from 0x%06X\n", size, address);
|
||||
|
||||
if (size > UPDI_MAX_REPEAT_SIZE) {
|
||||
avrdude_message(MSG_DEBUG, "%s: Can't read that many bytes in one go\n", progname);
|
||||
pmsg_debug("cannot read that many bytes in one go\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (updi_link_st_ptr(pgm, address) < 0) {
|
||||
avrdude_message(MSG_DEBUG, "%s: ST_PTR operation failed\n", progname);
|
||||
pmsg_debug("ST_PTR operation failed\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (size > 1) {
|
||||
if (updi_link_repeat(pgm, size) < 0) {
|
||||
avrdude_message(MSG_DEBUG, "%s: Repeat operation failed\n", progname);
|
||||
pmsg_debug("repeat operation failed\n");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
@ -200,21 +200,21 @@ int updi_write_data(const PROGRAMMER *pgm, uint32_t address, uint8_t *buffer, ui
|
|||
}
|
||||
if (size == 2) {
|
||||
if (updi_link_st(pgm, address, buffer[0]) < 0) {
|
||||
avrdude_message(MSG_DEBUG, "%s: ST operation failed\n", progname);
|
||||
pmsg_debug("ST operation failed\n");
|
||||
return -1;
|
||||
}
|
||||
return updi_link_st(pgm, address+1, buffer[1]);
|
||||
}
|
||||
if (size > UPDI_MAX_REPEAT_SIZE) {
|
||||
avrdude_message(MSG_DEBUG, "%s: Invalid length\n", progname);
|
||||
pmsg_debug("invalid length\n");
|
||||
return -1;
|
||||
}
|
||||
if (updi_link_st_ptr(pgm, address) < 0) {
|
||||
avrdude_message(MSG_DEBUG, "%s: ST_PTR operation failed\n", progname);
|
||||
pmsg_debug("ST_PTR operation failed\n");
|
||||
return -1;
|
||||
}
|
||||
if (updi_link_repeat(pgm, size) < 0) {
|
||||
avrdude_message(MSG_DEBUG, "%s: Repeat operation failed\n", progname);
|
||||
pmsg_debug("repeat operation failed\n");
|
||||
return -1;
|
||||
}
|
||||
return updi_link_st_ptr_inc(pgm, buffer, size);
|
||||
|
@ -245,21 +245,21 @@ int updi_read_data_words(const PROGRAMMER *pgm, uint32_t address, uint8_t *buffe
|
|||
# Do the read
|
||||
return self.datalink.ld_ptr_inc16(words)
|
||||
*/
|
||||
avrdude_message(MSG_DEBUG, "%s: Reading %d words from 0x%06X", progname, size, address);
|
||||
pmsg_debug("reading %d words from 0x%06X", size, address);
|
||||
|
||||
if (size > (UPDI_MAX_REPEAT_SIZE >> 1)) {
|
||||
avrdude_message(MSG_DEBUG, "%s: Can't read that many words in one go\n", progname);
|
||||
pmsg_debug("cannot read that many words in one go\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (updi_link_st_ptr(pgm, address) < 0) {
|
||||
avrdude_message(MSG_DEBUG, "%s: ST_PTR operation failed\n", progname);
|
||||
pmsg_debug("ST_PTR operation failed\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (size > 1) {
|
||||
if (updi_link_repeat(pgm, size) < 0) {
|
||||
avrdude_message(MSG_DEBUG, "%s: Repeat operation failed\n", progname);
|
||||
pmsg_debug("repeat operation failed\n");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
@ -295,11 +295,11 @@ int updi_write_data_words(const PROGRAMMER *pgm, uint32_t address, uint8_t *buff
|
|||
return updi_link_st16(pgm, address, buffer[0] + (buffer[1] << 8));
|
||||
}
|
||||
if (size > UPDI_MAX_REPEAT_SIZE << 1) {
|
||||
avrdude_message(MSG_DEBUG, "%s: Invalid length\n", progname);
|
||||
pmsg_debug("invalid length\n");
|
||||
return -1;
|
||||
}
|
||||
if (updi_link_st_ptr(pgm, address) < 0) {
|
||||
avrdude_message(MSG_DEBUG, "%s: ST_PTR operation failed\n", progname);
|
||||
pmsg_debug("ST_PTR operation failed\n");
|
||||
return -1;
|
||||
}
|
||||
return updi_link_st_ptr_inc16_RSD(pgm, buffer, size >> 1, -1);
|
||||
|
|
|
@ -79,8 +79,7 @@ static int usbhid_open(const char *port, union pinfo pinfo, union filedescriptor
|
|||
|
||||
if (strlen(serno) > 12)
|
||||
{
|
||||
avrdude_message(MSG_INFO, "%s: usbhid_open(): invalid serial number \"%s\"\n",
|
||||
progname, serno);
|
||||
pmsg_error("invalid serial number %s\n", serno);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -100,8 +99,7 @@ static int usbhid_open(const char *port, union pinfo pinfo, union filedescriptor
|
|||
walk = list;
|
||||
while (walk)
|
||||
{
|
||||
avrdude_message(MSG_NOTICE, "%s: usbhid_open(): Found %ls, serno: %ls\n",
|
||||
progname, walk->product_string, walk->serial_number);
|
||||
pmsg_notice("usbhid_open(): found %ls, serno: %ls\n", walk->product_string, walk->serial_number);
|
||||
size_t slen = wcslen(walk->serial_number);
|
||||
if (slen >= serlen &&
|
||||
wcscmp(walk->serial_number + slen - serlen, wserno) == 0)
|
||||
|
@ -109,26 +107,21 @@ static int usbhid_open(const char *port, union pinfo pinfo, union filedescriptor
|
|||
/* found matching serial number */
|
||||
break;
|
||||
}
|
||||
avrdude_message(MSG_DEBUG, "%s: usbhid_open(): serial number doesn't match\n",
|
||||
progname);
|
||||
pmsg_debug("usbhid_open(): serial number does not match\n");
|
||||
walk = walk->next;
|
||||
}
|
||||
if (walk == NULL)
|
||||
{
|
||||
avrdude_message(MSG_INFO, "%s: usbhid_open(): No matching device found\n",
|
||||
progname);
|
||||
pmsg_error("no matching device found\n");
|
||||
hid_free_enumeration(list);
|
||||
return -1;
|
||||
}
|
||||
avrdude_message(MSG_DEBUG, "%s: usbhid_open(): Opening path %s\n",
|
||||
progname, walk->path);
|
||||
pmsg_debug("usbhid_open(): opening path %s\n", walk->path);
|
||||
dev = hid_open_path(walk->path);
|
||||
hid_free_enumeration(list);
|
||||
if (dev == NULL)
|
||||
{
|
||||
avrdude_message(MSG_INFO,
|
||||
"%s: usbhid_open(): Found device, but hid_open_path() failed\n",
|
||||
progname);
|
||||
pmsg_error("found device, but hid_open_path() failed\n");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
@ -140,8 +133,7 @@ static int usbhid_open(const char *port, union pinfo pinfo, union filedescriptor
|
|||
dev = hid_open(pinfo.usbinfo.vid, pinfo.usbinfo.pid, NULL);
|
||||
if (dev == NULL)
|
||||
{
|
||||
avrdude_message(MSG_INFO, "%s: usbhid_open(): No device found\n",
|
||||
progname);
|
||||
pmsg_error("no device found\n");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
@ -176,8 +168,7 @@ static int usbhid_open(const char *port, union pinfo pinfo, union filedescriptor
|
|||
*/
|
||||
if (pinfo.usbinfo.vid == USB_VENDOR_ATMEL)
|
||||
{
|
||||
avrdude_message(MSG_DEBUG, "%s: usbhid_open(): Probing for max. packet size\n",
|
||||
progname);
|
||||
pmsg_debug("usbhid_open(): probing for max packet size\n");
|
||||
memset(usbbuf, 0, sizeof usbbuf);
|
||||
usbbuf[0] = 0; /* no HID reports used */
|
||||
usbbuf[1] = 0; /* DAP_Info */
|
||||
|
@ -195,26 +186,22 @@ static int usbhid_open(const char *port, union pinfo pinfo, union filedescriptor
|
|||
res = hid_read_timeout(dev, usbbuf, 10, 50);
|
||||
}
|
||||
if (res <= 0) {
|
||||
avrdude_message(MSG_INFO, "%s: usbhid_open(): No response from device\n",
|
||||
progname);
|
||||
pmsg_error("no response from device\n");
|
||||
hid_close(dev);
|
||||
return -1;
|
||||
}
|
||||
if (usbbuf[0] != 0 || usbbuf[1] != 2) {
|
||||
avrdude_message(MSG_INFO,
|
||||
"%s: usbhid_open(): Unexpected reply to DAP_Info: 0x%02x 0x%02x\n",
|
||||
progname, usbbuf[0], usbbuf[1]);
|
||||
pmsg_error("unexpected reply to DAP_Info: 0x%02x 0x%02x\n",
|
||||
usbbuf[0], usbbuf[1]);
|
||||
} else {
|
||||
fd->usb.max_xfer = usbbuf[2] + (usbbuf[3] << 8);
|
||||
avrdude_message(MSG_DEBUG,
|
||||
"%s: usbhid_open(): Setting max_xfer from DAP_Info response to %d\n",
|
||||
progname, fd->usb.max_xfer);
|
||||
pmsg_debug("usbhid_open(): setting max_xfer from DAP_Info response to %d\n",
|
||||
fd->usb.max_xfer);
|
||||
}
|
||||
}
|
||||
if (fd->usb.max_xfer > USBDEV_MAX_XFER_3) {
|
||||
avrdude_message(MSG_INFO,
|
||||
"%s: usbhid_open(): Unexpected max size %d, reducing to %d\n",
|
||||
progname, fd->usb.max_xfer, USBDEV_MAX_XFER_3);
|
||||
pmsg_error("unexpected max size %d, reducing to %d\n",
|
||||
fd->usb.max_xfer, USBDEV_MAX_XFER_3);
|
||||
fd->usb.max_xfer = USBDEV_MAX_XFER_3;
|
||||
}
|
||||
|
||||
|
@ -251,32 +238,30 @@ static int usbhid_send(const union filedescriptor *fd, const unsigned char *bp,
|
|||
memcpy(usbbuf + 1, bp, tx_size);
|
||||
rv = hid_write(udev, usbbuf, tx_size + 1);
|
||||
if (rv < 0) {
|
||||
avrdude_message(MSG_INFO, "%s: Failed to write %d bytes to USB\n",
|
||||
progname, tx_size);
|
||||
pmsg_error("unable to write %d bytes to USB\n", tx_size);
|
||||
return -1;
|
||||
}
|
||||
if (rv != tx_size + 1)
|
||||
avrdude_message(MSG_INFO, "%s: Short write to USB: %d bytes out of %d written\n",
|
||||
progname, rv, tx_size + 1);
|
||||
pmsg_error("short write to USB: %d bytes out of %d written\n", rv, tx_size + 1);
|
||||
|
||||
if (verbose > 4)
|
||||
{
|
||||
avrdude_message(MSG_TRACE2, "%s: Sent: ", progname);
|
||||
pmsg_trace2("sent: ");
|
||||
|
||||
while (i) {
|
||||
unsigned char c = *p;
|
||||
if (isprint(c)) {
|
||||
avrdude_message(MSG_TRACE2, "%c ", c);
|
||||
msg_trace2("%c ", c);
|
||||
}
|
||||
else {
|
||||
avrdude_message(MSG_TRACE2, ". ");
|
||||
msg_trace2(". ");
|
||||
}
|
||||
avrdude_message(MSG_TRACE2, "[%02x] ", c);
|
||||
msg_trace2("[%02x] ", c);
|
||||
|
||||
p++;
|
||||
i--;
|
||||
}
|
||||
avrdude_message(MSG_TRACE2, "\n");
|
||||
msg_trace2("\n");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -292,28 +277,26 @@ static int usbhid_recv(const union filedescriptor *fd, unsigned char *buf, size_
|
|||
|
||||
rv = i = hid_read_timeout(udev, buf, nbytes, 10000);
|
||||
if (i != nbytes)
|
||||
avrdude_message(MSG_INFO,
|
||||
"%s: Short read, read only %d out of %u bytes\n",
|
||||
progname, i, nbytes);
|
||||
pmsg_error("short read, read only %d out of %lu bytes\n", i, (unsigned long) nbytes);
|
||||
|
||||
if (verbose > 4)
|
||||
{
|
||||
avrdude_message(MSG_TRACE2, "%s: Recv: ", progname);
|
||||
pmsg_trace2("recv: ");
|
||||
|
||||
while (i) {
|
||||
unsigned char c = *p;
|
||||
if (isprint(c)) {
|
||||
avrdude_message(MSG_TRACE2, "%c ", c);
|
||||
msg_trace2("%c ", c);
|
||||
}
|
||||
else {
|
||||
avrdude_message(MSG_TRACE2, ". ");
|
||||
msg_trace2(". ");
|
||||
}
|
||||
avrdude_message(MSG_TRACE2, "[%02x] ", c);
|
||||
msg_trace2("[%02x] ", c);
|
||||
|
||||
p++;
|
||||
i--;
|
||||
}
|
||||
avrdude_message(MSG_TRACE2, "\n");
|
||||
msg_trace2("\n");
|
||||
}
|
||||
|
||||
return rv;
|
||||
|
|
|
@ -97,8 +97,7 @@ static int usbdev_open(const char *port, union pinfo pinfo, union filedescriptor
|
|||
|
||||
if (strlen(serno) > 12)
|
||||
{
|
||||
avrdude_message(MSG_INFO, "%s: usbdev_open(): invalid serial number \"%s\"\n",
|
||||
progname, serno);
|
||||
pmsg_error("invalid serial number %s\n", serno);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
@ -126,8 +125,7 @@ static int usbdev_open(const char *port, union pinfo pinfo, union filedescriptor
|
|||
dev->descriptor.iSerialNumber,
|
||||
string, sizeof(string)) < 0)
|
||||
{
|
||||
avrdude_message(MSG_INFO, "%s: usb_open(): cannot read serial number \"%s\"\n",
|
||||
progname, usb_strerror());
|
||||
pmsg_error("cannot read serial number: %s\n", usb_strerror());
|
||||
/*
|
||||
* On some systems, libusb appears to have
|
||||
* problems sending control messages. Catch the
|
||||
|
@ -145,8 +143,7 @@ static int usbdev_open(const char *port, union pinfo pinfo, union filedescriptor
|
|||
dev->descriptor.iProduct,
|
||||
product, sizeof(product)) < 0)
|
||||
{
|
||||
avrdude_message(MSG_INFO, "%s: usb_open(): cannot read product name \"%s\"\n",
|
||||
progname, usb_strerror());
|
||||
pmsg_error("cannot read product name: %s\n", usb_strerror());
|
||||
strcpy(product, "[unnamed product]");
|
||||
}
|
||||
/*
|
||||
|
@ -172,8 +169,7 @@ static int usbdev_open(const char *port, union pinfo pinfo, union filedescriptor
|
|||
fd->usb.wep = 0x02;
|
||||
}
|
||||
|
||||
avrdude_message(MSG_NOTICE, "%s: usbdev_open(): Found %s, serno: %s\n",
|
||||
progname, product, string);
|
||||
pmsg_notice("usbdev_open(): found %s, serno: %s\n", product, string);
|
||||
if (serno != NULL)
|
||||
{
|
||||
/*
|
||||
|
@ -184,8 +180,7 @@ static int usbdev_open(const char *port, union pinfo pinfo, union filedescriptor
|
|||
x = strlen(string) - strlen(serno);
|
||||
if (strcasecmp(string + x, serno) != 0)
|
||||
{
|
||||
avrdude_message(MSG_DEBUG, "%s: usbdev_open(): serial number doesn't match\n",
|
||||
progname);
|
||||
pmsg_debug("usbdev_open(): serial number does not match\n");
|
||||
usb_close(udev);
|
||||
continue;
|
||||
}
|
||||
|
@ -193,16 +188,14 @@ static int usbdev_open(const char *port, union pinfo pinfo, union filedescriptor
|
|||
|
||||
if (dev->config == NULL)
|
||||
{
|
||||
avrdude_message(MSG_INFO, "%s: usbdev_open(): USB device has no configuration\n",
|
||||
progname);
|
||||
pmsg_warning("USB device has no configuration\n");
|
||||
goto trynext;
|
||||
}
|
||||
|
||||
if (usb_set_configuration(udev, dev->config[0].bConfigurationValue))
|
||||
{
|
||||
avrdude_message(MSG_INFO, "%s: usbdev_open(): WARNING: failed to set configuration %d: %s\n",
|
||||
progname, dev->config[0].bConfigurationValue,
|
||||
usb_strerror());
|
||||
pmsg_warning("unable to set configuration %d: %s\n",
|
||||
dev->config[0].bConfigurationValue, usb_strerror());
|
||||
/* let's hope it has already been configured */
|
||||
// goto trynext;
|
||||
}
|
||||
|
@ -221,8 +214,8 @@ static int usbdev_open(const char *port, union pinfo pinfo, union filedescriptor
|
|||
#endif
|
||||
if (usb_claim_interface(udev, usb_interface))
|
||||
{
|
||||
avrdude_message(MSG_INFO, "%s: usbdev_open(): error claiming interface %d: %s\n",
|
||||
progname, usb_interface, usb_strerror());
|
||||
pmsg_error("unable to claim interface %d: %s\n",
|
||||
usb_interface, usb_strerror());
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -239,8 +232,7 @@ static int usbdev_open(const char *port, union pinfo pinfo, union filedescriptor
|
|||
}
|
||||
if (iface == dev->config[0].bNumInterfaces)
|
||||
{
|
||||
avrdude_message(MSG_INFO, "%s: usbdev_open(): no usable interface found\n",
|
||||
progname);
|
||||
pmsg_warning("no usable interface found\n");
|
||||
goto trynext;
|
||||
}
|
||||
|
||||
|
@ -255,16 +247,15 @@ static int usbdev_open(const char *port, union pinfo pinfo, union filedescriptor
|
|||
|
||||
if ((possible_ep & USB_ENDPOINT_DIR_MASK) != 0)
|
||||
{
|
||||
avrdude_message(MSG_NOTICE2, "%s: usbdev_open(): using read endpoint 0x%02x\n",
|
||||
progname, possible_ep);
|
||||
pmsg_notice2("usbdev_open(): using read endpoint 0x%02x\n", possible_ep);
|
||||
fd->usb.rep = possible_ep;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (fd->usb.rep == 0)
|
||||
{
|
||||
avrdude_message(MSG_INFO, "%s: usbdev_open(): cannot find a read endpoint, using 0x%02x\n",
|
||||
progname, USBDEV_BULK_EP_READ_MKII);
|
||||
pmsg_error("cannot find a read endpoint, using 0x%02x\n",
|
||||
USBDEV_BULK_EP_READ_MKII);
|
||||
fd->usb.rep = USBDEV_BULK_EP_READ_MKII;
|
||||
}
|
||||
}
|
||||
|
@ -274,8 +265,7 @@ static int usbdev_open(const char *port, union pinfo pinfo, union filedescriptor
|
|||
dev->config[0].interface[iface].altsetting[0].endpoint[i].bEndpointAddress == fd->usb.wep) &&
|
||||
dev->config[0].interface[iface].altsetting[0].endpoint[i].wMaxPacketSize < fd->usb.max_xfer)
|
||||
{
|
||||
avrdude_message(MSG_NOTICE, "%s: max packet size expected %d, but found %d due to EP 0x%02x's wMaxPacketSize\n",
|
||||
progname,
|
||||
pmsg_notice("max packet size expected %d, but found %d due to EP 0x%02x's wMaxPacketSize\n",
|
||||
fd->usb.max_xfer,
|
||||
dev->config[0].interface[iface].altsetting[0].endpoint[i].wMaxPacketSize,
|
||||
dev->config[0].interface[iface].altsetting[0].endpoint[i].bEndpointAddress);
|
||||
|
@ -285,23 +275,21 @@ static int usbdev_open(const char *port, union pinfo pinfo, union filedescriptor
|
|||
if (pinfo.usbinfo.flags & PINFO_FL_USEHID)
|
||||
{
|
||||
if (usb_control_msg(udev, 0x21, 0x0a /* SET_IDLE */, 0, 0, NULL, 0, 100) < 0)
|
||||
avrdude_message(MSG_INFO, "%s: usbdev_open(): SET_IDLE failed\n", progname);
|
||||
pmsg_error("SET_IDLE failed\n");
|
||||
}
|
||||
return 0;
|
||||
trynext:
|
||||
usb_close(udev);
|
||||
}
|
||||
else
|
||||
avrdude_message(MSG_INFO, "%s: usbdev_open(): cannot open device: %s\n",
|
||||
progname, usb_strerror());
|
||||
pmsg_error("cannot open device: %s\n", usb_strerror());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ((pinfo.usbinfo.flags & PINFO_FL_SILENT) == 0)
|
||||
avrdude_message(MSG_NOTICE, "%s: usbdev_open(): did not find any%s USB device \"%s\" (0x%04x:0x%04x)\n",
|
||||
progname, serno? " (matching)": "", port,
|
||||
(unsigned)pinfo.usbinfo.vid, (unsigned)pinfo.usbinfo.pid);
|
||||
pmsg_notice("usbdev_open(): did not find any%s USB device \"%s\" (0x%04x:0x%04x)\n",
|
||||
serno? " (matching)": "", port, (unsigned)pinfo.usbinfo.vid, (unsigned)pinfo.usbinfo.pid);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -353,8 +341,7 @@ static int usbdev_send(const union filedescriptor *fd, const unsigned char *bp,
|
|||
rv = usb_bulk_write(udev, fd->usb.wep, (char *)bp, tx_size, 10000);
|
||||
if (rv != tx_size)
|
||||
{
|
||||
avrdude_message(MSG_INFO, "%s: usbdev_send(): wrote %d out of %d bytes, err = %s\n",
|
||||
progname, rv, tx_size, usb_strerror());
|
||||
pmsg_error("wrote %d out of %d bytes, err = %s\n", rv, tx_size, usb_strerror());
|
||||
return -1;
|
||||
}
|
||||
bp += tx_size;
|
||||
|
@ -363,22 +350,22 @@ static int usbdev_send(const union filedescriptor *fd, const unsigned char *bp,
|
|||
|
||||
if (verbose > 3)
|
||||
{
|
||||
avrdude_message(MSG_TRACE, "%s: Sent: ", progname);
|
||||
pmsg_trace("sent: ");
|
||||
|
||||
while (i) {
|
||||
unsigned char c = *p;
|
||||
if (isprint(c)) {
|
||||
avrdude_message(MSG_TRACE, "%c ", c);
|
||||
msg_trace("%c ", c);
|
||||
}
|
||||
else {
|
||||
avrdude_message(MSG_TRACE, ". ");
|
||||
msg_trace(". ");
|
||||
}
|
||||
avrdude_message(MSG_TRACE, "[%02x] ", c);
|
||||
msg_trace("[%02x] ", c);
|
||||
|
||||
p++;
|
||||
i--;
|
||||
}
|
||||
avrdude_message(MSG_TRACE, "\n");
|
||||
msg_trace("\n");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -402,9 +389,8 @@ usb_fill_buf(usb_dev_handle *udev, int maxsize, int ep, int use_interrupt_xfer)
|
|||
rv = usb_bulk_read(udev, ep, usbbuf, maxsize, 10000);
|
||||
if (rv < 0)
|
||||
{
|
||||
avrdude_message(MSG_NOTICE2, "%s: usb_fill_buf(): usb_%s_read() error %s\n",
|
||||
progname, (use_interrupt_xfer? "interrupt": "bulk"),
|
||||
usb_strerror());
|
||||
pmsg_notice2("usb_fill_buf(): usb_%s_read() error: %s\n",
|
||||
use_interrupt_xfer? "interrupt": "bulk", usb_strerror());
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -439,22 +425,22 @@ static int usbdev_recv(const union filedescriptor *fd, unsigned char *buf, size_
|
|||
|
||||
if (verbose > 4)
|
||||
{
|
||||
avrdude_message(MSG_TRACE2, "%s: Recv: ", progname);
|
||||
pmsg_trace2("recv: ");
|
||||
|
||||
while (i) {
|
||||
unsigned char c = *p;
|
||||
if (isprint(c)) {
|
||||
avrdude_message(MSG_TRACE2, "%c ", c);
|
||||
msg_trace2("%c ", c);
|
||||
}
|
||||
else {
|
||||
avrdude_message(MSG_TRACE2, ". ");
|
||||
msg_trace2(". ");
|
||||
}
|
||||
avrdude_message(MSG_TRACE2, "[%02x] ", c);
|
||||
msg_trace2("[%02x] ", c);
|
||||
|
||||
p++;
|
||||
i--;
|
||||
}
|
||||
avrdude_message(MSG_TRACE2, "\n");
|
||||
msg_trace2("\n");
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -493,7 +479,7 @@ static int usbdev_recv_frame(const union filedescriptor *fd, unsigned char *buf,
|
|||
}
|
||||
else if (rv > 0)
|
||||
{
|
||||
avrdude_message(MSG_INFO, "Short event len = %d, ignored.\n", rv);
|
||||
pmsg_warning("short event len = %d, ignored\n", rv);
|
||||
/* fallthrough */
|
||||
}
|
||||
}
|
||||
|
@ -509,9 +495,8 @@ static int usbdev_recv_frame(const union filedescriptor *fd, unsigned char *buf,
|
|||
fd->usb.max_xfer, 10000);
|
||||
if (rv < 0)
|
||||
{
|
||||
avrdude_message(MSG_NOTICE2, "%s: usbdev_recv_frame(): usb_%s_read(): %s\n",
|
||||
progname, (fd->usb.use_interrupt_xfer? "interrupt": "bulk"),
|
||||
usb_strerror());
|
||||
pmsg_notice2("usbdev_recv_frame(): usb_%s_read(): %s\n",
|
||||
fd->usb.use_interrupt_xfer? "interrupt": "bulk", usb_strerror());
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -549,22 +534,22 @@ static int usbdev_recv_frame(const union filedescriptor *fd, unsigned char *buf,
|
|||
if (verbose > 3)
|
||||
{
|
||||
i = n & USB_RECV_LENGTH_MASK;
|
||||
avrdude_message(MSG_TRACE, "%s: Recv: ", progname);
|
||||
pmsg_trace("recv: ");
|
||||
|
||||
while (i) {
|
||||
unsigned char c = *p;
|
||||
if (isprint(c)) {
|
||||
avrdude_message(MSG_TRACE, "%c ", c);
|
||||
msg_trace("%c ", c);
|
||||
}
|
||||
else {
|
||||
avrdude_message(MSG_TRACE, ". ");
|
||||
msg_trace(". ");
|
||||
}
|
||||
avrdude_message(MSG_TRACE, "[%02x] ", c);
|
||||
msg_trace("[%02x] ", c);
|
||||
|
||||
p++;
|
||||
i--;
|
||||
}
|
||||
avrdude_message(MSG_TRACE, "\n");
|
||||
msg_trace("\n");
|
||||
}
|
||||
return n;
|
||||
}
|
||||
|
|
185
src/usbasp.c
185
src/usbasp.c
|
@ -119,7 +119,7 @@ static const char *errstr(int result)
|
|||
n = ENOSYS;
|
||||
break;
|
||||
default:
|
||||
snprintf(msg, sizeof msg, "Unknown libusb error: %d", result);
|
||||
snprintf(msg, sizeof msg, "Unknown libusb error code %d", result);
|
||||
return msg;
|
||||
}
|
||||
return strerror(n);
|
||||
|
@ -263,8 +263,7 @@ static int usbasp_write_byte(const PROGRAMMER *pgm, const AVRPART *p, const AVRM
|
|||
static void usbasp_setup(PROGRAMMER * pgm)
|
||||
{
|
||||
if ((pgm->cookie = malloc(sizeof(struct pdata))) == 0) {
|
||||
avrdude_message(MSG_INFO, "%s: usbasp_setup(): Out of memory allocating private data\n",
|
||||
progname);
|
||||
pmsg_error(" out of memory allocating private data\n");
|
||||
exit(1);
|
||||
}
|
||||
memset(pgm->cookie, 0, sizeof(struct pdata));
|
||||
|
@ -284,14 +283,12 @@ static int usbasp_parseextparms(const PROGRAMMER *pgm, const LISTID extparms) {
|
|||
extended_param = ldata(ln);
|
||||
|
||||
if (strncmp(extended_param, "section_config", strlen("section_config")) == 0) {
|
||||
avrdude_message(MSG_NOTICE2, "%s: usbasp_parseextparms(): set section_e to 1 (config section)\n",
|
||||
progname);
|
||||
pmsg_notice2("usbasp_parseextparms(): set section_e to 1 (config section)\n");
|
||||
PDATA(pgm)->section_e = 1;
|
||||
continue;
|
||||
}
|
||||
|
||||
avrdude_message(MSG_INFO, "%s: usbasp_parseextparms(): invalid extended parameter '%s'\n",
|
||||
progname, extended_param);
|
||||
pmsg_error("invalid extended parameter '%s'\n", extended_param);
|
||||
rv = -1;
|
||||
}
|
||||
|
||||
|
@ -336,15 +333,14 @@ static int usbasp_transmit(const PROGRAMMER *pgm,
|
|||
int nbytes;
|
||||
|
||||
if (verbose > 3) {
|
||||
avrdude_message(MSG_TRACE, "%s: usbasp_transmit(\"%s\", 0x%02x, 0x%02x, 0x%02x, 0x%02x)\n",
|
||||
progname,
|
||||
pmsg_trace("usbasp_transmit(\"%s\", 0x%02x, 0x%02x, 0x%02x, 0x%02x)\n",
|
||||
usbasp_get_funcname(functionid), send[0], send[1], send[2], send[3]);
|
||||
if (!receive && buffersize > 0) {
|
||||
int i;
|
||||
avrdude_message(MSG_TRACE, "%s => ", progbuf);
|
||||
imsg_trace(" => ");
|
||||
for (i = 0; i < buffersize; i++)
|
||||
avrdude_message(MSG_TRACE, "[%02x] ", buffer[i]);
|
||||
avrdude_message(MSG_TRACE, "\n");
|
||||
msg_trace("[%02x] ", buffer[i]);
|
||||
msg_trace("\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -358,7 +354,7 @@ static int usbasp_transmit(const PROGRAMMER *pgm,
|
|||
buffersize & 0xffff,
|
||||
5000);
|
||||
if(nbytes < 0){
|
||||
avrdude_message(MSG_INFO, "%s: error: usbasp_transmit: %s\n", progname, errstr(nbytes));
|
||||
pmsg_ext_error("%s\n", errstr(nbytes));
|
||||
return -1;
|
||||
}
|
||||
#else
|
||||
|
@ -370,17 +366,17 @@ static int usbasp_transmit(const PROGRAMMER *pgm,
|
|||
(char *)buffer, buffersize,
|
||||
5000);
|
||||
if(nbytes < 0){
|
||||
avrdude_message(MSG_INFO, "%s: error: usbasp_transmit: %s\n", progname, usb_strerror());
|
||||
pmsg_error("%s\n", usb_strerror());
|
||||
return -1;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (verbose > 3 && receive && nbytes > 0) {
|
||||
int i;
|
||||
avrdude_message(MSG_TRACE, "%s<= ", progbuf);
|
||||
imsg_trace("<= ");
|
||||
for (i = 0; i < nbytes; i++)
|
||||
avrdude_message(MSG_TRACE, "[%02x] ", buffer[i]);
|
||||
avrdude_message(MSG_TRACE, "\n");
|
||||
msg_trace("[%02x] ", buffer[i]);
|
||||
msg_trace("\n");
|
||||
}
|
||||
|
||||
return nbytes;
|
||||
|
@ -421,8 +417,7 @@ static int usbOpenDevice(libusb_device_handle **device, int vendor,
|
|||
r = libusb_open(dev, &handle);
|
||||
if (!handle) {
|
||||
errorCode = USB_ERROR_ACCESS;
|
||||
avrdude_message(MSG_INFO, "%s: Warning: cannot open USB device: %s\n",
|
||||
progname, errstr(r));
|
||||
pmsg_warning("cannot open USB device: %s\n", errstr(r));
|
||||
continue;
|
||||
}
|
||||
errorCode = 0;
|
||||
|
@ -432,12 +427,10 @@ static int usbOpenDevice(libusb_device_handle **device, int vendor,
|
|||
if (r < 0) {
|
||||
if ((vendorName != NULL) && (vendorName[0] != 0)) {
|
||||
errorCode = USB_ERROR_IO;
|
||||
avrdude_message(MSG_INFO, "%s: Warning: cannot query manufacturer for device: %s\n",
|
||||
progname, errstr(r));
|
||||
pmsg_warning("cannot query manufacturer for device: %s\n", errstr(r));
|
||||
}
|
||||
} else {
|
||||
avrdude_message(MSG_NOTICE2, "%s: seen device from vendor ->%s<-\n",
|
||||
progname, string);
|
||||
pmsg_notice2("seen device from vendor >%s<\n", string);
|
||||
if ((vendorName != NULL) && (vendorName[0] != 0) && (strcmp(string, vendorName) != 0))
|
||||
errorCode = USB_ERROR_NOTFOUND;
|
||||
}
|
||||
|
@ -446,12 +439,10 @@ static int usbOpenDevice(libusb_device_handle **device, int vendor,
|
|||
if (r < 0) {
|
||||
if ((productName != NULL) && (productName[0] != 0)) {
|
||||
errorCode = USB_ERROR_IO;
|
||||
avrdude_message(MSG_INFO, "%s: Warning: cannot query product for device: %s\n",
|
||||
progname, errstr(r));
|
||||
pmsg_warning("cannot query product for device: %s\n", errstr(r));
|
||||
}
|
||||
} else {
|
||||
avrdude_message(MSG_NOTICE2, "%s: seen product ->%s<-\n",
|
||||
progname, string);
|
||||
pmsg_notice2("seen product >%s<\n", string);
|
||||
if((productName != NULL) && (productName[0] != 0) && (strcmp(string, productName) != 0))
|
||||
errorCode = USB_ERROR_NOTFOUND;
|
||||
}
|
||||
|
@ -494,8 +485,7 @@ static int didUsbInit = 0;
|
|||
handle = usb_open(dev);
|
||||
if(!handle){
|
||||
errorCode = USB_ERROR_ACCESS;
|
||||
avrdude_message(MSG_INFO, "%s: Warning: cannot open USB device: %s\n",
|
||||
progname, usb_strerror());
|
||||
pmsg_warning("cannot open USB device: %s\n", usb_strerror());
|
||||
continue;
|
||||
}
|
||||
errorCode = 0;
|
||||
|
@ -506,12 +496,10 @@ static int didUsbInit = 0;
|
|||
if(len < 0){
|
||||
if ((vendorName != NULL) && (vendorName[0] != 0)) {
|
||||
errorCode = USB_ERROR_IO;
|
||||
avrdude_message(MSG_INFO, "%s: Warning: cannot query manufacturer for device: %s\n",
|
||||
progname, usb_strerror());
|
||||
pmsg_warning("cannot query manufacturer for device: %s\n", usb_strerror());
|
||||
}
|
||||
} else {
|
||||
avrdude_message(MSG_NOTICE2, "%s: seen device from vendor ->%s<-\n",
|
||||
progname, string);
|
||||
pmsg_notice2("seen device from vendor >%s<\n", string);
|
||||
if((vendorName != NULL) && (vendorName[0] != 0) && (strcmp(string, vendorName) != 0))
|
||||
errorCode = USB_ERROR_NOTFOUND;
|
||||
}
|
||||
|
@ -521,12 +509,10 @@ static int didUsbInit = 0;
|
|||
if(len < 0){
|
||||
if ((productName != NULL) && (productName[0] != 0)) {
|
||||
errorCode = USB_ERROR_IO;
|
||||
avrdude_message(MSG_INFO, "%s: Warning: cannot query product for device: %s\n",
|
||||
progname, usb_strerror());
|
||||
pmsg_warning("cannot query product for device: %s\n", usb_strerror());
|
||||
}
|
||||
} else {
|
||||
avrdude_message(MSG_NOTICE2, "%s: seen product ->%s<-\n",
|
||||
progname, string);
|
||||
pmsg_notice2("seen product >%s<\n", string);
|
||||
if((productName != NULL) && (productName[0] != 0) && (strcmp(string, productName) != 0))
|
||||
errorCode = USB_ERROR_NOTFOUND;
|
||||
}
|
||||
|
@ -550,8 +536,7 @@ static int didUsbInit = 0;
|
|||
|
||||
/* Interface - prog. */
|
||||
static int usbasp_open(PROGRAMMER *pgm, const char *port) {
|
||||
avrdude_message(MSG_DEBUG, "%s: usbasp_open(\"%s\")\n",
|
||||
progname, port);
|
||||
pmsg_debug("usbasp_open(\"%s\")\n", port);
|
||||
|
||||
/* usb_init will be done in usbOpenDevice */
|
||||
LNODEID usbpid = lfirst(pgm->usbpid);
|
||||
|
@ -559,8 +544,7 @@ static int usbasp_open(PROGRAMMER *pgm, const char *port) {
|
|||
if (usbpid) {
|
||||
pid = *(int *)(ldata(usbpid));
|
||||
if (lnext(usbpid))
|
||||
avrdude_message(MSG_INFO, "%s: Warning: using PID 0x%04x, ignoring remaining PIDs in list\n",
|
||||
progname, pid);
|
||||
pmsg_warning("using PID 0x%04x, ignoring remaining PIDs in list\n", pid);
|
||||
} else {
|
||||
pid = USBASP_SHARED_PID;
|
||||
}
|
||||
|
@ -570,14 +554,11 @@ static int usbasp_open(PROGRAMMER *pgm, const char *port) {
|
|||
if(strcasecmp(ldata(lfirst(pgm->id)), "usbasp") == 0) {
|
||||
/* for id usbasp autodetect some variants */
|
||||
if(strcasecmp(port, "nibobee") == 0) {
|
||||
avrdude_message(MSG_INFO, "%s: warning: Using \"-C usbasp -P nibobee\" is deprecated,"
|
||||
"use \"-C nibobee\" instead.\n",
|
||||
progname);
|
||||
pmsg_error("using -C usbasp -P nibobee is deprecated, use -C nibobee instead\n");
|
||||
if (usbOpenDevice(&PDATA(pgm)->usbhandle, USBASP_NIBOBEE_VID, "www.nicai-systems.com",
|
||||
USBASP_NIBOBEE_PID, "NIBObee") != 0) {
|
||||
avrdude_message(MSG_INFO, "%s: error: could not find USB device "
|
||||
"\"NIBObee\" with vid=0x%x pid=0x%x\n",
|
||||
progname, USBASP_NIBOBEE_VID, USBASP_NIBOBEE_PID);
|
||||
pmsg_error("cannot find USB device NIBObee with vid=0x%x pid=0x%x\n",
|
||||
USBASP_NIBOBEE_VID, USBASP_NIBOBEE_PID);
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
|
@ -586,24 +567,21 @@ static int usbasp_open(PROGRAMMER *pgm, const char *port) {
|
|||
if (usbOpenDevice(&PDATA(pgm)->usbhandle, USBASP_OLD_VID, "www.fischl.de",
|
||||
USBASP_OLD_PID, "USBasp") == 0) {
|
||||
/* found USBasp with old IDs */
|
||||
avrdude_message(MSG_INFO, "%s: Warning: Found USB device \"USBasp\" with "
|
||||
"old VID/PID! Please update firmware of USBasp!\n",
|
||||
progname);
|
||||
pmsg_error("found USB device USBasp with old VID/PID; please update firmware of USBasp\n");
|
||||
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 */
|
||||
}
|
||||
|
||||
avrdude_message(MSG_INFO, "%s: error: could not find USB device with vid=0x%x pid=0x%x",
|
||||
progname, vid, pid);
|
||||
pmsg_error("cannot find USB device with vid=0x%x pid=0x%x", vid, pid);
|
||||
if (pgm->usbvendor[0] != 0) {
|
||||
avrdude_message(MSG_INFO, " vendor='%s'", pgm->usbvendor);
|
||||
msg_error(" vendor='%s'", pgm->usbvendor);
|
||||
}
|
||||
if (pgm->usbproduct[0] != 0) {
|
||||
avrdude_message(MSG_INFO, " product='%s'", pgm->usbproduct);
|
||||
msg_error(" product='%s'", pgm->usbproduct);
|
||||
}
|
||||
avrdude_message(MSG_INFO, "\n");
|
||||
msg_error("\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -612,7 +590,7 @@ static int usbasp_open(PROGRAMMER *pgm, const char *port) {
|
|||
|
||||
static void usbasp_close(PROGRAMMER * pgm)
|
||||
{
|
||||
avrdude_message(MSG_DEBUG, "%s: usbasp_close()\n", progname);
|
||||
pmsg_debug("usbasp_close()\n");
|
||||
|
||||
if (PDATA(pgm)->usbhandle!=NULL) {
|
||||
unsigned char temp[4];
|
||||
|
@ -665,7 +643,7 @@ static int usbasp_initialize(const PROGRAMMER *pgm, const AVRPART *p) {
|
|||
unsigned char res[4];
|
||||
IMPORT_PDATA(pgm);
|
||||
|
||||
avrdude_message(MSG_DEBUG, "%s: usbasp_initialize()\n", progname);
|
||||
pmsg_debug("usbasp_initialize()\n");
|
||||
|
||||
/* get capabilities */
|
||||
memset(temp, 0, sizeof(temp));
|
||||
|
@ -712,23 +690,20 @@ static int usbasp_initialize(const PROGRAMMER *pgm, const AVRPART *p) {
|
|||
static int usbasp_spi_cmd(const PROGRAMMER *pgm, const unsigned char *cmd,
|
||||
unsigned char *res)
|
||||
{
|
||||
avrdude_message(MSG_DEBUG, "%s: usbasp_spi_cmd(0x%02x, 0x%02x, 0x%02x, 0x%02x)%s",
|
||||
progname, cmd[0], cmd[1], cmd[2], cmd[3],
|
||||
verbose > 3? "...\n": "");
|
||||
pmsg_debug("usbasp_spi_cmd(0x%02x, 0x%02x, 0x%02x, 0x%02x)%s",
|
||||
cmd[0], cmd[1], cmd[2], cmd[3], verbose > 3? " ...\n": "");
|
||||
|
||||
int nbytes =
|
||||
usbasp_transmit(pgm, 1, USBASP_FUNC_TRANSMIT, cmd, res, 4);
|
||||
|
||||
if(nbytes != 4){
|
||||
if (verbose == 3)
|
||||
putc('\n', stderr);
|
||||
msg_debug("\n");
|
||||
|
||||
avrdude_message(MSG_INFO, "%s: error: wrong response size\n",
|
||||
progname);
|
||||
pmsg_error("wrong response size\n");
|
||||
return -1;
|
||||
}
|
||||
avrdude_message(MSG_TRACE, "%s: usbasp_spi_cmd()", progname);
|
||||
avrdude_message(MSG_DEBUG, " => 0x%02x, 0x%02x, 0x%02x, 0x%02x\n",
|
||||
pmsg_trace("usbasp_spi_cmd()");
|
||||
msg_debug(" => 0x%02x, 0x%02x, 0x%02x, 0x%02x\n",
|
||||
res[0], res[1], res[2], res[3]);
|
||||
|
||||
return 0;
|
||||
|
@ -742,15 +717,13 @@ static int usbasp_spi_program_enable(const PROGRAMMER *pgm, const AVRPART *p) {
|
|||
|
||||
cmd[0] = 0;
|
||||
|
||||
avrdude_message(MSG_DEBUG, "%s: usbasp_program_enable()\n",
|
||||
progname);
|
||||
pmsg_debug("usbasp_program_enable()\n");
|
||||
|
||||
int nbytes =
|
||||
usbasp_transmit(pgm, 1, USBASP_FUNC_ENABLEPROG, cmd, res, sizeof(res));
|
||||
|
||||
if ((nbytes != 1) | (res[0] != 0)) {
|
||||
avrdude_message(MSG_INFO, "%s: error: program enable: target doesn't answer. %x \n",
|
||||
progname, res[0]);
|
||||
pmsg_error("program enable: target does not answer (0x%02x)\n", res[0]);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -761,12 +734,10 @@ static int usbasp_spi_chip_erase(const PROGRAMMER *pgm, const AVRPART *p) {
|
|||
unsigned char cmd[4];
|
||||
unsigned char res[4];
|
||||
|
||||
avrdude_message(MSG_DEBUG, "%s: usbasp_chip_erase()\n",
|
||||
progname);
|
||||
pmsg_debug("usbasp_chip_erase()\n");
|
||||
|
||||
if (p->op[AVR_OP_CHIP_ERASE] == NULL) {
|
||||
avrdude_message(MSG_INFO, "chip erase instruction not defined for part \"%s\"\n",
|
||||
p->desc);
|
||||
pmsg_error("chip erase instruction not defined for part %s\n", p->desc);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -790,8 +761,7 @@ static int usbasp_spi_paged_load(const PROGRAMMER *pgm, const AVRPART *p, const
|
|||
unsigned char *buffer = m->buf + address;
|
||||
int function;
|
||||
|
||||
avrdude_message(MSG_DEBUG, "%s: usbasp_program_paged_load(\"%s\", 0x%x, %d)\n",
|
||||
progname, m->desc, address, n_bytes);
|
||||
pmsg_debug("usbasp_program_paged_load(\"%s\", 0x%x, %d)\n", m->desc, address, n_bytes);
|
||||
|
||||
if (strcmp(m->desc, "flash") == 0) {
|
||||
function = USBASP_FUNC_READFLASH;
|
||||
|
@ -834,8 +804,7 @@ static int usbasp_spi_paged_load(const PROGRAMMER *pgm, const AVRPART *p, const
|
|||
n = usbasp_transmit(pgm, 1, function, cmd, buffer, blocksize);
|
||||
|
||||
if (n != blocksize) {
|
||||
avrdude_message(MSG_INFO, "%s: error: wrong reading bytes %x\n",
|
||||
progname, n);
|
||||
pmsg_error("wrong reading bytes %x\n", n);
|
||||
return -3;
|
||||
}
|
||||
|
||||
|
@ -857,8 +826,7 @@ static int usbasp_spi_paged_write(const PROGRAMMER *pgm, const AVRPART *p, const
|
|||
unsigned char blockflags = USBASP_BLOCKFLAG_FIRST;
|
||||
int function;
|
||||
|
||||
avrdude_message(MSG_DEBUG, "%s: usbasp_program_paged_write(\"%s\", 0x%x, %d)\n",
|
||||
progname, m->desc, address, n_bytes);
|
||||
pmsg_debug("usbasp_program_paged_write(\"%s\", 0x%x, %d)\n", m->desc, address, n_bytes);
|
||||
|
||||
if (strcmp(m->desc, "flash") == 0) {
|
||||
function = USBASP_FUNC_WRITEFLASH;
|
||||
|
@ -905,8 +873,7 @@ static int usbasp_spi_paged_write(const PROGRAMMER *pgm, const AVRPART *p, const
|
|||
n = usbasp_transmit(pgm, 0, function, cmd, buffer, blocksize);
|
||||
|
||||
if (n != blocksize) {
|
||||
avrdude_message(MSG_INFO, "%s: error: wrong count at writing %x\n",
|
||||
progname, n);
|
||||
pmsg_error("wrong count at writing %x\n", n);
|
||||
return -3;
|
||||
}
|
||||
|
||||
|
@ -944,8 +911,7 @@ static int usbasp_spi_set_sck_period(const PROGRAMMER *pgm, double sckperiod) {
|
|||
unsigned char res[4];
|
||||
unsigned char cmd[4];
|
||||
|
||||
avrdude_message(MSG_DEBUG, "%s: usbasp_spi_set_sck_period(%g)\n",
|
||||
progname, sckperiod);
|
||||
pmsg_debug("usbasp_spi_set_sck_period(%g)\n", sckperiod);
|
||||
|
||||
memset(cmd, 0, sizeof(cmd));
|
||||
memset(res, 0, sizeof(res));
|
||||
|
@ -956,22 +922,22 @@ static int usbasp_spi_set_sck_period(const PROGRAMMER *pgm, double sckperiod) {
|
|||
if (sckperiod == 0) {
|
||||
/* auto sck set */
|
||||
|
||||
avrdude_message(MSG_NOTICE, "%s: auto set sck period (because given equals null)\n", progname);
|
||||
pmsg_notice("auto set sck period (because given equals null)\n");
|
||||
|
||||
} else {
|
||||
|
||||
int sckfreq = 1 / sckperiod; /* sck in Hz */
|
||||
int usefreq = 0;
|
||||
|
||||
avrdude_message(MSG_NOTICE2, "%s: try to set SCK period to %g s (= %i Hz)\n", progname, sckperiod, sckfreq);
|
||||
pmsg_notice2("try to set SCK period to %g s (= %i Hz)\n", sckperiod, sckfreq);
|
||||
|
||||
/* Check if programmer is capable of 3 MHz SCK, if not then ommit 3 MHz setting */
|
||||
int i;
|
||||
if (PDATA(pgm)->sck_3mhz) {
|
||||
avrdude_message(MSG_NOTICE2, "%s: connected USBasp is capable of 3 MHz SCK\n",progname);
|
||||
pmsg_notice2("connected USBasp is capable of 3 MHz SCK\n");
|
||||
i = 0;
|
||||
} else {
|
||||
avrdude_message(MSG_NOTICE2, "%s: connected USBasp is not cabable of 3 MHz SCK\n",progname);
|
||||
pmsg_notice2("connected USBasp is not cabable of 3 MHz SCK\n");
|
||||
i = 1;
|
||||
}
|
||||
if (sckfreq >= usbaspSCKoptions[i].frequency) {
|
||||
|
@ -993,7 +959,7 @@ static int usbasp_spi_set_sck_period(const PROGRAMMER *pgm, double sckperiod) {
|
|||
/* save used sck frequency */
|
||||
PDATA(pgm)->sckfreq_hz = usefreq;
|
||||
|
||||
avrdude_message(MSG_INFO, "%s: set SCK frequency to %i Hz\n", progname, usefreq);
|
||||
pmsg_info("set SCK frequency to %i Hz\n", usefreq);
|
||||
}
|
||||
|
||||
cmd[0] = clockoption;
|
||||
|
@ -1002,8 +968,7 @@ static int usbasp_spi_set_sck_period(const PROGRAMMER *pgm, double sckperiod) {
|
|||
usbasp_transmit(pgm, 1, USBASP_FUNC_SETISPSCK, cmd, res, sizeof(res));
|
||||
|
||||
if ((nbytes != 1) | (res[0] != 0)) {
|
||||
avrdude_message(MSG_INFO, "%s: warning: cannot set sck period. please check for usbasp firmware update.\n",
|
||||
progname);
|
||||
pmsg_error("cannot set sck period; please check for usbasp firmware update\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -1027,7 +992,7 @@ static int usbasp_tpi_recv_byte(const PROGRAMMER *pgm) {
|
|||
|
||||
if(usbasp_transmit(pgm, 1, USBASP_FUNC_TPI_RAWREAD, temp, temp, sizeof(temp)) != 1)
|
||||
{
|
||||
avrdude_message(MSG_INFO, "%s: error: wrong response size\n", progname);
|
||||
pmsg_error("wrong response size\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -1038,7 +1003,7 @@ static int usbasp_tpi_recv_byte(const PROGRAMMER *pgm) {
|
|||
static int usbasp_tpi_nvm_waitbusy(const PROGRAMMER *pgm) {
|
||||
int retry;
|
||||
|
||||
avrdude_message(MSG_DEBUG, "%s: usbasp_tpi_nvm_waitbusy() ...", progname);
|
||||
pmsg_debug("usbasp_tpi_nvm_waitbusy() ...");
|
||||
|
||||
for(retry=50; retry>0; retry--)
|
||||
{
|
||||
|
@ -1046,25 +1011,25 @@ static int usbasp_tpi_nvm_waitbusy(const PROGRAMMER *pgm) {
|
|||
if(usbasp_tpi_recv_byte(pgm) & NVMCSR_BSY)
|
||||
continue;
|
||||
|
||||
avrdude_message(MSG_DEBUG, " ready\n");
|
||||
msg_debug(" ready\n");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
avrdude_message(MSG_DEBUG, " failure\n");
|
||||
msg_debug(" failure\n");
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
static int usbasp_tpi_cmd(const PROGRAMMER *pgm, const unsigned char *cmd, unsigned char *res) {
|
||||
avrdude_message(MSG_INFO, "%s: error: spi_cmd used in TPI mode: not allowed\n", progname);
|
||||
pmsg_error("spi_cmd used in TPI mode: not allowed\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
static int usbasp_tpi_program_enable(const PROGRAMMER *pgm, const AVRPART *p) {
|
||||
int retry;
|
||||
|
||||
avrdude_message(MSG_DEBUG, "%s: usbasp_tpi_program_enable()\n", progname);
|
||||
pmsg_debug("usbasp_tpi_program_enable()\n");
|
||||
|
||||
/* change guard time */
|
||||
usbasp_tpi_send_byte(pgm, TPI_OP_SSTCS(TPIPCR));
|
||||
|
@ -1094,7 +1059,7 @@ static int usbasp_tpi_program_enable(const PROGRAMMER *pgm, const AVRPART *p) {
|
|||
}
|
||||
if(retry >= 10)
|
||||
{
|
||||
avrdude_message(MSG_INFO, "%s: error: program enable: target doesn't answer.\n", progname);
|
||||
pmsg_error("program enable, target does not answer\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -1112,14 +1077,14 @@ static int usbasp_tpi_chip_erase(const PROGRAMMER *pgm, const AVRPART *p) {
|
|||
pr_0 = 0x41;
|
||||
pr_1 = 0x3F;
|
||||
nvm_cmd = NVMCMD_SECTION_ERASE;
|
||||
avrdude_message(MSG_DEBUG, "%s: usbasp_tpi_chip_erase() - section erase\n", progname);
|
||||
pmsg_debug("usbasp_tpi_chip_erase() - section erase\n");
|
||||
break;
|
||||
/* Chip erase (flash only) */
|
||||
default:
|
||||
pr_0 = 0x01;
|
||||
pr_1 = 0x40;
|
||||
nvm_cmd = NVMCMD_CHIP_ERASE;
|
||||
avrdude_message(MSG_DEBUG, "%s: usbasp_tpi_chip_erase() - chip erase\n", progname);
|
||||
pmsg_debug("usbasp_tpi_chip_erase() - chip erase\n");
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -1151,8 +1116,7 @@ static int usbasp_tpi_paged_load(const PROGRAMMER *pgm, const AVRPART *p, const
|
|||
uint16_t pr;
|
||||
|
||||
|
||||
avrdude_message(MSG_DEBUG, "%s: usbasp_tpi_paged_load(\"%s\", 0x%0x, %d)\n",
|
||||
progname, m->desc, addr, n_bytes);
|
||||
pmsg_debug("usbasp_tpi_paged_load(\"%s\", 0x%0x, %d)\n", m->desc, addr, n_bytes);
|
||||
|
||||
dptr = addr + m->buf;
|
||||
pr = addr + m->offset;
|
||||
|
@ -1172,7 +1136,7 @@ static int usbasp_tpi_paged_load(const PROGRAMMER *pgm, const AVRPART *p, const
|
|||
n = usbasp_transmit(pgm, 1, USBASP_FUNC_TPI_READBLOCK, cmd, dptr, clen);
|
||||
if(n != clen)
|
||||
{
|
||||
avrdude_message(MSG_INFO, "%s: error: wrong reading bytes %x\n", progname, n);
|
||||
pmsg_error("wrong reading bytes %x\n", n);
|
||||
return -3;
|
||||
}
|
||||
|
||||
|
@ -1193,8 +1157,7 @@ static int usbasp_tpi_paged_write(const PROGRAMMER *pgm, const AVRPART *p, const
|
|||
uint16_t pr;
|
||||
|
||||
|
||||
avrdude_message(MSG_DEBUG, "%s: usbasp_tpi_paged_write(\"%s\", 0x%0x, %d)\n",
|
||||
progname, m->desc, addr, n_bytes);
|
||||
pmsg_debug("usbasp_tpi_paged_write(\"%s\", 0x%0x, %d)\n", m->desc, addr, n_bytes);
|
||||
|
||||
sptr = addr + m->buf;
|
||||
pr = addr + m->offset;
|
||||
|
@ -1238,7 +1201,7 @@ static int usbasp_tpi_paged_write(const PROGRAMMER *pgm, const AVRPART *p, const
|
|||
n = usbasp_transmit(pgm, 0, USBASP_FUNC_TPI_WRITEBLOCK, cmd, sptr, clen);
|
||||
if(n != clen)
|
||||
{
|
||||
avrdude_message(MSG_INFO, "%s: error: wrong count at writing %x\n", progname, n);
|
||||
pmsg_error("wrong count at writing %x\n", n);
|
||||
return -3;
|
||||
}
|
||||
|
||||
|
@ -1260,8 +1223,7 @@ static int usbasp_tpi_read_byte(const PROGRAMMER * pgm, const AVRPART *p, const
|
|||
uint16_t pr;
|
||||
|
||||
|
||||
avrdude_message(MSG_DEBUG, "%s: usbasp_tpi_read_byte(\"%s\", 0x%0lx)\n",
|
||||
progname, m->desc, addr);
|
||||
pmsg_debug("usbasp_tpi_read_byte(\"%s\", 0x%0lx)\n", m->desc, addr);
|
||||
|
||||
pr = m->offset + addr;
|
||||
|
||||
|
@ -1273,7 +1235,7 @@ static int usbasp_tpi_read_byte(const PROGRAMMER * pgm, const AVRPART *p, const
|
|||
n = usbasp_transmit(pgm, 1, USBASP_FUNC_TPI_READBLOCK, cmd, value, 1);
|
||||
if(n != 1)
|
||||
{
|
||||
avrdude_message(MSG_INFO, "%s: error: wrong reading bytes %x\n", progname, n);
|
||||
pmsg_error("wrong reading bytes %x\n", n);
|
||||
return -3;
|
||||
}
|
||||
return 0;
|
||||
|
@ -1282,7 +1244,7 @@ static int usbasp_tpi_read_byte(const PROGRAMMER * pgm, const AVRPART *p, const
|
|||
static int usbasp_tpi_write_byte(const PROGRAMMER *pgm, const AVRPART *p, const AVRMEM *m,
|
||||
unsigned long addr, unsigned char data) { // FIXME: use avr_write_byte_cache() when implemented
|
||||
|
||||
avrdude_message(MSG_INFO, "%s: error: usbasp_write_byte in TPI mode: all writes have to be done at page level\n", progname);
|
||||
pmsg_error("usbasp_write_byte in TPI mode; all writes have to be done at page level\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -1323,8 +1285,7 @@ void usbasp_initpgm(PROGRAMMER *pgm) {
|
|||
#else /* HAVE_LIBUSB */
|
||||
|
||||
static int usbasp_nousb_open(PROGRAMMER *pgm, const char *name) {
|
||||
avrdude_message(MSG_INFO, "%s: error: no usb support. please compile again with libusb installed.\n",
|
||||
progname);
|
||||
pmsg_error("no usb support; please compile again with libusb installed\n");
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
|
|
@ -79,8 +79,7 @@ struct pdata
|
|||
static void usbtiny_setup(PROGRAMMER * pgm)
|
||||
{
|
||||
if ((pgm->cookie = malloc(sizeof(struct pdata))) == 0) {
|
||||
avrdude_message(MSG_INFO, "%s: usbtiny_setup(): Out of memory allocating private data\n",
|
||||
progname);
|
||||
pmsg_error("out of memory allocating private data\n");
|
||||
exit(1);
|
||||
}
|
||||
memset(pgm->cookie, 0, sizeof(struct pdata));
|
||||
|
@ -103,7 +102,8 @@ static int usb_control (const PROGRAMMER *pgm,
|
|||
NULL, 0, // no data buffer in control message
|
||||
USB_TIMEOUT ); // default timeout
|
||||
if(nbytes < 0){
|
||||
avrdude_message(MSG_INFO, "\n%s: error: usbtiny_transmit: %s\n", progname, usb_strerror());
|
||||
msg_error("\n");
|
||||
pmsg_error("%s\n", usb_strerror());
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -135,17 +135,15 @@ static int usb_in (const PROGRAMMER *pgm,
|
|||
}
|
||||
PDATA(pgm)->retries++;
|
||||
}
|
||||
avrdude_message(MSG_INFO, "\n%s: error: usbtiny_receive: %s (expected %d, got %d)\n",
|
||||
progname, usb_strerror(), buflen, nbytes);
|
||||
msg_error("\n");
|
||||
pmsg_error("%s (expected %d, got %d)\n", usb_strerror(), buflen, nbytes);
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Report the number of retries, and reset the counter.
|
||||
static void check_retries (const PROGRAMMER *pgm, const char *operation) {
|
||||
if (PDATA(pgm)->retries > 0 && quell_progress < 2) {
|
||||
avrdude_message(MSG_INFO, "%s: %d retries during %s\n", progname,
|
||||
PDATA(pgm)->retries, operation);
|
||||
}
|
||||
if (PDATA(pgm)->retries > 0)
|
||||
pmsg_info("%d retries during %s\n", PDATA(pgm)->retries, operation);
|
||||
PDATA(pgm)->retries = 0;
|
||||
}
|
||||
|
||||
|
@ -168,8 +166,8 @@ static int usb_out (const PROGRAMMER *pgm,
|
|||
(char *)buffer, buflen,
|
||||
timeout);
|
||||
if (nbytes != buflen) {
|
||||
avrdude_message(MSG_INFO, "\n%s: error: usbtiny_send: %s (expected %d, got %d)\n",
|
||||
progname, usb_strerror(), buflen, nbytes);
|
||||
msg_error("\n");
|
||||
pmsg_error("%s (expected %d, got %d)\n", usb_strerror(), buflen, nbytes);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -223,8 +221,7 @@ static int usbtiny_tpi_tx(const PROGRAMMER *pgm, unsigned char b0) {
|
|||
if (usb_in(pgm, USBTINY_SPI, tpi_frame(b0), 0xffff,
|
||||
res, sizeof(res), 8 * sizeof(res) * PDATA(pgm)->sck_period) < 0)
|
||||
return -1;
|
||||
if (verbose > 1)
|
||||
fprintf(stderr, "CMD_TPI_TX: [0x%02x]\n", b0);
|
||||
msg_notice2("CMD_TPI_TX: [0x%02x]\n", b0);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -238,8 +235,7 @@ static int usbtiny_tpi_txtx(const PROGRAMMER *pgm,
|
|||
if (usb_in(pgm, USBTINY_SPI, tpi_frame(b0), tpi_frame(b1),
|
||||
res, sizeof(res), 8 * sizeof(res) * PDATA(pgm)->sck_period) < 0)
|
||||
return -1;
|
||||
if (verbose > 1)
|
||||
fprintf(stderr, "CMD_TPI_TX_TX: [0x%02x 0x%02x]\n", b0, b1);
|
||||
msg_notice2("CMD_TPI_TX_TX: [0x%02x 0x%02x]\n", b0, b1);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -264,16 +260,15 @@ static int usbtiny_tpi_txrx(const PROGRAMMER *pgm, unsigned char b0) {
|
|||
bit and the 8 data bits, but the latter in reverse order. */
|
||||
r = reverse(w >> 7);
|
||||
if (tpi_parity(r) != ((w >> 6) & 1)) {
|
||||
fprintf(stderr, "%s: parity bit is wrong\n", __func__);
|
||||
pmsg_error("parity bit is wrong\n");
|
||||
return -1;
|
||||
}
|
||||
if (((w >> 4) & 0x3) != TPI_STOP_BITS) {
|
||||
fprintf(stderr, "%s: stop bits not received correctly\n", __func__);
|
||||
pmsg_error("stop bits not received correctly\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (verbose > 1)
|
||||
fprintf(stderr, "CMD_TPI_TX_RX: [0x%02x -> 0x%02x]\n", b0, r);
|
||||
msg_notice2("CMD_TPI_TX_RX: [0x%02x -> 0x%02x]\n", b0, r);
|
||||
return r;
|
||||
}
|
||||
|
||||
|
@ -288,7 +283,7 @@ static int usbtiny_avr_op (const PROGRAMMER *pgm, const AVRPART *p,
|
|||
unsigned char cmd[4];
|
||||
|
||||
if (p->op[op] == NULL) {
|
||||
avrdude_message(MSG_INFO, "Operation %d not defined for this chip!\n", op );
|
||||
pmsg_error("operation %d not defined for this chip\n", op);
|
||||
return -1;
|
||||
}
|
||||
memset(cmd, 0, sizeof(cmd));
|
||||
|
@ -337,8 +332,7 @@ static int usbtiny_open(PROGRAMMER *pgm, const char *name) {
|
|||
if (usbpid) {
|
||||
pid = *(int *)(ldata(usbpid));
|
||||
if (lnext(usbpid))
|
||||
avrdude_message(MSG_INFO, "%s: Warning: using PID 0x%04x, ignoring remaining PIDs in list\n",
|
||||
progname, pid);
|
||||
pmsg_warning("using PID 0x%04x, ignoring remaining PIDs in list\n", pid);
|
||||
} else {
|
||||
pid = USBTINY_PRODUCT_DEFAULT;
|
||||
}
|
||||
|
@ -349,8 +343,7 @@ static int usbtiny_open(PROGRAMMER *pgm, const char *name) {
|
|||
for ( dev = bus->devices; dev; dev = dev->next ) {
|
||||
if (dev->descriptor.idVendor == vid
|
||||
&& dev->descriptor.idProduct == pid ) { // found match?
|
||||
avrdude_message(MSG_NOTICE, "%s: usbdev_open(): Found USBtinyISP, bus:device: %s:%s\n",
|
||||
progname, bus->dirname, dev->filename);
|
||||
pmsg_notice("usbdev_open(): found USBtinyISP, bus:device: %s:%s\n", bus->dirname, dev->filename);
|
||||
// if -P was given, match device by device name and bus name
|
||||
if(name != NULL &&
|
||||
(NULL == dev_name ||
|
||||
|
@ -361,8 +354,7 @@ static int usbtiny_open(PROGRAMMER *pgm, const char *name) {
|
|||
|
||||
// wrong permissions or something?
|
||||
if (!PDATA(pgm)->usb_handle) {
|
||||
avrdude_message(MSG_INFO, "%s: Warning: cannot open USB device: %s\n",
|
||||
progname, usb_strerror());
|
||||
pmsg_warning("cannot open USB device: %s\n", usb_strerror());
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
@ -370,13 +362,12 @@ static int usbtiny_open(PROGRAMMER *pgm, const char *name) {
|
|||
}
|
||||
|
||||
if(NULL != name && NULL == dev_name) {
|
||||
avrdude_message(MSG_INFO, "%s: Error: Invalid -P value: '%s'\n", progname, name);
|
||||
avrdude_message(MSG_INFO, "%sUse -P usb:bus:device\n", progbuf);
|
||||
pmsg_error("invalid -P value: '%s'\n", name);
|
||||
imsg_error("use -P usb:bus:device\n");
|
||||
return -1;
|
||||
}
|
||||
if (!PDATA(pgm)->usb_handle) {
|
||||
avrdude_message(MSG_INFO, "%s: Error: Could not find USBtiny device (0x%x/0x%x)\n",
|
||||
progname, vid, pid );
|
||||
pmsg_error("cannot find USBtiny device (0x%x/0x%x)\n", vid, pid );
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -418,7 +409,7 @@ static int usbtiny_set_sck_period (const PROGRAMMER *pgm, double v) {
|
|||
if (PDATA(pgm)->sck_period > SCK_MAX)
|
||||
PDATA(pgm)->sck_period = SCK_MAX;
|
||||
|
||||
avrdude_message(MSG_NOTICE, "%s: Setting SCK period to %d usec\n", progname,
|
||||
pmsg_notice("setting SCK period to %d usec\n",
|
||||
PDATA(pgm)->sck_period );
|
||||
|
||||
// send the command to the usbtiny device.
|
||||
|
@ -443,8 +434,7 @@ static int usbtiny_initialize (const PROGRAMMER *pgm, const AVRPART *p ) {
|
|||
} else {
|
||||
// -B option not specified: use default
|
||||
PDATA(pgm)->sck_period = SCK_DEFAULT;
|
||||
avrdude_message(MSG_NOTICE, "%s: Using SCK period of %d usec\n",
|
||||
progname, PDATA(pgm)->sck_period );
|
||||
pmsg_notice("using SCK period of %d usec\n", PDATA(pgm)->sck_period );
|
||||
if (usb_control(pgm, USBTINY_POWERUP,
|
||||
PDATA(pgm)->sck_period, RESET_LOW ) < 0)
|
||||
return -1;
|
||||
|
@ -458,20 +448,18 @@ static int usbtiny_initialize (const PROGRAMMER *pgm, const AVRPART *p ) {
|
|||
/* Since there is a single TPIDATA line, MOSI and MISO must be
|
||||
linked together through a 1kOhm resistor. Verify that
|
||||
everything we send on MOSI gets mirrored back on MISO. */
|
||||
if (verbose >= 2)
|
||||
fprintf(stderr, "doing MOSI-MISO link check\n");
|
||||
msg_notice2("doing MOSI-MISO link check\n");
|
||||
|
||||
memset(res, 0xaa, sizeof(res));
|
||||
if (usb_in(pgm, USBTINY_SPI, LITTLE_TO_BIG_16(0x1234), LITTLE_TO_BIG_16(0x5678),
|
||||
res, 4, 32 * PDATA(pgm)->sck_period) < 0) {
|
||||
fprintf(stderr, "usb_in() failed\n");
|
||||
pmsg_error("usb_in() failed\n");
|
||||
return -1;
|
||||
}
|
||||
if (res[0] != 0x12 || res[1] != 0x34 || res[2] != 0x56 || res[3] != 0x78) {
|
||||
fprintf(stderr,
|
||||
"MOSI->MISO check failed (got 0x%02x 0x%02x 0x%02x 0x%02x)\n"
|
||||
"\tPlease verify that MISO is connected directly to TPIDATA and\n"
|
||||
"\tMOSI is connected to TPIDATA through a 1kOhm resistor.\n",
|
||||
pmsg_error("MOSI->MISO check failed (got 0x%02x 0x%02x 0x%02x 0x%02x)\n"
|
||||
"\tplease verify that MISO is connected directly to TPIDATA and\n"
|
||||
"\tMOSI is connected to TPIDATA through a 1kOhm resistor\n",
|
||||
res[0], res[1], res[2], res[3]);
|
||||
return -1;
|
||||
}
|
||||
|
@ -480,7 +468,7 @@ static int usbtiny_initialize (const PROGRAMMER *pgm, const AVRPART *p ) {
|
|||
if (usb_in(pgm, USBTINY_SPI, 0xffff, 0xffff, res, 4,
|
||||
32 * PDATA(pgm)->sck_period) < 0)
|
||||
{
|
||||
fprintf(stderr, "Unable to switch chip into TPI mode\n");
|
||||
pmsg_error("unable to switch chip into TPI mode\n");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
@ -538,7 +526,7 @@ static int usbtiny_cmd(const PROGRAMMER *pgm, const unsigned char *cmd, unsigned
|
|||
return -1;
|
||||
check_retries(pgm, "SPI command");
|
||||
// print out the data we sent and received
|
||||
avrdude_message(MSG_NOTICE2, "CMD: [%02x %02x %02x %02x] [%02x %02x %02x %02x]\n",
|
||||
msg_notice2("CMD: [%02x %02x %02x %02x] [%02x %02x %02x %02x]\n",
|
||||
cmd[0], cmd[1], cmd[2], cmd[3],
|
||||
res[0], res[1], res[2], res[3] );
|
||||
return ((nbytes == 4) && // should have read 4 bytes
|
||||
|
@ -574,8 +562,7 @@ int usbtiny_cmd_tpi(const PROGRAMMER *pgm, const unsigned char *cmd,
|
|||
}
|
||||
|
||||
if (rx < res_len) {
|
||||
fprintf(stderr, "%s: unexpected cmd_len=%d/res_len=%d\n",
|
||||
__func__, cmd_len, res_len);
|
||||
pmsg_error("unexpected cmd_len=%d/res_len=%d\n", cmd_len, res_len);
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
|
@ -588,8 +575,7 @@ static int usbtiny_spi(const PROGRAMMER *pgm, const unsigned char *cmd, unsigned
|
|||
memset(res, 0, count);
|
||||
|
||||
if (count % 4) {
|
||||
avrdude_message(MSG_INFO, "Direct SPI write must be a multiple of 4 bytes for %s\n",
|
||||
pgm->type);
|
||||
pmsg_error("direct SPI write must be a multiple of 4 bytes for %s\n", pgm->type);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -609,8 +595,7 @@ static int usbtiny_chip_erase(const PROGRAMMER *pgm, const AVRPART *p) {
|
|||
return avr_tpi_chip_erase(pgm, p);
|
||||
|
||||
if (p->op[AVR_OP_CHIP_ERASE] == NULL) {
|
||||
avrdude_message(MSG_INFO, "Chip erase instruction not defined for part \"%s\"\n",
|
||||
p->desc);
|
||||
pmsg_error("chip erase instruction not defined for part %s\n", p->desc);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -818,8 +803,7 @@ void usbtiny_initpgm(PROGRAMMER *pgm) {
|
|||
// Give a proper error if we were not compiled with libusb
|
||||
|
||||
static int usbtiny_nousb_open(PROGRAMMER *pgm, const char *name) {
|
||||
avrdude_message(MSG_INFO, "%s: error: no usb support. Please compile again with libusb installed.\n",
|
||||
progname);
|
||||
pmsg_error("no usb support; please compile again with libusb installed\n");
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
|
24
src/wiring.c
24
src/wiring.c
|
@ -85,8 +85,7 @@ static void wiring_setup(PROGRAMMER * pgm)
|
|||
* Now prepare our data
|
||||
*/
|
||||
if ((mycookie = malloc(sizeof(struct wiringpdata))) == 0) {
|
||||
avrdude_message(MSG_INFO, "%s: wiring_setup(): Out of memory allocating private data\n",
|
||||
progname);
|
||||
pmsg_error("out of memory allocating private data\n");
|
||||
exit(1);
|
||||
}
|
||||
memset(mycookie, 0, sizeof(struct wiringpdata));
|
||||
|
@ -122,20 +121,17 @@ static int wiring_parseextparms(const PROGRAMMER *pgm, const LISTID extparms) {
|
|||
int newsnooze;
|
||||
if (sscanf(extended_param, "snooze=%i", &newsnooze) != 1 ||
|
||||
newsnooze < 0) {
|
||||
avrdude_message(MSG_INFO, "%s: wiring_parseextparms(): invalid snooze time '%s'\n",
|
||||
progname, extended_param);
|
||||
pmsg_error("invalid snooze time '%s'\n", extended_param);
|
||||
rv = -1;
|
||||
continue;
|
||||
}
|
||||
avrdude_message(MSG_NOTICE2, "%s: wiring_parseextparms(): snooze time set to %d ms\n",
|
||||
progname, newsnooze);
|
||||
pmsg_notice2("wiring_parseextparms(): snooze time set to %d ms\n", newsnooze);
|
||||
WIRINGPDATA(mycookie)->snoozetime = newsnooze;
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
avrdude_message(MSG_INFO, "%s: wiring_parseextparms(): invalid extended parameter '%s'\n",
|
||||
progname, extended_param);
|
||||
pmsg_error("invalid extended parameter '%s'\n", extended_param);
|
||||
rv = -1;
|
||||
}
|
||||
|
||||
|
@ -157,20 +153,17 @@ static int wiring_open(PROGRAMMER *pgm, const char *port) {
|
|||
if (WIRINGPDATA(mycookie)->snoozetime > 0) {
|
||||
timetosnooze = WIRINGPDATA(mycookie)->snoozetime;
|
||||
|
||||
avrdude_message(MSG_NOTICE2, "%s: wiring_open(): snoozing for %d ms\n",
|
||||
progname, timetosnooze);
|
||||
pmsg_notice2("wiring_open(): snoozing for %d ms\n", timetosnooze);
|
||||
while (timetosnooze--)
|
||||
usleep(1000);
|
||||
avrdude_message(MSG_NOTICE2, "%s: wiring_open(): done snoozing\n",
|
||||
progname);
|
||||
pmsg_notice2("wiring_open(): done snoozing\n");
|
||||
} else {
|
||||
/* Perform Wiring programming mode RESET. */
|
||||
/* This effectively *releases* both DTR and RTS. */
|
||||
/* i.e. both DTR and RTS rise to a HIGH logic level */
|
||||
/* since they are active LOW signals. */
|
||||
|
||||
avrdude_message(MSG_NOTICE2, "%s: wiring_open(): releasing DTR/RTS\n",
|
||||
progname);
|
||||
pmsg_notice2("wiring_open(): releasing DTR/RTS\n");
|
||||
|
||||
serial_set_dtr_rts(&pgm->fd, 0);
|
||||
usleep(50*1000);
|
||||
|
@ -178,8 +171,7 @@ static int wiring_open(PROGRAMMER *pgm, const char *port) {
|
|||
/* After releasing for 50 milliseconds, DTR and RTS */
|
||||
/* are asserted (i.e. logic LOW) again. */
|
||||
|
||||
avrdude_message(MSG_NOTICE2, "%s: wiring_open(): asserting DTR/RTS\n",
|
||||
progname);
|
||||
pmsg_notice2("wiring_open(): asserting DTR/RTS\n");
|
||||
|
||||
serial_set_dtr_rts(&pgm->fd, 1);
|
||||
usleep(50*1000);
|
||||
|
|
199
src/xbee.c
199
src/xbee.c
|
@ -110,8 +110,7 @@ static int xbee_read_sig_bytes(const PROGRAMMER *pgm, const AVRPART *p, const AV
|
|||
/* Signature byte reads are always 3 bytes. */
|
||||
|
||||
if (m->size < 3) {
|
||||
avrdude_message(MSG_INFO, "%s: memsize too small for sig byte read\n",
|
||||
progname);
|
||||
pmsg_error("memsize too small for sig byte read\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -123,21 +122,16 @@ static int xbee_read_sig_bytes(const PROGRAMMER *pgm, const AVRPART *p, const AV
|
|||
if (serial_recv(&pgm->fd, buf, 5) < 0)
|
||||
return -1;
|
||||
if (buf[0] == Resp_STK_NOSYNC) {
|
||||
avrdude_message(MSG_INFO, "%s: stk500_cmd(): programmer is out of sync\n",
|
||||
progname);
|
||||
pmsg_error("programmer is out of sync\n");
|
||||
return -1;
|
||||
} else if (buf[0] != Resp_STK_INSYNC) {
|
||||
avrdude_message(MSG_INFO,
|
||||
"\n%s: xbee_read_sig_bytes(): (a) protocol error, "
|
||||
"expect=0x%02x, resp=0x%02x\n",
|
||||
progname, Resp_STK_INSYNC, buf[0]);
|
||||
msg_error("\n");
|
||||
pmsg_error("protocol expects sync byte 0x%02x but got 0x%02x\n", Resp_STK_INSYNC, buf[0]);
|
||||
return -2;
|
||||
}
|
||||
if (buf[4] != Resp_STK_OK) {
|
||||
avrdude_message(MSG_INFO,
|
||||
"\n%s: xbee_read_sig_bytes(): (a) protocol error, "
|
||||
"expect=0x%02x, resp=0x%02x\n",
|
||||
progname, Resp_STK_OK, buf[4]);
|
||||
msg_error("\n");
|
||||
pmsg_error("protocol expects OK byte 0x%02x but got 0x%02x\n", Resp_STK_OK, buf[4]);
|
||||
return -3;
|
||||
}
|
||||
|
||||
|
@ -252,10 +246,8 @@ static void xbeeStatsAdd(struct XBeeStaticticsSummary *summary,
|
|||
|
||||
static void xbeeStatsSummarise(struct XBeeStaticticsSummary const *summary)
|
||||
{
|
||||
avrdude_message(MSG_NOTICE, "%s: Minimum response time: %lu.%06lu\n",
|
||||
progname, summary->minimum.tv_sec, summary->minimum.tv_usec);
|
||||
avrdude_message(MSG_NOTICE, "%s: Maximum response time: %lu.%06lu\n",
|
||||
progname, summary->maximum.tv_sec, summary->maximum.tv_usec);
|
||||
pmsg_notice(" Minimum response time: %lu.%06lu\n", summary->minimum.tv_sec, summary->minimum.tv_usec);
|
||||
pmsg_notice(" Maximum response time: %lu.%06lu\n", summary->maximum.tv_sec, summary->maximum.tv_usec);
|
||||
|
||||
struct timeval average;
|
||||
|
||||
|
@ -268,8 +260,7 @@ static void xbeeStatsSummarise(struct XBeeStaticticsSummary const *summary)
|
|||
average.tv_sec += usecs / 1000000;
|
||||
average.tv_usec = usecs % 1000000;
|
||||
|
||||
avrdude_message(MSG_NOTICE, "%s: Average response time: %lu.%06lu\n",
|
||||
progname, average.tv_sec, average.tv_usec);
|
||||
pmsg_notice(" Average response time: %lu.%06lu\n", average.tv_sec, average.tv_usec);
|
||||
}
|
||||
|
||||
static void XBeeBootSessionInit(struct XBeeBootSession *xbs) {
|
||||
|
@ -319,19 +310,17 @@ static void xbeedev_stats_send(struct XBeeBootSession *xbs,
|
|||
stats->sendTime = *sendTime;
|
||||
|
||||
if (detailSequence >= 0) {
|
||||
avrdude_message(MSG_NOTICE2,
|
||||
"%s: Stats: Send Group %s Sequence %u : "
|
||||
pmsg_notice2("stats: send Group %s Sequence %u : "
|
||||
"Send %lu.%06lu %s Sequence %d\n",
|
||||
progname, groupNames[group],
|
||||
groupNames[group],
|
||||
(unsigned int) sequence,
|
||||
(unsigned long) sendTime->tv_sec,
|
||||
(unsigned long) sendTime->tv_usec,
|
||||
detail, detailSequence);
|
||||
} else {
|
||||
avrdude_message(MSG_NOTICE2,
|
||||
"%s: Stats: Send Group %s Sequence %u : "
|
||||
pmsg_notice2("stats: send Group %s Sequence %u : "
|
||||
"Send %lu.%06lu %s\n",
|
||||
progname, groupNames[group],
|
||||
groupNames[group],
|
||||
(unsigned int) sequence,
|
||||
(unsigned long) sendTime->tv_sec,
|
||||
(unsigned long) sendTime->tv_usec,
|
||||
|
@ -361,10 +350,9 @@ static void xbeedev_stats_receive(struct XBeeBootSession *xbs,
|
|||
delay.tv_sec = secs;
|
||||
delay.tv_usec = usecs;
|
||||
|
||||
avrdude_message(MSG_NOTICE2,
|
||||
"%s: Stats: Receive Group %s Sequence %u : "
|
||||
pmsg_notice2("stats: receive Group %s Sequence %u : "
|
||||
"Send %lu.%06lu Receive %lu.%06lu Delay %lu.%06lu %s\n",
|
||||
progname, groupNames[group],
|
||||
groupNames[group],
|
||||
(unsigned int) sequence,
|
||||
(unsigned long) stats->sendTime.tv_sec,
|
||||
(unsigned long) stats->sendTime.tv_usec,
|
||||
|
@ -403,9 +391,8 @@ static int sendAPIRequest(struct XBeeBootSession *xbs,
|
|||
|
||||
gettimeofday(&time, NULL);
|
||||
|
||||
avrdude_message(MSG_NOTICE2,
|
||||
"%s: sendAPIRequest(): %lu.%06lu %d, %d, %d, %d %s\n",
|
||||
progname, (unsigned long)time.tv_sec,
|
||||
pmsg_notice2("sendAPIRequest(): %lu.%06lu %d, %d, %d, %d %s\n",
|
||||
(unsigned long) time.tv_sec,
|
||||
(unsigned long) time.tv_usec,
|
||||
(int) packetType, (int)sequence, appType,
|
||||
data == NULL ? -1 : (int)*data, detail);
|
||||
|
@ -453,9 +440,7 @@ static int sendAPIRequest(struct XBeeBootSession *xbs,
|
|||
* instructions.
|
||||
*/
|
||||
if (apiType != 0x21 && xbs->sourceRouteChanged) {
|
||||
avrdude_message(MSG_NOTICE2, "%s: sendAPIRequest(): "
|
||||
"Issuing Create Source Route request with %d hops\n",
|
||||
progname, xbs->sourceRouteHops);
|
||||
pmsg_notice2("sendAPIRequest(): issuing Create Source Route request with %d hops\n", xbs->sourceRouteHops);
|
||||
|
||||
int rc = sendAPIRequest(xbs, 0x21, /* Create Source Route */
|
||||
0, -1, 0, xbs->sourceRouteHops,
|
||||
|
@ -583,9 +568,7 @@ static void xbeedev_record16Bit(struct XBeeBootSession *xbs,
|
|||
unsigned char * const tx16Bit =
|
||||
&xbs->xbee_address[XBEE_ADDRESS_64BIT_LEN];
|
||||
if (memcmp(rx16Bit, tx16Bit, XBEE_ADDRESS_16BIT_LEN) != 0) {
|
||||
avrdude_message(MSG_NOTICE2, "%s: xbeedev_record16Bit(): "
|
||||
"New 16-bit address: %02x%02x\n",
|
||||
progname,
|
||||
pmsg_notice2("xbeedev_record16Bit(): new 16-bit address: %02x%02x\n",
|
||||
(unsigned int)rx16Bit[0],
|
||||
(unsigned int)rx16Bit[1]);
|
||||
memcpy(tx16Bit, rx16Bit, XBEE_ADDRESS_16BIT_LEN);
|
||||
|
@ -666,9 +649,7 @@ static int xbeedev_poll(struct XBeeBootSession *xbs,
|
|||
|
||||
if (checksum) {
|
||||
/* Checksum didn't match */
|
||||
avrdude_message(MSG_NOTICE2,
|
||||
"%s: xbeedev_poll(): Bad checksum %d\n",
|
||||
progname, (int)checksum);
|
||||
pmsg_notice2("xbeedev_poll(): bad checksum %d\n", (int) checksum);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
@ -678,9 +659,8 @@ static int xbeedev_poll(struct XBeeBootSession *xbs,
|
|||
struct timeval receiveTime;
|
||||
gettimeofday(&receiveTime, NULL);
|
||||
|
||||
avrdude_message(MSG_NOTICE2,
|
||||
"%s: xbeedev_poll(): %lu.%06lu Received frame type %x\n",
|
||||
progname, (unsigned long)receiveTime.tv_sec,
|
||||
pmsg_notice2("xbeedev_poll(): %lu.%06lu Received frame type %x\n",
|
||||
(unsigned long) receiveTime.tv_sec,
|
||||
(unsigned long) receiveTime.tv_usec,
|
||||
(unsigned int) frameType);
|
||||
|
||||
|
@ -692,9 +672,8 @@ static int xbeedev_poll(struct XBeeBootSession *xbs,
|
|||
xbeedev_stats_receive(xbs, "Remote AT command response",
|
||||
XBEE_STATS_FRAME_REMOTE, txSequence, &receiveTime);
|
||||
|
||||
avrdude_message(MSG_NOTICE,
|
||||
"%s: xbeedev_poll(): Remote command %d result code %d\n",
|
||||
progname, (int)txSequence, (int)resultCode);
|
||||
pmsg_notice("xbeedev_poll(): remote command %d result code %d\n",
|
||||
(int) txSequence, (int) resultCode);
|
||||
|
||||
if (waitForSequence >= 0 && waitForSequence == frame[3])
|
||||
/* Received result for our sequence numbered request */
|
||||
|
@ -706,9 +685,8 @@ static int xbeedev_poll(struct XBeeBootSession *xbs,
|
|||
xbeedev_stats_receive(xbs, "Local AT command response",
|
||||
XBEE_STATS_FRAME_LOCAL, txSequence, &receiveTime);
|
||||
|
||||
avrdude_message(MSG_NOTICE,
|
||||
"%s: xbeedev_poll(): Local command %c%c result code %d\n",
|
||||
progname, frame[4], frame[5], (int)frame[6]);
|
||||
pmsg_notice("xbeedev_poll(): local command %c%c result code %d\n",
|
||||
frame[4], frame[5], (int)frame[6]);
|
||||
|
||||
if (waitForSequence >= 0 && waitForSequence == txSequence)
|
||||
/* Received result for our sequence numbered request */
|
||||
|
@ -720,9 +698,8 @@ static int xbeedev_poll(struct XBeeBootSession *xbs,
|
|||
xbeedev_stats_receive(xbs, "Transmit status", XBEE_STATS_FRAME_REMOTE,
|
||||
txSequence, &receiveTime);
|
||||
|
||||
avrdude_message(MSG_NOTICE2,
|
||||
"%s: xbeedev_poll(): Transmit status %d result code %d\n",
|
||||
progname, (int)frame[3], (int)frame[7]);
|
||||
pmsg_notice2("xbeedev_poll(): transmit status %d result code %d\n",
|
||||
(int) frame[3], (int) frame[7]);
|
||||
} else if (frameType == 0xa1 &&
|
||||
frameSize >= XBEE_LENGTH_LEN + XBEE_APITYPE_LEN +
|
||||
XBEE_ADDRESS_64BIT_LEN +
|
||||
|
@ -731,8 +708,7 @@ static int xbeedev_poll(struct XBeeBootSession *xbs,
|
|||
if (memcmp(&frame[XBEE_LENGTH_LEN + XBEE_APITYPE_LEN],
|
||||
xbs->xbee_address, XBEE_ADDRESS_64BIT_LEN) != 0) {
|
||||
/* Not from our target device */
|
||||
avrdude_message(MSG_NOTICE2, "%s: xbeedev_poll(): "
|
||||
"Route Record Indicator from other XBee\n");
|
||||
pmsg_notice2("xbeedev_poll(): route Record Indicator from other XBee\n");
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -755,10 +731,9 @@ static int xbeedev_poll(struct XBeeBootSession *xbs,
|
|||
const unsigned char receiveOptions = frame[header];
|
||||
const unsigned char hops = frame[header + 1];
|
||||
|
||||
avrdude_message(MSG_NOTICE2, "%s: xbeedev_poll(): "
|
||||
pmsg_notice2("xbeedev_poll(): "
|
||||
"Route Record Indicator from target XBee: "
|
||||
"hops=%d options=%d\n",
|
||||
progname, (int)hops, (int)receiveOptions);
|
||||
"hops=%d options=%d\n", (int)hops, (int)receiveOptions);
|
||||
|
||||
if (frameSize < header + 2 + hops * 2 + XBEE_CHECKSUM_LEN)
|
||||
/* Bounds check: Frame is too small */
|
||||
|
@ -768,9 +743,8 @@ static int xbeedev_poll(struct XBeeBootSession *xbs,
|
|||
|
||||
unsigned char index;
|
||||
for (index = 0; index < hops; index++) {
|
||||
avrdude_message(MSG_NOTICE2, "%s: xbeedev_poll(): "
|
||||
"Route Intermediate Hop %d : %02x%02x\n",
|
||||
progname, (int)index,
|
||||
pmsg_notice2("xbeedev_poll(): "
|
||||
"Route Intermediate Hop %d : %02x%02x\n", (int)index,
|
||||
(int)frame[tableOffset + index * 2],
|
||||
(int)frame[tableOffset + index * 2 + 1]);
|
||||
}
|
||||
|
@ -782,9 +756,7 @@ static int xbeedev_poll(struct XBeeBootSession *xbs,
|
|||
xbs->sourceRouteHops = hops;
|
||||
xbs->sourceRouteChanged = 1;
|
||||
|
||||
avrdude_message(MSG_NOTICE2, "%s: xbeedev_poll(): "
|
||||
"Route has changed\n",
|
||||
progname);
|
||||
pmsg_notice2("xbeedev_poll(): route has changed\n");
|
||||
}
|
||||
}
|
||||
} else if (frameType == 0x10 || frameType == 0x90) {
|
||||
|
@ -844,9 +816,8 @@ static int xbeedev_poll(struct XBeeBootSession *xbs,
|
|||
const unsigned char protocolType = dataStart[0];
|
||||
const unsigned char sequence = dataStart[1];
|
||||
|
||||
avrdude_message(MSG_NOTICE2, "%s: xbeedev_poll(): "
|
||||
"%lu.%06lu Packet %d #%d\n",
|
||||
progname, (unsigned long)receiveTime.tv_sec,
|
||||
pmsg_notice2("xbeedev_poll(): "
|
||||
"%lu.%06lu Packet %d #%d\n", (unsigned long)receiveTime.tv_sec,
|
||||
(unsigned long)receiveTime.tv_usec,
|
||||
(int)protocolType, (int)sequence);
|
||||
|
||||
|
@ -887,14 +858,14 @@ static int xbeedev_poll(struct XBeeBootSession *xbs,
|
|||
xbs->inInIndex = 0;
|
||||
if (xbs->inInIndex == xbs->inOutIndex) {
|
||||
/* Should be impossible */
|
||||
avrdude_message(MSG_INFO, "%s: Buffer overrun\n", progname);
|
||||
pmsg_error("buffer overrun\n");
|
||||
xbs->transportUnusable = 1;
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*avrdude_message(MSG_INFO, "ACK %x\n", (unsigned int)sequence);*/
|
||||
/*msg_error("ACK %x\n", (unsigned int)sequence);*/
|
||||
sendPacket(xbs, "Transmit Request ACK for RECEIVE",
|
||||
XBEEBOOT_PACKET_TYPE_ACK, sequence,
|
||||
XBEE_STATS_NOT_RETRY,
|
||||
|
@ -952,8 +923,7 @@ static int localAsyncAT(struct XBeeBootSession *xbs, char const *detail,
|
|||
if (value >= 0)
|
||||
buf[length++] = (unsigned char)value;
|
||||
|
||||
avrdude_message(MSG_NOTICE, "%s: Local AT command: %c%c\n",
|
||||
progname, at1, at2);
|
||||
pmsg_notice("local AT command: %c%c\n", at1, at2);
|
||||
|
||||
/* Local AT command 0x08 */
|
||||
int rc = sendAPIRequest(xbs, 0x08, sequence, -1, -1, -1, -1, -1, -1,
|
||||
|
@ -1016,8 +986,7 @@ static int sendAT(struct XBeeBootSession *xbs, char const *detail,
|
|||
if (value >= 0)
|
||||
buf[length++] = (unsigned char)value;
|
||||
|
||||
avrdude_message(MSG_NOTICE,
|
||||
"%s: Remote AT command: %c%c\n", progname, at1, at2);
|
||||
pmsg_notice("remote AT command: %c%c\n", at1, at2);
|
||||
|
||||
/* Remote AT command 0x17 with Apply Changes 0x02 */
|
||||
sendAPIRequest(xbs, 0x17, sequence, -1,
|
||||
|
@ -1042,8 +1011,7 @@ static int sendAT(struct XBeeBootSession *xbs, char const *detail,
|
|||
}
|
||||
|
||||
/*
|
||||
* Return 0 on no error recognised, 1 if error was detected and
|
||||
* reported.
|
||||
* Return 0 on no error recognised, 1 if error was detected and reported
|
||||
*/
|
||||
static int xbeeATError(int rc) {
|
||||
const int xbeeRc = XBEE_AT_RETURN_CODE(rc);
|
||||
|
@ -1051,23 +1019,15 @@ static int xbeeATError(int rc) {
|
|||
return 0;
|
||||
|
||||
if (xbeeRc == 1) {
|
||||
avrdude_message(MSG_INFO, "%s: Error communicating with Remote XBee\n",
|
||||
progname);
|
||||
pmsg_error("unable to communicate with remote XBee\n");
|
||||
} else if (xbeeRc == 2) {
|
||||
avrdude_message(MSG_INFO, "%s: Remote XBee command error: "
|
||||
"Invalid command\n",
|
||||
progname);
|
||||
pmsg_error("remote XBee: invalid command\n");
|
||||
} else if (xbeeRc == 3) {
|
||||
avrdude_message(MSG_INFO, "%s: Remote XBee command error: "
|
||||
"Invalid parameter\n",
|
||||
progname);
|
||||
pmsg_error("remote XBee: invalid command parameter\n");
|
||||
} else if (xbeeRc == 4) {
|
||||
avrdude_message(MSG_INFO, "%s: Remote XBee error: "
|
||||
"Transmission failure\n",
|
||||
progname);
|
||||
pmsg_error("remote XBee: transmission failure\n");
|
||||
} else {
|
||||
avrdude_message(MSG_INFO, "%s: Unrecognised remote XBee error code %d\n",
|
||||
progname, xbeeRc);
|
||||
pmsg_error("unrecognised remote XBee error code %d\n", xbeeRc);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
@ -1100,17 +1060,13 @@ static int xbeedev_open(const char *port, union pinfo pinfo,
|
|||
*/
|
||||
char *ttySeparator = strchr(port, '@');
|
||||
if (ttySeparator == NULL) {
|
||||
avrdude_message(MSG_INFO,
|
||||
"%s: XBee: Bad port syntax: "
|
||||
"require \"<xbee-address>@<serial-device>\"\n",
|
||||
progname);
|
||||
pmsg_error("XBee: bad port syntax, require <xbee-address>@<serial-device>\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
struct XBeeBootSession *xbs = malloc(sizeof(struct XBeeBootSession));
|
||||
if (xbs == NULL) {
|
||||
avrdude_message(MSG_INFO, "%s: xbeedev_open(): out of memory\n",
|
||||
progname);
|
||||
pmsg_error("out of memory\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -1149,10 +1105,7 @@ static int xbeedev_open(const char *port, union pinfo pinfo,
|
|||
}
|
||||
|
||||
if (addrIndex != 8 || address != ttySeparator || nybble != -1) {
|
||||
avrdude_message(MSG_INFO,
|
||||
"%s: XBee: Bad XBee address: "
|
||||
"require 16-character hexadecimal address\"\n",
|
||||
progname);
|
||||
pmsg_error("XBee: bad XBee address, require 16-character hexadecimal address\n");
|
||||
free(xbs);
|
||||
return -1;
|
||||
}
|
||||
|
@ -1164,9 +1117,7 @@ static int xbeedev_open(const char *port, union pinfo pinfo,
|
|||
xbs->xbee_address[8] = 0xff;
|
||||
xbs->xbee_address[9] = 0xfe;
|
||||
|
||||
avrdude_message(MSG_TRACE,
|
||||
"%s: XBee address: %02x%02x%02x%02x%02x%02x%02x%02x\n",
|
||||
progname,
|
||||
pmsg_trace("XBee address: %02x%02x%02x%02x%02x%02x%02x%02x\n",
|
||||
(unsigned int) xbs->xbee_address[0],
|
||||
(unsigned int) xbs->xbee_address[1],
|
||||
(unsigned int) xbs->xbee_address[2],
|
||||
|
@ -1216,7 +1167,7 @@ static int xbeedev_open(const char *port, union pinfo pinfo,
|
|||
}
|
||||
pinfo.serialinfo.cflags = SERIAL_8N1;
|
||||
|
||||
avrdude_message(MSG_NOTICE, "%s: Baud %ld\n", progname, (long)pinfo.serialinfo.baud);
|
||||
pmsg_notice("baud %ld\n", (long)pinfo.serialinfo.baud);
|
||||
|
||||
{
|
||||
const int rc = xbs->serialDevice->open(tty, pinfo,
|
||||
|
@ -1232,8 +1183,7 @@ static int xbeedev_open(const char *port, union pinfo pinfo,
|
|||
{
|
||||
const int rc = localAT(xbs, "AT AP=2", 'A', 'P', 2);
|
||||
if (rc < 0) {
|
||||
avrdude_message(MSG_INFO, "%s: Local XBee is not responding.\n",
|
||||
progname);
|
||||
pmsg_error("local XBee is not responding\n");
|
||||
xbeedev_free(xbs);
|
||||
return rc;
|
||||
}
|
||||
|
@ -1273,8 +1223,7 @@ static int xbeedev_open(const char *port, union pinfo pinfo,
|
|||
{
|
||||
const int rc = localAT(xbs, "AT AR=0", 'A', 'R', 0);
|
||||
if (rc < 0) {
|
||||
avrdude_message(MSG_INFO, "%s: Local XBee is not responding.\n",
|
||||
progname);
|
||||
pmsg_error("local XBee is not responding\n");
|
||||
xbeedev_free(xbs);
|
||||
return rc;
|
||||
}
|
||||
|
@ -1296,8 +1245,7 @@ static int xbeedev_open(const char *port, union pinfo pinfo,
|
|||
if (xbeeATError(rc))
|
||||
return -1;
|
||||
|
||||
avrdude_message(MSG_INFO, "%s: Remote XBee is not responding.\n",
|
||||
progname);
|
||||
pmsg_error("remote XBee is not responding\n");
|
||||
return rc;
|
||||
}
|
||||
}
|
||||
|
@ -1515,8 +1463,7 @@ static int xbeedev_drain(const union filedescriptor *fdp, int display)
|
|||
return -1;
|
||||
|
||||
/*
|
||||
* Flushing the local serial buffer is unhelpful under this
|
||||
* protocol.
|
||||
* Flushing the local serial buffer is unhelpful under this protocol
|
||||
*/
|
||||
do {
|
||||
xbs->inOutIndex = xbs->inInIndex = 0;
|
||||
|
@ -1544,8 +1491,7 @@ static int xbeedev_set_dtr_rts(const union filedescriptor *fdp, int is_on)
|
|||
if (xbeeATError(rc))
|
||||
return -1;
|
||||
|
||||
avrdude_message(MSG_INFO,
|
||||
"%s: Remote XBee is not responding.\n", progname);
|
||||
pmsg_error("remote XBee is not responding\n");
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
@ -1578,10 +1524,7 @@ static int xbee_getsync(const PROGRAMMER *pgm) {
|
|||
|
||||
int sendRc = serial_send(&pgm->fd, buf, 2);
|
||||
if (sendRc < 0) {
|
||||
avrdude_message(MSG_INFO,
|
||||
"%s: xbee_getsync(): failed to deliver STK_GET_SYNC "
|
||||
"to the remote XBeeBoot bootloader\n",
|
||||
progname);
|
||||
pmsg_error("unable to deliver STK_GET_SYNC to the remote XBeeBoot bootloader\n");
|
||||
return sendRc;
|
||||
}
|
||||
|
||||
|
@ -1591,23 +1534,17 @@ static int xbee_getsync(const PROGRAMMER *pgm) {
|
|||
*/
|
||||
int recvRc = serial_recv(&pgm->fd, resp, 2);
|
||||
if (recvRc < 0) {
|
||||
avrdude_message(MSG_INFO,
|
||||
"%s: xbee_getsync(): no response to STK_GET_SYNC "
|
||||
"from the remote XBeeBoot bootloader\n",
|
||||
progname);
|
||||
pmsg_error("no response to STK_GET_SYNC from the remote XBeeBoot bootloader\n");
|
||||
return recvRc;
|
||||
}
|
||||
|
||||
if (resp[0] != Resp_STK_INSYNC) {
|
||||
avrdude_message(MSG_INFO, "%s: xbee_getsync(): not in sync: resp=0x%02x\n",
|
||||
progname, (unsigned int)resp[0]);
|
||||
pmsg_error("not in sync, resp=0x%02x\n", (unsigned int) resp[0]);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (resp[1] != Resp_STK_OK) {
|
||||
avrdude_message(MSG_INFO, "%s: xbee_getsync(): in sync, not OK: "
|
||||
"resp=0x%02x\n",
|
||||
progname, (unsigned int)resp[1]);
|
||||
pmsg_error("in sync, not OK, resp=0x%02x\n", (unsigned int) resp[1]);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -1676,16 +1613,16 @@ static void xbee_close(PROGRAMMER *pgm)
|
|||
xbeeATError(rc);
|
||||
}
|
||||
|
||||
avrdude_message(MSG_NOTICE, "%s: Statistics for FRAME_LOCAL requests - %s->XBee(local)\n", progname, progname);
|
||||
pmsg_notice("statistics for FRAME_LOCAL requests - %s->XBee(local)\n", progname);
|
||||
xbeeStatsSummarise(&xbs->groupSummary[XBEE_STATS_FRAME_LOCAL]);
|
||||
|
||||
avrdude_message(MSG_NOTICE, "%s: Statistics for FRAME_REMOTE requests - %s->XBee(local)->XBee(target)\n", progname, progname);
|
||||
pmsg_notice("statistics for FRAME_REMOTE requests - %s->XBee(local)->XBee(target)\n", progname);
|
||||
xbeeStatsSummarise(&xbs->groupSummary[XBEE_STATS_FRAME_REMOTE]);
|
||||
|
||||
avrdude_message(MSG_NOTICE, "%s: Statistics for TRANSMIT requests - %s->XBee(local)->XBee(target)->XBeeBoot\n", progname, progname);
|
||||
pmsg_notice("statistics for TRANSMIT requests - %s->XBee(local)->XBee(target)->XBeeBoot\n", progname);
|
||||
xbeeStatsSummarise(&xbs->groupSummary[XBEE_STATS_TRANSMIT]);
|
||||
|
||||
avrdude_message(MSG_NOTICE, "%s: Statistics for RECEIVE requests - XBeeBoot->XBee(target)->XBee(local)->%s\n", progname, progname);
|
||||
pmsg_notice("statistics for RECEIVE requests - XBeeBoot->XBee(target)->XBee(local)->%s\n", progname);
|
||||
xbeeStatsSummarise(&xbs->groupSummary[XBEE_STATS_RECEIVE]);
|
||||
|
||||
xbeedev_free(xbs);
|
||||
|
@ -1706,9 +1643,7 @@ static int xbee_parseextparms(const PROGRAMMER *pgm, const LISTID extparms) {
|
|||
int resetpin;
|
||||
if (sscanf(extended_param, "xbeeresetpin=%i", &resetpin) != 1 ||
|
||||
resetpin <= 0 || resetpin > 7) {
|
||||
avrdude_message(MSG_INFO, "%s: xbee_parseextparms(): "
|
||||
"invalid xbeeresetpin '%s'\n",
|
||||
progname, extended_param);
|
||||
pmsg_error("invalid xbeeresetpin '%s'\n", extended_param);
|
||||
rc = -1;
|
||||
continue;
|
||||
}
|
||||
|
@ -1717,9 +1652,7 @@ static int xbee_parseextparms(const PROGRAMMER *pgm, const LISTID extparms) {
|
|||
continue;
|
||||
}
|
||||
|
||||
avrdude_message(MSG_INFO, "%s: xbee_parseextparms(): "
|
||||
"invalid extended parameter '%s'\n",
|
||||
progname, extended_param);
|
||||
pmsg_error("invalid extended parameter '%s'\n", extended_param);
|
||||
rc = -1;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue