From 97e468083e02675ea5726cbb8a9afe906df60d44 Mon Sep 17 00:00:00 2001 From: Khairulmizam Samsudin Date: Wed, 15 Jun 2022 19:39:26 +0800 Subject: [PATCH 1/3] Fix word-based addressing for dumping EEPROM content --- ArduinoISP/ArduinoISP/ArduinoISP.ino | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ArduinoISP/ArduinoISP/ArduinoISP.ino b/ArduinoISP/ArduinoISP/ArduinoISP.ino index 18e6561d2..1692db3c6 100644 --- a/ArduinoISP/ArduinoISP/ArduinoISP.ino +++ b/ArduinoISP/ArduinoISP/ArduinoISP.ino @@ -549,8 +549,10 @@ char flash_read_page(int length) { char eeprom_read_page(int length) { // here again we have a word address + int start = _addr*2; for (int x = 0; x < length; x++) { - byte ee = spi_transaction(0xA0, 0x00, _addr*2+x, 0xFF); + int addr = start +x; + byte ee = spi_transaction(0xA0, (addr >> 8) && 0xFF, addr && 0xFF, 0xFF); Serial.write( ee); } return STK_OK; From 2d8882b886539d28112058337a0c91f743bb45ee Mon Sep 17 00:00:00 2001 From: Khairulmizam Samsudin Date: Wed, 15 Jun 2022 21:04:47 +0800 Subject: [PATCH 2/3] Wrong operator --- ArduinoISP/ArduinoISP/ArduinoISP.ino | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ArduinoISP/ArduinoISP/ArduinoISP.ino b/ArduinoISP/ArduinoISP/ArduinoISP.ino index 1692db3c6..7f327e64c 100644 --- a/ArduinoISP/ArduinoISP/ArduinoISP.ino +++ b/ArduinoISP/ArduinoISP/ArduinoISP.ino @@ -552,7 +552,7 @@ char eeprom_read_page(int length) { int start = _addr*2; for (int x = 0; x < length; x++) { int addr = start +x; - byte ee = spi_transaction(0xA0, (addr >> 8) && 0xFF, addr && 0xFF, 0xFF); + byte ee = spi_transaction(0xA0, (addr >> 8) & 0xFF, addr & 0xFF, 0xFF); Serial.write( ee); } return STK_OK; From 95e99f2ef6102988225375ee55ec0423e7f15b37 Mon Sep 17 00:00:00 2001 From: Khairulmizam Samsudin Date: Wed, 15 Jun 2022 21:11:06 +0800 Subject: [PATCH 3/3] Fix word-based addressing for writing EEPROM --- ArduinoISP/ArduinoISP/ArduinoISP.ino | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/ArduinoISP/ArduinoISP/ArduinoISP.ino b/ArduinoISP/ArduinoISP/ArduinoISP.ino index 7f327e64c..e31449975 100644 --- a/ArduinoISP/ArduinoISP/ArduinoISP.ino +++ b/ArduinoISP/ArduinoISP/ArduinoISP.ino @@ -488,8 +488,10 @@ 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) + int start = _addr*2; for (int x = 0; x < length; x++) { - spi_transaction(0xC0, 0x00, _addr*2+x, buff[x]); + int addr = start + x; + spi_transaction(0xC0, (addr >> 8) & 0xFF, addr & 0xFF, buff[x]); delay(45); } return STK_OK; @@ -497,8 +499,9 @@ byte write_eeprom(int length) { void program_page() { byte result = STK_FAILED; - int length = 256 * getch() + getch(); - if (length > 256) { + unsigned int length = 256 * getch(); + length += getch(); + if (length > param.eepromsize) { Serial.write(STK_FAILED); error++; return;