mirror of
https://github.com/sanni/cartreader.git
synced 2024-11-15 01:15:06 +01:00
Flash: Add progress bar to read/verify/blankcheck flashrom
This commit is contained in:
parent
68ae4b7111
commit
dac242cd2f
@ -1526,7 +1526,15 @@ void eraseFlash29F1610() {
|
|||||||
// Set data pins to input again
|
// Set data pins to input again
|
||||||
dataIn8();
|
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
|
// Delay between write operations based on status register
|
||||||
@ -1857,17 +1865,34 @@ void writeFlashLH28F0XX() {
|
|||||||
Common flashrom functions
|
Common flashrom functions
|
||||||
*****************************************/
|
*****************************************/
|
||||||
void blankcheck_Flash() {
|
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;
|
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
|
// Check if all bytes are 0xFF
|
||||||
if (readByte_Flash(currByte) != 0xFF) {
|
for (uint32_t currByte = 0; currByte < 512; currByte++) {
|
||||||
currByte = flashSize;
|
if (sdBuffer[currByte] != 0xFF) {
|
||||||
|
currByte = 512;
|
||||||
|
currBuffer = flashSize;
|
||||||
blank = 0;
|
blank = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// Update progress bar
|
||||||
|
processedProgressBar += 512;
|
||||||
|
draw_progressbar(processedProgressBar, totalProgressBar);
|
||||||
|
// Blink led
|
||||||
|
if (currBuffer % 25600 == 0)
|
||||||
|
blinkLED();
|
||||||
|
}
|
||||||
if (blank) {
|
if (blank) {
|
||||||
println_Msg(F("Flashrom is empty"));
|
println_Msg(F("Flashrom is empty"));
|
||||||
display_Update();
|
display_Update();
|
||||||
@ -1898,6 +1923,11 @@ void verifyFlash(byte romChips) {
|
|||||||
fileSize = 0;
|
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) {
|
for (unsigned long currByte = 0; currByte < fileSize; currByte += 512) {
|
||||||
//fill sdBuffer
|
//fill sdBuffer
|
||||||
myFile.read(sdBuffer, 512);
|
myFile.read(sdBuffer, 512);
|
||||||
@ -1906,6 +1936,12 @@ void verifyFlash(byte romChips) {
|
|||||||
blank++;
|
blank++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// Update progress bar
|
||||||
|
processedProgressBar += 512;
|
||||||
|
draw_progressbar(processedProgressBar, totalProgressBar);
|
||||||
|
// Blink led
|
||||||
|
if (currByte % 25600 == 0)
|
||||||
|
blinkLED();
|
||||||
}
|
}
|
||||||
if (blank == 0) {
|
if (blank == 0) {
|
||||||
println_Msg(F("Flashrom verified OK"));
|
println_Msg(F("Flashrom verified OK"));
|
||||||
@ -1927,11 +1963,22 @@ void readFlash() {
|
|||||||
|
|
||||||
createFolderAndOpenFile("FLASH", NULL, "FL", "bin");
|
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 (unsigned long currByte = 0; currByte < flashSize; currByte += 512) {
|
||||||
for (int c = 0; c < 512; c++) {
|
for (int c = 0; c < 512; c++) {
|
||||||
sdBuffer[c] = readByte_Flash(currByte + c);
|
sdBuffer[c] = readByte_Flash(currByte + c);
|
||||||
}
|
}
|
||||||
myFile.write(sdBuffer, 512);
|
myFile.write(sdBuffer, 512);
|
||||||
|
// Update progress bar
|
||||||
|
processedProgressBar += 512;
|
||||||
|
draw_progressbar(processedProgressBar, totalProgressBar);
|
||||||
|
// Blink led
|
||||||
|
if (currByte % 25600 == 0)
|
||||||
|
blinkLED();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Close the file:
|
// Close the file:
|
||||||
|
Loading…
Reference in New Issue
Block a user