ESP32:如何构建自定义 ESPTool flasher stub

首先,记住不要克隆 espressif/esp-flasher-stub 仓库。虽然它最终会替代"legacy" flasher stub,但截至 2025-08 还没有。

相反,克隆 espressif/esptool-legacy-flasher-stub

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

现在激活你的 ESP-IDF 环境,例如:

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

现在进入构建目录:

cd_flashing_stub_builddir.sh
cd esptool-legacy-flasher-stub/flasher-stub

现在你可以使用以下命令构建 stub:

make_build_stub.sh
make WITHOUT_ESP8266=1

当然,如果你确实需要,也可以构建带 ESP8266 支持的版本,但对于我的 ESP-IDF 安装,这会导致以下错误:

build_error_output.txt
  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

Check out similar posts by category: ESP32