greatfet_firmware: include fw from official pypi

Include the latest cross-compiled firmware to match the host SW version.
This allows to use the standard `greatfet_firmware --autoflash` command
to perform the update. In addition it adds the DFU package for recovery
of a corrupt system.

Signed-off-by: Brian McGillion <bmg.avoin@gmail.com>
This commit is contained in:
Brian McGillion
2026-06-07 22:11:43 +04:00
parent d6461e376f
commit f016482361
@@ -2,6 +2,7 @@
buildPythonPackage,
cmsis-svd,
fetchFromGitHub,
fetchPypi,
ipython,
lib,
prompt-toolkit,
@@ -11,6 +12,7 @@
setuptools,
tabulate,
tqdm,
unzip,
}:
buildPythonPackage rec {
@@ -25,12 +27,36 @@ buildPythonPackage rec {
hash = "sha256-qXPNatakMVtvl26FG1bx+ngCeqRpg1So6qFamKK8WWk=";
};
# The prebuilt LPC firmware image (greatfet_usb.bin) and the DFU recovery
# stub (flash_stub.bin) are release artifacts cross-compiled from firmware/.
# They are absent from the git checkout (their build inputs are now-empty
# submodules) but are shipped in the upstream wheel. Without them
# `greatfet_firmware --autoflash` and DFU-mode firmware recovery are
# unavailable, so vendor them from the wheel to match `pip install greatfet`.
firmwareAssets = fetchPypi {
inherit pname version;
format = "wheel";
dist = "py3";
python = "py3";
hash = "sha256-sH1FAkfdC0HxRLZjfx7b2AYWMh4rtSijFgsU/YnVKq0=";
};
sourceRoot = "${src.name}/host";
nativeBuildInputs = [ unzip ];
postPatch = ''
substituteInPlace pyproject.toml \
--replace-fail ', "setuptools-git-versioning<2"' "" \
--replace-fail 'dynamic = ["version"]' 'version = "${version}"'
# Restore the prebuilt firmware images shipped in the upstream wheel; the
# existing MANIFEST.in (recursive-include greatfet/assets *) then packages
# them into greatfet/assets/ where find_greatfet_asset() looks at runtime.
unzip -j -o ${firmwareAssets} \
'greatfet/assets/greatfet_usb.bin' \
'greatfet/assets/flash_stub.bin' \
-d greatfet/assets/
'';
build-system = [ setuptools ];