From 1066766bfa4d885b6af01b9435eb5e015b853874 Mon Sep 17 00:00:00 2001 From: Cristian Maglie Date: Thu, 7 Mar 2013 22:00:26 +0100 Subject: [PATCH] Mega2560 bootloader: fix wrong eeprom addressing --- .../arduino/bootloaders/stk500v2/stk500boot.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/hardware/arduino/bootloaders/stk500v2/stk500boot.c b/hardware/arduino/bootloaders/stk500v2/stk500boot.c index 3e8becc9599..104ab3bf938 100755 --- a/hardware/arduino/bootloaders/stk500v2/stk500boot.c +++ b/hardware/arduino/bootloaders/stk500v2/stk500boot.c @@ -1021,13 +1021,14 @@ int main(void) else { //* 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 */ do { - EEARL = address; // Setup EEPROM address - EEARH = (address >> 8); - address++; // Select next EEPROM byte + EEARL = ii; // Setup EEPROM address + EEARH = (ii >> 8); + address+=2; // Select next EEPROM byte + ii++; EEDR = *p++; // get byte from buffer EECR |= (1<