Poll for BOOTSEL readiness instead of fixed sleep, load with -x
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user