added verbose level in avrdude_message()

git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@1321 81a1dc3b-b13d-400b-aceb-764788c761c2
This commit is contained in:
Axel Wachtler
2014-06-13 20:07:40 +00:00
parent 471b504278
commit c6788bd795
45 changed files with 1854 additions and 2128 deletions

View File

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