Re: [PATCH v2 08/10] fdtfactor: Add -S/--strip-local-fixups option

From: Simon Glass

Date: Fri Oct 30 2026 - 08:51:21 EST


Hi Doug,

On 2026-10-28T21:46:49, Douglas Anderson <dianders@xxxxxxxxxxxx> wrote:
> fdtfactor: Add -S/--strip-local-fixups option
>
> By default, `fdtfactor` preserves `/__local_fixups__` on `base.dtb` so
> that when `fdt_overlay_apply()` merges a `.dtbo` overlay, the
> reconstructed device tree retains full `/__local_fixups__` information
> (for instance, if an OS kernel wants to know which property cells
> contain phandles at runtime).
>
> When `-L` was passed to `dtc` solely to help `fdtfactor` locate phandle
> cells at build time and `/__local_fixups__` is not needed at runtime,
> retaining `/__local_fixups__` in `base.dtb` wastes space.
>
> Add `-S` / `--strip-local-fixups` to omit `/__local_fixups__` from
> `base.dtb` (and therefore from the merged device trees produced by
> `fdt_overlay_apply()`). On a set of 47 Qualcomm SC7180 Trogdor
> Chromebook board DTBs, `fdtfactor -S` reduces total uncompressed size
> from 7.69 MB to 634 KB (91.8% savings).

This compares against the unfactored DTBs, so it doesn't show what -S
itself saves. Please can you also give the size without -S, so it is
clear what the /__local_fixups__ in base.dtb costs?

>
> Add a test case in `tests/run_tests.sh` verifying that `fdtfactor -S`
> followed by `fdtoverlay` reproduces DTBs compiled with `-@` (without
> [...]
>
> README.md | 9 +++++++++
> fdtfactor | 34 ++++++++++++++++++++++++++--------
> tests/run_tests.sh | 22 ++++++++++++++++++++++
> 3 files changed, 57 insertions(+), 8 deletions(-)

> diff --git a/tests/run_tests.sh b/tests/run_tests.sh
> @@ -1234,6 +1234,28 @@ fdtfactor_tests () {
> + # Strip local fixups (-S): verify that merged DTBs match DTBs compiled
> + # with -@ (without -L), and that inputs lacking /__local_fixups__ are
> + # rejected.
> + for i in 1 2 3; do
> + run_dtc_test -b 2 -@ -I dts -O dtb -o fdtfactor_board${i}.nolf.test.dtb \
> + "$SRCDIR/fdtfactor_board${i}.dts"
> + done
> + run_wrap_error_test $PYTHON $FDTFACTOR -o fdtfactor_strip.test.dir \
> + fdtfactor_board1.nolf.test.dtb fdtfactor_board2.test.dtb

This rejection test has no -S, so it checks the -L requirement from
the previous patch rather than anything added here. Since -S could
easily be read as 'my inputs don't need -L', I think it is more useful
to pass -S here, to show that it does not relax that requirement. The
plain no-S case could then go into the previous patch with the other
rejection tests.

Regards,
Simon