Commit changes in preparation for support the ATMega line.

git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@76 81a1dc3b-b13d-400b-aceb-764788c761c2
This commit is contained in:
Brian S. Dean 2001-10-13 03:12:52 +00:00
parent 0e18e555ed
commit 42a81370c7
6 changed files with 181 additions and 103 deletions

160
avr.c
View File

@ -32,6 +32,7 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <unistd.h> #include <unistd.h>
#include <string.h>
#include "avr.h" #include "avr.h"
@ -49,26 +50,38 @@ char * avr_version = "$Id$";
/* Need to add information for 2323, 2343, and 4414 */ /* Need to add information for 2323, 2343, and 4414 */
struct avrpart parts[] = { struct avrpart parts[] = {
{ "AT90S1200", "1200", { 64, 1024 }, 0xff, { 0x00, 0xff }, {"AT90S1200", "1200", 20000,
9000, 20000, 20000, { NULL, NULL } }, {{0, 64, 0, 0, 9000, 20000, {0x00, 0xff }, NULL}, /* eeprom */
{0, 1024, 0, 0, 9000, 20000, {0xff, 0 }, NULL}}}, /* flash */
{ "AT90S2313", "2313", { 128, 2048 }, 0x7f, { 0x80, 0x7f }, {"AT90S2313", "2313", 20000,
9000, 20000, 20000, { NULL, NULL } }, {{0, 128, 0, 0, 9000, 20000, {0x80, 0x7f }, NULL}, /* eeprom */
{0, 2048, 0, 0, 9000, 20000, {0x7f, 0 }, NULL}}}, /* flash */
{ "AT90S2333", "2333", { 128, 2048 }, 0xff, { 0x00, 0xff }, {"AT90S2333", "2333", 20000,
9000, 20000, 20000, { NULL, NULL } }, {{0, 128, 0, 0, 9000, 20000, {0x00, 0xff }, NULL}, /* eeprom */
{0, 2048, 0, 0, 9000, 20000, {0xff, 0 }, NULL}}}, /* flash */
{ "AT90S4433", "4433", { 256, 4096 }, 0xff, { 0x00, 0xff }, {"AT90S4433", "4433", 20000,
9000, 20000, 20000, { NULL, NULL } }, {{0, 256, 0, 0, 9000, 20000, {0x00, 0xff }, NULL}, /* eeprom */
{0, 4096, 0, 0, 9000, 20000, {0xff, 0 }, NULL}}}, /* flash */
{ "AT90S4434", "4434", { 256, 4096 }, 0xff, { 0x00, 0xff }, {"AT90S4434", "4434", 20000,
9000, 20000, 20000, { NULL, NULL } }, {{0, 256, 0, 0, 9000, 20000, {0x00, 0xff }, NULL}, /* eeprom */
{0, 4096, 0, 0, 9000, 20000, {0xff, 0 }, NULL}}}, /* flash */
{ "AT90S8515", "8515", { 512, 8192 }, 0x7f, { 0x80, 0x7f }, {"AT90S8515", "8515", 20000,
9000, 20000, 20000, { NULL, NULL } }, {{0, 512, 0, 0, 9000, 20000, {0x80, 0x7f }, NULL}, /* eeprom */
{0, 8192, 0, 0, 9000, 20000, {0x7f, 0x00 }, NULL}}}, /* flash */
{"AT90S8535", "8535", 20000,
{{0, 512, 0, 0, 9000, 20000, {0x00, 0xff }, NULL}, /* eeprom */
{0, 8192, 0, 0, 9000, 20000, {0xff, 0x00 }, NULL}}}, /* flash */
{"ATMEGA103", "103", 20000,
{{0, 4096, 0, 0, 9000, 20000, {0x00, 0xff }, NULL}, /* eeprom */
{1, 131072, 256, 512, 22000, 56000, {0xff, 0x00 }, NULL}}}, /* flash */
{ "AT90S8535", "8535", { 512, 8192 }, 0xff, { 0x00, 0xff },
9000, 20000, 20000, { NULL, NULL } },
}; };
#define N_AVRPARTS (sizeof(parts)/sizeof(struct avrpart)) #define N_AVRPARTS (sizeof(parts)/sizeof(struct avrpart))
@ -168,7 +181,7 @@ int avr_cmd ( int fd, unsigned char cmd[4], unsigned char res[4] )
* read a byte of data from the indicated memory region * read a byte of data from the indicated memory region
*/ */
unsigned char avr_read_byte ( int fd, struct avrpart * p, unsigned char avr_read_byte ( int fd, struct avrpart * p,
AVRMEM memtype, unsigned short addr ) int memtype, unsigned short addr )
{ {
unsigned short offset; unsigned short offset;
unsigned char cmd[4]; unsigned char cmd[4];
@ -181,7 +194,7 @@ unsigned char avr_read_byte ( int fd, struct avrpart * p,
offset = 0; offset = 0;
if (memtype == AVR_FLASH) { if (memtype == AVR_M_FLASH) {
offset = addr & 0x01; offset = addr & 0x01;
addr = addr / 2; addr = addr / 2;
} }
@ -205,15 +218,15 @@ unsigned char avr_read_byte ( int fd, struct avrpart * p,
* *
* Return the number of bytes read, or -1 if an error occurs. * Return the number of bytes read, or -1 if an error occurs.
*/ */
int avr_read ( int fd, struct avrpart * p, AVRMEM memtype ) int avr_read ( int fd, struct avrpart * p, int memtype )
{ {
unsigned char rbyte; unsigned char rbyte;
unsigned short i; unsigned short i;
unsigned char * buf; unsigned char * buf;
int size; int size;
buf = p->mem[memtype]; buf = p->mem[memtype].buf;
size = p->memsize[memtype]; size = p->mem[memtype].size;
for (i=0; i<size; i++) { for (i=0; i<size; i++) {
rbyte = avr_read_byte(fd, p, memtype, i); rbyte = avr_read_byte(fd, p, memtype, i);
@ -230,7 +243,7 @@ int avr_read ( int fd, struct avrpart * p, AVRMEM memtype )
/* /*
* write a byte of data to the indicated memory region * write a byte of data to the indicated memory region
*/ */
int avr_write_byte ( int fd, struct avrpart * p, AVRMEM memtype, int avr_write_byte ( int fd, struct avrpart * p, int memtype,
unsigned short addr, unsigned char data ) unsigned short addr, unsigned char data )
{ {
unsigned char cmd[4]; unsigned char cmd[4];
@ -241,7 +254,7 @@ int avr_write_byte ( int fd, struct avrpart * p, AVRMEM memtype,
unsigned char b; unsigned char b;
unsigned short offset; unsigned short offset;
unsigned short caddr; unsigned short caddr;
/* order here is very important, AVR_EEPROM, AVR_FLASH, AVR_FLASH+1 */ /* order here is very important, AVR_M_EEPROM, AVR_M_FLASH, AVR_M_FLASH+1 */
static unsigned char cmdbyte[3] = { 0xc0, 0x40, 0x48 }; static unsigned char cmdbyte[3] = { 0xc0, 0x40, 0x48 };
/* /*
@ -259,7 +272,7 @@ int avr_write_byte ( int fd, struct avrpart * p, AVRMEM memtype,
offset = 0; offset = 0;
caddr = addr; caddr = addr;
if (memtype == AVR_FLASH) { if (memtype == AVR_M_FLASH) {
offset = addr & 0x01; offset = addr & 0x01;
caddr = addr / 2; caddr = addr / 2;
} }
@ -274,17 +287,17 @@ int avr_write_byte ( int fd, struct avrpart * p, AVRMEM memtype,
tries = 0; tries = 0;
ready = 0; ready = 0;
while (!ready) { while (!ready) {
usleep(p->min_write_delay); /* typical flash/eeprom write delay */ usleep(p->mem[memtype].min_write_delay); /* typical write delay */
r = avr_read_byte(fd, p, memtype, addr); r = avr_read_byte(fd, p, memtype, addr);
if ((data == p->f_readback) || if ((data == p->mem[memtype].readback[0]) ||
(data == p->e_readback[0]) || (data == p->e_readback[1])) { (data == p->mem[memtype].readback[1])) {
/* /*
* use an extra long delay when we happen to be writing values * use an extra long delay when we happen to be writing values
* used for polled data read-back. In this case, polling * used for polled data read-back. In this case, polling
* doesn't work, and we need to delay the worst case write time * doesn't work, and we need to delay the worst case write time
* specified for the chip. * specified for the chip.
*/ */
usleep(p->max_write_delay); usleep(p->mem[memtype].max_write_delay);
ready = 1; ready = 1;
} }
else if (r == data) { else if (r == data) {
@ -318,7 +331,7 @@ int avr_write_byte ( int fd, struct avrpart * p, AVRMEM memtype,
* *
* Return the number of bytes written, or -1 if an error occurs. * Return the number of bytes written, or -1 if an error occurs.
*/ */
int avr_write ( int fd, struct avrpart * p, AVRMEM memtype, int size ) int avr_write ( int fd, struct avrpart * p, int memtype, int size )
{ {
int rc; int rc;
int wsize; int wsize;
@ -331,8 +344,8 @@ int avr_write ( int fd, struct avrpart * p, AVRMEM memtype, int size )
werror = 0; werror = 0;
buf = p->mem[memtype]; buf = p->mem[memtype].buf;
wsize = p->memsize[memtype]; wsize = p->mem[memtype].size;
if (size < wsize) { if (size < wsize) {
wsize = size; wsize = size;
} }
@ -497,11 +510,11 @@ int avr_initialize ( int fd, struct avrpart * p )
char * avr_memtstr ( AVRMEM memtype ) char * avr_memtstr ( int memtype )
{ {
switch (memtype) { switch (memtype) {
case AVR_EEPROM : return "eeprom"; break; case AVR_M_EEPROM : return "eeprom"; break;
case AVR_FLASH : return "flash"; break; case AVR_M_FLASH : return "flash"; break;
default : return "unknown-memtype"; break; default : return "unknown-memtype"; break;
} }
} }
@ -512,10 +525,10 @@ int avr_initmem ( struct avrpart * p )
int i; int i;
for (i=0; i<AVR_MAXMEMTYPES; i++) { for (i=0; i<AVR_MAXMEMTYPES; i++) {
p->mem[i] = (unsigned char *) malloc(p->memsize[i]); p->mem[i].buf = (unsigned char *) malloc(p->mem[i].size);
if (p->mem[i] == NULL) { if (p->mem[i].buf == NULL) {
fprintf(stderr, "%s: can't alloc buffer for %s size of %d bytes\n", fprintf(stderr, "%s: can't alloc buffer for %s size of %d bytes\n",
progname, avr_memtstr(i), p->memsize[i]); progname, avr_memtstr(i), p->mem[i].size);
return -1; return -1;
} }
} }
@ -531,15 +544,15 @@ int avr_initmem ( struct avrpart * p )
* *
* Return the number of bytes verified, or -1 if they don't match. * Return the number of bytes verified, or -1 if they don't match.
*/ */
int avr_verify(struct avrpart * p, struct avrpart * v, AVRMEM memtype, int size) int avr_verify(struct avrpart * p, struct avrpart * v, int memtype, int size)
{ {
int i; int i;
unsigned char * buf1, * buf2; unsigned char * buf1, * buf2;
int vsize; int vsize;
buf1 = p->mem[memtype]; buf1 = p->mem[memtype].buf;
buf2 = v->mem[memtype]; buf2 = v->mem[memtype].buf;
vsize = p->memsize[memtype]; vsize = p->mem[memtype].size;
if (vsize < size) { if (vsize < size) {
fprintf(stderr, fprintf(stderr,
@ -567,22 +580,61 @@ int avr_verify(struct avrpart * p, struct avrpart * v, AVRMEM memtype, int size)
} }
void avr_display ( FILE * f, struct avrpart * p, char * prefix )
void avr_mem_display(char * prefix, FILE * f, AVRMEM * m, int type)
{ {
if (m == NULL) {
fprintf(f, fprintf(f,
"%sAVR Part = %s\n" "%sMem Bank\n"
"%sFlash memory size = %d bytes\n" "%sType Banked Size Size #Banks MinW MaxW ReadBack\n"
"%sEEPROM memory size = %d bytes\n" "%s------ ------ ------ ---- ------ ----- ----- ---------\n",
"%sMin/Max program delay = %d/%d us\n" prefix, prefix, prefix);
"%sChip Erase delay = %d us\n" }
"%sFlash Polled Readback = 0x%02x\n" else {
"%sEEPROM Polled Readback = 0x%02x, 0x%02x\n", fprintf(f,
prefix, p->partdesc, "%s%-6s %-6s %6d %4d %6d %5d %5d 0x%02x 0x%02x\n",
prefix, p->memsize[AVR_FLASH], prefix, avr_memtstr(type), m->banked ? "yes" : "no",
prefix, p->memsize[AVR_EEPROM], m->size, m->bank_size, m->num_banks,
prefix, p->min_write_delay, p->max_write_delay, m->min_write_delay, m->max_write_delay,
prefix, p->chip_erase_delay, m->readback[0], m->readback[1]);
prefix, p->f_readback, }
prefix, p->e_readback[0], p->e_readback[1]);
} }
void avr_display ( FILE * f, struct avrpart * p, char * prefix )
{
int i;
char * buf;
char * px;
fprintf(f,
"%sAVR Part : %s\n"
"%sChip Erase delay : %d us\n"
"%sMemory Detail :\n\n",
prefix, p->partdesc,
prefix, p->chip_erase_delay,
prefix);
px = prefix;
i = strlen(prefix) + 5;
buf = (char *)malloc(i);
if (buf == NULL) {
/* ugh, this is not important enough to bail, just ignore it */
}
else {
strcpy(buf, prefix);
strcat(buf, " ");
px = buf;
}
avr_mem_display(px, f, NULL, 0);
for (i=0; i<AVR_MAXMEMTYPES; i++) {
avr_mem_display(px, f, &p->mem[i], i);
}
if (buf)
free(buf);
}

40
avr.h
View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2000 Brian S. Dean <bsd@bsdhome.com> * Copyright 2001 Brian S. Dean <bsd@bsdhome.com>
* All Rights Reserved. * All Rights Reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@ -40,10 +40,8 @@
* around. Specifically, avr_read_byte() and avr_write_byte() rely on * around. Specifically, avr_read_byte() and avr_write_byte() rely on
* the order. * the order.
*/ */
typedef enum { #define AVR_M_EEPROM 0
AVR_EEPROM, #define AVR_M_FLASH 1
AVR_FLASH
} AVRMEM;
#define AVR_MAXMEMTYPES 2 /* just flash and eeprom */ #define AVR_MAXMEMTYPES 2 /* just flash and eeprom */
@ -56,9 +54,27 @@ struct avrmem {
}; };
#endif #endif
typedef struct avrmem {
int banked; /* bank addressed (e.g. ATmega flash) */
int size; /* total memory size in bytes */
int bank_size; /* size of memory bank (if bank addressed) */
int num_banks; /* number of banks (if bank addressed) */
int min_write_delay; /* microseconds */
int max_write_delay; /* microseconds */
unsigned char readback[2]; /* polled read-back values */
unsigned char * buf; /* pointer to memory buffer */
} AVRMEM;
struct avrpart { struct avrpart {
char * partdesc; /* long part name */ char * partdesc; /* long part name */
char * optiontag; /* short part name */ char * optiontag; /* short part name */
int chip_erase_delay; /* microseconds */
AVRMEM mem[AVR_MAXMEMTYPES];
#if 0
int memsize[AVR_MAXMEMTYPES]; /* sizes for eeprom, int memsize[AVR_MAXMEMTYPES]; /* sizes for eeprom,
flash, etc, indexed by flash, etc, indexed by
AVR_EEPROM or AVR_FLASH */ AVR_EEPROM or AVR_FLASH */
@ -66,7 +82,6 @@ struct avrpart {
unsigned char e_readback[2]; /* eeprom write polled readback values */ unsigned char e_readback[2]; /* eeprom write polled readback values */
int min_write_delay; /* microseconds */ int min_write_delay; /* microseconds */
int max_write_delay; /* microseconds */ int max_write_delay; /* microseconds */
int chip_erase_delay; /* microseconds */
#if 1 #if 1
unsigned char * mem[AVR_MAXMEMTYPES]; /* pointers to avr memory unsigned char * mem[AVR_MAXMEMTYPES]; /* pointers to avr memory
buffers, indexed by buffers, indexed by
@ -76,6 +91,7 @@ struct avrpart {
buffers, indexed by buffers, indexed by
AVR_EEPROM or AVR_FLASH */ AVR_EEPROM or AVR_FLASH */
#endif #endif
#endif
}; };
@ -94,14 +110,14 @@ unsigned char avr_txrx ( int fd, unsigned char byte );
int avr_cmd ( int fd, unsigned char cmd[4], unsigned char res[4] ); int avr_cmd ( int fd, unsigned char cmd[4], unsigned char res[4] );
unsigned char avr_read_byte ( int fd, struct avrpart * p, unsigned char avr_read_byte ( int fd, struct avrpart * p,
AVRMEM memtype, unsigned short addr ); int memtype, unsigned short addr );
int avr_read ( int fd, struct avrpart * p, AVRMEM memtype ); int avr_read ( int fd, struct avrpart * p, int memtype );
int avr_write_byte ( int fd, struct avrpart * p, AVRMEM memtype, int avr_write_byte ( int fd, struct avrpart * p, int memtype,
unsigned short addr, unsigned char data ); unsigned short addr, unsigned char data );
int avr_write ( int fd, struct avrpart * p, AVRMEM memtype, int size ); int avr_write ( int fd, struct avrpart * p, int memtype, int size );
int avr_program_enable ( int fd ); int avr_program_enable ( int fd );
@ -115,11 +131,11 @@ void avr_powerdown ( int fd );
int avr_initialize ( int fd, struct avrpart * p ); int avr_initialize ( int fd, struct avrpart * p );
char * avr_memtstr ( AVRMEM memtype ); char * avr_memtstr ( int memtype );
int avr_initmem ( struct avrpart * p ); int avr_initmem ( struct avrpart * p );
int avr_verify(struct avrpart * p, struct avrpart * v, AVRMEM memtype, int avr_verify(struct avrpart * p, struct avrpart * v, int memtype,
int size); int size);
void avr_display ( FILE * f, struct avrpart * p, char * prefix ); void avr_display ( FILE * f, struct avrpart * p, char * prefix );

View File

@ -502,7 +502,7 @@ int fmt_autodetect ( char * fname )
int fileio ( int op, char * filename, FILEFMT format, int fileio ( int op, char * filename, FILEFMT format,
struct avrpart * p, AVRMEM memtype, int size ) struct avrpart * p, int memtype, int size )
{ {
int rc; int rc;
FILE * f; FILE * f;
@ -536,9 +536,9 @@ int fileio ( int op, char * filename, FILEFMT format,
} }
/* point at the requested memory buffer */ /* point at the requested memory buffer */
buf = p->mem[memtype]; buf = p->mem[memtype].buf;
if (fio.op == FIO_READ) if (fio.op == FIO_READ)
size = p->memsize[memtype]; size = p->mem[memtype].size;
if (fio.op == FIO_READ) { if (fio.op == FIO_READ) {
/* 0xff fill unspecified memory */ /* 0xff fill unspecified memory */

View File

@ -57,6 +57,6 @@ char * fmtstr ( FILEFMT format );
int fileio_setparms ( int op, struct fioparms * fp ); int fileio_setparms ( int op, struct fioparms * fp );
int fileio ( int op, char * filename, FILEFMT format, int fileio ( int op, char * filename, FILEFMT format,
struct avrpart * p, AVRMEM memtype, int size ); struct avrpart * p, int memtype, int size );
#endif #endif

44
main.c
View File

@ -700,13 +700,14 @@ int main ( int argc, char * argv [] )
int ppisetbits; /* bits to set in ppi data register at exit */ int ppisetbits; /* bits to set in ppi data register at exit */
int ppiclrbits; /* bits to clear in ppi data register at exit */ int ppiclrbits; /* bits to clear in ppi data register at exit */
char * exitspecs; /* exit specs string from command line */ char * exitspecs; /* exit specs string from command line */
int verbose;
readorwrite = 0; readorwrite = 0;
parallel = DEFAULT_PARALLEL; parallel = DEFAULT_PARALLEL;
outputf = NULL; outputf = NULL;
inputf = NULL; inputf = NULL;
doread = 1; doread = 1;
memtype = AVR_FLASH; memtype = AVR_M_FLASH;
erase = 0; erase = 0;
p = NULL; p = NULL;
ovsigck = 0; ovsigck = 0;
@ -718,6 +719,7 @@ int main ( int argc, char * argv [] )
ppiclrbits = 0; ppiclrbits = 0;
exitspecs = NULL; exitspecs = NULL;
pinconfig = NULL; pinconfig = NULL;
verbose = 0;
strcpy(configfile, CONFIG_DIR); strcpy(configfile, CONFIG_DIR);
i = strlen(configfile); i = strlen(configfile);
@ -757,14 +759,6 @@ int main ( int argc, char * argv [] )
print_module_versions(NULL, timestamp); print_module_versions(NULL, timestamp);
/*
* Print out an identifying string so folks can tell what version
* they are running
*/
fprintf(stderr, "\n%s: Copyright 2001 Brian Dean, bsd@bsdhome.com\n"
"%sVersion %s Revision Timestamp %s\n\n",
progname, progbuf, version, timestamp);
/* /*
* check for no arguments * check for no arguments
*/ */
@ -777,7 +771,7 @@ int main ( int argc, char * argv [] )
/* /*
* process command line arguments * process command line arguments
*/ */
while ((ch = getopt(argc,argv,"?c:C:eE:f:Fi:m:no:p:P:tV")) != -1) { while ((ch = getopt(argc,argv,"?c:C:eE:f:Fi:m:no:p:P:tv")) != -1) {
switch (ch) { switch (ch) {
case 'c': /* pin configuration */ case 'c': /* pin configuration */
@ -791,11 +785,11 @@ int main ( int argc, char * argv [] )
case 'm': /* select memory type to operate on */ case 'm': /* select memory type to operate on */
if ((strcasecmp(optarg,"e")==0)||(strcasecmp(optarg,"eeprom")==0)) { if ((strcasecmp(optarg,"e")==0)||(strcasecmp(optarg,"eeprom")==0)) {
memtype = AVR_EEPROM; memtype = AVR_M_EEPROM;
} }
else if ((strcasecmp(optarg,"f")==0)|| else if ((strcasecmp(optarg,"f")==0)||
(strcasecmp(optarg,"flash")==0)) { (strcasecmp(optarg,"flash")==0)) {
memtype = AVR_FLASH; memtype = AVR_M_FLASH;
} }
else { else {
fprintf(stderr, "%s: invalid memory type \"%s\"\n\n", fprintf(stderr, "%s: invalid memory type \"%s\"\n\n",
@ -894,8 +888,8 @@ int main ( int argc, char * argv [] )
parallel = optarg; parallel = optarg;
break; break;
case 'V': case 'v':
print_module_versions(stderr, NULL); verbose++;
break; break;
case '?': /* help */ case '?': /* help */
@ -912,6 +906,21 @@ int main ( int argc, char * argv [] )
} }
if (verbose) {
/*
* Print out an identifying string so folks can tell what version
* they are running
*/
fprintf(stderr, "\n%s: Copyright 2001 Brian Dean, bsd@bsdhome.com\n"
"%sVersion %s Revision Timestamp %s\n\n",
progname, progbuf, version, timestamp);
if (verbose > 1) {
print_module_versions(stderr, NULL);
}
}
if (p == NULL) { if (p == NULL) {
fprintf(stderr, fprintf(stderr,
"%s: No AVR part has been specified, use \"-p Part\"\n\n" "%s: No AVR part has been specified, use \"-p Part\"\n\n"
@ -956,10 +965,11 @@ int main ( int argc, char * argv [] )
avr_initmem(p); avr_initmem(p);
avr_initmem(v); avr_initmem(v);
if (verbose) {
avr_display(stderr, p, progbuf); avr_display(stderr, p, progbuf);
#if 1 fprintf(stderr, "\n");
pinconfig_display(progbuf, pinconfig, desc); pinconfig_display(progbuf, pinconfig, desc);
#endif }
fprintf(stderr, "\n"); fprintf(stderr, "\n");
@ -1158,7 +1168,7 @@ int main ( int argc, char * argv [] )
if (!doread && verify) { if (!doread && verify) {
/* /*
* verify that the in memory file (p->mem[AVR_FLASH|AVR_EEPROM]) * verify that the in memory file (p->mem[AVR_M_FLASH|AVR_M_EEPROM])
* is the same as what is on the chip * is the same as what is on the chip
*/ */
LED_ON(fd, pinno[PIN_LED_VFY]); LED_ON(fd, pinno[PIN_LED_VFY]);

16
term.c
View File

@ -204,7 +204,7 @@ int cmd_dump ( int fd, struct avrpart * p, int argc, char * argv[] )
int i, l; int i, l;
char * buf; char * buf;
int maxsize; int maxsize;
static AVRMEM memtype=AVR_FLASH; static int memtype=AVR_M_FLASH;
static unsigned short addr=0; static unsigned short addr=0;
static int len=64; static int len=64;
@ -219,10 +219,10 @@ int cmd_dump ( int fd, struct avrpart * p, int argc, char * argv[] )
l = strlen(argv[1]); l = strlen(argv[1]);
if (strncasecmp(argv[1],"flash",l)==0) { if (strncasecmp(argv[1],"flash",l)==0) {
memtype = AVR_FLASH; memtype = AVR_M_FLASH;
} }
else if (strncasecmp(argv[1],"eeprom",l)==0) { else if (strncasecmp(argv[1],"eeprom",l)==0) {
memtype = AVR_EEPROM; memtype = AVR_M_EEPROM;
} }
else { else {
fprintf(stderr, "%s (dump): invalid memory type \"%s\"\n", fprintf(stderr, "%s (dump): invalid memory type \"%s\"\n",
@ -247,7 +247,7 @@ int cmd_dump ( int fd, struct avrpart * p, int argc, char * argv[] )
} }
} }
maxsize = p->memsize[memtype]; maxsize = p->mem[memtype].size;
if (argc == 2) { if (argc == 2) {
addr = 0; addr = 0;
@ -288,7 +288,7 @@ int cmd_write ( int fd, struct avrpart * p, int argc, char * argv[] )
char * e; char * e;
int i, l; int i, l;
int len, maxsize; int len, maxsize;
AVRMEM memtype; int memtype;
unsigned short addr; unsigned short addr;
char * buf; char * buf;
int rc; int rc;
@ -302,10 +302,10 @@ int cmd_write ( int fd, struct avrpart * p, int argc, char * argv[] )
l = strlen(argv[1]); l = strlen(argv[1]);
if (strncasecmp(argv[1],"flash",l)==0) { if (strncasecmp(argv[1],"flash",l)==0) {
memtype = AVR_FLASH; memtype = AVR_M_FLASH;
} }
else if (strncasecmp(argv[1],"eeprom",l)==0) { else if (strncasecmp(argv[1],"eeprom",l)==0) {
memtype = AVR_EEPROM; memtype = AVR_M_EEPROM;
} }
else { else {
fprintf(stderr, "%s (write): invalid memory type \"%s\"\n", fprintf(stderr, "%s (write): invalid memory type \"%s\"\n",
@ -313,7 +313,7 @@ int cmd_write ( int fd, struct avrpart * p, int argc, char * argv[] )
return -1; return -1;
} }
maxsize = p->memsize[memtype]; maxsize = p->mem[memtype].size;
addr = strtoul(argv[2], &e, 0); addr = strtoul(argv[2], &e, 0);
if (*e || (e == argv[2])) { if (*e || (e == argv[2])) {