main: update to espflasher 0.7.1 and add flash erase progress tracker

Signed-off-by: deadprogram <ron@hybridgroup.com>
This commit is contained in:
deadprogram
2026-07-14 00:34:08 +02:00
committed by Ron Evans
parent 0a9b3f91bc
commit 2602d4c25d
3 changed files with 20 additions and 23 deletions
+11 -11
View File
@@ -1122,6 +1122,15 @@ const (
jtagReset = "jtag"
)
var progressFunc = func(current, total int) {
pct := float64(current) / float64(total) * 100
bar := int(pct / 2)
fmt.Printf("\r[%-50s] %6.1f%%", strings.Repeat("#", bar)+strings.Repeat(".", 50-bar), pct)
if current >= total {
fmt.Println()
}
}
func flashBinUsingEsp32(port, resetMode, tmppath string, options *compileopts.Options) error {
opts := espflasher.DefaultOptions()
opts.Compress = true
@@ -1152,21 +1161,12 @@ func flashBinUsingEsp32(port, resetMode, tmppath string, options *compileopts.Op
return err
}
if err := flasher.EraseFlash(); err != nil {
if err := flasher.EraseFlash(progressFunc); err != nil {
return fmt.Errorf("erase failed: %v", err)
}
progress := func(current, total int) {
pct := float64(current) / float64(total) * 100
bar := int(pct / 2)
fmt.Printf("\r[%-50s] %6.1f%%", strings.Repeat("#", bar)+strings.Repeat(".", 50-bar), pct)
if current >= total {
fmt.Println()
}
}
// Flash with progress reporting
err = flasher.FlashImage(data, offset, progress)
err = flasher.FlashImage(data, offset, progressFunc)
if err != nil {
return err
}