mirror of
https://github.com/mariusgreuel/avrdude.git
synced 2025-12-17 02:54:17 +00:00
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:
173
src/buspirate.c
173
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",
|
||||
submode.name, PDATA(pgm)->submode_version);
|
||||
|
||||
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...
|
||||
// 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));
|
||||
|
||||
Reference in New Issue
Block a user