When programming controllers, it is often needed to adjust the bitclock value to a more conservative value; This patch allows the specification of a default value in the configuration files, making it unnecessary to add "-B x" to each invocation of avrdude.
Signed-off-by: Stefan Tomanek <[email protected]> --- avrdude/avrdude.1 | 4 ++++ avrdude/avrdude.conf.in | 1 + avrdude/config.c | 1 + avrdude/config.h | 1 + avrdude/config_gram.y | 6 ++++++ avrdude/doc/avrdude.texi | 6 ++++++ avrdude/lexer.l | 1 + avrdude/main.c | 5 +++++ 8 files changed, 25 insertions(+), 0 deletions(-) diff --git a/avrdude/avrdude.1 b/avrdude/avrdude.1 index 3da8b55..fcd4d73 100644 --- a/avrdude/avrdude.1 +++ b/avrdude/avrdude.1 @@ -321,6 +321,10 @@ Unlike certain parameters in the STK500, the JTAG ICE resets all its parameters to default values when the programming software signs off from the ICE, so for MCUs running at lower clock speeds, this parameter must be specified on the command-line. +You can use the 'default_bitclock' keyword in your +.Pa ${HOME}/.avrduderc +file to assign a default value to keep from having to specify this +option on every invocation. .It Fl c Ar programmer-id Use the pin configuration specified by the argument. Pin configurations are read from the config file (see the diff --git a/avrdude/avrdude.conf.in b/avrdude/avrdude.conf.in index ebd9093..b94f419 100644 --- a/avrdude/avrdude.conf.in +++ b/avrdude/avrdude.conf.in @@ -308,6 +308,7 @@ # default_parallel = "@DEFAULT_PAR_PORT@"; default_serial = "@DEFAULT_SER_PORT@"; +# default_bitclock = 2.5 # diff --git a/avrdude/config.c b/avrdude/config.c index 7105884..6f0b571 100644 --- a/avrdude/config.c +++ b/avrdude/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; char string_buf[MAX_STR_CONST]; char *string_buf_ptr; diff --git a/avrdude/config.h b/avrdude/config.h index e557bf4..0235579 100644 --- a/avrdude/config.h +++ b/avrdude/config.h @@ -57,6 +57,7 @@ extern LISTID programmers; extern char default_programmer[]; extern char default_parallel[]; extern char default_serial[]; +extern double default_bitclock; diff --git a/avrdude/config_gram.y b/avrdude/config_gram.y index 2ff8452..169aae6 100644 --- a/avrdude/config_gram.y +++ b/avrdude/config_gram.y @@ -91,6 +91,7 @@ static int parse_cmdbits(OPCODE * op); %token K_DEFAULT_PARALLEL %token K_DEFAULT_PROGRAMMER %token K_DEFAULT_SERIAL +%token K_DEFAULT_BITCLOCK %token K_DESC %token K_DEVICECODE %token K_DRAGON_DW @@ -263,6 +264,11 @@ def : strncpy(default_serial, $3->value.string, PATH_MAX); default_serial[PATH_MAX-1] = 0; free_token($3); + } | + + K_DEFAULT_BITCLOCK TKN_EQUAL TKN_NUMBER TKN_SEMI { + default_bitclock = $3->value.number; + free_token($3); } ; diff --git a/avrdude/doc/avrdude.texi b/avrdude/doc/avrdude.texi index c22ed10..6b92771 100644 --- a/avrdude/doc/avrdude.texi +++ b/avrdude/doc/avrdude.texi @@ -415,6 +415,8 @@ Unlike certain parameters in the STK500, the JTAG ICE resets all its parameters to default values when the programming software signs off from the ICE, so for MCUs running at lower clock speeds, this parameter must be specified on the command-line. +It can also be set in the configuration file by using the 'default_bitclock' +keyword. @item -c @var{programmer-id} Specify the programmer to be used. AVRDUDE knows about several common @@ -1446,6 +1448,10 @@ Assign the default serial port device. Can be overridden using the Assign the default programmer id. Can be overridden using the @option{-c} option. +@item default_bitclock = "@var{default-bitclock}"; +Assign the default bitclock value. Can be overridden using the @option{-B} +option. + @end table diff --git a/avrdude/lexer.l b/avrdude/lexer.l index 926aca1..daaaf9f 100644 --- a/avrdude/lexer.l +++ b/avrdude/lexer.l @@ -134,6 +134,7 @@ desc { yylval=NULL; return K_DESC; } default_parallel { yylval=NULL; return K_DEFAULT_PARALLEL; } default_programmer { yylval=NULL; return K_DEFAULT_PROGRAMMER; } default_serial { yylval=NULL; return K_DEFAULT_SERIAL; } +default_bitclock { yylval=NULL; return K_DEFAULT_BITCLOCK; } devicecode { yylval=NULL; return K_DEVICECODE; } dragon_dw { yylval=NULL; return K_DRAGON_DW; } dragon_hvsp { yylval=NULL; return K_DRAGON_HVSP; } diff --git a/avrdude/main.c b/avrdude/main.c index 4d1ee27..13c7fa4 100644 --- a/avrdude/main.c +++ b/avrdude/main.c @@ -314,6 +314,7 @@ int main(int argc, char * argv []) default_parallel[0] = 0; default_serial[0] = 0; + default_bitclock = 0.0; init_config(); @@ -607,6 +608,10 @@ int main(int argc, char * argv []) } } } + // set bitclock from configuration files unless changed by command line + if (default_bitclock > 0 && bitclock == 0.0) { + bitclock = default_bitclock; + } if (verbose) { fprintf(stderr, "\n"); -- 1.7.4.1 _______________________________________________ avrdude-dev mailing list [email protected] https://lists.nongnu.org/mailman/listinfo/avrdude-dev
