Add a connection_type attribute to each programmer, rather than

trying to hard-code the default port name in main.c.



git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@1047 81a1dc3b-b13d-400b-aceb-764788c761c2
This commit is contained in:
joerg_wunsch 2012-01-30 17:08:48 +00:00
parent cfe513363f
commit a86aff7232
8 changed files with 130 additions and 17 deletions

View File

@ -1,3 +1,18 @@
2012-01-30 Joerg Wunsch <j.gnu@uriah.heep.sax.de>
Add a connection_type attribute to each programmer, rather than
trying to hard-code the default port name in main.c.
* pgm.h: Add conntype to struct pgm.
* lexer.l: Extend grammar for connection_type.
* config_gram.y: (Dito.)
* config.h: Add DEFAULT_USB, for symmetry with default_parallel
and default_serial.
* main.c: Replace old default portname hack by avrdude.conf-based
knowledge.
* usbtiny.c: Drop an old hack that's no longer necessary.
* avrdude.conf.in: Add connection_type to each programmer
definition.
2012-01-27 Rene Liebscher <R.Liebscher@gmx.de>
* avrdude.conf.in: used parent parts for some other parts, added

View File

@ -23,6 +23,7 @@
# jtagmkII_avr32 | jtagmkii_pdi |
# dragon_dw | dragon_jtag | dragon_isp | dragon_pp |
# dragon_hvsp | dragon_pdi | arduino | wiring; # programmer type
# connection_type = parallel | serial | usb
# baudrate = <num> ; # baudrate for avr910-programmer
# vcc = <num1> [, <num2> ... ] ; # pin number(s)
# buff = <num1> [, <num2> ... ] ; # pin number(s)
@ -344,12 +345,14 @@ programmer
id = "wiring";
desc = "Wiring";
type = wiring;
connection_type = serial;
;
programmer
id = "arduino";
desc = "Arduino";
type = arduino;
connection_type = serial;
;
# this will interface with the chips on these programmers:
#
@ -370,6 +373,7 @@ programmer
id = "avrftdi";
desc = "FT2232D based generic programmer";
type = avrftdi;
connection_type = usb;
usbvid = 0x0403;
usbpid = 0x6010;
usbvendor = "";
@ -397,6 +401,7 @@ programmer
id = "2232HIO";
desc = "FT2232H based generic programmer";
type = avrftdi;
connection_type = usb;
usbvid = 0x0403;
# Note: This PID is reserved for generic H devices and
# should be programmed into the EEPROM
@ -423,6 +428,7 @@ programmer
id = "jtagkey";
desc = "Amontec JTAGKey, JTAGKey-Tiny and JTAGKey2";
type = avrftdi;
connection_type = usb;
usbvid = 0x0403;
# Note: This PID is used in all JTAGKey variants
usbpid = 0xCFF8;
@ -468,18 +474,21 @@ programmer
id = "avrisp";
desc = "Atmel AVR ISP";
type = stk500;
connection_type = serial;
;
programmer
id = "avrispv2";
desc = "Atmel AVR ISP V2";
type = stk500v2;
connection_type = serial;
;
programmer
id = "avrispmkII";
desc = "Atmel AVR ISP mkII";
type = stk500v2;
connection_type = usb;
;
programmer parent "avrispmkII"
@ -490,6 +499,7 @@ programmer
id = "buspirate";
desc = "The Bus Pirate";
type = buspirate;
connection_type = serial;
;
# This is supposed to be the "default" STK500 entry.
@ -500,66 +510,77 @@ programmer
id = "stk500";
desc = "Atmel STK500";
type = stk500generic;
connection_type = serial;
;
programmer
id = "stk500v1";
desc = "Atmel STK500 Version 1.x firmware";
type = stk500;
connection_type = serial;
;
programmer
id = "mib510";
desc = "Crossbow MIB510 programming board";
type = stk500;
connection_type = serial;
;
programmer
id = "stk500v2";
desc = "Atmel STK500 Version 2.x firmware";
type = stk500v2;
connection_type = serial;
;
programmer
id = "stk500pp";
desc = "Atmel STK500 V2 in parallel programming mode";
type = stk500pp;
connection_type = serial;
;
programmer
id = "stk500hvsp";
desc = "Atmel STK500 V2 in high-voltage serial programming mode";
type = stk500hvsp;
connection_type = serial;
;
programmer
id = "stk600";
desc = "Atmel STK600";
type = stk600;
connection_type = usb;
;
programmer
id = "stk600pp";
desc = "Atmel STK600 in parallel programming mode";
type = stk600pp;
connection_type = usb;
;
programmer
id = "stk600hvsp";
desc = "Atmel STK600 in high-voltage serial programming mode";
type = stk600hvsp;
connection_type = usb;
;
programmer
id = "avr910";
desc = "Atmel Low Cost Serial Programmer";
type = avr910;
connection_type = serial;
;
programmer
id = "usbasp";
desc = "USBasp, http://www.fischl.de/usbasp/";
type = usbasp;
connection_type = usb;
usbvid = 0x16C0; # VOTI
usbpid = 0x05DC; # Obdev's free shared PID
usbvendor = "www.fischl.de";
@ -584,6 +605,7 @@ programmer
id = "nibobee";
desc = "NIBObee";
type = usbasp;
connection_type = usb;
usbvid = 0x16C0; # VOTI
usbpid = 0x092F; # NIBObee PID
usbvendor = "www.nicai-systems.com";
@ -594,6 +616,7 @@ programmer
id = "usbasp-clone";
desc = "Any usbasp clone with correct VID/PID";
type = usbasp;
connection_type = usb;
usbvid = 0x16C0; # VOTI
usbpid = 0x05DC; # Obdev's free shared PID
#usbvendor = "";
@ -604,24 +627,28 @@ programmer
id = "usbtiny";
desc = "USBtiny simple USB programmer, http://www.ladyada.net/make/usbtinyisp/";
type = usbtiny;
connection_type = usb;
;
programmer
id = "butterfly";
desc = "Atmel Butterfly Development Board";
type = butterfly;
connection_type = serial;
;
programmer
id = "avr109";
desc = "Atmel AppNote AVR109 Boot Loader";
type = butterfly;
connection_type = serial;
;
programmer
id = "avr911";
desc = "Atmel AppNote AVR911 AVROSP";
type = butterfly;
connection_type = serial;
;
# suggested in http://forum.mikrokopter.de/topic-post48317.html
@ -629,6 +656,7 @@ programmer
id = "mkbutterfly";
desc = "Mikrokopter.de Butterfly";
type = butterfly_mk;
connection_type = serial;
;
programmer parent "mkbutterfly"
@ -640,6 +668,7 @@ programmer
desc = "Atmel JTAG ICE (mkI)";
baudrate = 115200; # default is 115200
type = jtagmki;
connection_type = serial;
;
# easier to type
@ -653,11 +682,17 @@ programmer parent "jtag1"
baudrate = 19200;
;
# The JTAG ICE mkII has both, serial and USB connectivity. As it is
# mostly used through USB these days (AVR Studio 5 only supporting it
# that way), we make connection_type = usb the default. Users are
# still free to use a serial port with the -P option.
programmer
id = "jtagmkII";
desc = "Atmel JTAG ICE mkII";
baudrate = 19200; # default is 19200
type = jtagmkii;
connection_type = usb;
;
# easier to type
@ -682,6 +717,7 @@ programmer
desc = "Atmel JTAG ICE mkII in ISP mode";
baudrate = 115200;
type = jtagmkii_isp;
connection_type = usb;
;
# JTAG ICE mkII in debugWire mode
@ -690,6 +726,7 @@ programmer
desc = "Atmel JTAG ICE mkII in debugWire mode";
baudrate = 115200;
type = jtagmkii_dw;
connection_type = usb;
;
# JTAG ICE mkII in AVR32 mode
@ -698,6 +735,7 @@ programmer
desc = "Atmel JTAG ICE mkII im AVR32 mode";
baudrate = 115200;
type = jtagmkii_avr32;
connection_type = usb;
;
# JTAG ICE mkII in AVR32 mode
@ -706,6 +744,7 @@ programmer
desc = "Atmel JTAG ICE mkII im AVR32 mode";
baudrate = 115200;
type = jtagmkii_avr32;
connection_type = usb;
;
# JTAG ICE mkII in PDI mode
@ -714,6 +753,7 @@ programmer
desc = "Atmel JTAG ICE mkII PDI mode";
baudrate = 115200;
type = jtagmkii_pdi;
connection_type = usb;
;
# AVR Dragon in JTAG mode
@ -722,6 +762,7 @@ programmer
desc = "Atmel AVR Dragon in JTAG mode";
baudrate = 115200;
type = dragon_jtag;
connection_type = usb;
;
# AVR Dragon in ISP mode
@ -730,6 +771,7 @@ programmer
desc = "Atmel AVR Dragon in ISP mode";
baudrate = 115200;
type = dragon_isp;
connection_type = usb;
;
# AVR Dragon in PP mode
@ -738,6 +780,7 @@ programmer
desc = "Atmel AVR Dragon in PP mode";
baudrate = 115200;
type = dragon_pp;
connection_type = usb;
;
# AVR Dragon in HVSP mode
@ -746,6 +789,7 @@ programmer
desc = "Atmel AVR Dragon in HVSP mode";
baudrate = 115200;
type = dragon_hvsp;
connection_type = usb;
;
# AVR Dragon in debugWire mode
@ -754,6 +798,7 @@ programmer
desc = "Atmel AVR Dragon in debugWire mode";
baudrate = 115200;
type = dragon_dw;
connection_type = usb;
;
# AVR Dragon in PDI mode
@ -762,12 +807,14 @@ programmer
desc = "Atmel AVR Dragon in PDI mode";
baudrate = 115200;
type = dragon_pdi;
connection_type = usb;
;
programmer
id = "pavr";
desc = "Jason Kyle's pAVR Serial Programmer";
type = avr910;
connection_type = serial;
;
@HAVE_PARPORT_BEGIN@ Inclusion of the following depends on --enable-parport
@ -777,6 +824,7 @@ programmer
id = "bsd";
desc = "Brian Dean's Programmer, http://www.bsdhome.com/avrdude/";
type = par;
connection_type = parallel;
vcc = 2, 3, 4, 5;
reset = 7;
sck = 8;
@ -788,6 +836,7 @@ programmer
id = "stk200";
desc = "STK200";
type = par;
connection_type = parallel;
buff = 4, 5;
sck = 6;
mosi = 7;
@ -810,6 +859,7 @@ programmer
id = "dt006";
desc = "Dontronics DT006";
type = par;
connection_type = parallel;
reset = 4;
sck = 5;
mosi = 2;
@ -825,6 +875,7 @@ programmer
id = "alf";
desc = "Nightshade ALF-PgmAVR, http://nightshade.homeip.net/";
type = par;
connection_type = parallel;
vcc = 2, 3, 4, 5;
buff = 6;
reset = 7;
@ -841,6 +892,7 @@ programmer
id = "sp12";
desc = "Steve Bolt's Programmer";
type = par;
connection_type = parallel;
vcc = 4,5,6,7,8;
reset = 3;
sck = 2;
@ -852,6 +904,7 @@ programmer
id = "picoweb";
desc = "Picoweb Programming Cable, http://www.picoweb.net/";
type = par;
connection_type = parallel;
reset = 2;
sck = 3;
mosi = 4;
@ -862,6 +915,7 @@ programmer
id = "abcmini";
desc = "ABCmini Board, aka Dick Smith HOTCHIP";
type = par;
connection_type = parallel;
reset = 4;
sck = 3;
mosi = 2;
@ -872,6 +926,7 @@ programmer
id = "futurlec";
desc = "Futurlec.com programming cable.";
type = par;
connection_type = parallel;
reset = 3;
sck = 2;
mosi = 1;
@ -890,6 +945,7 @@ programmer
id = "xil";
desc = "Xilinx JTAG cable";
type = par;
connection_type = parallel;
mosi = 2;
sck = 3;
reset = 4;
@ -903,6 +959,7 @@ programmer
id = "dapa";
desc = "Direct AVR Parallel Access cable";
type = par;
connection_type = parallel;
vcc = 3;
reset = 16;
sck = 1;
@ -914,6 +971,7 @@ programmer
id = "atisp";
desc = "AT-ISP V1.1 programming cable for AVR-SDK1 from <http://micro-research.co.th/> micro-research.co.th";
type = par;
connection_type = parallel;
reset = ~6;
sck = ~8;
mosi = ~7;
@ -924,6 +982,7 @@ programmer
id = "ere-isp-avr";
desc = "ERE ISP-AVR <http://www.ere.co.th/download/sch050713.pdf>";
type = par;
connection_type = parallel;
reset = ~4;
sck = 3;
mosi = 2;
@ -934,6 +993,7 @@ programmer
id = "blaster";
desc = "Altera ByteBlaster";
type = par;
connection_type = parallel;
sck = 2;
miso = 11;
reset = 3;
@ -956,6 +1016,7 @@ programmer
id = "89isp";
desc = "Atmel at89isp cable";
type = par;
connection_type = parallel;
reset = 17;
sck = 1;
mosi = 2;
@ -990,6 +1051,7 @@ programmer
id = "ponyser";
desc = "design ponyprog serial, reset=!txd sck=rts mosi=dtr miso=cts";
type = serbb;
connection_type = serial;
reset = ~3;
sck = 7;
mosi = 4;
@ -1011,6 +1073,7 @@ programmer
id = "dasa";
desc = "serial port banging, reset=rts sck=dtr mosi=txd miso=cts";
type = serbb;
connection_type = serial;
reset = 7;
sck = 4;
mosi = 3;
@ -1024,6 +1087,7 @@ programmer
id = "dasa3";
desc = "serial port banging, reset=!dtr sck=rts mosi=txd miso=cts";
type = serbb;
connection_type = serial;
reset = ~4;
sck = 7;
mosi = 3;
@ -1037,6 +1101,7 @@ programmer
id = "c2n232i";
desc = "serial port banging, reset=dtr sck=!rts mosi=!txd miso=!cts";
type = serbb;
connection_type = serial;
reset = 4;
sck = ~7;
mosi = ~3;

