How to build custom ESP32/ESPTool flasher stub

First, remember to not clone the espressif/esp-flasher-stub repo. While this will replace the “legacy” flasher stub at some point, it has not yet, at least as of 2025-08.

Instead, clone espressif/esptool-legacy-flasher-stub:

git clone --recursive https://github.com/espressif/esptool-legacy-flasher-stub.git

Now activate your ESP-IDF environment, e.g.

source ~/esp/v5.5/esp-idf/export.sh

Now go to the build directory:

cd esptool-legacy-flasher-stub/flasher-stub

Now you can build the stub using

make WITHOUT_ESP8266=1

Of course you can also build with ESP8266 support if you really need it, but for my ESP-IDF installation, this results in the following error:

  CC(8266)   stub_flasher.c slip.c stub_commands.c stub_write_flash.c stub_io.c miniz.c build ld/stub_8266.ld -> build/esp8266.elf
make: xtensa-lx106-elf-gcc: Datei oder Verzeichnis nicht gefunden
make: *** [Makefile:136: build/esp8266.elf] Fehler 127