diff options
author | sanni <[email protected]> | 2024-07-19 22:18:22 +0200 |
---|---|---|
committer | sanni <[email protected]> | 2024-07-19 22:18:22 +0200 |
commit | dac242cd2f3e71490ec5fc3b7d35eadeadd0f420 (patch) | |
tree | 66be22ade170b83cc91c7900430f1f30ceb77a7f /Cart_Reader/FLASH.ino | |
parent | 68ae4b711100e2386a6d85f8225151853188459c (diff) | |
download | cartreader-dac242cd2f3e71490ec5fc3b7d35eadeadd0f420.tar.gz cartreader-dac242cd2f3e71490ec5fc3b7d35eadeadd0f420.zip |
Flash: Add progress bar to read/verify/blankcheck flashrom
Diffstat (limited to 'Cart_Reader/FLASH.ino')
-rw-r--r-- | Cart_Reader/FLASH.ino | 61 |
1 files changed, 54 insertions, 7 deletions
diff --git a/Cart_Reader/FLASH.ino b/Cart_Reader/FLASH.ino index 48568df..f0788e0 100644 --- a/Cart_Reader/FLASH.ino +++ b/Cart_Reader/FLASH.ino @@ -1526,7 +1526,15 @@ void eraseFlash29F1610() { // Set data pins to input again
dataIn8();
- busyCheck29F1610();
+ // Read the status register
+ byte statusReg = readByte_Flash(0);
+
+ while ((statusReg & 0x80) != 0x80) {
+ statusReg = readByte_Flash(0);
+ // Blink led
+ blinkLED();
+ delay(100);
+ }
}
// Delay between write operations based on status register
@@ -1857,16 +1865,33 @@ void writeFlashLH28F0XX() { Common flashrom functions
*****************************************/
void blankcheck_Flash() {
- println_Msg(F("Please wait..."));
- display_Update();
+
+ //Initialize progress bar
+ uint32_t processedProgressBar = 0;
+ uint32_t totalProgressBar = flashSize;
+ draw_progressbar(0, totalProgressBar);
blank = 1;
- for (unsigned long currByte = 0; currByte < flashSize; currByte++) {
+ for (unsigned long currBuffer = 0; currBuffer < flashSize; currBuffer += 512) {
+ // Fill buffer
+ for (int c = 0; c < 512; c++) {
+ // Read byte
+ sdBuffer[c] = readByte_Flash(currBuffer + c);
+ }
// Check if all bytes are 0xFF
- if (readByte_Flash(currByte) != 0xFF) {
- currByte = flashSize;
- blank = 0;
+ for (uint32_t currByte = 0; currByte < 512; currByte++) {
+ if (sdBuffer[currByte] != 0xFF) {
+ currByte = 512;
+ currBuffer = flashSize;
+ blank = 0;
+ }
}
+ // Update progress bar
+ processedProgressBar += 512;
+ draw_progressbar(processedProgressBar, totalProgressBar);
+ // Blink led
+ if (currBuffer % 25600 == 0)
+ blinkLED();
}
if (blank) {
println_Msg(F("Flashrom is empty"));
@@ -1898,6 +1923,11 @@ void verifyFlash(byte romChips) { fileSize = 0;
}
+ //Initialize progress bar
+ uint32_t processedProgressBar = 0;
+ uint32_t totalProgressBar = fileSize;
+ draw_progressbar(0, totalProgressBar);
+
for (unsigned long currByte = 0; currByte < fileSize; currByte += 512) {
//fill sdBuffer
myFile.read(sdBuffer, 512);
@@ -1906,6 +1936,12 @@ void verifyFlash(byte romChips) { blank++;
}
}
+ // Update progress bar
+ processedProgressBar += 512;
+ draw_progressbar(processedProgressBar, totalProgressBar);
+ // Blink led
+ if (currByte % 25600 == 0)
+ blinkLED();
}
if (blank == 0) {
println_Msg(F("Flashrom verified OK"));
@@ -1927,11 +1963,22 @@ void readFlash() { createFolderAndOpenFile("FLASH", NULL, "FL", "bin");
+ //Initialize progress bar
+ uint32_t processedProgressBar = 0;
+ uint32_t totalProgressBar = flashSize;
+ draw_progressbar(0, totalProgressBar);
+
for (unsigned long currByte = 0; currByte < flashSize; currByte += 512) {
for (int c = 0; c < 512; c++) {
sdBuffer[c] = readByte_Flash(currByte + c);
}
myFile.write(sdBuffer, 512);
+ // Update progress bar
+ processedProgressBar += 512;
+ draw_progressbar(processedProgressBar, totalProgressBar);
+ // Blink led
+ if (currByte % 25600 == 0)
+ blinkLED();
}
// Close the file:
|