Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ArduinoISP.ino does not properly handle word-based address for EEPROM read/write #2186

Open
x0urc3 opened this issue Jun 14, 2022 · 2 comments · May be fixed by #2188
Open

ArduinoISP.ino does not properly handle word-based address for EEPROM read/write #2186

x0urc3 opened this issue Jun 14, 2022 · 2 comments · May be fixed by #2188

Comments

@x0urc3
Copy link

x0urc3 commented Jun 14, 2022

Steps to reproduce
Reading and writing EEPROM using Adafruit ArduinoISP.ino will cause Bad EEPROM data. The official Arduino ArduinoISP.ino does not have similar issue. See avrdudes/avrdude/issues/990

Possible solution
The read and write EEPROM function does not handle word-based address. The high address byte is 0x00 in both function.

char eeprom_read_page(int length) {
// here again we have a word address
for (int x = 0; x < length; x++) {
byte ee = spi_transaction(0xA0, 0x00, _addr*2+x, 0xFF);
Serial.write( ee);
}
return STK_OK;
}

byte write_eeprom(int length) {
// here is a word address, so we use here*2
// this writes byte-by-byte,
// page writing may be faster (4 bytes at a time)
for (int x = 0; x < length; x++) {
spi_transaction(0xC0, 0x00, _addr*2+x, buff[x]);
delay(45);
}
return STK_OK;
}

@TheKitty
Copy link
Collaborator

Please submit a pull request if at all possible.

@mcuee
Copy link

mcuee commented Jun 14, 2022

FYI, Arduino's example has the fix back in Dec 2011.
arduino/arduino-examples@ea98fc8

Specific fix here.
rsbohn/ArduinoISP@bc480b0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants