Replace internal knowledge in jtag3.c by a public API

In certain situations (CRC failure, device locked), that JTAG3
read functions need to return an indication to the caller that
it is OK to proceed, and allow erasing the device anyway.

Historically, the JTAG3 code passed the respective protocol
errors directly (and unexplained) up to the caller, leaving
the decision to the caller how to handle the situation.

Replace that by a more common return value API. New code should
prefer this API instead of any hardcoded return values.
This commit is contained in:
Joerg Wunsch
2022-06-15 23:32:22 +02:00
parent cb114233ef
commit 3082630430
5 changed files with 40 additions and 19 deletions

View File

@@ -439,16 +439,16 @@ int avr_read(PROGRAMMER * pgm, AVRPART * p, char * memtype,
(vmem->tags[i] & TAG_ALLOCATED) != 0)
{
rc = pgm->read_byte(pgm, p, mem, i, mem->buf + i);
if (rc != 0) {
if (rc != LIBAVRDUDE_SUCCESS) {
avrdude_message(MSG_INFO, "avr_read(): error reading address 0x%04lx\n", i);
if (rc == -1) {
if (rc == LIBAVRDUDE_GENERAL_FAILURE) {
avrdude_message(MSG_INFO, " read operation not supported for memory \"%s\"\n",
memtype);
return -2;
return LIBAVRDUDE_NOTSUPPORTED;
}
avrdude_message(MSG_INFO, " read operation failed for memory \"%s\"\n",
memtype);
return rc;
return LIBAVRDUDE_SOFTFAIL;
}
}
report_progress(i, mem->size, NULL);
@@ -1035,14 +1035,14 @@ int avr_signature(PROGRAMMER * pgm, AVRPART * p)
report_progress (0,1,"Reading");
rc = avr_read(pgm, p, "signature", 0);
if (rc < 0) {
if (rc < LIBAVRDUDE_SUCCESS) {
avrdude_message(MSG_INFO, "%s: error reading signature data for part \"%s\", rc=%d\n",
progname, p->desc, rc);
return rc;
}
report_progress (1,1,NULL);
return 0;
return LIBAVRDUDE_SUCCESS;
}
static uint8_t get_fuse_bitmask(AVRMEM * m) {