From 3203d8c054eb82a43fb73c61c9a30ea1c5e16d28 Mon Sep 17 00:00:00 2001 From: Joerg Wunsch Date: Fri, 13 Sep 2013 17:22:38 +0000 Subject: [PATCH] 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 --- ChangeLog | 12 ++++++++++++ NEWS | 6 +++++- avrdude.1 | 13 ++++++++++++- avrdude.conf.in | 5 ++++- config.c | 1 + config.h | 1 + config_gram.y | 11 ++++++++++- doc/avrdude.texi | 18 ++++++++++++++++++ lexer.l | 1 + main.c | 23 +++++++++++++++++------ 10 files changed, 81 insertions(+), 10 deletions(-) diff --git a/ChangeLog b/ChangeLog index bfbec161..5a04a6b5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +2013-09-13 Joerg Wunsch + + 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 Submitted by HubertB: diff --git a/NEWS b/NEWS index 1cfd6389..9cb179b3 100644 --- a/NEWS +++ b/NEWS @@ -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 diff --git a/avrdude.1 b/avrdude.1 index f36b5d45..8ba69fae 100644 --- a/avrdude.1 +++ b/avrdude.1 @@ -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 diff --git a/avrdude.conf.in b/avrdude.conf.in index e4fc7986..6a2750dc 100644 --- a/avrdude.conf.in +++ b/avrdude.conf.in @@ -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 diff --git a/config.c b/config.c index 718a094f..a63d5456 100644 --- a/config.c +++ b/config.c @@ -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; diff --git a/config.h b/config.h index c627cadc..137bc558 100644 --- a/config.h +++ b/config.h @@ -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. */ diff --git a/config_gram.y b/config_gram.y index a04906dc..d7b7d8f1 100644 --- a/config_gram.y +++ b/config_gram.y @@ -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); } ; diff --git a/doc/avrdude.texi b/doc/avrdude.texi index 9eafe751..6f3331a1 100644 --- a/doc/avrdude.texi +++ b/doc/avrdude.texi @@ -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 diff --git a/lexer.l b/lexer.l index f9fd7c7d..9079739f 100644 --- a/lexer.l +++ b/lexer.l @@ -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; } diff --git a/main.c b/main.c index 41875c81..c4c6d58d 100644 --- a/main.c +++ b/main.c @@ -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");