Mega2560 bootloader: fix wrong eeprom addressing
This commit is contained in:
parent
911e9ac4e3
commit
095e99aae5
|
@ -1021,13 +1021,14 @@ int main(void)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
//* issue 543, this should work, It has not been tested.
|
//* issue 543, this should work, It has not been tested.
|
||||||
// #if (!defined(__AVR_ATmega1280__) && !defined(__AVR_ATmega2560__) && !defined(__AVR_ATmega2561__) && !defined(__AVR_ATmega1284P__) && !defined(__AVR_ATmega640__))
|
#if (defined(EEARL) && defined(EEARH) && defined(EEMWE) && defined(EEWE) && defined(EEDR))
|
||||||
#if (defined(EEARL) && defined(EEARH) && defined(EEMWE) && defined(EEWE) && defined(EEDR))
|
uint16_t ii = address >> 1;
|
||||||
/* write EEPROM */
|
/* write EEPROM */
|
||||||
do {
|
do {
|
||||||
EEARL = address; // Setup EEPROM address
|
EEARL = ii; // Setup EEPROM address
|
||||||
EEARH = (address >> 8);
|
EEARH = (ii >> 8);
|
||||||
address++; // Select next EEPROM byte
|
address+=2; // Select next EEPROM byte
|
||||||
|
ii++;
|
||||||
|
|
||||||
EEDR = *p++; // get byte from buffer
|
EEDR = *p++; // get byte from buffer
|
||||||
EECR |= (1<<EEMWE); // Write data into EEPROM
|
EECR |= (1<<EEMWE); // Write data into EEPROM
|
||||||
|
@ -1036,9 +1037,9 @@ int main(void)
|
||||||
while (EECR & (1<<EEWE)); // Wait for write operation to finish
|
while (EECR & (1<<EEWE)); // Wait for write operation to finish
|
||||||
size--; // Decrease number of bytes to write
|
size--; // Decrease number of bytes to write
|
||||||
} while (size); // Loop until all bytes written
|
} while (size); // Loop until all bytes written
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
msgLength = 2;
|
msgLength = 2;
|
||||||
msgBuffer[1] = STATUS_CMD_OK;
|
msgBuffer[1] = STATUS_CMD_OK;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in New Issue