bug #35474 Feature request: print fuse values in safemode output

* config_gram.y: New configuration token "default_safemode".
* lexer.l: (Dito.)
* avrdude.conf.in: (Dito.)
* config.h: Add variable default_safemode.
* config.c: (Dito.)
* main.c: Handle default_safemode, including -u option.
* avrdude.1: Document all this.
* doc/avrdude.texi: (Dito.)



git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@1226 81a1dc3b-b13d-400b-aceb-764788c761c2
This commit is contained in:
Joerg Wunsch 2013-09-13 17:22:38 +00:00
parent e358e7079e
commit 3203d8c054
10 changed files with 81 additions and 10 deletions

View File

@ -1,3 +1,15 @@
2013-09-13 Joerg Wunsch <j.gnu@uriah.heep.sax.de>
bug #35474 Feature request: print fuse values in safemode output
* config_gram.y: New configuration token "default_safemode".
* lexer.l: (Dito.)
* avrdude.conf.in: (Dito.)
* config.h: Add variable default_safemode.
* config.c: (Dito.)
* main.c: Handle default_safemode, including -u option.
* avrdude.1: Document all this.
* doc/avrdude.texi: (Dito.)
2013-09-13 Joerg Wunsch <j.gnu@uriah.heep.sax.de>
Submitted by HubertB:

6
NEWS
View File

@ -110,6 +110,7 @@ Current:
- patch #5708 avrdude should make 10 synchronization attempts instead of just one
- patch #7606 ATtiny43u support
- patch #7657 Add ATmega406 support for avrdude using DRAGON + JTAG
- bug #35474 Feature request: print fuse values in safemode output.
* Keep track of input file contents
@ -122,7 +123,7 @@ Current:
everything mentioned in the file (even in case the file has
large 0xFF blocks).
* The eraes cycle counter (formerly options -y / -Y) has been
* The erase cycle counter (formerly options -y / -Y) has been
removed.
* The -U option now accepts ELF files as input files, and extracts
@ -183,6 +184,9 @@ Current:
* The "verbose" terminal mode command allows to query or modify the
verbosity level.
* "Safemode" can now be turned off by default in a configuration
file.
* Internals:
- Restructuring and compacting programmer definition part of

View File

@ -18,7 +18,7 @@
.\"
.\" $Id$
.\"
.Dd DATE September 8, 2013
.Dd DATE September 13, 2013
.Os
.Dt AVRDUDE 1
.Sh NAME
@ -531,6 +531,17 @@ prompt for instructions, unless the terminal is non-interactive, in
which case safemode is disabled. See the
.Fl s
option to disable safemode prompting.
.Pp
If one of the configuration files has a line
.Dl "default_safemode = no;"
safemode is disabled by default.
The
.Fl u
option's effect is negated in that case, i. e. it
.Em enables
safemode.
.Pp
Safemode is always disabled for AVR32, Xmega and TPI devices.
.It Xo Fl U Ar memtype Ns
.Ar \&: Ns Ar op Ns
.Ar \&: Ns Ar filename Ns

View File

@ -325,12 +325,15 @@
# ATmega169 0x78
#
# Overall avrdude defaults
# Overall avrdude defaults; suitable for ~/.avrduderc
#
default_parallel = "@DEFAULT_PAR_PORT@";
default_serial = "@DEFAULT_SER_PORT@";
# default_bitclock = 2.5;
# Turn off safemode by default
#default_safemode = no;
#
# PROGRAMMER DEFINITIONS

View File

@ -35,6 +35,7 @@ char default_programmer[MAX_STR_CONST];
char default_parallel[PATH_MAX];
char default_serial[PATH_MAX];
double default_bitclock;
int default_safemode;
char string_buf[MAX_STR_CONST];
char *string_buf_ptr;

View File

@ -60,6 +60,7 @@ extern char default_programmer[];
extern char default_parallel[];
extern char default_serial[];
extern double default_bitclock;
extern int default_safemode;
/* This name is fixed, it's only here for symmetry with
* default_parallel and default_serial. */

View File

