From 11f48a569945614ef7f5afed91e8f8a600c7bb31 Mon Sep 17 00:00:00 2001 From: "Brian S. Dean" Date: Wed, 20 Dec 2000 02:26:31 +0000 Subject: [PATCH] Add support for the 8515. Make the addition for other devices easier. git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@14 81a1dc3b-b13d-400b-aceb-764788c761c2 --- Makefile | 2 +- avrprog.c | 87 +++++++++++++++++++++++++++++++++++++++++++++++++------ 2 files changed, 79 insertions(+), 10 deletions(-) diff --git a/Makefile b/Makefile index 42dac2c7..1bd9e676 100644 --- a/Makefile +++ b/Makefile @@ -8,7 +8,7 @@ DEST = ${HOME}/bin/0.${ARCH} all : ${TARGET} -CFLAGS = -Wall --pedantic +CFLAGS = -Wall --pedantic -g ${TARGET} : avrprog.c ${CC} ${CFLAGS} -o ${TARGET} avrprog.c diff --git a/avrprog.c b/avrprog.c index a2c07dd6..b8721bc6 100644 --- a/avrprog.c +++ b/avrprog.c @@ -41,10 +41,12 @@ * Pin 4 -> PB5(MOSI) Instruction input * Pin 5 -> /RESET * Pin 10 <- PB6(MISO) Data out + * Pin 18 <- GND * */ #include +#include #include #include #include @@ -93,6 +95,21 @@ typedef enum { } AVRMEM; +struct avrpart { + char * partdesc; + char * optiontag; + int flash_size; + int eeprom_size; +}; + + +struct avrpart parts[] = { + { "AT90S8515", "8515", 8192, 512 }, + { "AT90S2313", "2313", 2048, 128 } +}; + + + /* * variable declarations required for getopt() */ @@ -303,7 +320,7 @@ unsigned char avr_read_byte ( int fd, AVRMEM memtype, unsigned short addr ) break; case AVR_EEPROM: cmd[0] = 0xa0; - addr &= 0x7f; + /* addr &= 0x7f; */ break; default: fprintf(stderr, "%s: avr_read_byte(); internal error: invalid memtype=%d\n", @@ -644,6 +661,7 @@ void usage ( void ) " -r : erase the flash and eeprom (required before programming)\n" " -e : select eeprom for reading or writing\n" " -f : select flash for reading or writing\n" + " -p Part : 8515 or 2313\n" " -u InputFile : write data from this file\n" " -o OutputFile : write data to this file\n" "\n", @@ -659,7 +677,7 @@ int main ( int argc, char * argv [] ) int fd; int rc, exitrc; int i; - unsigned char buf[2048]; + unsigned char * buf; unsigned char sig[4]; int ch; int iofd; @@ -668,6 +686,7 @@ int main ( int argc, char * argv [] ) char * outputf; char * inputf; char * p1, * p2; + struct avrpart * p; iofd = -1; outputf = NULL; @@ -677,6 +696,7 @@ int main ( int argc, char * argv [] ) flash = 0; erase = 0; dosig = 0; + p = NULL; progname = rindex(argv[0],'/'); if (progname) @@ -706,7 +726,7 @@ int main ( int argc, char * argv [] ) fprintf(stderr, " Revision " ); for (i=0; ipartdesc, p->flash_size, p->eeprom_size); + fprintf(stderr, "\n"); + + if (p->flash_size >= p->eeprom_size) + size = p->flash_size; + else + size = p->eeprom_size; + + buf = (unsigned char *) malloc(size); + if (buf == NULL) { + fprintf(stderr, + "%s: out of memory allocating %d bytes for on-chip memory buffer\n", + progname, size); + return 1; + } + + /* * open the parallel port */ @@ -799,7 +869,6 @@ int main ( int argc, char * argv [] ) return 1; } - exitrc = 0; @@ -875,7 +944,7 @@ int main ( int argc, char * argv [] ) * read out the specified device memory and write it to a file */ if (flash) { - size = 2048; + size = p->flash_size; fprintf ( stderr, "%s: reading flash memory:\n", progname ); rc = avr_read ( fd, AVR_FLASH, 0, size/2, buf, size ); if (rc) { @@ -886,7 +955,7 @@ int main ( int argc, char * argv [] ) } } else if (eeprom) { - size = 128; + size = p->eeprom_size; fprintf ( stderr, "%s: reading eeprom memory:\n", progname ); rc = avr_read ( fd, AVR_EEPROM, 0, size, buf, size ); if (rc) { @@ -918,10 +987,10 @@ int main ( int argc, char * argv [] ) * write the selected device memory using data from a file */ if (flash) { - size = 2048; + size = p->flash_size; } else if (eeprom) { - size = 128; + size = p->eeprom_size; } /*