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:
bdean 2003-02-21 21:07:43 +00:00
parent 131cd12d10
commit 61ab2bc318
6 changed files with 48 additions and 52 deletions

View File

@ -172,8 +172,9 @@
#
# Overall avrdude defaults
#
default_parallel = "/dev/ppi0";
default_serial = "/dev/cuaa0";
default_parallel = "/dev/ppi0";
default_serial = "/dev/cuaa0";
default_programmer = "stk500";
#
@ -181,7 +182,7 @@ default_serial = "/dev/cuaa0";
#
programmer
id = "bsd", "default";
id = "bsd";
desc = "Brian Dean's Programmer";
type = par;
vcc = 2, 3, 4, 5;

View File

@ -30,6 +30,7 @@
#include "config.h"
#include "config_gram.h"
char default_programmer[MAX_STR_CONST];
char default_parallel[PATH_MAX];
char default_serial[PATH_MAX];

View File

@ -53,6 +53,7 @@ extern int lineno;
extern char * infile;
extern LISTID string_list;
extern LISTID number_list;
extern char default_programmer[];
extern char default_parallel[];
extern char default_serial[];

View File

@ -68,6 +68,7 @@ static int parse_cmdbits(OPCODE * op);
%token K_CHIP_ERASE_DELAY
%token K_DEDICATED
%token K_DEFAULT_PARALLEL
%token K_DEFAULT_PROGRAMMER
%token K_DEFAULT_SERIAL
%token K_DESC
%token K_DEVICECODE
@ -131,6 +132,12 @@ def :
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 {
strncpy(default_parallel, $3->value.string, PATH_MAX);
default_parallel[PATH_MAX-1] = 0;

View File

@ -122,6 +122,7 @@ buff { yylval=NULL; return K_BUFF; }
chip_erase_delay { yylval=NULL; return K_CHIP_ERASE_DELAY; }
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; }
devicecode { yylval=NULL; return K_DEVICECODE; }
eeprom { yylval=NULL; return K_EEPROM; }

83
main.c
View File

@ -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);
@ -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;
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 ppiclrbits; /* bits to clear in ppi data register at exit */
char * exitspecs; /* exit specs string from command line */
char * pinconfig; /* programmer id */
char * programmer; /* programmer id */
char * partdesc; /* part id */
char configfile[PATH_MAX]; /* pin configuration file */
int cycles; /* erase-rewrite cycles */
@ -341,7 +341,7 @@ int main(int argc, char * argv [])
ppiclrbits = 0;
exitspecs = NULL;
pgm = NULL;
pinconfig = "avrdude"; /* compiled-in default */
programmer = default_programmer;
verbose = 0;
do_cycles = 0;
set_cycles = -1;
@ -352,25 +352,6 @@ int main(int argc, char * argv [])
strcat(configfile, "/");
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;
for (i=0; i<len; 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) {
switch (ch) {
case 'c': /* pin configuration */
pinconfig = optarg;
if (strcmp(pinconfig, "stk500") == 0) {
if (port == default_parallel) {
port = default_serial;
}
}
case 'c': /* programmer id */
programmer = optarg;
break;
case 'C': /* pin configuration file */
@ -544,26 +520,34 @@ int main(int argc, char * argv [])
rc = read_config(configfile);
if (rc) {
fprintf(stderr, "%s: error reading \"%s\" configuration from \"%s\"\n",
progname, pinconfig, configfile);
fprintf(stderr, "%s: error reading configuration file \"%s\"\n",
progname, configfile);
exit(1);
}
if (strcmp(pinconfig, "avrdude") == 0) {
pgm = locate_pinconfig(programmers, "default");
if (pgm == NULL) {
/* no default config listed, use the compile-in default */
pgm = compiled_in_pgm;
}
if (programmer[0] == 0) {
fprintf(stderr,
"\n%s: no programmer has been specified on the command line "
"or the config file\n",
progname);
fprintf(stderr,
"%sSpecify a programmer using the -c option and try again\n\n",
progbuf);
exit(1);
}
else {
pgm = locate_pinconfig(programmers, pinconfig);
if (pgm == NULL) {
fprintf(stderr,
"%s: Can't find programmer id \"%s\"\n",
progname, pinconfig);
fprintf(stderr,"\n");
exit(1);
pgm = locate_programmer(programmers, programmer);
if (pgm == NULL) {
fprintf(stderr,
"%s: Can't find programmer id \"%s\"\n",
progname, programmer);
fprintf(stderr,"\n");
exit(1);
}
if (strcmp(programmer, "stk500") == 0) {
if (port == default_parallel) {
port = default_serial;
}
}
@ -627,8 +611,8 @@ int main(int argc, char * argv [])
* open the programmer
*/
if (port[0] == 0) {
fprintf(stderr, "\n%s: no port has been specified on the command or the "
"config file\n",
fprintf(stderr, "\n%s: no port has been specified on the command line "
"or the config file\n",
progname);
fprintf(stderr, "%sSpecify a port using the -P option and try again\n\n",
progbuf);
@ -637,6 +621,7 @@ int main(int argc, char * argv [])
if (verbose) {
fprintf(stderr, "%sUsing Port : %s\n", progbuf, port);
fprintf(stderr, "%sUsing Programmer : %s\n", progbuf, programmer);
}
pgm->open(pgm, port);
@ -644,7 +629,7 @@ int main(int argc, char * argv [])
if (verbose) {
avr_display(stderr, p, progbuf, verbose);
fprintf(stderr, "\n");
pinconfig_display(progbuf);
programmer_display(progbuf);
}
fprintf(stderr, "\n");