@ -78,10 +78,11 @@ static int pin_name;
%token K_CHIP_ERASE_DELAY
%token K_CONNTYPE
%token K_DEDICATED
%token K_DEFAULT_BITCLOCK
%token K_DEFAULT_PARALLEL
%token K_DEFAULT_PROGRAMMER
%token K_DEFAULT_SAFEMODE
%token K_DEFAULT_SERIAL
%token K_DEFAULT_BITCLOCK
%token K_DESC
%token K_DEVICECODE
%token K_STK500_DEVCODE
@ -257,6 +258,14 @@ def :
K_DEFAULT_BITCLOCK TKN_EQUAL number_real TKN_SEMI {
default_bitclock = $3->value.number_real;
free_token($3);
} |
K_DEFAULT_SAFEMODE TKN_EQUAL yesno TKN_SEMI {
if ($3->primary == K_YES)
default_safemode = 1;
else if ($3->primary == K_NO)
default_safemode = 0;
free_token($3);
}
;

View File

@ -567,6 +567,24 @@ as avrdude will see the fuses have changed (even though you wanted to) and
will change them back for your "safety". This option was designed to
prevent cases of fuse bits magically changing (usually called @emph{safemode}).
If one of the configuration files contains a line
@code{default_safemode = no;}
safemode is disabled by default.
The @option{-u} option's effect is negated in that case, i. e. it
@emph{enables} safemode.
Safemode is always disabled for AVR32, Xmega and TPI devices.
@item -s
Disable safemode prompting. When safemode discovers that one or more
fuse bits have unintentionally changed, it will prompt for
confirmation regarding whether or not it should attempt to recover the
fuse bit(s). Specifying this flag disables the prompt and assumes
that the fuse bit(s) should be recovered without asking for
confirmation first.
@item -t
Tells AVRDUDE to enter the interactive ``terminal'' mode instead of up-
or downloading files. See below for a detailed description of the

View File

@ -140,6 +140,7 @@ dedicated { yylval=new_token(K_DEDICATED); return K_DEDICATED; }
default_bitclock { yylval=NULL; return K_DEFAULT_BITCLOCK; }
default_parallel { yylval=NULL; return K_DEFAULT_PARALLEL; }
default_programmer { yylval=NULL; return K_DEFAULT_PROGRAMMER; }
default_safemode { yylval=NULL; return K_DEFAULT_SAFEMODE; }
default_serial { yylval=NULL; return K_DEFAULT_SERIAL; }
delay { yylval=NULL; return K_DELAY; }
desc { yylval=NULL; return K_DESC; }

23
main.c
View File

@ -366,6 +366,7 @@ int main(int argc, char * argv [])
default_parallel[0] = 0;
default_serial[0] = 0;
default_bitclock = 0.0;
default_safemode = -1;
init_config();
@ -410,11 +411,6 @@ int main(int argc, char * argv [])
is_open = 0;
logfile = NULL;
if (isatty(STDIN_FILENO) == 0)
safemode = 0; /* Turn off safemode if this isn't a terminal */
#if defined(WIN32NATIVE)
win_sys_config_set(sys_config);
@ -845,6 +841,20 @@ int main(int argc, char * argv [])
}
}
if (default_safemode == 0) {
/* configuration disables safemode: revert meaning of -u */
if (safemode == 0)
/* -u was given: enable safemode */
safemode = 1;
else
/* -u not given: turn off */
safemode = 0;
}
if (isatty(STDIN_FILENO) == 0 && silentsafe == 0)
safemode = 0; /* Turn off safemode if this isn't a terminal */
if(p->flags & AVRPART_AVR32) {
safemode = 0;
}
@ -1353,7 +1363,8 @@ int main(int argc, char * argv [])
if (quell_progress < 2) {
fprintf(stderr, "%s: safemode: ", progname);
if (failures == 0) {
fprintf(stderr, "Fuses OK\n");
fprintf(stderr, "Fuses OK (H:%02X, E:%02X, L:%02X)\n",
safemode_efuse, safemode_hfuse, safemode_lfuse);
}
else {
fprintf(stderr, "Fuses not recovered, sorry\n");