Improve progress reporting in firmware flashing by adjusting the calculation of overall percentage to account for uncompressed image size. Update console log messages to clarify the reporting of compressed stream data during the flashing process.

This commit is contained in:
Ben Allfree
2026-04-10 17:57:11 -07:00
parent a298086999
commit 8a527530aa
+6 -2
View File
@@ -167,7 +167,11 @@ export async function runEspFlash(options: {
reportProgress: (i, written, total) => {
let offset = 0
for (let j = 0; j < i; j++) offset += lengths[j] ?? 0
const overallPct = totalBytes > 0 ? Math.min(100, Math.round((100 * (offset + written)) / totalBytes)) : 0
const uncSize = lengths[i] ?? 0
// Callback counts deflated bytes; scale by uncompressed image size for the bar.
const streamFrac = total > 0 ? written / total : 0
const overallBytes = offset + streamFrac * uncSize
const overallPct = totalBytes > 0 ? Math.min(100, Math.round((100 * overallBytes) / totalBytes)) : 0
onWriteProgress?.({
imageIndex: i,
imageCount: fileArray.length,
@@ -181,7 +185,7 @@ export async function runEspFlash(options: {
lastProgressLogImage = i
lastProgressLogDecile = decile
console.log(
`[esptool] flash image ${i + 1}/${fileArray.length}: ${written}/${total} bytes (${overallPct}% overall)`
`[esptool] flash image ${i + 1}/${fileArray.length}: compressed stream ${written}/${total} bytes, ${overallPct}% overall (uncompressed-weighted)`
)
}
},