Skip to content

Commit

Permalink
Flash: Add progress bar to read/verify/blankcheck flashrom
Browse files Browse the repository at this point in the history
  • Loading branch information
sanni committed Jul 19, 2024
1 parent 68ae4b7 commit dac242c
Showing 1 changed file with 54 additions and 7 deletions.
61 changes: 54 additions & 7 deletions Cart_Reader/FLASH.ino
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"));
Expand Down Expand Up @@ -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);
Expand All @@ -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"));
Expand All @@ -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:
Expand Down

0 comments on commit dac242c

Please sign in to comment.