Poll for BOOTSEL readiness instead of fixed sleep, load with -x

This commit is contained in:
Ian Gulliver
2026-04-06 09:19:26 +09:00
parent ee8563ab69
commit 1fa1b2076c
2 changed files with 27 additions and 17 deletions

View File

@@ -116,7 +116,19 @@ func run(buildDir string) error {
}
}
time.Sleep(2 * time.Second)
for i := range 2 {
wg.Add(1)
go func() {
defer wg.Done()
errs[i] = picotool.WaitForBootsel(serials[i], 10*time.Second)
}()
}
wg.Wait()
for i, err := range errs {
if err != nil {
return fmt.Errorf("wait %s: %w", serials[i], err)
}
}
uf2s := []string{
filepath.Join(buildDir, "picomap.uf2"),
@@ -138,21 +150,6 @@ func run(buildDir string) error {
}
}
fmt.Println("Rebooting...")
for i := range 2 {
wg.Add(1)
go func() {
defer wg.Done()
errs[i] = picotool.Reboot(serials[i])
}()
}
wg.Wait()
for i, err := range errs {
if err != nil {
return fmt.Errorf("reboot %s: %w", serials[i], err)
}
}
fmt.Println("Done.")
return nil
}