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('