diff options
author | Cristian Maglie <c.maglie@bug.st> | 2013-03-07 22:00:26 +0100 |
---|---|---|
committer | Cristian Maglie <c.maglie@bug.st> | 2013-03-07 22:00:26 +0100 |
commit | 095e99aae5c4e94e06382ca40a0b00bae05a7f3a (patch) | |
tree | 9309590dbbca29a3355f493c56d4daa5f6380bae /bootloaders | |
parent | 911e9ac4e3874fce63a1685bf7262a022a1f60e4 (diff) |
Mega2560 bootloader: fix wrong eeprom addressing
Diffstat (limited to 'bootloaders')
-rwxr-xr-x | bootloaders/stk500v2/stk500boot.c | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/bootloaders/stk500v2/stk500boot.c b/bootloaders/stk500v2/stk500boot.c index 3e8becc..104ab3b 100755 --- a/bootloaders/stk500v2/stk500boot.c +++ b/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<<EEMWE); // Write data into EEPROM @@ -1036,9 +1037,9 @@ int main(void) while (EECR & (1<<EEWE)); // Wait for write operation to finish size--; // Decrease number of bytes to write } while (size); // Loop until all bytes written - #endif + #endif } - msgLength = 2; + msgLength = 2; msgBuffer[1] = STATUS_CMD_OK; } break; |