Hi Petr, On 2026-10-10T14:24:46, Petr Hodina via B4 Relay <[email protected]> wrote: > binman: fit: Actually compress generated fdt images > > Reads the node's "compression" property while generating each fdt > node and actually compresses the data before writing it when the value > isn't "none". Only "lzma" is implemented for now.
Please can you put the problem first? Binman requires 100% test coverage for each commit, so you could squash patches 2 and 3 into this one. > > Signed-off-by: Petr Hodina <[email protected]> > > tools/binman/etype/fit.py | 12 ++++++++++++ > 1 file changed, 12 insertions(+) > diff --git a/tools/binman/etype/fit.py b/tools/binman/etype/fit.py > @@ -13,6 +13,7 @@ import os > > from binman.entry import Entry, EntryArg > from binman.etype.section import Entry_section > +from binman import bintool > from binman import elf Please put this with the other 'from binman import' lines in alphabetical order, i.e. before 'from binman import elf'. > diff --git a/tools/binman/etype/fit.py b/tools/binman/etype/fit.py > @@ -922,6 +926,14 @@ class Entry_fit(Entry_section): > + if compression != 'none': > + if compression != 'lzma': > + self.Raise( > + "Unsupported fdt compression " > + f"'{compression}' (only 'lzma' is " > + "implemented)") > + comp = bintool.Bintool.create('lzma_alone') > + data = comp.compress(data) Creating the bintool on the fly bypasses AddBintools(), so 'binman tool -l' and 'binman tool -f missing' don't know that this FIT needs lzma_alone. It also skips the missing-tool handling: if lzma_alone is not installed, run_cmd() returns None, so compress() returns None and fsw.property('data', None) fails with a Python traceback instead of the usual 'missing bintool' warning. Please can you follow what Entry.CompressData() does: check is_present(), call record_missing_bintool() if the tool is absent, and add a test for that case. To register the tool you could scan the generator nodes for a 'compression' property in AddBintools(), or just add lzma_alone there unconditionally, as is done for mkimage and fdtgrep. Also, why limit this to lzma? Entry.AddBintools() already maps every algorithm binman supports to a bintool ({'lzma': 'lzma_alone', 'lzo': 'lzop'}, otherwise the same name), and SPL can load gzip-compressed images as well as lzma ones. It should be easy to factor out that mapping and support any algorithm, raising an error only for unknown names. What do you think? Finally, please can you update the generator-node documentation in the Entry_fit docstring (and regenerate entries.rst) to say that 'compression' in an @fdt-SEQ image node now causes the .dtb to be compressed? Regards, Simon
