Update look and feel

This commit is contained in:
Stefan Rueger
2024-08-01 01:17:24 +01:00
parent f5117fffe0
commit cf0822bb71
12 changed files with 124 additions and 126 deletions

View File

@@ -30,8 +30,7 @@
#endif
extern char *progname; // Name of program, for messages
extern char progbuf[]; // Spaces same length as progname
#define progbuf "" // Used to be for indenting continuation below "avrdude: msg"
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)
@@ -64,11 +63,13 @@ int avrdude_message2(FILE *fp, int lno, const char *file, const char *func, int
#define MSG2_PROGNAME 1 // Start by printing progname
#define MSG2_FUNCTION 2 // Print calling function (1st arg) after progname if >= notice
#define MSG2_FILELINE 4 // Print source file and line number after function if >= debug
#define MSG2_TYPE 8 // Print message type after function or progname
#define MSG2_TYPE 8 // Print message type after progname
#define MSG2_INDENT1 16 // Start by printing indentation of progname+1 blanks
#define MSG2_INDENT2 32 // Start by printing indentation of progname+2 blanks
#define MSG2_FLUSH 64 // Flush before and after printing
#define MSG2_LEFT_MARGIN 128 // Print \n unless last character printed was \n
#define MSG2_INDENT 256 // Intent by two spaces
#define MSG2_UCFIRST 512 // Uppercase first character of output
// Shortcuts
#define msg_ext_error(...) avrdude_message2(stderr, __LINE__, __FILE__, __func__, 0, MSG_EXT_ERROR, __VA_ARGS__)
@@ -81,25 +82,25 @@ int avrdude_message2(FILE *fp, int lno, const char *file, const char *func, int
#define msg_trace(...) avrdude_message2(stderr, __LINE__, __FILE__, __func__, 0, MSG_TRACE, __VA_ARGS__)
#define msg_trace2(...) avrdude_message2(stderr, __LINE__, __FILE__, __func__, 0, MSG_TRACE2, __VA_ARGS__)
#define pmsg_ext_error(...) avrdude_message2(stderr, __LINE__, __FILE__, __func__, MSG2_PROGNAME|MSG2_FUNCTION|MSG2_FILELINE|MSG2_TYPE|MSG2_FLUSH|MSG2_LEFT_MARGIN, MSG_EXT_ERROR, __VA_ARGS__)
#define pmsg_error(...) avrdude_message2(stderr, __LINE__, __FILE__, __func__, MSG2_PROGNAME|MSG2_FUNCTION|MSG2_FILELINE|MSG2_TYPE|MSG2_FLUSH|MSG2_LEFT_MARGIN, MSG_ERROR, __VA_ARGS__)
#define pmsg_warning(...) avrdude_message2(stderr, __LINE__, __FILE__, __func__, MSG2_PROGNAME|MSG2_FUNCTION|MSG2_FILELINE|MSG2_TYPE|MSG2_FLUSH|MSG2_LEFT_MARGIN, MSG_WARNING, __VA_ARGS__)
#define pmsg_info(...) avrdude_message2(stderr, __LINE__, __FILE__, __func__, MSG2_PROGNAME|MSG2_FLUSH|MSG2_LEFT_MARGIN, MSG_INFO, __VA_ARGS__)
#define pmsg_notice(...) avrdude_message2(stderr, __LINE__, __FILE__, __func__, MSG2_PROGNAME|MSG2_FLUSH|MSG2_LEFT_MARGIN, MSG_NOTICE, __VA_ARGS__)
#define pmsg_notice2(...) avrdude_message2(stderr, __LINE__, __FILE__, __func__, MSG2_PROGNAME|MSG2_FLUSH|MSG2_LEFT_MARGIN, MSG_NOTICE2, __VA_ARGS__)
#define pmsg_debug(...) avrdude_message2(stderr, __LINE__, __FILE__, __func__, MSG2_PROGNAME|MSG2_FLUSH|MSG2_LEFT_MARGIN, MSG_DEBUG, __VA_ARGS__)
#define pmsg_trace(...) avrdude_message2(stderr, __LINE__, __FILE__, __func__, MSG2_PROGNAME|MSG2_FLUSH|MSG2_LEFT_MARGIN, MSG_TRACE, __VA_ARGS__)
#define pmsg_trace2(...) avrdude_message2(stderr, __LINE__, __FILE__, __func__, MSG2_PROGNAME|MSG2_FLUSH|MSG2_LEFT_MARGIN, MSG_TRACE2, __VA_ARGS__)
#define pmsg_ext_error(...) avrdude_message2(stderr, __LINE__, __FILE__, __func__, MSG2_UCFIRST|MSG2_FUNCTION|MSG2_FILELINE|MSG2_TYPE|MSG2_FLUSH|MSG2_LEFT_MARGIN, MSG_EXT_ERROR, __VA_ARGS__)
#define pmsg_error(...) avrdude_message2(stderr, __LINE__, __FILE__, __func__, MSG2_UCFIRST|MSG2_FUNCTION|MSG2_FILELINE|MSG2_TYPE|MSG2_FLUSH|MSG2_LEFT_MARGIN, MSG_ERROR, __VA_ARGS__)
#define pmsg_warning(...) avrdude_message2(stderr, __LINE__, __FILE__, __func__, MSG2_UCFIRST|MSG2_FUNCTION|MSG2_FILELINE|MSG2_TYPE|MSG2_FLUSH|MSG2_LEFT_MARGIN, MSG_WARNING, __VA_ARGS__)
#define pmsg_info(...) avrdude_message2(stderr, __LINE__, __FILE__, __func__, MSG2_UCFIRST|MSG2_FLUSH|MSG2_LEFT_MARGIN, MSG_INFO, __VA_ARGS__)
#define pmsg_notice(...) avrdude_message2(stderr, __LINE__, __FILE__, __func__, MSG2_UCFIRST|MSG2_FLUSH|MSG2_LEFT_MARGIN, MSG_NOTICE, __VA_ARGS__)
#define pmsg_notice2(...) avrdude_message2(stderr, __LINE__, __FILE__, __func__, MSG2_UCFIRST|MSG2_FLUSH|MSG2_LEFT_MARGIN, MSG_NOTICE2, __VA_ARGS__)
#define pmsg_debug(...) avrdude_message2(stderr, __LINE__, __FILE__, __func__, MSG2_UCFIRST|MSG2_FLUSH|MSG2_LEFT_MARGIN, MSG_DEBUG, __VA_ARGS__)
#define pmsg_trace(...) avrdude_message2(stderr, __LINE__, __FILE__, __func__, MSG2_UCFIRST|MSG2_FLUSH|MSG2_LEFT_MARGIN, MSG_TRACE, __VA_ARGS__)
#define pmsg_trace2(...) avrdude_message2(stderr, __LINE__, __FILE__, __func__, MSG2_UCFIRST|MSG2_FLUSH|MSG2_LEFT_MARGIN, MSG_TRACE2, __VA_ARGS__)
#define imsg_ext_error(...) avrdude_message2(stderr, __LINE__, __FILE__, __func__, MSG2_INDENT1|MSG2_FLUSH|MSG2_LEFT_MARGIN, MSG_EXT_ERROR, __VA_ARGS__)
#define imsg_error(...) avrdude_message2(stderr, __LINE__, __FILE__, __func__, MSG2_INDENT1|MSG2_FLUSH|MSG2_LEFT_MARGIN, MSG_ERROR, __VA_ARGS__)
#define imsg_warning(...) avrdude_message2(stderr, __LINE__, __FILE__, __func__, MSG2_INDENT1|MSG2_FLUSH|MSG2_LEFT_MARGIN, MSG_WARNING, __VA_ARGS__)
#define imsg_info(...) avrdude_message2(stderr, __LINE__, __FILE__, __func__, MSG2_INDENT2|MSG2_FLUSH|MSG2_LEFT_MARGIN, MSG_INFO, __VA_ARGS__)
#define imsg_notice(...) avrdude_message2(stderr, __LINE__, __FILE__, __func__, MSG2_INDENT2|MSG2_FLUSH|MSG2_LEFT_MARGIN, MSG_NOTICE, __VA_ARGS__)
#define imsg_notice2(...) avrdude_message2(stderr, __LINE__, __FILE__, __func__, MSG2_INDENT2|MSG2_FLUSH|MSG2_LEFT_MARGIN, MSG_NOTICE2, __VA_ARGS__)
#define imsg_debug(...) avrdude_message2(stderr, __LINE__, __FILE__, __func__, MSG2_INDENT2|MSG2_FLUSH|MSG2_LEFT_MARGIN, MSG_DEBUG, __VA_ARGS__)
#define imsg_trace(...) avrdude_message2(stderr, __LINE__, __FILE__, __func__, MSG2_INDENT2|MSG2_FLUSH|MSG2_LEFT_MARGIN, MSG_TRACE, __VA_ARGS__)
#define imsg_trace2(...) avrdude_message2(stderr, __LINE__, __FILE__, __func__, MSG2_INDENT2|MSG2_FLUSH|MSG2_LEFT_MARGIN, MSG_TRACE2, __VA_ARGS__)
#define imsg_ext_error(...) avrdude_message2(stderr, __LINE__, __FILE__, __func__, MSG2_INDENT|MSG2_FLUSH|MSG2_LEFT_MARGIN, MSG_EXT_ERROR, __VA_ARGS__)
#define imsg_error(...) avrdude_message2(stderr, __LINE__, __FILE__, __func__, MSG2_INDENT|MSG2_FLUSH|MSG2_LEFT_MARGIN, MSG_ERROR, __VA_ARGS__)
#define imsg_warning(...) avrdude_message2(stderr, __LINE__, __FILE__, __func__, MSG2_INDENT|MSG2_FLUSH|MSG2_LEFT_MARGIN, MSG_WARNING, __VA_ARGS__)
#define imsg_info(...) avrdude_message2(stderr, __LINE__, __FILE__, __func__, MSG2_FLUSH|MSG2_LEFT_MARGIN, MSG_INFO, __VA_ARGS__)
#define imsg_notice(...) avrdude_message2(stderr, __LINE__, __FILE__, __func__, MSG2_FLUSH|MSG2_LEFT_MARGIN, MSG_NOTICE, __VA_ARGS__)
#define imsg_notice2(...) avrdude_message2(stderr, __LINE__, __FILE__, __func__, MSG2_FLUSH|MSG2_LEFT_MARGIN, MSG_NOTICE2, __VA_ARGS__)
#define imsg_debug(...) avrdude_message2(stderr, __LINE__, __FILE__, __func__, MSG2_FLUSH|MSG2_LEFT_MARGIN, MSG_DEBUG, __VA_ARGS__)
#define imsg_trace(...) avrdude_message2(stderr, __LINE__, __FILE__, __func__, MSG2_FLUSH|MSG2_LEFT_MARGIN, MSG_TRACE, __VA_ARGS__)
#define imsg_trace2(...) avrdude_message2(stderr, __LINE__, __FILE__, __func__, MSG2_FLUSH|MSG2_LEFT_MARGIN, MSG_TRACE2, __VA_ARGS__)
#define lmsg_ext_error(...) avrdude_message2(stderr, __LINE__, __FILE__, __func__, MSG2_LEFT_MARGIN, MSG_EXT_ERROR, __VA_ARGS__)
#define lmsg_error(...) avrdude_message2(stderr, __LINE__, __FILE__, __func__, MSG2_LEFT_MARGIN, MSG_ERROR, __VA_ARGS__)

View File

@@ -883,7 +883,7 @@ void dev_output_part_defs(char *partdesc) {
flags = "s";
if(!*flags || !strchr("dsASRvcreow*tiBCUPTIJWHQ", *flags)) {
dev_info("%s: flags for developer option -p <wildcard>/<flags> not recognised\n", progname);
dev_info("Error: flags for developer option -p <wildcard>/<flags> not recognised\n");
dev_info(
"Wildcard examples (these need protecting in the shell through quoting):\n"
" * all known parts\n"
@@ -1427,7 +1427,7 @@ void dev_output_pgm_defs(char *pgmidcp) {
flags = "s";
if(!*flags || !strchr("dASsrtiBUPTIJWHQ", *flags)) {
dev_info("%s: flags for developer option -c <wildcard>/<flags> not recognised\n", progname);
dev_info("Error: flags for developer option -c <wildcard>/<flags> not recognised\n");
dev_info(
"Wildcard examples (these need protecting in the shell through quoting):\n"
" * all known programmers\n"

View File

@@ -992,7 +992,7 @@ static int dryrun_vfy_led(const PROGRAMMER *pgm, int value) {
static void dryrun_display(const PROGRAMMER *pgm, const char *p_unused) {
imsg_info("%c%s programmer for %s\n", toupper(*pgmid), pgmid+1, dry.dp? dry.dp->desc: partdesc? partdesc: "???");
// imsg_info("%c%s programmer for %s\n", toupper(*pgmid), pgmid+1, dry.dp? dry.dp->desc: partdesc? partdesc: "???");
return;
}

View File

@@ -1231,7 +1231,7 @@ static int elf2b(const char *infile, FILE *inf, const AVRMEM *mem,
if(idx >= 0 && idx < mem->size && end >= 0 && end <= mem->size && end-idx >= 0) {
if (end > size)
size = end;
imsg_debug("writing %d bytes to mem offset 0x%x\n", end-idx, idx);
pmsg_debug("writing %d bytes to mem offset 0x%x\n", end-idx, idx);
memcpy(mem->buf + idx, d->d_buf, end-idx);
memset(mem->tags + idx, TAG_ALLOCATED, end-idx);
} else {

View File

@@ -51,9 +51,6 @@
#include "developer_opts.h"
char * progname = "avrdude";
char progbuf[PATH_MAX]; /* temporary buffer of spaces the same
length as progname; used for lining up
multiline messages */
static const char *avrdude_message_type(int msglvl) {
switch(msglvl) {
@@ -120,9 +117,20 @@ int avrdude_message2(FILE *fp, int lno, const char *file, const char *func, int
}
}
if(msgmode & MSG2_PROGNAME) {
fprintf(fp, "%s", progname);
if(verbose >= MSG_NOTICE && (msgmode & MSG2_FUNCTION))
if(msgmode & (MSG2_PROGNAME | MSG2_TYPE)) {
if(msgmode & MSG2_PROGNAME) {
fprintf(fp, "%s", progname);
bols[bi].bol = 0;
}
if(msgmode & MSG2_TYPE) {
const char *mt = avrdude_message_type(msglvl);
if(bols[bi].bol)
fprintf(fp, "%c%s", msgmode & (MSG2_UCFIRST)? toupper(*mt & 0xff): *mt, mt+1);
else
fprintf(fp, " %s", mt);
bols[bi].bol = 0;
}
if(verbose >= MSG_NOTICE2 && (msgmode & MSG2_FUNCTION))
fprintf(fp, " %s()", func);
if(verbose >= MSG_DEBUG && (msgmode & MSG2_FILELINE)) {
const char *pr = strrchr(file, '/'); // Only print basename
@@ -133,16 +141,16 @@ int avrdude_message2(FILE *fp, int lno, const char *file, const char *func, int
pr = pr? pr+1: file;
fprintf(fp, " [%s:%d]", pr, lno);
}
if(msgmode & MSG2_TYPE)
fprintf(fp, " %s", avrdude_message_type(msglvl));
fprintf(fp, ": ");
bols[bi].bol = 0;
} else if(msgmode & MSG2_INDENT1) {
fprintf(fp, "%*s", (int) strlen(progname)+1, "");
bols[bi].bol = 0;
} else if(msgmode & MSG2_INDENT2) {
fprintf(fp, "%*s", (int) strlen(progname)+2, "");
bols[bi].bol = 0;
} else if(msgmode & MSG2_INDENT) {
fprintf(fp, " ");
bols[bi].bol = 0;
}
// Figure out whether this print will leave us at beginning of line
@@ -166,8 +174,11 @@ int avrdude_message2(FILE *fp, int lno, const char *file, const char *func, int
return 0;
}
if(*p) {
fprintf(fp, "%s", p); // Finally: print!
if(*p) { // Finally: print!
if(bols[bi].bol && (msgmode & MSG2_UCFIRST))
fprintf(fp, "%c%s", toupper(*p & 0xff), p+1);
else
fprintf(fp, "%s", p);
bols[bi].bol = p[strlen(p)-1] == '\n';
}
mmt_free(p);
@@ -619,7 +630,6 @@ int main(int argc, char * argv [])
int exitrc; /* exit code for main() */
int i; /* general loop counter */
int ch; /* options flag */
int len; /* length for various strings */
struct avrpart * p; /* which avr part we are programming */
AVRMEM * sig; /* signature data */
struct stat sb;
@@ -741,15 +751,7 @@ int main(int argc, char * argv [])
ce_delayed = 0;
logfile = NULL;
len = strlen(progname) + 2;
for (i=0; i<len; i++)
progbuf[i] = ' ';
progbuf[i] = 0;
/*
* check for no arguments
*/
if (argc == 1) {
if(argc == 1) { // No arguments?
usage();
return 0;
}
@@ -769,7 +771,7 @@ int main(int argc, char * argv [])
/*
* process command line arguments
*/
while ((ch = getopt(argc,argv,"?Ab:B:c:C:DeE:Fi:l:nNp:OP:qrstT:U:uvVx:yY:")) != -1) {
while ((ch = getopt(argc, argv, "?Ab:B:c:C:DeE:Fi:l:nNp:OP:qrstT:U:uvVx:yY")) != -1) {
switch (ch) {
case 'b': /* override default programmer baud rate */
@@ -866,7 +868,7 @@ int main(int argc, char * argv [])
calibrate = 1;
break;
case 'p' : /* specify AVR part */
case 'p': /* specify AVR part */
partdesc = optarg;
break;
@@ -874,7 +876,7 @@ int main(int argc, char * argv [])
port = mmt_strdup(optarg);
break;
case 'q' : /* Quell progress output */
case 'q': /* Quell progress output */
quell_progress++ ;
break;
@@ -917,9 +919,6 @@ int main(int argc, char * argv [])
break;
case 'y':
pmsg_error("erase cycle counter no longer supported\n");
break;
case 'Y':
pmsg_error("erase cycle counter no longer supported\n");
break;
@@ -938,6 +937,9 @@ int main(int argc, char * argv [])
}
if (logfile != NULL) {
FILE *newstderr = freopen(logfile, "w", stderr);
if (newstderr == NULL) {
@@ -1055,10 +1057,8 @@ int main(int argc, char * argv [])
* Print out an identifying string so folks can tell what version
* they are running
*/
msg_notice("\n");
pmsg_notice("Version %s\n", AVRDUDE_FULL_VERSION);
imsg_notice("Copyright the AVRDUDE authors;\n");
imsg_notice("see https://github.com/avrdudes/avrdude/blob/main/AUTHORS\n\n");
pmsg_notice("%s version %s\n", progname, AVRDUDE_FULL_VERSION);
imsg_notice("Copyright see https://github.com/avrdudes/avrdude/blob/main/AUTHORS\n\n");
if(*sys_config) {
char *real_sys_config = realpath(sys_config, NULL);
@@ -1076,12 +1076,11 @@ int main(int argc, char * argv [])
}
if (usr_config[0] != 0 && !no_avrduderc) {
imsg_notice("User configuration file is %s\n", usr_config);
int ok = (rc = stat(usr_config, &sb)) >= 0 && (sb.st_mode & S_IFREG);
imsg_notice("User configuration file %s%s%s\n", ok? "is ": "", usr_config,
rc<0? " does not exist": !(sb.st_mode & S_IFREG)? " is not a regular file, skipping": "");
rc = stat(usr_config, &sb);
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 {
if(ok) {
rc = read_config(usr_config);
if (rc) {
pmsg_error("unable to process user configuration file %s\n", usr_config);
@@ -1101,7 +1100,7 @@ int main(int argc, char * argv [])
for (ln1=lfirst(additional_config_files); ln1; ln1=lnext(ln1)) {
p = ldata(ln1);
imsg_notice("additional configuration file is %s\n", p);
pmsg_notice("additional configuration file is %s\n", p);
rc = read_config(p);
if (rc) {
@@ -1369,39 +1368,40 @@ int main(int argc, char * argv [])
// Open the programmer
if (verbose > 0) {
if(!is_dryrun)
imsg_notice("Using port : %s\n", port);
imsg_notice("Using programmer : %s\n", pgmid);
pmsg_notice("using port : %s\n", port);
pmsg_notice("using programmer : %s\n", pgmid);
}
if (baudrate && !pgm->baudrate && !default_baudrate) { // none set
imsg_notice("Setting baud rate : %d\n", baudrate);
pmsg_notice("setting baud rate : %d\n", baudrate);
pgm->baudrate = baudrate;
}
else if (baudrate && ((pgm->baudrate && pgm->baudrate != baudrate)
|| (!pgm->baudrate && default_baudrate != baudrate))) {
imsg_notice("Overriding baud rate : %d\n", baudrate);
pmsg_notice("overriding baud rate : %d\n", baudrate);
pgm->baudrate = baudrate;
}
else if (!pgm->baudrate && default_baudrate) {
imsg_notice("Default baud rate : %d\n", default_baudrate);
pmsg_notice("default baud rate : %d\n", default_baudrate);
pgm->baudrate = default_baudrate;
}
else if (ser && ser->baudrate) {
imsg_notice("Serial baud rate : %d\n", ser->baudrate);
pmsg_notice("serial baud rate : %d\n", ser->baudrate);
pgm->baudrate = ser->baudrate;
}
else if (pgm->baudrate != 0)
imsg_notice("Programmer baud rate : %d\n", pgm->baudrate);
pmsg_notice("programmer baud rate : %d\n", pgm->baudrate);
if (bitclock != 0.0) {
imsg_notice("Setting bit clk period: %.1f us\n", bitclock);
pmsg_notice("setting bit clk period: %.1f us\n", bitclock);
pgm->bitclock = bitclock * 1e-6;
}
if (ispdelay != 0) {
imsg_notice("Setting ISP clk delay : %3i us\n", ispdelay);
pmsg_notice("setting ISP clk delay : %3i us\n", ispdelay);
pgm->ispdelay = ispdelay;
}
msg_notice("\n");
rc = pgm->open(pgm, port);
if (rc < 0) {
@@ -1505,11 +1505,14 @@ skipopen:
pmsg_error("programmer does not support RC oscillator calibration\n");
exitrc = 1;
} else {
pmsg_notice("performing RC oscillator calibration\n");
pmsg_notice2("performing RC oscillator calibration\n");
exitrc = pgm->perform_osccal(pgm);
}
if (exitrc == 0)
pmsg_info("calibration value is now stored in EEPROM at address 0\n");
if (exitrc)
pmsg_error("RC calibration unsuccesful\n");
else
pmsg_notice("calibration value is now stored in EEPROM at address 0\n");
goto main_exit;
}
@@ -1545,15 +1548,15 @@ skipopen:
if (rc == -2)
imsg_error("the programmer ISP clock is too fast for the target\n");
else
imsg_error("- double check the connections and try again\n");
imsg_error(" - double check the connections and try again\n");
if(str_eq(pgm->type, "serialupdi") || str_eq(pgm->type, "SERBB"))
imsg_error("- use -b to set lower baud rate, e.g. -b %d\n", baudrate? baudrate/2: 57600);
imsg_error(" - use -b to set lower baud rate, e.g. -b %d\n", baudrate? baudrate/2: 57600);
else
imsg_error("- use -B to set lower the bit clock frequency, e.g. -B 125kHz\n");
imsg_error(" - use -B to set lower the bit clock frequency, e.g. -B 125kHz\n");
if (!ovsigck) {
imsg_error("- use -F to override this check\n");
imsg_error(" - use -F to override this check\n");
exitrc = 1;
goto main_exit;
}
@@ -1790,7 +1793,8 @@ main_exit:
pgm->close(pgm);
}
msg_info("\n%s done. Thank you.\n\n", progname);
msg_info("\n");
pmsg_info("%s done. Thank you.\n", progname);
return ce_delayed? 1: exitrc;
}

View File

@@ -555,7 +555,7 @@ static int micronucleus_initialize(const PROGRAMMER *pgm, const AVRPART *p) {
}
static void micronucleus_display(const PROGRAMMER *pgm, const char *prefix) {
pmsg_debug("micronucleus_display()\n");
// pmsg_debug("micronucleus_display()\n");
}
static void micronucleus_powerup(const PROGRAMMER *pgm) {

View File

@@ -3573,8 +3573,7 @@ static int stk500v2_setparm_real(const PROGRAMMER *pgm, unsigned char parm, unsi
buf[2] = value;
if (stk500v2_command(pgm, buf, 3, sizeof(buf)) < 0) {
pmsg_error("\n%s stk500v2_setparm(): unable to set parameter 0x%02x\n",
progname, parm);
pmsg_error("unable to set parameter 0x%02x\n", parm);
return -1;
}
@@ -3625,8 +3624,7 @@ static int stk500v2_setparm2(const PROGRAMMER *pgm, unsigned char parm, unsigned
buf[3] = value;
if (stk500v2_command(pgm, buf, 4, sizeof(buf)) < 0) {
pmsg_error("\n%s stk500v2_setparm2(): unable to set parameter 0x%02x\n",
progname, parm);
pmsg_error("unable to set parameter 0x%02x\n", parm);
return -1;
}

View File

@@ -493,6 +493,13 @@ const char *str_plural(int x) {
return x==1? "": "s";
}
static const char *str_filename(const char *fn, const char *stdname) {
if(!fn)
fn = "???";
char *p1 = strrchr(fn, '/'), *p2 = strrchr(fn, '\\');
return str_eq(fn, "-")? stdname: str_starts(fn, "/dev/")? fn: p1? p1+1: p2? p2+1: fn;
}
// Path name fn or <stdin> if fn is -
const char *str_inname(const char *fn) {
return !fn? "???": str_eq(fn, "-")? "<stdin>": fn;
@@ -500,10 +507,7 @@ const char *str_inname(const char *fn) {
// File name of fn or <stdin> if fn is -
const char *str_infilename(const char *fn) {
if(!fn)
fn = "???";
char *p1 = strrchr(fn, '/'), *p2 = strrchr(fn, '\\');
return str_eq(fn, "-")? "<stdin>": p1? p1+1: p2? p2+1: fn;
return str_filename(fn, "<stdin>");
}
// Path name fn or <stdout> if fn is -
@@ -513,10 +517,7 @@ const char *str_outname(const char *fn) {
// File name of fn or <stdout> if fn is -
const char *str_outfilename(const char *fn) {
if(!fn)
fn = "???";
char *p1 = strrchr(fn, '/'), *p2 = strrchr(fn, '\\');
return str_eq(fn, "-")? "<stdout>": p1? p1+1: p2? p2+1: fn;
return str_filename(fn, "<stdin>");
}
// Return sth like "[0, 0x1ff]" in closed-circuit space

View File

@@ -250,7 +250,7 @@ static int teensy_initialize(const PROGRAMMER *pgm, const AVRPART *p) {
}
static void teensy_display(const PROGRAMMER *pgm, const char *prefix) {
pmsg_debug("teensy_display()\n");
// pmsg_debug("teensy_display()\n");
}
static void teensy_powerup(const PROGRAMMER *pgm) {

View File

@@ -470,30 +470,30 @@ static int update_avr_write(const PROGRAMMER *pgm, const AVRPART *p, const AVRME
if(memstats_mem(p, mem, size, &fs) < 0)
return -1;
if(multiple) // Single file writes multiple memories, say which ones
pmsg_info("%d byte%s %s ", fs.nbytes, str_plural(fs.nbytes), m_name);
pmsg_notice("%d byte%s %s ", fs.nbytes, str_plural(fs.nbytes), m_name);
else
imsg_info("");
msg_info("in %d section%s %s%s", fs.nsections, str_plural(fs.nsections),
imsg_notice("");
msg_notice("in %d section%s %s%s", fs.nsections, str_plural(fs.nsections),
fs.nsections == 1? "": "of ", str_ccinterval(fs.firstaddr, fs.lastaddr));
if(mem->page_size > 1) {
msg_info(": %d page%s and %d pad byte%s",
msg_notice(": %d page%s and %d pad byte%s",
fs.npages, str_plural(fs.npages), fs.nfill, str_plural(fs.nfill));
if(fs.ntrailing)
imsg_info("cutting off %d trailing 0xff byte%s (use -A to keep trailing 0xff)",
imsg_notice("cutting off %d trailing 0xff byte%s (use -A to keep trailing 0xff)",
fs.ntrailing, str_plural(fs.ntrailing));
}
msg_info("\n");
msg_notice("\n");
// Patch flash input, eg, for vector bootloaders
if(pgm->flash_readhook && mem_is_flash(mem)) {
if((size = pgm->flash_readhook(pgm, p, mem, upd->filename, size)) < 0) {
pmsg_notice("readhook for file %s failed\n", str_infilename(upd->filename));
pmsg_error("readhook for file %s failed\n", str_infilename(upd->filename));
return -1;
}
if(memstats_mem(p, mem, size, &fs_patched) < 0)
return -1;
if(memcmp(&fs_patched, &fs, sizeof fs)) {
imsg_info("preparing flash input for device%s\n",
imsg_notice("preparing flash input for device%s\n",
pgm->prog_modes & PM_SPM? " bootloader": "");
imsg_notice("%d byte%s in %d section%s %s%s",
fs_patched.nbytes, str_plural(fs_patched.nbytes),
@@ -514,15 +514,16 @@ static int update_avr_write(const PROGRAMMER *pgm, const AVRPART *p, const AVRME
}
// Write the buffer contents to the selected memory
imsg_info("writing %d byte%s to %s %s", fs.nbytes, str_plural(fs.nbytes), m_name,
size == 1 && fs.nbytes == 1? str_ccprintf("(0x%02x)", mem->buf[0]): "...");
int spellout = size > 0 && size <= 4 && fs.nbytes == size;
pmsg_info("writing %d byte%s %sto %s", fs.nbytes, str_plural(fs.nbytes),
spellout? str_ccprintf("(0x%s) ", str_cchex(mem->buf, size, 1)+1): "", m_name);
if(flags & UF_NOWRITE) {
// Test mode: write to stdout in intel hex rather than to the chip
rc = fileio_mem(FIO_WRITE, "-", FMT_IHEX, p, mem, size);
} else {
if(pbar)
report_progress(0, 1, str_ccprintf("%*swriting", (int) strlen(progname)+2, ""));
report_progress(0, 1, str_ccprintf("%*sWriting", (int) strlen(progbuf), ""));
rc = avr_write_mem(pgm, p, mem, size, (flags & UF_AUTO_ERASE) != 0);
report_progress(1, 1, NULL);
}
@@ -673,7 +674,7 @@ int do_op(const PROGRAMMER *pgm, const AVRPART *p, const UPDATE *upd, enum updat
return LIBAVRDUDE_SOFTFAIL;
}
const char *rcap = str_ccprintf("%*sreading", (int) strlen(progname)+2, "");
const char *rcap = str_ccprintf("%*sReading", (int) strlen(progbuf), "");
const char *mem_desc = !umemlist? avr_mem_name(p, mem):
ns==1? avr_mem_name(p, umemlist[0]): "multiple memories";
int rc = 0;
@@ -704,12 +705,12 @@ int do_op(const PROGRAMMER *pgm, const AVRPART *p, const UPDATE *upd, enum updat
pmsg_warning("generating %s file format with multiple memories that cannot\n", fileio_fmtstr(upd->format));
imsg_warning("be read by %s; consider using :I :i or :s instead\n", progname);
}
imsg_info("reading %s ...\n", mem_desc);
pmsg_info("reading %s ...\n", mem_desc);
int nn = 0, nbytes = 0;
for(int ii = 0; ii < ns; ii++) {
m = umemlist[ii];
const char *m_name = avr_mem_name(p, m);
const char *cap = str_ccprintf("%*s%-*s", (int) strlen(progname)+2, "", maxrlen, m_name);
const char *cap = str_ccprintf("%*s - %-*s", (int) strlen(progbuf), "", maxrlen, m_name);
report_progress(0, 1, cap);
int ret = avr_read_mem(pgm, p, m, NULL);
report_progress(1, 1, NULL);
@@ -734,7 +735,7 @@ int do_op(const PROGRAMMER *pgm, const AVRPART *p, const UPDATE *upd, enum updat
}
}
imsg_info("writing %d byte%s to output file %s\n",
pmsg_info("writing %d byte%s to output file %s\n",
nbytes, str_plural(nbytes), str_outfilename(upd->filename));
if(nn)
rc = fileio_segments(FIO_WRITE, upd->filename, upd->format, p, mem, nn, seglist);
@@ -742,7 +743,7 @@ int do_op(const PROGRAMMER *pgm, const AVRPART *p, const UPDATE *upd, enum updat
pmsg_notice("empty memory, resulting file has no contents\n");
cx->avr_disableffopt = dffo;
} else { // Regular file
imsg_info("reading %s memory ...\n", mem_desc);
pmsg_info("reading %s memory ...\n", mem_desc);
if(mem->size > 32)
report_progress(0, 1, rcap);
rc = avr_read(pgm, p, umstr, 0);
@@ -753,7 +754,7 @@ int do_op(const PROGRAMMER *pgm, const AVRPART *p, const UPDATE *upd, enum updat
}
if(rc == 0)
pmsg_notice("empty memory, resulting file has no contents\n");
imsg_info("writing %d byte%s to output file %s\n",
pmsg_info("writing %d byte%s to output file %s\n",
rc, str_plural(rc), str_outfilename(upd->filename));
rc = fileio_mem(FIO_WRITE, upd->filename, upd->format, p, mem, rc);
}

View File

@@ -803,13 +803,12 @@ nopatch_nometa:
if(reset2addr(flm->buf, vecsz, flm->size, &resetdest) < 0)
Return("input would overwrite the reset vector bricking the bootloader\n"
"%*susing -F will try to patch the input but this may not be what is needed",
(int) strlen(progname)+1, "");
" using -F will try to patch the input but this may not be what is needed");
if(resetdest != ur.blstart)
Return("input points reset to 0x%04x, not to bootloader at 0x%04x\n"
"%*susing -F will try to patch the input but this may not be what is needed",
resetdest, ur.blstart, (int) strlen(progname)+1, "");
" using -F will try to patch the input but this may not be what is needed",
resetdest, ur.blstart);
}
}
@@ -2395,14 +2394,8 @@ static int urclock_term_keep_alive(const PROGRAMMER *pgm, const AVRPART *p_unuse
}
// Display what we know so far (too early in the process to say much)
static void urclock_display(const PROGRAMMER *pgm, const char *p_unused) {
if(ur.urprotocol) {
imsg_info("Urboot protocol for %s\n", ur.uP.name);
} else {
imsg_info("Bootloader using STK500v1 communication protocol\n");
}
imsg_info("Protocol : %s\n", ur.urprotocol? "Urprotocol": "STK500v1 skeleton");
return;
}

View File

@@ -1162,7 +1162,7 @@ static int usbasp_tpi_paged_load(const PROGRAMMER *pgm, const AVRPART *p, const
unsigned char cmd[4];
unsigned char* dptr;
int readed, clen, n;
int read, clen, n;
uint16_t pr;
@@ -1170,11 +1170,11 @@ static int usbasp_tpi_paged_load(const PROGRAMMER *pgm, const AVRPART *p, const
dptr = addr + m->buf;
pr = addr + m->offset;
readed = 0;
read = 0;
while(readed < (int) n_bytes)
while(read < (int) n_bytes)
{
clen = n_bytes - readed;
clen = n_bytes - read;
if(clen > 32)
clen = 32;
@@ -1190,7 +1190,7 @@ static int usbasp_tpi_paged_load(const PROGRAMMER *pgm, const AVRPART *p, const
return -3;
}
readed += clen;
read += clen;
pr += clen;
dptr += clen;
}