75.2. python3-esptool-5.4.0
Talk to the ESP8266 and ESP32 ROM bootloader over serial
| Version | 5.4.0, release 1 |
| Shelf | python-hw — python3-* hardware, serial, USB, instrument, CAN and device-protocol modules |
| Phase | 40_lang (Languages), 82 of 186 in build order |
| Licence | GPL-2.0-or-later AND MIT AND BSD-2-Clause AND BSD-3-Clause AND Apache-2.0 AND PSF-2.0 AND (Unlicense OR MIT-0) |
| Homepage | https://github.com/espressif/esptool |
| Build time | 0.5 SBU |
| Installed size | 8.9 MiB in 604 files |
| Recipe | ports/core/python-hw/python3-esptool/kpkgbuild |
About
esptool talks to the ROM bootloader of Espressif’s ESP8266 and ESP32 chips over a serial line: it reads chip information, and writes, reads and erases flash. The bootloader is in mask ROM, so a chip with nothing valid in flash still answers it. The package also installs espefuse and espsecure, for the chips’ eFuses and for flash encryption and secure-boot signing, and esp_rfc2217_server, which serves a local serial port over the network (RFC 2217). meshtastic-firmware depends on it. The serial adapter is reached through the dialout group; see The device groups and the udev rules.
Why it is in KDOS
The comment above it in script/phases/40_lang/packages.d/python-hw.txt:
The ESP ROM bootloader is in mask ROM and cannot be bricked, which is what makes esptool the one flashing tool that always answers.
Sources
python3-esptool-5.4.0.tar.gz(501.5 KiB)
sha256fd756598db0a26c9975fa18511b08687c54bf2ce7322ede80cf1f5117dad1f50
upstream: https://files.pythonhosted.org/packages/source/e/esptool/esptool-5.4.0.tar.gz
archive copy: sources-4/python-hw--python3-esptool-5.4.0.tar.gzpython3-esptool-vendor-5.4.0.tar.xz(11.9 MiB)
sha25682077d588e62a2644bc2db194eecb4bbf40fd0be98398a8308f479e2676b1c54
a vendor bundle: the dependencies upstream’s own tool would download, packed once
archive copy: sources-4/python-hw--python3-esptool-vendor-5.4.0.tar.xz
Dependencies
Depends on: python3, python3-setuptools, python3-pip, python3-pyserial, python3-cryptography, python3-yaml, python3-pygments, python3-click, python3-rich.
Required by (1): meshtastic-firmware.
Installation
From the repository root, inside the build container, this is the line kdosbuild runs for the port:
script/chroot/exec.sh bash -c 'source script/phases/40_lang/phase.env && kpkg install python3-esptool'
What kpkg does
kpkg runs these steps, in this order, as root inside the chroot. The port directory is /ports/core/python-hw/python3-esptool.
1. Verify every declared source. Each file a sha256 = line names, found in the port directory or in /var/cache/kpkg/sources, must hash to its line; a mismatch stops the build before anything is unpacked.
cd /ports/core/python-hw/python3-esptool
echo 'fd756598db0a26c9975fa18511b08687c54bf2ce7322ede80cf1f5117dad1f50 python3-esptool-5.4.0.tar.gz' | sha256sum -c -
echo '82077d588e62a2644bc2db194eecb4bbf40fd0be98398a8308f479e2676b1c54 python3-esptool-vendor-5.4.0.tar.xz' | sha256sum -c -
2. Unpack. The work directory is emptied and the first source is unpacked into $SRC with its top directory stripped; any later tarball lands unstripped beside it in $SRC_ROOT, and a file that is not a tarball is copied into $SRC.
SRC_ROOT=/var/cache/kpkg/work/python3-esptool
SRC=$SRC_ROOT/python3-esptool-5.4.0
PKG=$SRC_ROOT/pkg
rm -rf "$SRC_ROOT"
mkdir -p "$SRC" "$PKG"
tar --no-same-permissions --warning=no-unknown-keyword -xf python3-esptool-5.4.0.tar.gz -C "$SRC" --strip-components=1
Every config.guess and config.sub older than automake’s is then replaced with automake’s, so a configure script recognises the musl target.
3. Build. build.sh is sourced in a subshell under set -e, from $SRC, with name, version, release and the recipe’s helpers pyrequirements, pyruntime and the five paths PKGNAME, PORT_SRC, SRC_ROOT, SRC and PKG set as shell variables. Its body, verbatim:
mkdir -p vendor
tar -xf $PORT_SRC/$name-vendor-$version.tar.xz --strip-components=1 -C vendor
BUILD_EXTENSION=yes pip3 install --ignore-installed --no-deps --no-index --find-links=vendor --root=$PKG --prefix=/usr \
bitarray bitstring esp-pylib intelhex reedsolo rich-click websockets .
The switches, and why each is set:
BUILD_EXTENSION=yes— Read by websockets’setup.py: build its Cspeedupsextension and stop if it does not compile. Unset, the extension is optional, and a failed compile leaves pure-Python websockets with only a warning in the build log.
The common switches of each build system are explained in the Flag glossary.
4. Package. kpkg removes libtool archives, the info directory index, mimeinfo.cache and every fonts.dir from $PKG, copies the source’s licence files into /usr/share/licenses/python3-esptool, prunes what the image does not ship, lints the tree and rolls it reproducibly:
tar --sort=name --format=gnu --numeric-owner --owner=0 --group=0 \
--mtime=@$SOURCE_DATE_EPOCH \
--use-compress-program='xz -9 -T0 --block-size=32MiB --no-adjust' \
-cf python3-esptool-5.4.0-1.tar.xz -C "$PKG" .
5. Adopt. kpkgadd installs the package’s files over the root, refusing a path another package owns, records the file list in /var/lib/kpkg/db/python3-esptool, and runs the triggers its paths call for.
Contents
Installed programs: bin2hex.py, esp_rfc2217_server, esp_rfc2217_server.py, espefuse, espefuse.py, espsecure, espsecure.py, esptool, esptool.py, hex2bin.py, hex2dump.py, hexdiff.py, hexinfo.py, hexmerge.py, rich-click, websockets.
Installed directories: /usr/lib/python3.14/site-packages/bitarray, /usr/lib/python3.14/site-packages/bitarray-3.11.0.dist-info, /usr/lib/python3.14/site-packages/bitstring, /usr/lib/python3.14/site-packages/bitstring-4.3.1.dist-info, /usr/lib/python3.14/site-packages/esp_pylib, /usr/lib/python3.14/site-packages/esp_pylib-1.1.5.dist-info, /usr/lib/python3.14/site-packages/esp_rfc2217_server, /usr/lib/python3.14/site-packages/espefuse, /usr/lib/python3.14/site-packages/espsecure, /usr/lib/python3.14/site-packages/esptool, /usr/lib/python3.14/site-packages/esptool-5.4.0.dist-info, /usr/lib/python3.14/site-packages/intelhex, /usr/lib/python3.14/site-packages/intelhex-2.3.0.dist-info, /usr/lib/python3.14/site-packages/reedsolo-1.7.0.dist-info, /usr/lib/python3.14/site-packages/rich_click, /usr/lib/python3.14/site-packages/rich_click-1.9.9.dist-info, /usr/lib/python3.14/site-packages/websockets, /usr/lib/python3.14/site-packages/websockets-17.1.dist-info, /usr/share/licenses/python3-esptool.
Notes
The pip install line installs, with --no-deps, esptool itself and the seven distributions of its runtime closure that are not ports: bitarray, bitstring, esp-pylib, intelhex, reedsolo, rich-click and websockets, all from the vendor bundle that pypackages describes. pyserial, cryptography, PyYAML, Pygments, click and rich are ports in depends; PyYAML and Pygments are named in pypackages as well, so the bundle carries their sdists too, and pip installs neither. See The three Python keys.
Build isolation stays on, pointed at the bundle: it also carries the build backends those sdists name (setuptools, setuptools-scm, hatchling, poetry-core, flit_core, Cython and their own requirements), and pip installs them into each sdist’s temporary build environment, never into the package. pypackages pins bitstring to one release.