Re: [PATCH v2 09/10] fdtfactor: Support compressed DTB inputs and outputs
From: Simon Glass
Date: Fri Oct 30 2026 - 08:52:54 EST
On 2026-10-28T21:46:49, Douglas Anderson <dianders@xxxxxxxxxxxx> wrote:
> fdtfactor: Support compressed DTB inputs and outputs
>
> Firmware and FIT image build pipelines frequently store device tree
> blobs compressed with LZ4, LZMA/XZ, or gzip (e.g., `.dtb.lz4`).
>
> Extend `fdtfactor` to detect compressed input blobs by magic bytes or
> file extension, transparently decompress them before factoring, and
> compress the resulting `.dtbo` and `base.dtb` outputs when appropriate:
>
> - Support `.lz4` (including legacy `-l` frames via the `lz4` CLI),
> `.lzma`/`.xz` (via Python's `lzma` module, using `CHECK_CRC32` for XZ
> compatibility with kernel/bootloader decompressors), and `.gz` (via
> Python's `gzip` module).
> - Preserve the input compression format on generated `.dtbo` files and
> compress `base.dtb` according to `--base-compression` (which defaults
> to `auto`, auto-detecting from `--base-dtb`'s filename extension such
> as `-b base.dtb.lz4`).
> - Report compressed size savings alongside uncompressed savings when
> `-s`/`--stats` is specified.
>
> On the 47 Qualcomm SC7180 Trogdor Chromebook `.dtb.lz4` files,
> `fdtfactor -S` reduces total LZ4-compressed size from 1.71 MB to 213 KB
> (87.5% savings).
>
> Assisted-by: Gemini:gemini-pro-prerelease
> Signed-off-by: Douglas Anderson <dianders@xxxxxxxxxxxx>
>
> README.md | 17 ++-
> fdtfactor | 312 +++++++++++++++++++++++++++++++++++++++++++++++----
> tests/Makefile.tests | 5 +-
> tests/run_tests.sh | 77 ++++++++++++-
> 4 files changed, 379 insertions(+), 32 deletions(-)
Reviewed-by: Simon Glass <sjg@xxxxxxxxxxxx>