Fix (again, hopefully) page addressing for the ATMega parts.
Rename the poorly chosen name "bank" to "page" for page addressing. Atmel calls it "page" in their documentation. git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@91 81a1dc3b-b13d-400b-aceb-764788c761c2
This commit is contained in:
parent
b1b4ac48d4
commit
90d4f82fc9
66
avr.c
66
avr.c
|
@ -295,34 +295,32 @@ int avr_read(int fd, AVRPART * p, int memtype)
|
||||||
/*
|
/*
|
||||||
* write a byte of data to the indicated memory region
|
* write a byte of data to the indicated memory region
|
||||||
*/
|
*/
|
||||||
int avr_write_bank(int fd, AVRPART * p, int memtype,
|
int avr_write_page(int fd, AVRPART * p, int memtype,
|
||||||
unsigned short bank)
|
unsigned short page)
|
||||||
{
|
{
|
||||||
unsigned char cmd[4];
|
unsigned char cmd[4];
|
||||||
unsigned char res[4];
|
unsigned char res[4];
|
||||||
unsigned int shift;
|
|
||||||
|
|
||||||
LED_ON(fd, pgm->pinno[PIN_LED_PGM]);
|
LED_ON(fd, pgm->pinno[PIN_LED_PGM]);
|
||||||
LED_OFF(fd, pgm->pinno[PIN_LED_ERR]);
|
LED_OFF(fd, pgm->pinno[PIN_LED_ERR]);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* 'bank' indicates which bank is being programmed: 0 for the first
|
* 'page' indicates which page is being programmed: 0 for the first
|
||||||
* bank_size block, 1 for the second, up to num_banks-1 for the
|
* page_size block, 1 for the second, up to num_pages-1 for the
|
||||||
* last. The MCU actually wants the high-order bits of what would
|
* last. The MCU actually wants the high-order bits of what would
|
||||||
* be the actual address instead, shifted left to the upper most
|
* be the actual address instead, shifted left to the upper most
|
||||||
* bits of a 16 bit word. For a 128K flash, the actual address is a
|
* bits of a 16 bit word. For a 128K flash, the actual address is a
|
||||||
* 17 bits. To get the right value to send to the MCU, we want to
|
* 17 bits. To get the right value to send to the MCU, we want to
|
||||||
* shift 'bank' left by 16 - the number of bits in the bank
|
* shift 'page' left by 16 - the number of bits in the page
|
||||||
* address.
|
* address.
|
||||||
*/
|
*/
|
||||||
shift = 16 - p->mem[memtype].bankaddrbits;
|
page = page << p->mem[memtype].pageaddr_shift;
|
||||||
bank = bank << shift;
|
|
||||||
|
|
||||||
fprintf(stderr, "bank address=%u\n", bank);
|
fprintf(stderr, "page address=%u\n", page);
|
||||||
|
|
||||||
cmd[0] = 0x4c;
|
cmd[0] = 0x4c;
|
||||||
cmd[1] = bank >> 8; /* high order bits of address */
|
cmd[1] = page >> 8; /* high order bits of address */
|
||||||
cmd[2] = bank & 0x0ff; /* low order bits of address */
|
cmd[2] = page & 0x0ff; /* low order bits of address */
|
||||||
cmd[3] = 0; /* these bits are ignored */
|
cmd[3] = 0; /* these bits are ignored */
|
||||||
|
|
||||||
avr_cmd(fd, cmd, res);
|
avr_cmd(fd, cmd, res);
|
||||||
|
@ -355,11 +353,11 @@ int avr_write_byte(int fd, AVRPART * p, int memtype,
|
||||||
/* order here is very important, AVR_M_EEPROM, AVR_M_FLASH, AVR_M_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 };
|
||||||
|
|
||||||
if (!p->mem[memtype].banked) {
|
if (!p->mem[memtype].paged) {
|
||||||
/*
|
/*
|
||||||
* check to see if the write is necessary by reading the existing
|
* check to see if the write is necessary by reading the existing
|
||||||
* value and only write if we are changing the value; we can't
|
* value and only write if we are changing the value; we can't
|
||||||
* use this optimization for banked addressing.
|
* use this optimization for paged addressing.
|
||||||
*/
|
*/
|
||||||
b = avr_read_byte(fd, p, memtype, addr);
|
b = avr_read_byte(fd, p, memtype, addr);
|
||||||
if (b == data) {
|
if (b == data) {
|
||||||
|
@ -367,7 +365,7 @@ int avr_write_byte(int fd, AVRPART * p, int memtype,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
addr = addr % p->mem[memtype].bank_size;
|
addr = addr % p->mem[memtype].page_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
LED_ON(fd, pgm->pinno[PIN_LED_PGM]);
|
LED_ON(fd, pgm->pinno[PIN_LED_PGM]);
|
||||||
|
@ -388,11 +386,11 @@ int avr_write_byte(int fd, AVRPART * p, int memtype,
|
||||||
|
|
||||||
avr_cmd(fd, cmd, res);
|
avr_cmd(fd, cmd, res);
|
||||||
|
|
||||||
if (p->mem[memtype].banked) {
|
if (p->mem[memtype].paged) {
|
||||||
/*
|
/*
|
||||||
* in banked addressing, single bytes to written to the memory
|
* in paged addressing, single bytes to written to the memory
|
||||||
* page complete immediately, we only need to delay when we commit
|
* page complete immediately, we only need to delay when we commit
|
||||||
* the whole page via the avr_write_bank() routine.
|
* the whole page via the avr_write_page() routine.
|
||||||
*/
|
*/
|
||||||
LED_OFF(fd, pgm->pinno[PIN_LED_PGM]);
|
LED_OFF(fd, pgm->pinno[PIN_LED_PGM]);
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -483,15 +481,15 @@ int avr_write(int fd, AVRPART * p, int memtype, int size)
|
||||||
werror = 1;
|
werror = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (p->mem[memtype].banked) {
|
if (p->mem[memtype].paged) {
|
||||||
if (((i % p->mem[memtype].bank_size) == p->mem[memtype].bank_size-1) ||
|
if (((i % p->mem[memtype].page_size) == p->mem[memtype].page_size-1) ||
|
||||||
(i == wsize-1)) {
|
(i == wsize-1)) {
|
||||||
rc = avr_write_bank(fd, p, memtype, i/p->mem[memtype].bank_size);
|
rc = avr_write_page(fd, p, memtype, i/p->mem[memtype].page_size);
|
||||||
if (rc) {
|
if (rc) {
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
" *** bank %ld (addresses 0x%04lx - 0x%04lx) failed to write\n",
|
" *** page %ld (addresses 0x%04lx - 0x%04lx) failed to write\n",
|
||||||
i % p->mem[memtype].bank_size,
|
i % p->mem[memtype].page_size,
|
||||||
i-p->mem[memtype].bank_size+1, i);
|
i-p->mem[memtype].page_size+1, i);
|
||||||
fprintf(stderr, "\n");
|
fprintf(stderr, "\n");
|
||||||
LED_ON(fd, pgm->pinno[PIN_LED_ERR]);
|
LED_ON(fd, pgm->pinno[PIN_LED_ERR]);
|
||||||
werror = 1;
|
werror = 1;
|
||||||
|
@ -717,18 +715,24 @@ void avr_mem_display(char * prefix, FILE * f, AVRMEM * m, int type)
|
||||||
{
|
{
|
||||||
if (m == NULL) {
|
if (m == NULL) {
|
||||||
fprintf(f,
|
fprintf(f,
|
||||||
"%sMem Bank Polled\n"
|
"%sMem Page Page Polled\n"
|
||||||
"%sType Banked Size Size #Banks MinW MaxW ReadBack\n"
|
"%sType Paged Size Size Shift #Pages MinW MaxW ReadBack\n"
|
||||||
"%s------ ------ ------ ---- ------ ----- ----- ---------\n",
|
"%s------ ------ ------ ---- ----- ------ ----- ----- ---------\n",
|
||||||
prefix, prefix, prefix);
|
prefix, prefix, prefix);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
fprintf(f,
|
fprintf(f,
|
||||||
"%s%-6s %-6s %6d %4d %6d %5d %5d 0x%02x 0x%02x\n",
|
"%s%-6s %-6s %6d %4d %5d %6d %5d %5d 0x%02x 0x%02x\n",
|
||||||
prefix, avr_memtstr(type), m->banked ? "yes" : "no",
|
prefix, avr_memtstr(type),
|
||||||
m->size, m->bank_size, m->num_banks,
|
m->paged ? "yes" : "no",
|
||||||
m->min_write_delay, m->max_write_delay,
|
m->size,
|
||||||
m->readback[0], m->readback[1]);
|
m->page_size,
|
||||||
|
m->pageaddr_shift,
|
||||||
|
m->num_pages,
|
||||||
|
m->min_write_delay,
|
||||||
|
m->max_write_delay,
|
||||||
|
m->readback[0],
|
||||||
|
m->readback[1]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
8
avr.h
8
avr.h
|
@ -46,11 +46,11 @@
|
||||||
#define AVR_MAXMEMTYPES 2 /* just flash and eeprom */
|
#define AVR_MAXMEMTYPES 2 /* just flash and eeprom */
|
||||||
|
|
||||||
typedef struct avrmem {
|
typedef struct avrmem {
|
||||||
int banked; /* bank addressed (e.g. ATmega flash) */
|
int paged; /* page addressed (e.g. ATmega flash) */
|
||||||
int size; /* total memory size in bytes */
|
int size; /* total memory size in bytes */
|
||||||
int bank_size; /* size of memory bank (if bank addressed) */
|
int page_size; /* size of memory page (if page addressed) */
|
||||||
int num_banks; /* number of banks (if bank addressed) */
|
int num_pages; /* number of pages (if page addressed) */
|
||||||
int bankaddrbits; /* number of bits in the bank address */
|
int pageaddr_shift; /* number of bits in the page address */
|
||||||
int min_write_delay; /* microseconds */
|
int min_write_delay; /* microseconds */
|
||||||
int max_write_delay; /* microseconds */
|
int max_write_delay; /* microseconds */
|
||||||
unsigned char readback[2]; /* polled read-back values */
|
unsigned char readback[2]; /* polled read-back values */
|
||||||
|
|
|
@ -31,20 +31,20 @@
|
||||||
# desc = <description> ; # quoted string
|
# desc = <description> ; # quoted string
|
||||||
# chip_erase_delay = <num> ; # micro-seconds
|
# chip_erase_delay = <num> ; # micro-seconds
|
||||||
# eeprom
|
# eeprom
|
||||||
# banked = <yes/no> ; # yes / no
|
# paged = <yes/no> ; # yes / no
|
||||||
# size = <num> ; # bytes
|
# size = <num> ; # bytes
|
||||||
# bank_size = <num> ; # bytes
|
# page_size = <num> ; # bytes
|
||||||
# num_banks = <num> ; # numeric
|
# num_pages = <num> ; # numeric
|
||||||
# min_write_delay = <num> ; # micro-seconds
|
# min_write_delay = <num> ; # micro-seconds
|
||||||
# max_write_delay = <num> ; # micro-seconds
|
# max_write_delay = <num> ; # micro-seconds
|
||||||
# readback_p1 = <num> ; # byte value
|
# readback_p1 = <num> ; # byte value
|
||||||
# readback_p2 = <num> ; # byte value
|
# readback_p2 = <num> ; # byte value
|
||||||
# ;
|
# ;
|
||||||
# flash
|
# flash
|
||||||
# banked = <yes/no> ; # yes / no
|
# paged = <yes/no> ; # yes / no
|
||||||
# size = <num> ; # bytes
|
# size = <num> ; # bytes
|
||||||
# bank_size = <num> ; # bytes
|
# page_size = <num> ; # bytes
|
||||||
# num_banks = <num> ; # numeric
|
# num_pages = <num> ; # numeric
|
||||||
# min_write_delay = <num> ; # micro-seconds
|
# min_write_delay = <num> ; # micro-seconds
|
||||||
# max_write_delay = <num> ; # micro-seconds
|
# max_write_delay = <num> ; # micro-seconds
|
||||||
# readback_p1 = <num> ; # byte value
|
# readback_p1 = <num> ; # byte value
|
||||||
|
@ -99,20 +99,20 @@ part
|
||||||
desc = "AT90S1200";
|
desc = "AT90S1200";
|
||||||
chip_erase_delay = 20000;
|
chip_erase_delay = 20000;
|
||||||
eeprom
|
eeprom
|
||||||
banked = no;
|
paged = no;
|
||||||
size = 64;
|
size = 64;
|
||||||
bank_size = 0;
|
page_size = 0;
|
||||||
num_banks = 0;
|
num_pages = 0;
|
||||||
min_write_delay = 9000;
|
min_write_delay = 9000;
|
||||||
max_write_delay = 20000;
|
max_write_delay = 20000;
|
||||||
readback_p1 = 0x00;
|
readback_p1 = 0x00;
|
||||||
readback_p2 = 0xff;
|
readback_p2 = 0xff;
|
||||||
;
|
;
|
||||||
flash
|
flash
|
||||||
banked = no;
|
paged = no;
|
||||||
size = 1024;
|
size = 1024;
|
||||||
bank_size = 0;
|
page_size = 0;
|
||||||
num_banks = 0;
|
num_pages = 0;
|
||||||
min_write_delay = 9000;
|
min_write_delay = 9000;
|
||||||
max_write_delay = 20000;
|
max_write_delay = 20000;
|
||||||
readback_p1 = 0xff;
|
readback_p1 = 0xff;
|
||||||
|
@ -126,20 +126,20 @@ part
|
||||||
desc = "AT90S2313";
|
desc = "AT90S2313";
|
||||||
chip_erase_delay = 20000;
|
chip_erase_delay = 20000;
|
||||||
eeprom
|
eeprom
|
||||||
banked = no;
|
paged = no;
|
||||||
size = 128;
|
size = 128;
|
||||||
bank_size = 0;
|
page_size = 0;
|
||||||
num_banks = 0;
|
num_pages = 0;
|
||||||
min_write_delay = 9000;
|
min_write_delay = 9000;
|
||||||
max_write_delay = 20000;
|
max_write_delay = 20000;
|
||||||
readback_p1 = 0x80;
|
readback_p1 = 0x80;
|
||||||
readback_p2 = 0x7f;
|
readback_p2 = 0x7f;
|
||||||
;
|
;
|
||||||
flash
|
flash
|
||||||
banked = no;
|
paged = no;
|
||||||
size = 2048;
|
size = 2048;
|
||||||
bank_size = 0;
|
page_size = 0;
|
||||||
num_banks = 0;
|
num_pages = 0;
|
||||||
min_write_delay = 9000;
|
min_write_delay = 9000;
|
||||||
max_write_delay = 20000;
|
max_write_delay = 20000;
|
||||||
readback_p1 = 0x7f;
|
readback_p1 = 0x7f;
|
||||||
|
@ -153,20 +153,20 @@ part
|
||||||
desc = "AT90S2333";
|
desc = "AT90S2333";
|
||||||
chip_erase_delay = 20000;
|
chip_erase_delay = 20000;
|
||||||
eeprom
|
eeprom
|
||||||
banked = no;
|
paged = no;
|
||||||
size = 128;
|
size = 128;
|
||||||
bank_size = 0;
|
page_size = 0;
|
||||||
num_banks = 0;
|
num_pages = 0;
|
||||||
min_write_delay = 9000;
|
min_write_delay = 9000;
|
||||||
max_write_delay = 20000;
|
max_write_delay = 20000;
|
||||||
readback_p1 = 0x00;
|
readback_p1 = 0x00;
|
||||||
readback_p2 = 0xff;
|
readback_p2 = 0xff;
|
||||||
;
|
;
|
||||||
flash
|
flash
|
||||||
banked = no;
|
paged = no;
|
||||||
size = 2048;
|
size = 2048;
|
||||||
bank_size = 0;
|
page_size = 0;
|
||||||
num_banks = 0;
|
num_pages = 0;
|
||||||
min_write_delay = 9000;
|
min_write_delay = 9000;
|
||||||
max_write_delay = 20000;
|
max_write_delay = 20000;
|
||||||
readback_p1 = 0xff;
|
readback_p1 = 0xff;
|
||||||
|
@ -180,20 +180,20 @@ part
|
||||||
desc = "AT90S4433";
|
desc = "AT90S4433";
|
||||||
chip_erase_delay = 20000;
|
chip_erase_delay = 20000;
|
||||||
eeprom
|
eeprom
|
||||||
banked = no;
|
paged = no;
|
||||||
size = 256;
|
size = 256;
|
||||||
bank_size = 0;
|
page_size = 0;
|
||||||
num_banks = 0;
|
num_pages = 0;
|
||||||
min_write_delay = 9000;
|
min_write_delay = 9000;
|
||||||
max_write_delay = 20000;
|
max_write_delay = 20000;
|
||||||
readback_p1 = 0x00;
|
readback_p1 = 0x00;
|
||||||
readback_p2 = 0xff;
|
readback_p2 = 0xff;
|
||||||
;
|
;
|
||||||
flash
|
flash
|
||||||
banked = no;
|
paged = no;
|
||||||
size = 4096;
|
size = 4096;
|
||||||
bank_size = 0;
|
page_size = 0;
|
||||||
num_banks = 0;
|
num_pages = 0;
|
||||||
min_write_delay = 9000;
|
min_write_delay = 9000;
|
||||||
max_write_delay = 20000;
|
max_write_delay = 20000;
|
||||||
readback_p1 = 0xff;
|
readback_p1 = 0xff;
|
||||||
|
@ -207,20 +207,20 @@ part
|
||||||
desc = "AT90S4434";
|
desc = "AT90S4434";
|
||||||
chip_erase_delay = 20000;
|
chip_erase_delay = 20000;
|
||||||
eeprom
|
eeprom
|
||||||
banked = no;
|
paged = no;
|
||||||
size = 256;
|
size = 256;
|
||||||
bank_size = 0;
|
page_size = 0;
|
||||||
num_banks = 0;
|
num_pages = 0;
|
||||||
min_write_delay = 9000;
|
min_write_delay = 9000;
|
||||||
max_write_delay = 20000;
|
max_write_delay = 20000;
|
||||||
readback_p1 = 0x00;
|
readback_p1 = 0x00;
|
||||||
readback_p2 = 0xff;
|
readback_p2 = 0xff;
|
||||||
;
|
;
|
||||||
flash
|
flash
|
||||||
banked = no;
|
paged = no;
|
||||||
size = 4096;
|
size = 4096;
|
||||||
bank_size = 0;
|
page_size = 0;
|
||||||
num_banks = 0;
|
num_pages = 0;
|
||||||
min_write_delay = 9000;
|
min_write_delay = 9000;
|
||||||
max_write_delay = 20000;
|
max_write_delay = 20000;
|
||||||
readback_p1 = 0xff;
|
readback_p1 = 0xff;
|
||||||
|
@ -234,20 +234,20 @@ part
|
||||||
desc = "AT90S8515";
|
desc = "AT90S8515";
|
||||||
chip_erase_delay = 20000;
|
chip_erase_delay = 20000;
|
||||||
eeprom
|
eeprom
|
||||||
banked = no;
|
paged = no;
|
||||||
size = 512;
|
size = 512;
|
||||||
bank_size = 0;
|
page_size = 0;
|
||||||
num_banks = 0;
|
num_pages = 0;
|
||||||
min_write_delay = 9000;
|
min_write_delay = 9000;
|
||||||
max_write_delay = 20000;
|
max_write_delay = 20000;
|
||||||
readback_p1 = 0x80;
|
readback_p1 = 0x80;
|
||||||
readback_p2 = 0x7f;
|
readback_p2 = 0x7f;
|
||||||
;
|
;
|
||||||
flash
|
flash
|
||||||
banked = no;
|
paged = no;
|
||||||
size = 8192;
|
size = 8192;
|
||||||
bank_size = 0;
|
page_size = 0;
|
||||||
num_banks = 0;
|
num_pages = 0;
|
||||||
min_write_delay = 9000;
|
min_write_delay = 9000;
|
||||||
max_write_delay = 20000;
|
max_write_delay = 20000;
|
||||||
readback_p1 = 0x7f;
|
readback_p1 = 0x7f;
|
||||||
|
@ -261,20 +261,20 @@ part
|
||||||
desc = "AT90S8535";
|
desc = "AT90S8535";
|
||||||
chip_erase_delay = 20000;
|
chip_erase_delay = 20000;
|
||||||
eeprom
|
eeprom
|
||||||
banked = no;
|
paged = no;
|
||||||
size = 512;
|
size = 512;
|
||||||
bank_size = 0;
|
page_size = 0;
|
||||||
num_banks = 0;
|
num_pages = 0;
|
||||||
min_write_delay = 9000;
|
min_write_delay = 9000;
|
||||||
max_write_delay = 20000;
|
max_write_delay = 20000;
|
||||||
readback_p1 = 0x00;
|
readback_p1 = 0x00;
|
||||||
readback_p2 = 0xff;
|
readback_p2 = 0xff;
|
||||||
;
|
;
|
||||||
flash
|
flash
|
||||||
banked = no;
|
paged = no;
|
||||||
size = 8192;
|
size = 8192;
|
||||||
bank_size = 0;
|
page_size = 0;
|
||||||
num_banks = 0;
|
num_pages = 0;
|
||||||
min_write_delay = 9000;
|
min_write_delay = 9000;
|
||||||
max_write_delay = 20000;
|
max_write_delay = 20000;
|
||||||
readback_p1 = 0xff;
|
readback_p1 = 0xff;
|
||||||
|
@ -288,20 +288,20 @@ part
|
||||||
desc = "ATMEGA103";
|
desc = "ATMEGA103";
|
||||||
chip_erase_delay = 112000;
|
chip_erase_delay = 112000;
|
||||||
eeprom
|
eeprom
|
||||||
banked = no;
|
paged = no;
|
||||||
size = 4096;
|
size = 4096;
|
||||||
bank_size = 0;
|
page_size = 0;
|
||||||
num_banks = 0;
|
num_pages = 0;
|
||||||
min_write_delay = 4000;
|
min_write_delay = 4000;
|
||||||
max_write_delay = 9000;
|
max_write_delay = 9000;
|
||||||
readback_p1 = 0x00;
|
readback_p1 = 0x00;
|
||||||
readback_p2 = 0xff;
|
readback_p2 = 0xff;
|
||||||
;
|
;
|
||||||
flash
|
flash
|
||||||
banked = yes;
|
paged = yes;
|
||||||
size = 131072;
|
size = 131072;
|
||||||
bank_size = 256;
|
page_size = 256;
|
||||||
num_banks = 512;
|
num_pages = 512;
|
||||||
min_write_delay = 22000;
|
min_write_delay = 22000;
|
||||||
max_write_delay = 56000;
|
max_write_delay = 56000;
|
||||||
readback_p1 = 0xff;
|
readback_p1 = 0xff;
|
||||||
|
@ -315,20 +315,20 @@ part
|
||||||
desc = "ATMEGA16";
|
desc = "ATMEGA16";
|
||||||
chip_erase_delay = 9000;
|
chip_erase_delay = 9000;
|
||||||
eeprom
|
eeprom
|
||||||
banked = no;
|
paged = no;
|
||||||
size = 512;
|
size = 512;
|
||||||
bank_size = 0;
|
page_size = 0;
|
||||||
num_banks = 0;
|
num_pages = 0;
|
||||||
min_write_delay = 9000;
|
min_write_delay = 9000;
|
||||||
max_write_delay = 9000;
|
max_write_delay = 9000;
|
||||||
readback_p1 = 0xff;
|
readback_p1 = 0xff;
|
||||||
readback_p2 = 0xff;
|
readback_p2 = 0xff;
|
||||||
;
|
;
|
||||||
flash
|
flash
|
||||||
banked = yes;
|
paged = yes;
|
||||||
size = 16384;
|
size = 16384;
|
||||||
bank_size = 128;
|
page_size = 128;
|
||||||
num_banks = 128;
|
num_pages = 128;
|
||||||
min_write_delay = 4500;
|
min_write_delay = 4500;
|
||||||
max_write_delay = 9000;
|
max_write_delay = 9000;
|
||||||
readback_p1 = 0xff;
|
readback_p1 = 0xff;
|
||||||
|
|
|
@ -29,8 +29,8 @@
|
||||||
|
|
||||||
/* $Id$ */
|
/* $Id$ */
|
||||||
|
|
||||||
%token K_BANK_SIZE
|
%token K_PAGE_SIZE
|
||||||
%token K_BANKED
|
%token K_PAGEED
|
||||||
%token K_BUFF
|
%token K_BUFF
|
||||||
%token K_CHIP_ERASE_DELAY
|
%token K_CHIP_ERASE_DELAY
|
||||||
%token K_DESC
|
%token K_DESC
|
||||||
|
@ -38,23 +38,27 @@
|
||||||
%token K_ERRLED
|
%token K_ERRLED
|
||||||
%token K_FLASH
|
%token K_FLASH
|
||||||
%token K_ID
|
%token K_ID
|
||||||
|
%token K_LOADPAGE
|
||||||
%token K_MAX_WRITE_DELAY
|
%token K_MAX_WRITE_DELAY
|
||||||
%token K_MIN_WRITE_DELAY
|
%token K_MIN_WRITE_DELAY
|
||||||
%token K_MISO
|
%token K_MISO
|
||||||
%token K_MOSI
|
%token K_MOSI
|
||||||
%token K_NO
|
%token K_NUM_PAGES
|
||||||
%token K_NUM_BANKS
|
|
||||||
%token K_PART
|
%token K_PART
|
||||||
%token K_PGMLED
|
%token K_PGMLED
|
||||||
%token K_PROGRAMMER
|
%token K_PROGRAMMER
|
||||||
%token K_RDYLED
|
%token K_RDYLED
|
||||||
%token K_READBACK_P1
|
%token K_READBACK_P1
|
||||||
%token K_READBACK_P2
|
%token K_READBACK_P2
|
||||||
|
%token K_READMEM
|
||||||
%token K_RESET
|
%token K_RESET
|
||||||
%token K_SCK
|
%token K_SCK
|
||||||
%token K_SIZE
|
%token K_SIZE
|
||||||
%token K_VCC
|
%token K_VCC
|
||||||
%token K_VFYLED
|
%token K_VFYLED
|
||||||
|
%token K_WRITEPAGE
|
||||||
|
|
||||||
|
%token K_NO
|
||||||
%token K_YES
|
%token K_YES
|
||||||
|
|
||||||
%token TKN_COMMA
|
%token TKN_COMMA
|
||||||
|
@ -103,7 +107,8 @@ part_def :
|
||||||
{ current_part = avr_new_part(); }
|
{ current_part = avr_new_part(); }
|
||||||
part_parms
|
part_parms
|
||||||
{
|
{
|
||||||
unsigned int i, j, pagebits;
|
unsigned int i, j, shift, psize;
|
||||||
|
|
||||||
if (current_part->id[0] == 0) {
|
if (current_part->id[0] == 0) {
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"%s: error at %s:%d: required parameter id not specified\n",
|
"%s: error at %s:%d: required parameter id not specified\n",
|
||||||
|
@ -115,46 +120,48 @@ part_def :
|
||||||
* perform some sanity checking
|
* perform some sanity checking
|
||||||
*/
|
*/
|
||||||
for (i=0; i<AVR_MAXMEMTYPES; i++) {
|
for (i=0; i<AVR_MAXMEMTYPES; i++) {
|
||||||
if (current_part->mem[i].banked) {
|
if (current_part->mem[i].paged) {
|
||||||
if (!current_part->mem[i].bank_size) {
|
if (!current_part->mem[i].page_size) {
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"%s: error at %s:%d: must specify bank_size for banked "
|
"%s: error at %s:%d: must specify page_size for paged "
|
||||||
"memory\n",
|
"memory\n",
|
||||||
progname, infile, lineno);
|
progname, infile, lineno);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
if (!current_part->mem[i].num_banks) {
|
if (!current_part->mem[i].num_pages) {
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"%s: error at %s:%d: must specify num_banks for banked "
|
"%s: error at %s:%d: must specify num_pages for paged "
|
||||||
"memory\n",
|
"memory\n",
|
||||||
progname, infile, lineno);
|
progname, infile, lineno);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
if (current_part->mem[i].size != current_part->mem[i].bank_size *
|
if (current_part->mem[i].size != current_part->mem[i].page_size *
|
||||||
current_part->mem[i].num_banks) {
|
current_part->mem[i].num_pages) {
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"%s: error at %s:%d: bank size (%u) * num_banks (%u) = "
|
"%s: error at %s:%d: page size (%u) * num_pages (%u) = "
|
||||||
"%u does not match memory size (%u)\n",
|
"%u does not match memory size (%u)\n",
|
||||||
progname, infile, lineno,
|
progname, infile, lineno,
|
||||||
current_part->mem[i].bank_size,
|
current_part->mem[i].page_size,
|
||||||
current_part->mem[i].num_banks,
|
current_part->mem[i].num_pages,
|
||||||
current_part->mem[i].bank_size * current_part->mem[i].num_banks,
|
current_part->mem[i].page_size * current_part->mem[i].num_pages,
|
||||||
current_part->mem[i].size);
|
current_part->mem[i].size);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
pagebits = 0;
|
shift = 0;
|
||||||
for (j=0; j<32 && !pagebits; j++) {
|
psize = current_part->mem[i].page_size / 2 - 1;
|
||||||
if ((1 << j) == current_part->mem[i].num_banks)
|
for (j=0; j<32 && !shift; j++) {
|
||||||
pagebits = j;
|
if ((psize >> j) == 0) {
|
||||||
|
shift = j;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (!pagebits) {
|
if (!shift) {
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"%s: error at %s:%d: can't determine the number of bank address bits\n"
|
"%s: error at %s:%d: can't determine amount to shift for the page address\n"
|
||||||
" Are you sure num_banks (=%u) is correct?\n",
|
" Are you sure page_size (=%u) is correct?\n",
|
||||||
progname, infile, lineno, current_part->mem[i].num_banks);
|
progname, infile, lineno, current_part->mem[i].page_size);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
current_part->mem[i].bankaddrbits = pagebits;
|
current_part->mem[i].pageaddr_shift = shift;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -284,9 +291,9 @@ mem_specs :
|
||||||
|
|
||||||
|
|
||||||
mem_spec :
|
mem_spec :
|
||||||
K_BANKED TKN_EQUAL yesno
|
K_PAGED TKN_EQUAL yesno
|
||||||
{
|
{
|
||||||
current_part->mem[current_mem].banked = $3->primary == K_YES ? 1 : 0;
|
current_part->mem[current_mem].paged = $3->primary == K_YES ? 1 : 0;
|
||||||
free_token($3);
|
free_token($3);
|
||||||
} |
|
} |
|
||||||
|
|
||||||
|
@ -297,15 +304,15 @@ mem_spec :
|
||||||
} |
|
} |
|
||||||
|
|
||||||
|
|
||||||
K_BANK_SIZE TKN_EQUAL TKN_NUMBER
|
K_PAGE_SIZE TKN_EQUAL TKN_NUMBER
|
||||||
{
|
{
|
||||||
current_part->mem[current_mem].bank_size = $3->value.number;
|
current_part->mem[current_mem].page_size = $3->value.number;
|
||||||
free_token($3);
|
free_token($3);
|
||||||
} |
|
} |
|
||||||
|
|
||||||
K_NUM_BANKS TKN_EQUAL TKN_NUMBER
|
K_NUM_PAGES TKN_EQUAL TKN_NUMBER
|
||||||
{
|
{
|
||||||
current_part->mem[current_mem].num_banks = $3->value.number;
|
current_part->mem[current_mem].num_pages = $3->value.number;
|
||||||
free_token($3);
|
free_token($3);
|
||||||
} |
|
} |
|
||||||
|
|
||||||
|
|
9
lexer.l
9
lexer.l
|
@ -123,8 +123,8 @@ SIGN [+-]
|
||||||
exit(1); }
|
exit(1); }
|
||||||
}
|
}
|
||||||
|
|
||||||
bank_size { yylval=NULL; return K_BANK_SIZE; }
|
bank_size { yylval=NULL; return K_PAGE_SIZE; }
|
||||||
banked { yylval=NULL; return K_BANKED; }
|
banked { yylval=NULL; return K_PAGED; }
|
||||||
buff { yylval=NULL; return K_BUFF; }
|
buff { yylval=NULL; return K_BUFF; }
|
||||||
chip_erase_delay { yylval=NULL; return K_CHIP_ERASE_DELAY; }
|
chip_erase_delay { yylval=NULL; return K_CHIP_ERASE_DELAY; }
|
||||||
desc { yylval=NULL; return K_DESC; }
|
desc { yylval=NULL; return K_DESC; }
|
||||||
|
@ -136,7 +136,10 @@ max_write_delay { yylval=NULL; return K_MAX_WRITE_DELAY; }
|
||||||
min_write_delay { yylval=NULL; return K_MIN_WRITE_DELAY; }
|
min_write_delay { yylval=NULL; return K_MIN_WRITE_DELAY; }
|
||||||
miso { yylval=NULL; return K_MISO; }
|
miso { yylval=NULL; return K_MISO; }
|
||||||
mosi { yylval=NULL; return K_MOSI; }
|
mosi { yylval=NULL; return K_MOSI; }
|
||||||
num_banks { yylval=NULL; return K_NUM_BANKS; }
|
num_banks { yylval=NULL; return K_NUM_PAGES; }
|
||||||
|
num_pages { yylval=NULL; return K_NUM_PAGES; }
|
||||||
|
page_size { yylval=NULL; return K_PAGE_SIZE; }
|
||||||
|
paged { yylval=NULL; return K_PAGED; }
|
||||||
part { yylval=NULL; return K_PART; }
|
part { yylval=NULL; return K_PART; }
|
||||||
pgmled { yylval=NULL; return K_PGMLED; }
|
pgmled { yylval=NULL; return K_PGMLED; }
|
||||||
programmer { yylval=NULL; return K_PROGRAMMER; }
|
programmer { yylval=NULL; return K_PROGRAMMER; }
|
||||||
|
|
4
term.c
4
term.c
|
@ -316,8 +316,8 @@ int cmd_write(int fd, struct avrpart * p, int argc, char * argv[])
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (p->mem[memtype].banked) {
|
if (p->mem[memtype].paged) {
|
||||||
fprintf(stderr, "%s (write): sorry, interactive write of bank addressed "
|
fprintf(stderr, "%s (write): sorry, interactive write of page addressed "
|
||||||
"memory is not supported\n", progname);
|
"memory is not supported\n", progname);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue