diff --git a/avrdude/Makefile b/avrdude/Makefile index 06e08b90..d2abae1a 100644 --- a/avrdude/Makefile +++ b/avrdude/Makefile @@ -34,7 +34,7 @@ main.o : avr.h fileio.h ppi.h term.h pindefs.h avr.o : avr.h ppi.h pindefs.h fileio.o : fileio.h avr.h ppi.o : ppi.h -term.o : term.h avr.h +term.o : term.h avr.h pindefs.h ppi.h clean : rm -f *~ *.core ${TARGET} *.o diff --git a/avrdude/avr.c b/avrdude/avr.c index dde99323..0d7ec5fa 100644 --- a/avrdude/avr.c +++ b/avrdude/avr.c @@ -175,6 +175,7 @@ unsigned char avr_read_byte ( int fd, struct avrpart * p, static unsigned char cmdbyte[3] = { 0xa0, 0x20, 0x28 }; LED_ON(fd, PIN_LED_PGM); + LED_OFF(fd, PIN_LED_ERR); offset = 0; @@ -251,6 +252,7 @@ int avr_write_byte ( int fd, struct avrpart * p, AVRMEM memtype, } LED_ON(fd, PIN_LED_PGM); + LED_OFF(fd, PIN_LED_ERR); offset = 0; @@ -294,6 +296,7 @@ int avr_write_byte ( int fd, struct avrpart * p, AVRMEM memtype, * returning an error code */ LED_OFF(fd, PIN_LED_PGM); + LED_ON(fd, PIN_LED_ERR); return -1; } } @@ -319,9 +322,12 @@ int avr_write ( int fd, struct avrpart * p, AVRMEM memtype, int size ) unsigned char * buf; unsigned short i; unsigned char data; + int werror; LED_OFF(fd, PIN_LED_ERR); + werror = 0; + buf = p->mem[memtype]; wsize = p->memsize[memtype]; if (size < wsize) { @@ -344,6 +350,14 @@ int avr_write ( int fd, struct avrpart * p, AVRMEM memtype, int size ) fprintf(stderr, " ***failed; "); fprintf(stderr, "\n"); LED_ON(fd, PIN_LED_ERR); + werror = 1; + } + if (werror) { + /* + * make sure the error led stay on if there was a previous write + * error, otherwise it gets cleared in avr_write_byte() + */ + LED_ON(fd, PIN_LED_ERR); } } diff --git a/avrdude/term.c b/avrdude/term.c index 8bdb09ad..80cc8008 100644 --- a/avrdude/term.c +++ b/avrdude/term.c @@ -37,6 +37,8 @@ #include #include "avr.h" +#include "pindefs.h" +#include "ppi.h" extern char * progname; @@ -69,6 +71,7 @@ int cmd_quit (int fd, struct avrpart * p, int argc, char *argv[]); struct command cmd[] = { { "dump", cmd_dump, "dump memory : %s [eeprom|flash] " }, + { "read", cmd_dump, "alias for dump" }, { "write", cmd_write, "write memory : %s [eeprom|flash] ... " }, { "erase", cmd_erase, "perform a chip erase" }, { "sig", cmd_sig, "display device signature bytes" }, @@ -209,8 +212,8 @@ int cmd_dump ( int fd, struct avrpart * p, int argc, char * argv[] ) addr += len; } else { - if (argc != 4) { - fprintf(stderr, "Usage: dump flash|eeprom \n"); + if (!((argc == 2) || (argc == 4))) { + fprintf(stderr, "Usage: dump flash|eeprom [ ]\n"); return -1; } @@ -227,23 +230,30 @@ int cmd_dump ( int fd, struct avrpart * p, int argc, char * argv[] ) return -1; } - addr = strtoul(argv[2], &e, 0); - if (*e || (e == argv[2])) { - fprintf(stderr, "%s (dump): can't parse address \"%s\"\n", - progname, argv[2]); - return -1; - } + if (argc == 4) { + addr = strtoul(argv[2], &e, 0); + if (*e || (e == argv[2])) { + fprintf(stderr, "%s (dump): can't parse address \"%s\"\n", + progname, argv[2]); + return -1; + } - len = strtol(argv[3], &e, 0); - if (*e || (e == argv[3])) { - fprintf(stderr, "%s (dump): can't parse length \"%s\"\n", - progname, argv[3]); - return -1; + len = strtol(argv[3], &e, 0); + if (*e || (e == argv[3])) { + fprintf(stderr, "%s (dump): can't parse length \"%s\"\n", + progname, argv[3]); + return -1; + } } } maxsize = p->memsize[memtype]; + if (argc == 2) { + addr = 0; + len = maxsize; + } + if (addr > maxsize) { fprintf(stderr, "%s (dump): address 0x%04x is out of range for %s memory\n", @@ -282,6 +292,7 @@ int cmd_write ( int fd, struct avrpart * p, int argc, char * argv[] ) unsigned short addr; char * buf; int rc; + int werror; if (argc < 4) { fprintf(stderr, @@ -344,11 +355,16 @@ int cmd_write ( int fd, struct avrpart * p, int argc, char * argv[] ) } } - for (i=0; i