From 7054eb974f31831d76c2feaa6a83f53197eb933e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bruno=20Ryb=C3=A1rsky?= Date: Mon, 23 Nov 2026 22:01:43 +0100 Subject: [PATCH] Patch U-Boot env for a standalone full image env-patch.py edits a U-Boot env image (CRC32 + NUL-separated vars), used to bake mtdparts, the SD-update bootcmd and the build id into full.bin. Co-Authored-By: Claude Opus 5.5 --- toolkit/env-patch.py | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100755 toolkit/env-patch.py diff --git a/toolkit/env-patch.py b/toolkit/env-patch.py new file mode 100755 index 0000000..2f6413d --- /dev/null +++ b/toolkit/env-patch.py @@ -0,0 +1,26 @@ +#!/usr/bin/env python3 +"""env-patch.py IN OUT KEY=VALUE ... : set variables in a U-Boot env image +(non-redundant: CRC32 LE of the data area, then NUL-separated vars, 00-padded). +An empty VALUE deletes the variable. Size is kept; fails if it no longer fits.""" +import sys, struct, zlib +src, dst, sets = sys.argv[1], sys.argv[2], sys.argv[3:] +d = open(src, 'rb').read() +size = len(d) +if struct.unpack(' size - 4: + sys.exit(f'env too big: {len(data)} > {size - 4}') +data += b'\x00' * (size - 4 - len(data)) +open(dst, 'wb').write(struct.pack('