Introduce 'default_programmer' to the config file instead of requiring
one of the programmers to be tagged "default" within its definition. Also, axe the notion of a compiled-in default programmer. It is kind've pointless now that nearly all configuration comes from the config file, thus, avrdude is not very useful without the config file, and thus, having a programmer compiled-in offers little or no benefit. git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@218 81a1dc3b-b13d-400b-aceb-764788c761c2
This commit is contained in:
parent
131cd12d10
commit
61ab2bc318
|
@ -174,6 +174,7 @@
|
||||||
#
|
#
|
||||||
default_parallel = "/dev/ppi0";
|
default_parallel = "/dev/ppi0";
|
||||||
default_serial = "/dev/cuaa0";
|
default_serial = "/dev/cuaa0";
|
||||||
|
default_programmer = "stk500";
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
|
@ -181,7 +182,7 @@ default_serial = "/dev/cuaa0";
|
||||||
#
|
#
|
||||||
|
|
||||||
programmer
|
programmer
|
||||||
id = "bsd", "default";
|
id = "bsd";
|
||||||
desc = "Brian Dean's Programmer";
|
desc = "Brian Dean's Programmer";
|
||||||
type = par;
|
type = par;
|
||||||
vcc = 2, 3, 4, 5;
|
vcc = 2, 3, 4, 5;
|
||||||
|
|
1
config.c
1
config.c
|
@ -30,6 +30,7 @@
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "config_gram.h"
|
#include "config_gram.h"
|
||||||
|
|
||||||
|
char default_programmer[MAX_STR_CONST];
|
||||||
char default_parallel[PATH_MAX];
|
char default_parallel[PATH_MAX];
|
||||||
char default_serial[PATH_MAX];
|
char default_serial[PATH_MAX];
|
||||||
|
|
||||||
|
|
1
config.h
1
config.h
|
@ -53,6 +53,7 @@ extern int lineno;
|
||||||
extern char * infile;
|
extern char * infile;
|
||||||
extern LISTID string_list;
|
extern LISTID string_list;
|
||||||
extern LISTID number_list;
|
extern LISTID number_list;
|
||||||
|
extern char default_programmer[];
|
||||||
extern char default_parallel[];
|
extern char default_parallel[];
|
||||||
extern char default_serial[];
|
extern char default_serial[];
|
||||||
|
|
||||||
|
|
|
@ -68,6 +68,7 @@ static int parse_cmdbits(OPCODE * op);
|
||||||
%token K_CHIP_ERASE_DELAY
|
%token K_CHIP_ERASE_DELAY
|
||||||
%token K_DEDICATED
|
%token K_DEDICATED
|
||||||
%token K_DEFAULT_PARALLEL
|
%token K_DEFAULT_PARALLEL
|
||||||
|
%token K_DEFAULT_PROGRAMMER
|
||||||
%token K_DEFAULT_SERIAL
|
%token K_DEFAULT_SERIAL
|
||||||
%token K_DESC
|
%token K_DESC
|
||||||
%token K_DEVICECODE
|
%token K_DEVICECODE
|
||||||
|
@ -131,6 +132,12 @@ def :
|
||||||
|
|
||||||
part_def TKN_SEMI |
|
part_def TKN_SEMI |
|
||||||
|
|
||||||
|
K_DEFAULT_PROGRAMMER TKN_EQUAL TKN_STRING TKN_SEMI {
|
||||||
|
strncpy(default_programmer, $3->value.string, MAX_STR_CONST);
|
||||||
|
default_programmer[MAX_STR_CONST-1] = 0;
|
||||||
|
free_token($3);
|
||||||
|
} |
|
||||||
|
|
||||||
K_DEFAULT_PARALLEL TKN_EQUAL TKN_STRING TKN_SEMI {
|
K_DEFAULT_PARALLEL TKN_EQUAL TKN_STRING TKN_SEMI {
|
||||||
strncpy(default_parallel, $3->value.string, PATH_MAX);
|
strncpy(default_parallel, $3->value.string, PATH_MAX);
|
||||||
default_parallel[PATH_MAX-1] = 0;
|
default_parallel[PATH_MAX-1] = 0;
|
||||||
|
|
1
lexer.l
1
lexer.l
|
@ -122,6 +122,7 @@ buff { yylval=NULL; return K_BUFF; }
|
||||||
chip_erase_delay { yylval=NULL; return K_CHIP_ERASE_DELAY; }
|
chip_erase_delay { yylval=NULL; return K_CHIP_ERASE_DELAY; }
|
||||||
desc { yylval=NULL; return K_DESC; }
|
desc { yylval=NULL; return K_DESC; }
|
||||||
default_parallel { yylval=NULL; return K_DEFAULT_PARALLEL; }
|
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_serial { yylval=NULL; return K_DEFAULT_SERIAL; }
|
||||||
devicecode { yylval=NULL; return K_DEVICECODE; }
|
devicecode { yylval=NULL; return K_DEVICECODE; }
|
||||||
eeprom { yylval=NULL; return K_EEPROM; }
|
eeprom { yylval=NULL; return K_EEPROM; }
|
||||||
|
|
73
main.c
73
main.c
|
@ -190,7 +190,7 @@ int read_config(char * file)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void pinconfig_display(char * p)
|
void programmer_display(char * p)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "%sProgrammer Type: %s\n", p, pgm->type);
|
fprintf(stderr, "%sProgrammer Type: %s\n", p, pgm->type);
|
||||||
|
|
||||||
|
@ -210,7 +210,7 @@ void verify_pin_assigned(int pin, char * desc)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
PROGRAMMER * locate_pinconfig(LISTID programmers, char * configid)
|
PROGRAMMER * locate_programmer(LISTID programmers, char * configid)
|
||||||
{
|
{
|
||||||
LNODEID ln1, ln2;
|
LNODEID ln1, ln2;
|
||||||
PROGRAMMER * p = NULL;
|
PROGRAMMER * p = NULL;
|
||||||
|
@ -305,7 +305,7 @@ int main(int argc, char * argv [])
|
||||||
int ppisetbits; /* bits to set in ppi data register at exit */
|
int ppisetbits; /* bits to set in ppi data register at exit */
|
||||||
int ppiclrbits; /* bits to clear in ppi data register at exit */
|
int ppiclrbits; /* bits to clear in ppi data register at exit */
|
||||||
char * exitspecs; /* exit specs string from command line */
|
char * exitspecs; /* exit specs string from command line */
|
||||||
char * pinconfig; /* programmer id */
|
char * programmer; /* programmer id */
|
||||||
char * partdesc; /* part id */
|
char * partdesc; /* part id */
|
||||||
char configfile[PATH_MAX]; /* pin configuration file */
|
char configfile[PATH_MAX]; /* pin configuration file */
|
||||||
int cycles; /* erase-rewrite cycles */
|
int cycles; /* erase-rewrite cycles */
|
||||||
|
@ -341,7 +341,7 @@ int main(int argc, char * argv [])
|
||||||
ppiclrbits = 0;
|
ppiclrbits = 0;
|
||||||
exitspecs = NULL;
|
exitspecs = NULL;
|
||||||
pgm = NULL;
|
pgm = NULL;
|
||||||
pinconfig = "avrdude"; /* compiled-in default */
|
programmer = default_programmer;
|
||||||
verbose = 0;
|
verbose = 0;
|
||||||
do_cycles = 0;
|
do_cycles = 0;
|
||||||
set_cycles = -1;
|
set_cycles = -1;
|
||||||
|
@ -352,25 +352,6 @@ int main(int argc, char * argv [])
|
||||||
strcat(configfile, "/");
|
strcat(configfile, "/");
|
||||||
strcat(configfile, "avrdude.conf");
|
strcat(configfile, "avrdude.conf");
|
||||||
|
|
||||||
/*
|
|
||||||
* initialize compiled-in default programmer
|
|
||||||
*/
|
|
||||||
compiled_in_pgm = pgm_new();
|
|
||||||
pgm = compiled_in_pgm;
|
|
||||||
par_initpgm(pgm);
|
|
||||||
ladd(pgm->id, dup_string("avrdude"));
|
|
||||||
strcpy(pgm->desc, "avrdude compiled-in default");
|
|
||||||
pgm->pinno[PPI_AVR_VCC] = 0x0f; /* ppi pins 2-5, data reg bits 0-3 */
|
|
||||||
pgm->pinno[PPI_AVR_BUFF] = 0;
|
|
||||||
pgm->pinno[PIN_AVR_RESET] = 7;
|
|
||||||
pgm->pinno[PIN_AVR_SCK] = 8;
|
|
||||||
pgm->pinno[PIN_AVR_MOSI] = 9;
|
|
||||||
pgm->pinno[PIN_AVR_MISO] = 10;
|
|
||||||
pgm->pinno[PIN_LED_ERR] = 0;
|
|
||||||
pgm->pinno[PIN_LED_RDY] = 0;
|
|
||||||
pgm->pinno[PIN_LED_PGM] = 0;
|
|
||||||
pgm->pinno[PIN_LED_VFY] = 0;
|
|
||||||
|
|
||||||
len = strlen(progname) + 2;
|
len = strlen(progname) + 2;
|
||||||
for (i=0; i<len; i++)
|
for (i=0; i<len; i++)
|
||||||
progbuf[i] = ' ';
|
progbuf[i] = ' ';
|
||||||
|
@ -391,13 +372,8 @@ int main(int argc, char * argv [])
|
||||||
while ((ch = getopt(argc,argv,"?c:C:eE:f:Fi:m:no:p:P:tvVyY:")) != -1) {
|
while ((ch = getopt(argc,argv,"?c:C:eE:f:Fi:m:no:p:P:tvVyY:")) != -1) {
|
||||||
|
|
||||||
switch (ch) {
|
switch (ch) {
|
||||||
case 'c': /* pin configuration */
|
case 'c': /* programmer id */
|
||||||
pinconfig = optarg;
|
programmer = optarg;
|
||||||
if (strcmp(pinconfig, "stk500") == 0) {
|
|
||||||
if (port == default_parallel) {
|
|
||||||
port = default_serial;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'C': /* pin configuration file */
|
case 'C': /* pin configuration file */
|
||||||
|
@ -544,27 +520,35 @@ int main(int argc, char * argv [])
|
||||||
|
|
||||||
rc = read_config(configfile);
|
rc = read_config(configfile);
|
||||||
if (rc) {
|
if (rc) {
|
||||||
fprintf(stderr, "%s: error reading \"%s\" configuration from \"%s\"\n",
|
fprintf(stderr, "%s: error reading configuration file \"%s\"\n",
|
||||||
progname, pinconfig, configfile);
|
progname, configfile);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strcmp(pinconfig, "avrdude") == 0) {
|
if (programmer[0] == 0) {
|
||||||
pgm = locate_pinconfig(programmers, "default");
|
fprintf(stderr,
|
||||||
if (pgm == NULL) {
|
"\n%s: no programmer has been specified on the command line "
|
||||||
/* no default config listed, use the compile-in default */
|
"or the config file\n",
|
||||||
pgm = compiled_in_pgm;
|
progname);
|
||||||
|
fprintf(stderr,
|
||||||
|
"%sSpecify a programmer using the -c option and try again\n\n",
|
||||||
|
progbuf);
|
||||||
|
exit(1);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else {
|
pgm = locate_programmer(programmers, programmer);
|
||||||
pgm = locate_pinconfig(programmers, pinconfig);
|
|
||||||
if (pgm == NULL) {
|
if (pgm == NULL) {
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"%s: Can't find programmer id \"%s\"\n",
|
"%s: Can't find programmer id \"%s\"\n",
|
||||||
progname, pinconfig);
|
progname, programmer);
|
||||||
fprintf(stderr,"\n");
|
fprintf(stderr,"\n");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (strcmp(programmer, "stk500") == 0) {
|
||||||
|
if (port == default_parallel) {
|
||||||
|
port = default_serial;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (partdesc == NULL) {
|
if (partdesc == NULL) {
|
||||||
|
@ -627,8 +611,8 @@ int main(int argc, char * argv [])
|
||||||
* open the programmer
|
* open the programmer
|
||||||
*/
|
*/
|
||||||
if (port[0] == 0) {
|
if (port[0] == 0) {
|
||||||
fprintf(stderr, "\n%s: no port has been specified on the command or the "
|
fprintf(stderr, "\n%s: no port has been specified on the command line "
|
||||||
"config file\n",
|
"or the config file\n",
|
||||||
progname);
|
progname);
|
||||||
fprintf(stderr, "%sSpecify a port using the -P option and try again\n\n",
|
fprintf(stderr, "%sSpecify a port using the -P option and try again\n\n",
|
||||||
progbuf);
|
progbuf);
|
||||||
|
@ -637,6 +621,7 @@ int main(int argc, char * argv [])
|
||||||
|
|
||||||
if (verbose) {
|
if (verbose) {
|
||||||
fprintf(stderr, "%sUsing Port : %s\n", progbuf, port);
|
fprintf(stderr, "%sUsing Port : %s\n", progbuf, port);
|
||||||
|
fprintf(stderr, "%sUsing Programmer : %s\n", progbuf, programmer);
|
||||||
}
|
}
|
||||||
|
|
||||||
pgm->open(pgm, port);
|
pgm->open(pgm, port);
|
||||||
|
@ -644,7 +629,7 @@ int main(int argc, char * argv [])
|
||||||
if (verbose) {
|
if (verbose) {
|
||||||
avr_display(stderr, p, progbuf, verbose);
|
avr_display(stderr, p, progbuf, verbose);
|
||||||
fprintf(stderr, "\n");
|
fprintf(stderr, "\n");
|
||||||
pinconfig_display(progbuf);
|
programmer_display(progbuf);
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf(stderr, "\n");
|
fprintf(stderr, "\n");
|
||||||
|
|
Loading…
Reference in New Issue