Update FLASH.ino

This commit is contained in:
sanni 2024-08-09 12:37:55 +02:00
parent 70e450afd7
commit 3c04277d98

View File

@ -2067,7 +2067,7 @@ void verifyFlash(byte currChip, byte totalChips, boolean reversed) {
blank = 0; blank = 0;
// Adjust filesize to fit flashchip // Adjust filesize to fit flashchip
adjustFileSize(currChip, totalChips, reversed); adjustFileSizeOffset(currChip, totalChips, reversed);
//Initialize progress bar //Initialize progress bar
uint32_t processedProgressBar = 0; uint32_t processedProgressBar = 0;
@ -2857,19 +2857,30 @@ void identifyCFI_Flash() {
display_Update(); display_Update();
} }
// Adjust file size to fit flash chip // Adjust file size to fit flash chip and goto needed file offset
void adjustFileSize(byte currChip, byte totalChips, boolean reversed) { void adjustFileSizeOffset(byte currChip, byte totalChips, boolean reversed) {
// 1 flash chip // 1*2MB, 1*4MB or 1*8MB
if ((currChip == 1) && (totalChips == 1) && reversed) { if ((currChip == 1) && (totalChips == 1)) {
myFile.seekSet(4194304); if (reversed)
myFile.seekSet(4194304);
} }
// 2 flash chips
// 2*2MB or 2*4MB
else if ((currChip == 1) && (totalChips == 2)) { else if ((currChip == 1) && (totalChips == 2)) {
if (fileSize > flashSize / 2) if (reversed) {
fileSize = fileSize - flashSize / 2;
myFile.seekSet(4194304);
} else if (fileSize > flashSize / 2)
fileSize = flashSize / 2; fileSize = flashSize / 2;
} else if ((currChip == 2) && (totalChips == 2) && (fileSize > flashSize / 2)) {
fileSize = fileSize - flashSize / 2; } else if ((currChip == 2) && (totalChips == 2)) {
myFile.seekSet(flashSize / 2); if (reversed) {
fileSize = flashSize / 2;
myFile.seekSet(0);
} else if (fileSize > flashSize / 2) {
fileSize = fileSize - flashSize / 2;
myFile.seekSet(flashSize / 2);
}
} }
// 4*2MB // 4*2MB
@ -2966,7 +2977,7 @@ void writeCFI_Flash(byte currChip, byte totalChips, boolean reversed) {
} }
// Adjust filesize to fit flashchip // Adjust filesize to fit flashchip
adjustFileSize(currChip, totalChips, reversed); adjustFileSizeOffset(currChip, totalChips, reversed);
print_Msg(F("Writing flash")); print_Msg(F("Writing flash"));