Implement enough state in cmd_dump so that if it is called with no
arguments, it successively dumps the next chunk of data of the same previously specified length. git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@39 81a1dc3b-b13d-400b-aceb-764788c761c2
This commit is contained in:
parent
4265bfa150
commit
7dc244ac12
32
term.c
32
term.c
|
@ -197,11 +197,17 @@ int cmd_dump ( int fd, struct avrpart * p, int argc, char * argv[] )
|
||||||
{
|
{
|
||||||
char * e;
|
char * e;
|
||||||
int i, j;
|
int i, j;
|
||||||
int len, maxsize;
|
unsigned short daddr;
|
||||||
AVRMEM memtype;
|
|
||||||
unsigned short addr, daddr;
|
|
||||||
char * buf;
|
char * buf;
|
||||||
|
int maxsize;
|
||||||
|
static AVRMEM memtype=AVR_FLASH;
|
||||||
|
static unsigned short addr=0;
|
||||||
|
static int len=64;
|
||||||
|
|
||||||
|
if (argc == 1) {
|
||||||
|
addr += len;
|
||||||
|
}
|
||||||
|
else {
|
||||||
if (argc != 4) {
|
if (argc != 4) {
|
||||||
fprintf(stderr, "Usage: dump flash|eeprom <addr> <len>\n");
|
fprintf(stderr, "Usage: dump flash|eeprom <addr> <len>\n");
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -209,11 +215,9 @@ int cmd_dump ( int fd, struct avrpart * p, int argc, char * argv[] )
|
||||||
|
|
||||||
if (strcmp(argv[1],"flash")==0) {
|
if (strcmp(argv[1],"flash")==0) {
|
||||||
memtype = AVR_FLASH;
|
memtype = AVR_FLASH;
|
||||||
maxsize = p->flash_size;
|
|
||||||
}
|
}
|
||||||
else if (strcmp(argv[1],"eeprom")==0) {
|
else if (strcmp(argv[1],"eeprom")==0) {
|
||||||
memtype = AVR_EEPROM;
|
memtype = AVR_EEPROM;
|
||||||
maxsize = p->eeprom_size;
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
fprintf(stderr, "%s (dump): invalid memory type \"%s\"\n",
|
fprintf(stderr, "%s (dump): invalid memory type \"%s\"\n",
|
||||||
|
@ -234,6 +238,14 @@ int cmd_dump ( int fd, struct avrpart * p, int argc, char * argv[] )
|
||||||
progname, argv[3]);
|
progname, argv[3]);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (memtype) {
|
||||||
|
case AVR_FLASH : maxsize = p->flash_size; break;
|
||||||
|
case AVR_EEPROM : maxsize = p->eeprom_size; break;
|
||||||
|
default : return -1; /* this can't happen, but is silences gcc
|
||||||
|
warnings */
|
||||||
|
}
|
||||||
|
|
||||||
if (addr > maxsize) {
|
if (addr > maxsize) {
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
|
@ -242,13 +254,9 @@ int cmd_dump ( int fd, struct avrpart * p, int argc, char * argv[] )
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((addr + len) > maxsize) {
|
/* trim len if nessary to not read past the end of memory */
|
||||||
fprintf(stderr,
|
if ((addr + len) > maxsize)
|
||||||
"%s (dump): selected address and length exceed "
|
len = maxsize - addr;
|
||||||
"range for %s memory\n",
|
|
||||||
progname, avr_memtstr(memtype));
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
buf = malloc(len);
|
buf = malloc(len);
|
||||||
if (buf == NULL) {
|
if (buf == NULL) {
|
||||||
|
|
Loading…
Reference in New Issue