Class Esptool

java.lang.Object
org.emrick.project.dev.Esptool

public final class Esptool extends Object
Locates (or downloads once) Espressif's esptool and uses it to flash receivers. Order of preference: the esptool bundled with an existing PlatformIO install (no download), then a standalone esptool previously downloaded into the Emrick Designer folder, then a one-time download of the standalone build from Espressif's GitHub releases. Downloads are pinned to a version and checked against Espressif's published SHA-256 digests.
  • Field Details

  • Constructor Details

    • Esptool

      private Esptool()
  • Method Details

    • isWindows

      public static boolean isWindows()
    • command

      public static List<String> command(Consumer<String> status) throws IOException
      Parameters:
      status - receives short progress messages (e.g. while downloading)
      Returns:
      the command prefix that runs esptool (e.g. [path/esptool.exe] or [python, esptool.py])
      Throws:
      IOException
    • fromPlatformIO

      private static List<String> fromPlatformIO()
      Returns:
      the esptool that ships with PlatformIO, if PlatformIO is installed
    • findExecutable

      private static File findExecutable(File dir)
    • assetForPlatform

      private static Esptool.Asset assetForPlatform() throws IOException
      Throws:
      IOException
    • download

      private static void download(File dir, Consumer<String> status) throws IOException
      Throws:
      IOException
    • unzip

      private static void unzip(File zip, File dir) throws IOException
      Throws:
      IOException
    • flash

      public static boolean flash(String systemPortName, FirmwareRelease release, Consumer<Integer> progress, Consumer<String> log) throws IOException
      Flashes a release to one receiver. Only the app, bootloader, and partition table regions are written, so the unit's stored data (board ID, label, show) is kept.
      Parameters:
      progress - receives 0-100 for the firmware image
      log - receives every line esptool prints
      Returns:
      true if esptool reported success
      Throws:
      IOException
    • portPath

      private static String portPath(String systemPortName)
      esptool wants a device path on macOS/Linux (e.g. /dev/cu.usbserial-0001) and the plain name on Windows.