Fix ATMega flash addressing. Add an ATMEGA16 part. Perform sanity

checking on the memory parameters for parts that do bank addressing.


git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@88 81a1dc3b-b13d-400b-aceb-764788c761c2
This commit is contained in:
Brian S. Dean
2001-10-16 02:47:55 +00:00
parent 4ccecfdbe6
commit c934f8cc7a
5 changed files with 105 additions and 10 deletions

22
avr.c
View File

@@ -281,7 +281,8 @@ int avr_read(int fd, AVRPART * p, int memtype)
for (i=0; i<size; i++) {
rbyte = avr_read_byte(fd, p, memtype, i);
fprintf(stderr, " \r%4lu 0x%02x", i, rbyte);
if (i % 1024 == 0)
fprintf(stderr, " \r%4lu 0x%02x", i, rbyte);
buf[i] = rbyte;
}
@@ -299,10 +300,26 @@ int avr_write_bank(int fd, AVRPART * p, int memtype,
{
unsigned char cmd[4];
unsigned char res[4];
unsigned int shift;
LED_ON(fd, pgm->pinno[PIN_LED_PGM]);
LED_OFF(fd, pgm->pinno[PIN_LED_ERR]);
/*
* 'bank' indicates which bank is being programmed: 0 for the first
* bank_size block, 1 for the second, up to num_banks-1 for the
* last. The MCU actually wants the high-order bits of what would
* 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
* 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
* address.
*/
shift = 16 - p->mem[memtype].bankaddrbits;
bank = bank << shift;
fprintf(stderr, "bank address=%u\n", bank);
cmd[0] = 0x4c;
cmd[1] = bank >> 8; /* high order bits of address */
cmd[2] = bank & 0x0ff; /* low order bits of address */
@@ -457,7 +474,8 @@ int avr_write(int fd, AVRPART * p, int memtype, int size)
/* eeprom or low byte of flash */
data = p->mem[memtype].buf[i];
rc = avr_write_byte(fd, p, memtype, i, data);
fprintf(stderr, " \r%4lu 0x%02x", i, data);
if (i % 1024 == 0)
fprintf(stderr, " \r%4lu 0x%02x", i, data);
if (rc) {
fprintf(stderr, " ***failed; ");
fprintf(stderr, "\n");