From 09d122369fb5bbec1bffa3a6568dc0b8f87921db Mon Sep 17 00:00:00 2001 From: sanni Date: Thu, 5 Apr 2018 16:47:19 +0200 Subject: [PATCH] V32A: Add verifying ST M27C322 Eproms (beta) --- Cart_Reader/Cart_Reader.ino | 6 ++--- Cart_Reader/FLASH.ino | 47 +++++++++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+), 3 deletions(-) diff --git a/Cart_Reader/Cart_Reader.ino b/Cart_Reader/Cart_Reader.ino index 1fb23d1..1e39524 100644 --- a/Cart_Reader/Cart_Reader.ino +++ b/Cart_Reader/Cart_Reader.ino @@ -2,8 +2,8 @@ Cartridge Reader for Arduino Mega2560 Author: sanni - Date: 2018-04-04 - Version: V32 + Date: 2018-05-04 + Version: V32A SD lib: https://github.com/greiman/SdFat LCD lib: https://github.com/adafruit/Adafruit_SSD1306 @@ -35,7 +35,7 @@ infinest - help with GB Memory cart **********************************************************************************/ -char ver[5] = "V32"; +char ver[5] = "V32A"; /****************************************** Define Starting Point diff --git a/Cart_Reader/FLASH.ino b/Cart_Reader/FLASH.ino index 65b744e..1436069 100644 --- a/Cart_Reader/FLASH.ino +++ b/Cart_Reader/FLASH.ino @@ -336,6 +336,7 @@ void epromMenu() { display_Clear(); time = millis(); write_Eprom(); + verify_Eprom(); break; case 3: @@ -1822,6 +1823,52 @@ void write_Eprom() { } } +void verify_Eprom() { + println_Msg(F("Verifying...")); + display_Update(); + + // Open file on sd card + if (myFile.open(filePath, O_READ)) { + // Get rom size from file + fileSize = myFile.fileSize(); + if (fileSize > flashSize) { + print_Error(F("File size exceeds flash size."), true); + } + + blank = 0; + word d = 0; + for (unsigned long currWord = 0; currWord < fileSize / 2; currWord += 256) { + //fill sdBuffer + myFile.read(sdBuffer, 512); + for (int c = 0; c < 256; c++) { + word myWord = ((sdBuffer[d + 1] << 8) | sdBuffer[d]); + + if (readWord_Eprom(currWord + c) != myWord) { + blank++; + } + d += 2; + } + d = 0; + } + if (blank == 0) { + println_Msg(F("Eprom verified OK")); + display_Update(); + } + else { + println_Msg(F("Verification ERROR!")); + print_Msg(blank); + print_Error(F("B did not verify."), false); + display_Update(); + } + // Close the file: + myFile.close(); + } + else { + println_Msg(F("Can't open file on SD.")); + display_Update(); + } +} + //****************************************** // End of File //******************************************