Batch Flash Multiple Boards

Medium Shell Build Asked at Tesla
Solve this problem

Write a shell script that flashes every connected board in parallel, bounded to a maximum concurrency, and reports which serial numbers failed.

Constraints

  • Board serials are read one per line from a file given as the first argument.
  • Maximum 4 concurrent flash operations.
  • Each flash is `flash_tool --serial <serial>`.
  • Exit non-zero if any board failed.
  • Print a summary listing failed serials.
  • POSIX sh compatible; no bashisms beyond wait.
Starter codeShell
1#!/bin/sh2# TODO: parallel flash with bounded concurrency