diff --git a/avrdude/avr.c b/avrdude/avr.c index 70d86f33..5bafe37d 100644 --- a/avrdude/avr.c +++ b/avrdude/avr.c @@ -786,7 +786,7 @@ int avr_signature(int fd, AVRPART * p) */ void avr_powerup(int fd) { - ppi_set(fd, PPIDATA, PPI_AVR_VCC); /* power up */ + ppi_set(fd, PPIDATA, pgm->pinno[PPI_AVR_VCC]); /* power up */ usleep(100000); } @@ -796,7 +796,7 @@ void avr_powerup(int fd) */ void avr_powerdown(int fd) { - ppi_clr(fd, PPIDATA, PPI_AVR_VCC); /* power down */ + ppi_clr(fd, PPIDATA, pgm->pinno[PPI_AVR_VCC]); /* power down */ } @@ -809,9 +809,12 @@ int avr_initialize(int fd, AVRPART * p) int tries; avr_powerup(fd); + usleep(20000); ppi_setpin(fd, pgm->pinno[PIN_AVR_SCK], 0); ppi_setpin(fd, pgm->pinno[PIN_AVR_RESET], 0); + usleep(20000); + ppi_pulsepin(fd, pgm->pinno[PIN_AVR_RESET]); usleep(20000); /* 20 ms XXX should be a per-chip parameter */ @@ -831,16 +834,16 @@ int avr_initialize(int fd, AVRPART * p) tries = 0; do { rc = avr_program_enable(fd, p); - if (rc == 0) + if ((rc == 0)||(rc == -1)) break; ppi_pulsepin(fd, pgm->pinno[PIN_AVR_SCK]); tries++; - } while (tries < 32); + } while (tries < 65); /* * can't sync with the device, maybe it's not attached? */ - if (tries == 32) { + if (rc) { fprintf(stderr, "%s: AVR device not responding\n", progname); return -1; } diff --git a/avrdude/avrdude.conf.sample b/avrdude/avrdude.conf.sample index 04222849..299bcf68 100644 --- a/avrdude/avrdude.conf.sample +++ b/avrdude/avrdude.conf.sample @@ -107,6 +107,16 @@ programmer miso = 10; ; +programmer + id = "stk200"; + desc = "STK200"; + buff = 4, 5; + sck = 6; + mosi = 7; + reset = 9; + miso = 10; +; + programmer id = "dt006"; desc = "Dontronics DT006"; @@ -148,11 +158,11 @@ part max_write_delay = 20000; readback_p1 = 0x00; readback_p2 = 0xff; - read = "1 0 1 0 0 0 0 0 x x x x x x x x", - "x x a a a a a a o o o o o o o o"; + read = "1 0 1 0 0 0 0 0 x x x x x x x x", + "x x a5 a4 a3 a2 a1 a0 o o o o o o o o"; - write = "1 1 0 0 0 0 0 0 x x x x x x x x", - "x x a a a a a a i i i i i i i i"; + write = "1 1 0 0 0 0 0 0 x x x x x x x x", + "x x a5 a4 a3 a2 a1 a0 i i i i i i i i"; ; memory "flash" size = 1024; @@ -204,11 +214,11 @@ part max_write_delay = 20000; readback_p1 = 0x80; readback_p2 = 0x7f; - read = "1 0 1 0 0 0 0 0 x x x x x x x x", - "x a a a a a a a o o o o o o o o"; + read = "1 0 1 0 0 0 0 0 x x x x x x x x", + "x a6 a5 a4 a3 a2 a1 a0 o o o o o o o o"; - write = "1 1 0 0 0 0 0 0 x x x x x x x x", - "x a a a a a a a i i i i i i i i"; + write = "1 1 0 0 0 0 0 0 x x x x x x x x", + "x a6 a5 a4 a3 a2 a1 a0 i i i i i i i i"; ; memory "flash" size = 2048; @@ -265,11 +275,11 @@ part max_write_delay = 20000; readback_p1 = 0x00; readback_p2 = 0xff; - read = "1 0 1 0 0 0 0 0 x x x x x x x x", - "x a a a a a a a o o o o o o o o"; + read = "1 0 1 0 0 0 0 0 x x x x x x x x", + "x a6 a5 a4 a3 a2 a1 a0 o o o o o o o o"; - write = "1 1 0 0 0 0 0 0 x x x x x x x x", - "x a a a a a a a i i i i i i i i"; + write = "1 1 0 0 0 0 0 0 x x x x x x x x", + "x a6 a5 a4 a3 a2 a1 a0 i i i i i i i i"; ; memory "flash" size = 2048; @@ -377,11 +387,11 @@ part max_write_delay = 20000; readback_p1 = 0x00; readback_p2 = 0xff; - read = "1 0 1 0 0 0 0 0 x x x x x x x x", - "a a a a a a a a o o o o o o o o"; + read = " 1 0 1 0 0 0 0 0 x x x x x x x x", + "a7 a6 a5 a4 a3 a2 a1 a0 o o o o o o o o"; - write = "1 1 0 0 0 0 0 0 x x x x x x x x", - "a a a a a a a a i i i i i i i i"; + write = " 1 1 0 0 0 0 0 0 x x x x x x x x", + "a7 a6 a5 a4 a3 a2 a1 a0 i i i i i i i i"; ; memory "flash" size = 4096; @@ -433,11 +443,11 @@ part max_write_delay = 20000; readback_p1 = 0x80; readback_p2 = 0x7f; - read = "1 0 1 0 0 0 0 0 x x x x x x x a8", - "a a a a a a a a o o o o o o o o"; + read = " 1 0 1 0 0 0 0 0 x x x x x x x a8", + "a7 a6 a5 a4 a3 a2 a1 a0 o o o o o o o o"; - write = "1 1 0 0 0 0 0 0 x x x x x x x a8", - "a a a a a a a a i i i i i i i i"; + write = " 1 1 0 0 0 0 0 0 x x x x x x x a8", + "a7 a6 a5 a4 a3 a2 a1 a0 i i i i i i i i"; ; memory "flash" size = 8192; @@ -489,11 +499,11 @@ part max_write_delay = 20000; readback_p1 = 0x00; readback_p2 = 0xff; - read = "1 0 1 0 0 0 0 0 x x x x x x x a8", - "a a a a a a a a o o o o o o o o"; + read = " 1 0 1 0 0 0 0 0 x x x x x x x a8", + "a7 a6 a5 a4 a3 a2 a1 a0 o o o o o o o o"; - write = "1 1 0 0 0 0 0 0 x x x x x x x a8", - "a a a a a a a a i i i i i i i i"; + write = " 1 1 0 0 0 0 0 0 x x x x x x x a8", + "a7 a6 a5 a4 a3 a2 a1 a0 i i i i i i i i"; ; memory "flash" size = 8192; diff --git a/avrdude/config_gram.y b/avrdude/config_gram.y index 62f3fb8d..17a42394 100644 --- a/avrdude/config_gram.y +++ b/avrdude/config_gram.y @@ -235,11 +235,35 @@ prog_parm : } } | + K_BUFF TKN_EQUAL num_list { + { + TOKEN * t; + int pin; + + current_prog->pinno[PPI_AVR_BUFF] = 0; + + while (lsize(number_list)) { + t = lrmv_n(number_list, 1); + pin = t->value.number; + if ((pin < 2) || (pin > 9)) { + fprintf(stderr, + "%s: error at line %d of %s: BUFF must be one or more " + "pins from the range 2-9\n", + progname, lineno, infile); + exit(1); + } + + current_prog->pinno[PPI_AVR_BUFF] |= (1 << (pin-2)); + + free_token(t); + } + } + } | + K_RESET TKN_EQUAL TKN_NUMBER { assign_pin(PIN_AVR_RESET, $3); } | K_SCK TKN_EQUAL TKN_NUMBER { assign_pin(PIN_AVR_SCK, $3); } | K_MOSI TKN_EQUAL TKN_NUMBER { assign_pin(PIN_AVR_MOSI, $3); } | K_MISO TKN_EQUAL TKN_NUMBER { assign_pin(PIN_AVR_MISO, $3); } | - K_BUFF TKN_EQUAL TKN_NUMBER { assign_pin(PIN_AVR_BUFF, $3); } | K_ERRLED TKN_EQUAL TKN_NUMBER { assign_pin(PIN_LED_ERR, $3); } | K_RDYLED TKN_EQUAL TKN_NUMBER { assign_pin(PIN_LED_RDY, $3); } | K_PGMLED TKN_EQUAL TKN_NUMBER { assign_pin(PIN_LED_PGM, $3); } | diff --git a/avrdude/main.c b/avrdude/main.c index 216491ac..adc6bf2b 100644 --- a/avrdude/main.c +++ b/avrdude/main.c @@ -328,21 +328,30 @@ char * vccpins_str(unsigned int pmask) void pinconfig_display(char * p) { char vccpins[64]; + char buffpins[64]; if (pgm->pinno[PPI_AVR_VCC]) { snprintf(vccpins, sizeof(vccpins), " = pins %s", vccpins_str(pgm->pinno[PPI_AVR_VCC])); } else { - vccpins[0] = 0; + strcpy(vccpins, " (not used)"); + } + + if (pgm->pinno[PPI_AVR_BUFF]) { + snprintf(buffpins, sizeof(buffpins), " = pins %s", + vccpins_str(pgm->pinno[PPI_AVR_BUFF])); + } + else { + strcpy(buffpins, " (not used)"); } fprintf(stderr, "%sProgrammer Pin Configuration: %s (%s)\n", p, (char *)ldata(lfirst(pgm->id)), pgm->desc); fprintf(stderr, - "%s VCC = 0x%02x %s\n" - "%s BUFF = %d\n" + "%s VCC = 0x%02x%s\n" + "%s BUFF = 0x%02x%s\n" "%s RESET = %d\n" "%s SCK = %d\n" "%s MOSI = %d\n" @@ -352,7 +361,7 @@ void pinconfig_display(char * p) "%s PGM LED = %d\n" "%s VFY LED = %d\n", p, pgm->pinno[PPI_AVR_VCC], vccpins, - p, pgm->pinno[PIN_AVR_BUFF], + p, pgm->pinno[PPI_AVR_BUFF], buffpins, p, pgm->pinno[PIN_AVR_RESET], p, pgm->pinno[PIN_AVR_SCK], p, pgm->pinno[PIN_AVR_MOSI], @@ -523,7 +532,7 @@ int main(int argc, char * argv []) for (i=0; ipinno[i] = 0; pgm->pinno[PPI_AVR_VCC] = 0x0f; /* ppi pins 2-5, data reg bits 0-3 */ - pgm->pinno[PIN_AVR_BUFF] = 0; + pgm->pinno[PPI_AVR_BUFF] = 0; pgm->pinno[PIN_AVR_RESET] = 7; pgm->pinno[PIN_AVR_SCK] = 8; pgm->pinno[PIN_AVR_MOSI] = 9; @@ -804,7 +813,8 @@ int main(int argc, char * argv []) /* * enable the 74367 buffer, if connected; this signal is active low */ - ppi_setpin(fd, pgm->pinno[PIN_AVR_BUFF], 0); + /*ppi_setpin(fd, pgm->pinno[PIN_AVR_BUFF], 0);*/ + ppi_clr(fd, PPIDATA, pgm->pinno[PPI_AVR_BUFF]); /* * initialize the chip in preperation for accepting commands @@ -1025,7 +1035,8 @@ int main(int argc, char * argv []) /* * disable the 74367 buffer, if connected; this signal is active low */ - ppi_setpin(fd, pgm->pinno[PIN_AVR_BUFF], 1); + /* ppi_setpin(fd, pgm->pinno[PIN_AVR_BUFF], 1); */ + ppi_set(fd, PPIDATA, pgm->pinno[PPI_AVR_BUFF]); LED_OFF(fd, pgm->pinno[PIN_LED_RDY]); diff --git a/avrdude/pindefs.h b/avrdude/pindefs.h index 4c102315..e60e422c 100644 --- a/avrdude/pindefs.h +++ b/avrdude/pindefs.h @@ -34,7 +34,7 @@ enum { PPI_AVR_VCC=1, - PIN_AVR_BUFF, + PPI_AVR_BUFF, PIN_AVR_RESET, PIN_AVR_SCK, PIN_AVR_MOSI,