Makefile : update dependencies
avr.c : correct status led updates term.c : update status leds on write, make the address and length arguments for dump optional. git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@58 81a1dc3b-b13d-400b-aceb-764788c761c2
This commit is contained in:
parent
88940e11bd
commit
6bb8158920
2
Makefile
2
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
|
avr.o : avr.h ppi.h pindefs.h
|
||||||
fileio.o : fileio.h avr.h
|
fileio.o : fileio.h avr.h
|
||||||
ppi.o : ppi.h
|
ppi.o : ppi.h
|
||||||
term.o : term.h avr.h
|
term.o : term.h avr.h pindefs.h ppi.h
|
||||||
|
|
||||||
clean :
|
clean :
|
||||||
rm -f *~ *.core ${TARGET} *.o
|
rm -f *~ *.core ${TARGET} *.o
|
||||||
|
|
14
avr.c
14
avr.c
|
@ -175,6 +175,7 @@ unsigned char avr_read_byte ( int fd, struct avrpart * p,
|
||||||
static unsigned char cmdbyte[3] = { 0xa0, 0x20, 0x28 };
|
static unsigned char cmdbyte[3] = { 0xa0, 0x20, 0x28 };
|
||||||
|
|
||||||
LED_ON(fd, PIN_LED_PGM);
|
LED_ON(fd, PIN_LED_PGM);
|
||||||
|
LED_OFF(fd, PIN_LED_ERR);
|
||||||
|
|
||||||
offset = 0;
|
offset = 0;
|
||||||
|
|
||||||
|
@ -251,6 +252,7 @@ int avr_write_byte ( int fd, struct avrpart * p, AVRMEM memtype,
|
||||||
}
|
}
|
||||||
|
|
||||||
LED_ON(fd, PIN_LED_PGM);
|
LED_ON(fd, PIN_LED_PGM);
|
||||||
|
LED_OFF(fd, PIN_LED_ERR);
|
||||||
|
|
||||||
offset = 0;
|
offset = 0;
|
||||||
|
|
||||||
|
@ -294,6 +296,7 @@ int avr_write_byte ( int fd, struct avrpart * p, AVRMEM memtype,
|
||||||
* returning an error code
|
* returning an error code
|
||||||
*/
|
*/
|
||||||
LED_OFF(fd, PIN_LED_PGM);
|
LED_OFF(fd, PIN_LED_PGM);
|
||||||
|
LED_ON(fd, PIN_LED_ERR);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -319,9 +322,12 @@ int avr_write ( int fd, struct avrpart * p, AVRMEM memtype, int size )
|
||||||
unsigned char * buf;
|
unsigned char * buf;
|
||||||
unsigned short i;
|
unsigned short i;
|
||||||
unsigned char data;
|
unsigned char data;
|
||||||
|
int werror;
|
||||||
|
|
||||||
LED_OFF(fd, PIN_LED_ERR);
|
LED_OFF(fd, PIN_LED_ERR);
|
||||||
|
|
||||||
|
werror = 0;
|
||||||
|
|
||||||
buf = p->mem[memtype];
|
buf = p->mem[memtype];
|
||||||
wsize = p->memsize[memtype];
|
wsize = p->memsize[memtype];
|
||||||
if (size < wsize) {
|
if (size < wsize) {
|
||||||
|
@ -344,6 +350,14 @@ int avr_write ( int fd, struct avrpart * p, AVRMEM memtype, int size )
|
||||||
fprintf(stderr, " ***failed; ");
|
fprintf(stderr, " ***failed; ");
|
||||||
fprintf(stderr, "\n");
|
fprintf(stderr, "\n");
|
||||||
LED_ON(fd, PIN_LED_ERR);
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
22
term.c
22
term.c
|
@ -37,6 +37,8 @@
|
||||||
#include <readline/history.h>
|
#include <readline/history.h>
|
||||||
|
|
||||||
#include "avr.h"
|
#include "avr.h"
|
||||||
|
#include "pindefs.h"
|
||||||
|
#include "ppi.h"
|
||||||
|
|
||||||
|
|
||||||
extern char * progname;
|
extern char * progname;
|
||||||
|
@ -69,6 +71,7 @@ int cmd_quit (int fd, struct avrpart * p, int argc, char *argv[]);
|
||||||
|
|
||||||
struct command cmd[] = {
|
struct command cmd[] = {
|
||||||
{ "dump", cmd_dump, "dump memory : %s [eeprom|flash] <addr> <N-Bytes>" },
|
{ "dump", cmd_dump, "dump memory : %s [eeprom|flash] <addr> <N-Bytes>" },
|
||||||
|
{ "read", cmd_dump, "alias for dump" },
|
||||||
{ "write", cmd_write, "write memory : %s [eeprom|flash] <addr> <b1> <b2> ... <bN>" },
|
{ "write", cmd_write, "write memory : %s [eeprom|flash] <addr> <b1> <b2> ... <bN>" },
|
||||||
{ "erase", cmd_erase, "perform a chip erase" },
|
{ "erase", cmd_erase, "perform a chip erase" },
|
||||||
{ "sig", cmd_sig, "display device signature bytes" },
|
{ "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;
|
addr += len;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (argc != 4) {
|
if (!((argc == 2) || (argc == 4))) {
|
||||||
fprintf(stderr, "Usage: dump flash|eeprom <addr> <len>\n");
|
fprintf(stderr, "Usage: dump flash|eeprom [<addr> <len>]\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -227,6 +230,7 @@ int cmd_dump ( int fd, struct avrpart * p, int argc, char * argv[] )
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (argc == 4) {
|
||||||
addr = strtoul(argv[2], &e, 0);
|
addr = strtoul(argv[2], &e, 0);
|
||||||
if (*e || (e == argv[2])) {
|
if (*e || (e == argv[2])) {
|
||||||
fprintf(stderr, "%s (dump): can't parse address \"%s\"\n",
|
fprintf(stderr, "%s (dump): can't parse address \"%s\"\n",
|
||||||
|
@ -241,9 +245,15 @@ int cmd_dump ( int fd, struct avrpart * p, int argc, char * argv[] )
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
maxsize = p->memsize[memtype];
|
maxsize = p->memsize[memtype];
|
||||||
|
|
||||||
|
if (argc == 2) {
|
||||||
|
addr = 0;
|
||||||
|
len = maxsize;
|
||||||
|
}
|
||||||
|
|
||||||
if (addr > maxsize) {
|
if (addr > maxsize) {
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"%s (dump): address 0x%04x is out of range for %s memory\n",
|
"%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;
|
unsigned short addr;
|
||||||
char * buf;
|
char * buf;
|
||||||
int rc;
|
int rc;
|
||||||
|
int werror;
|
||||||
|
|
||||||
if (argc < 4) {
|
if (argc < 4) {
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
|
@ -344,11 +355,16 @@ int cmd_write ( int fd, struct avrpart * p, int argc, char * argv[] )
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i=0; i<len; i++) {
|
LED_OFF(fd, PIN_LED_ERR);
|
||||||
|
for (werror=0, i=0; i<len; i++) {
|
||||||
rc = avr_write_byte(fd, p, memtype, addr+i, buf[i]);
|
rc = avr_write_byte(fd, p, memtype, addr+i, buf[i]);
|
||||||
if (rc) {
|
if (rc) {
|
||||||
fprintf(stderr, "%s (write): error writing 0x%02x at 0x%04x\n",
|
fprintf(stderr, "%s (write): error writing 0x%02x at 0x%04x\n",
|
||||||
progname, buf[i], addr+i);
|
progname, buf[i], addr+i);
|
||||||
|
werror = 1;
|
||||||
|
}
|
||||||
|
if (werror) {
|
||||||
|
LED_ON(fd, PIN_LED_ERR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue