Minor cosmetic changes: STK500 firmware version numbers are M.NN, so

always display the minor number as two digits.  Examine the response
to the sign-on command to see which programmer hardware we are talking
to, and then restrict the STK500 topcard display to devices detected
as STK500.


git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@614 81a1dc3b-b13d-400b-aceb-764788c761c2
This commit is contained in:
joerg_wunsch 2006-08-18 21:23:34 +00:00
parent cba30c304f
commit 94e7fb19b0
2 changed files with 57 additions and 4 deletions

View File

@ -1,3 +1,11 @@
2006-08-18 Joerg Wunsch <j@uriah.heep.sax.de>
* stk500v2: Minor cosmetic changes: STK500 firmware version
numbers are M.NN, so always display the minor number as two
digits. Examine the response to the sign-on command to see which
programmer hardware we are talking to, and then restrict the
STK500 topcard display to devices detected as STK500.
2006-08-18 Joerg Wunsch <j@uriah.heep.sax.de> 2006-08-18 Joerg Wunsch <j@uriah.heep.sax.de>
* Makefile.am: Add a dist-hook, and make it remove lexer.c, * Makefile.am: Add a dist-hook, and make it remove lexer.c,

View File

@ -93,6 +93,22 @@ static unsigned int eeprom_pagesize;
static unsigned char command_sequence = 1; static unsigned char command_sequence = 1;
static int is_mk2; /* Is the device an AVRISP mkII? */ static int is_mk2; /* Is the device an AVRISP mkII? */
static enum
{
PGMTYPE_UNKNOWN,
PGMTYPE_STK500,
PGMTYPE_AVRISP,
PGMTYPE_AVRISP_MKII,
}
pgmtype;
static const char *pgmname[] =
{
"unknown",
"STK500",
"AVRISP",
"AVRISP mkII",
};
static int stk500v2_getparm(PROGRAMMER * pgm, unsigned char parm, unsigned char * value); static int stk500v2_getparm(PROGRAMMER * pgm, unsigned char parm, unsigned char * value);
static int stk500v2_setparm(PROGRAMMER * pgm, unsigned char parm, unsigned char value); static int stk500v2_setparm(PROGRAMMER * pgm, unsigned char parm, unsigned char value);
@ -297,8 +313,32 @@ retry:
// if we got bytes returned, check to see what came back // if we got bytes returned, check to see what came back
if (status > 0) { if (status > 0) {
if ((resp[0] == CMD_SIGN_ON) && (resp[1] == STATUS_CMD_OK)) { if ((resp[0] == CMD_SIGN_ON) && (resp[1] == STATUS_CMD_OK) &&
(status > 3)) {
// success! // success!
unsigned int siglen = resp[2];
if (siglen >= strlen("STK500_2") &&
memcmp(resp + 3, "STK500_2", strlen("STK500_2")) == 0) {
pgmtype = PGMTYPE_STK500;
} else if (siglen >= strlen("AVRISP_2") &&
memcmp(resp + 3, "AVRISP_2", strlen("AVRISP_2")) == 0) {
pgmtype = PGMTYPE_AVRISP;
} else if (siglen >= strlen("AVRISP_MK2") &&
memcmp(resp + 3, "AVRISP_MK2", strlen("AVRISP_MK2")) == 0) {
pgmtype = PGMTYPE_AVRISP_MKII;
} else {
resp[siglen + 3] = 0;
if (verbose)
fprintf(stderr,
"%s: stk500v2_getsync(): got response from unknown "
"programmer %s, assuming STK500\n",
progname, resp + 3);
pgmtype = PGMTYPE_STK500;
}
if (verbose >= 2)
fprintf(stderr,
"%s: stk500v2_getsync(): found %s programmer\n",
progname, pgmname[pgmtype]);
return 0; return 0;
} else { } else {
if (tries > 33) { if (tries > 33) {
@ -559,6 +599,9 @@ static int stk500hvsp_program_enable(PROGRAMMER * pgm, AVRPART * p)
*/ */
static int stk500v2_initialize(PROGRAMMER * pgm, AVRPART * p) static int stk500v2_initialize(PROGRAMMER * pgm, AVRPART * p)
{ {
pgmtype = PGMTYPE_UNKNOWN;
return pgm->program_enable(pgm, p); return pgm->program_enable(pgm, p);
} }
@ -628,6 +671,8 @@ static int stk500hv_initialize(PROGRAMMER * pgm, AVRPART * p, enum hvmode mode)
} }
flash_pageaddr = eeprom_pageaddr = (unsigned long)-1L; flash_pageaddr = eeprom_pageaddr = (unsigned long)-1L;
pgmtype = PGMTYPE_UNKNOWN;
return pgm->program_enable(pgm, p); return pgm->program_enable(pgm, p);
} }
@ -1797,12 +1842,12 @@ static void stk500v2_display(PROGRAMMER * pgm, char * p)
stk500v2_getparm(pgm, PARAM_HW_VER, &hdw); stk500v2_getparm(pgm, PARAM_HW_VER, &hdw);
stk500v2_getparm(pgm, PARAM_SW_MAJOR, &maj); stk500v2_getparm(pgm, PARAM_SW_MAJOR, &maj);
stk500v2_getparm(pgm, PARAM_SW_MINOR, &min); stk500v2_getparm(pgm, PARAM_SW_MINOR, &min);
stk500v2_getparm(pgm, PARAM_TOPCARD_DETECT, &topcard);
fprintf(stderr, "%sHardware Version: %d\n", p, hdw); fprintf(stderr, "%sHardware Version: %d\n", p, hdw);
fprintf(stderr, "%sFirmware Version: %d.%d\n", p, maj, min); fprintf(stderr, "%sFirmware Version: %d.%02d\n", p, maj, min);
if (1) { // should check to see if it's a stk500 first if (pgmtype == PGMTYPE_STK500) {
stk500v2_getparm(pgm, PARAM_TOPCARD_DETECT, &topcard);
switch (topcard) { switch (topcard) {
case 0xAA: topcard_name = "STK501"; break; case 0xAA: topcard_name = "STK501"; break;
case 0x55: topcard_name = "STK502"; break; case 0x55: topcard_name = "STK502"; break;