Add progressbar to flashrom programmer

Only tested with 29F032 and 29LV640 but should still work for all since it was just copy&paste.
This commit is contained in:
sanni 2024-06-30 11:36:33 +02:00
parent f798336aaa
commit fd2c332ea9
3 changed files with 68 additions and 3 deletions

View File

@ -4,8 +4,8 @@
This project represents a community-driven effort to provide This project represents a community-driven effort to provide
an easy to build and easy to modify cartridge dumper. an easy to build and easy to modify cartridge dumper.
Date: 2024-06-26 Date: 2024-06-30
Version: 13.3 Version: 13.4
SD lib: https://github.com/greiman/SdFat SD lib: https://github.com/greiman/SdFat
LCD lib: https://github.com/olikraus/u8g2 LCD lib: https://github.com/olikraus/u8g2

View File

@ -1266,6 +1266,12 @@ void writeFlash29F032() {
// Retry writing, for when /RESET is not connected (floating) // Retry writing, for when /RESET is not connected (floating)
int dq5failcnt = 0; int dq5failcnt = 0;
int noread = 0; int noread = 0;
//Initialize progress bar
uint32_t processedProgressBar = 0;
uint32_t totalProgressBar = (uint32_t)fileSize;
draw_progressbar(0, totalProgressBar);
// Fill sdBuffer // Fill sdBuffer
for (unsigned long currByte = 0; currByte < fileSize; currByte += 512) { for (unsigned long currByte = 0; currByte < fileSize; currByte += 512) {
// if (currByte >= 0) { // if (currByte >= 0) {
@ -1314,6 +1320,9 @@ void writeFlash29F032() {
} else { } else {
noread = 0; noread = 0;
} }
// update progress bar
processedProgressBar += 512;
draw_progressbar(processedProgressBar, totalProgressBar);
} }
// Set data pins to input again // Set data pins to input again
dataIn8(); dataIn8();
@ -1384,6 +1393,11 @@ void writeFlash29F1610() {
// Set data pins to output // Set data pins to output
dataOut(); dataOut();
//Initialize progress bar
uint32_t processedProgressBar = 0;
uint32_t totalProgressBar = (uint32_t)fileSize;
draw_progressbar(0, totalProgressBar);
for (unsigned long currByte = 0; currByte < fileSize; currByte += 128) { for (unsigned long currByte = 0; currByte < fileSize; currByte += 128) {
// Fill sdBuffer with 1 page at a time then write it repeat until all bytes are written // Fill sdBuffer with 1 page at a time then write it repeat until all bytes are written
myFile.read(sdBuffer, 128); myFile.read(sdBuffer, 128);
@ -1403,6 +1417,9 @@ void writeFlash29F1610() {
for (byte c = 0; c < 128; c++) { for (byte c = 0; c < 128; c++) {
writeByte_Flash(currByte + c, sdBuffer[c]); writeByte_Flash(currByte + c, sdBuffer[c]);
} }
// update progress bar
processedProgressBar += 128;
draw_progressbar(processedProgressBar, totalProgressBar);
} }
// Check if write is complete // Check if write is complete
@ -1422,6 +1439,11 @@ void writeFlash29F1601() {
// Set data pins to output // Set data pins to output
dataOut(); dataOut();
//Initialize progress bar
uint32_t processedProgressBar = 0;
uint32_t totalProgressBar = (uint32_t)fileSize;
draw_progressbar(0, totalProgressBar);
for (unsigned long currByte = 0; currByte < fileSize; currByte += 128) { for (unsigned long currByte = 0; currByte < fileSize; currByte += 128) {
// Fill sdBuffer with 1 page at a time then write it repeat until all bytes are written // Fill sdBuffer with 1 page at a time then write it repeat until all bytes are written
myFile.read(sdBuffer, 128); myFile.read(sdBuffer, 128);
@ -1446,6 +1468,9 @@ void writeFlash29F1601() {
writeByte_Flash(currByte + c, sdBuffer[c]); writeByte_Flash(currByte + c, sdBuffer[c]);
} }
} }
// update progress bar
processedProgressBar += 128;
draw_progressbar(processedProgressBar, totalProgressBar);
} }
// Check if write is complete // Check if write is complete
@ -1542,6 +1567,11 @@ void writeFlash29LV640() {
// Set data pins to output // Set data pins to output
dataOut(); dataOut();
//Initialize progress bar
uint32_t processedProgressBar = 0;
uint32_t totalProgressBar = (uint32_t)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);
@ -1558,6 +1588,9 @@ void writeFlash29LV640() {
// Check if write is complete // Check if write is complete
busyCheck29LV640(currByte + c, sdBuffer[c]); busyCheck29LV640(currByte + c, sdBuffer[c]);
} }
// update progress bar
processedProgressBar += 512;
draw_progressbar(processedProgressBar, totalProgressBar);
} }
// Set data pins to input again // Set data pins to input again
dataIn8(); dataIn8();
@ -1574,6 +1607,11 @@ void writeFlash29GL(unsigned long sectorSize, byte bufferSize) {
// Set data pins to output // Set data pins to output
dataOut(); dataOut();
//Initialize progress bar
uint32_t processedProgressBar = 0;
uint32_t totalProgressBar = (uint32_t)fileSize;
draw_progressbar(0, totalProgressBar);
for (unsigned long currSector = 0; currSector < fileSize; currSector += sectorSize) { for (unsigned long currSector = 0; currSector < fileSize; currSector += sectorSize) {
// Blink led // Blink led
blinkLED(); blinkLED();
@ -1610,6 +1648,9 @@ void writeFlash29GL(unsigned long sectorSize, byte bufferSize) {
dataOut(); dataOut();
} }
} }
// update progress bar
processedProgressBar += sectorSize;
draw_progressbar(processedProgressBar, totalProgressBar);
} }
// Set data pins to input again // Set data pins to input again
dataIn8(); dataIn8();
@ -1626,6 +1667,11 @@ void writeFlash29F800() {
// Set data pins to output // Set data pins to output
dataOut(); dataOut();
//Initialize progress bar
uint32_t processedProgressBar = 0;
uint32_t totalProgressBar = (uint32_t)fileSize;
draw_progressbar(0, totalProgressBar);
// Fill sdBuffer // Fill sdBuffer
for (unsigned long currByte = 0; currByte < fileSize; currByte += 512) { for (unsigned long currByte = 0; currByte < fileSize; currByte += 512) {
myFile.read(sdBuffer, 512); myFile.read(sdBuffer, 512);
@ -1640,6 +1686,9 @@ void writeFlash29F800() {
writeByte_Flash(currByte + c, sdBuffer[c]); writeByte_Flash(currByte + c, sdBuffer[c]);
busyCheck29F032(currByte + c, sdBuffer[c]); busyCheck29F032(currByte + c, sdBuffer[c]);
} }
// update progress bar
processedProgressBar += 512;
draw_progressbar(processedProgressBar, totalProgressBar);
} }
// Set data pins to input again // Set data pins to input again
@ -1713,6 +1762,11 @@ void writeFlashE28FXXXJ3A() {
uint32_t block_addr; uint32_t block_addr;
uint32_t block_addr_mask = ~(sectorSize - 1); uint32_t block_addr_mask = ~(sectorSize - 1);
//Initialize progress bar
uint32_t processedProgressBar = 0;
uint32_t totalProgressBar = (uint32_t)fileSize;
draw_progressbar(0, totalProgressBar);
// Fill sdBuffer // Fill sdBuffer
for (uint32_t currByte = 0; currByte < fileSize; currByte += 512) { for (uint32_t currByte = 0; currByte < fileSize; currByte += 512) {
myFile.read(sdBuffer, 512); myFile.read(sdBuffer, 512);
@ -1749,6 +1803,9 @@ void writeFlashE28FXXXJ3A() {
while ((readByte_Flash(block_addr) & 0x80) == 0x00) while ((readByte_Flash(block_addr) & 0x80) == 0x00)
; ;
} }
// update progress bar
processedProgressBar += 512;
draw_progressbar(processedProgressBar, totalProgressBar);
} }
dataIn8(); dataIn8();
@ -1756,6 +1813,11 @@ void writeFlashE28FXXXJ3A() {
void writeFlashLH28F0XX() { void writeFlashLH28F0XX() {
//Initialize progress bar
uint32_t processedProgressBar = 0;
uint32_t totalProgressBar = (uint32_t)fileSize;
draw_progressbar(0, totalProgressBar);
// Fill sdBuffer // Fill sdBuffer
for (uint32_t currByte = 0; currByte < fileSize; currByte += 512) { for (uint32_t currByte = 0; currByte < fileSize; currByte += 512) {
myFile.read(sdBuffer, 512); myFile.read(sdBuffer, 512);
@ -1783,6 +1845,9 @@ void writeFlashLH28F0XX() {
while ((readByte_Flash(currByte + c) & 0x80) == 0x00) while ((readByte_Flash(currByte + c) & 0x80) == 0x00)
; ;
} }
// update progress bar
processedProgressBar += 512;
draw_progressbar(processedProgressBar, totalProgressBar);
} }
dataIn8(); dataIn8();

View File

@ -49,7 +49,7 @@
* String Constants * String Constants
**/ **/
// Firmware Version // Firmware Version
constexpr char PROGMEM FSTRING_VERSION[] = "V13.3"; constexpr char PROGMEM FSTRING_VERSION[] = "V13.4";
// Universal // Universal
constexpr char PROGMEM FSTRING_RESET[] = "Reset"; constexpr char PROGMEM FSTRING_RESET[] = "Reset";