View File

@ -59,6 +59,9 @@ extern char default_parallel[];
extern char default_serial[];
extern double default_bitclock;
/* This name is fixed, it's only here for symmetry with
* default_parallel and default_serial. */
#define DEFAULT_USB "usb"
#if !defined(HAS_YYSTYPE)

View File

@ -91,6 +91,7 @@ static int pin_name;
%token K_BUFF
%token K_BUSPIRATE
%token K_CHIP_ERASE_DELAY
%token K_CONNTYPE
%token K_DEDICATED
%token K_DEFAULT_PARALLEL
%token K_DEFAULT_PROGRAMMER
@ -154,6 +155,7 @@ static int pin_name;
%token K_STK600HVSP
%token K_STK600PP
%token K_AVR910
%token K_USB
%token K_USBASP
%token K_USBDEV
%token K_USBSN
@ -466,6 +468,8 @@ prog_parm :
|
prog_parm_usb
|
prog_parm_conntype
|
K_DESC TKN_EQUAL TKN_STRING {
strncpy(current_prog->desc, $3->value.string, PGM_DESCLEN);
current_prog->desc[PGM_DESCLEN-1] = 0;
@ -517,6 +521,16 @@ prog_parm_type_id:
K_DRAGON_PP { current_prog->initpgm = stk500v2_dragon_pp_initpgm; }
;
prog_parm_conntype:
K_CONNTYPE TKN_EQUAL prog_parm_conntype_id
;
prog_parm_conntype_id:
K_PARALLEL { current_prog->conntype = CONNTYPE_PARALLEL; } |
K_SERIAL { current_prog->conntype = CONNTYPE_SERIAL; } |
K_USB { current_prog->conntype = CONNTYPE_USB; }
;
prog_parm_usb:
K_USBDEV TKN_EQUAL TKN_STRING {
{

View File

@ -132,6 +132,7 @@ buspirate { yylval=NULL; return K_BUSPIRATE; }
butterfly { yylval=NULL; return K_BUTTERFLY; }
butterfly_mk { yylval=NULL; return K_BUTTERFLY_MK; }
chip_erase_delay { yylval=NULL; return K_CHIP_ERASE_DELAY; }
connection_type { yylval=NULL; return K_CONNTYPE; }
desc { yylval=NULL; return K_DESC; }
default_parallel { yylval=NULL; return K_DEFAULT_PARALLEL; }
default_programmer { yylval=NULL; return K_DEFAULT_PROGRAMMER; }
@ -202,6 +203,7 @@ stk600 { yylval=NULL; return K_STK600; }
stk600hvsp { yylval=NULL; return K_STK600HVSP; }
stk600pp { yylval=NULL; return K_STK600PP; }
type { yylval=NULL; return K_TYPE; }
usb { yylval=NULL; return K_USB; }
usbdev { yylval=NULL; return K_USBDEV; }
usbpid { yylval=NULL; return K_USBPID; }
usbproduct { yylval=NULL; return K_USBPRODUCT; }

21
main.c
View File

@ -375,7 +375,7 @@ int main(int argc, char * argv [])
}
partdesc = NULL;
port = default_parallel;
port = NULL;
erase = 0;
calibrate = 0;
auto_erase = 1;
@ -763,13 +763,20 @@ int main(int argc, char * argv [])
}
}
if ((strcmp(pgm->type, "STK500") == 0) ||
(strcmp(pgm->type, "avr910") == 0) ||
(strcmp(pgm->type, "BusPirate") == 0) ||
(strcmp(pgm->type, "STK500V2") == 0) ||
(strcmp(pgm->type, "JTAGMKII") == 0)) {
if (port == default_parallel) {
if (port == NULL) {
switch (pgm->conntype)
{
case CONNTYPE_PARALLEL:
port = default_parallel;
break;
case CONNTYPE_SERIAL:
port = default_serial;
break;
case CONNTYPE_USB:
port = DEFAULT_USB;
break;
}
}

7
pgm.h
View File

@ -56,6 +56,12 @@ typedef enum {
EXIT_DATAHIGH_DISABLED
} exit_datahigh_t;
typedef enum {
CONNTYPE_PARALLEL,
CONNTYPE_SERIAL,
CONNTYPE_USB
} conntype_t;
typedef struct programmer_t {
LISTID id;
char desc[PGM_DESCLEN];
@ -66,6 +72,7 @@ typedef struct programmer_t {
exit_vcc_t exit_vcc;
exit_reset_t exit_reset;
exit_datahigh_t exit_datahigh;
conntype_t conntype;
int ppidata;
int ppictrl;
int baudrate;

View File

@ -207,7 +207,7 @@ static int usbtiny_open(PROGRAMMER* pgm, char* name)
char *dev_name = NULL;
// if no -P was given or '-P usb' was given
if(name == default_parallel || strcmp(name, "usb") == 0)
if(strcmp(name, "usb") == 0)
name = NULL;
else {
// calculate bus and device names from -P option