[RFC][PATCH] kbuild: Produce diff between base DT and U-Boot augmented DT if DEVICE_TREE_DEBUG=1

Heinrich Schuchardt xypron.glpk at gmx.de
Fri Nov 7 10:12:04 CET 2025


On 11/6/25 22:08, Marek Vasut wrote:
> In case DEVICE_TREE_DEBUG is set, produce a diff between the base DT and
> DT with U-Boot extras, to show how much does the U-Boot DT differ from
> the base DT. This is particularly useful together with OF_UPSTREAM, to
> minimize the diff between upstream DTs and U-Boot DTs.
> 
> Example usage:
> $ make r8a779g3_sparrowhawk_defconfig && make DEVICE_TREE_DEBUG=1
> $ cat ./dts/upstream/src/arm64/renesas/r8a779g3-sparrow-hawk.dtb.diff
> 
> This still has a downside. Even 'dtc -I dts -O dts ...' applied on
> base DT and U-Boot augmented DT can produce different phandle IDs
> for the same node in those two DTs, which results in a lot of noise
> in the resulting diff. The only way I can think of is to patch DTC
> to emit full paths in those phandles instead, something like a
> phandle = <&{/full/path/to/remote/end} ...>;
> 
> Signed-off-by: Marek Vasut <marek.vasut+renesas at mailbox.org>
> ---
> Cc: Adriano Cordova <adrianox at gmail.com>
> Cc: Heinrich Schuchardt <xypron.glpk at gmx.de>
> Cc: Ilias Apalodimas <ilias.apalodimas at linaro.org>
> Cc: Peter Robinson <pbrobinson at gmail.com>
> Cc: Sam Edwards <cfsworks at gmail.com>
> Cc: Tom Rini <trini at konsulko.com>
> Cc: u-boot at lists.denx.de

Hello Marek,

Without documentation developers will not know about the new feature. 
Could you, please, add a doc/build/ change in the next iteration.

Tested-by: Heinrich Schuchardt <xypron.glpk at gmx.de>


> ---
>   scripts/Makefile.lib | 24 +++++++++++++++++++++++-
>   1 file changed, 23 insertions(+), 1 deletion(-)
> 
> diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
> index 5db2fbc418a..2d8bf3c04f4 100644
> --- a/scripts/Makefile.lib
> +++ b/scripts/Makefile.lib
> @@ -386,10 +386,31 @@ ifeq ($(CONFIG_OF_LIBFDT_OVERLAY),y)
>   DTC_FLAGS += -@
>   endif
>   
> +# In case DEVICE_TREE_DEBUG is set, produce a diff between the base DT and
> +# DT with U-Boot extras, to show how much does the U-Boot DT differ from
> +# the base DT. This is particularly useful together with OF_UPSTREAM, to
> +# minimize the diff between upstream DTs and U-Boot DTs.
> +ifdef DEVICE_TREE_DEBUG
> +cmd_dtc_diff = \
> +	$(HOSTCC) -E $(dtc_cpp_flags) -I$(obj) -x assembler-with-cpp -o $(dtn-tmp) $< ; \
> +	$(DTC) -s -O dts -o $@.clean.dts -b 0 \
> +		-i $(dir $<) $(DTC_FLAGS) $(dtn-tmp) || \
> +		(echo "Check $(shell pwd)/$< for errors" && false); \
> +	$(DTC) -s -O dts -o $@.full.dts -b 0 \
> +		-i $(dir $<) -i $(u_boot_dtsi_loc) $(DTC_FLAGS) $(dtc-tmp) || \
> +		(echo "Check $(shell pwd)/$(pre-tmp) for errors" && false); \
> +	(diff -Naru $@.clean.dts $@.full.dts > $@.diff || true)
> +
> +dtn-tmp = $(subst $(comma),_,$(dot-target).dtn.tmp)
> +else
> +cmd_dtc_diff =
> +endif
> +
>   quiet_cmd_dtc = DTC     $@
>   # Modified for U-Boot
>   # Bring in any U-Boot-specific include at the end of the file
>   # And finally any custom .dtsi fragments specified with CONFIG_DEVICE_TREE_INCLUDES
> +
>   cmd_dtc = mkdir -p $(dir ${dtc-tmp}) ; \
>   	(cat $< > $(pre-tmp)); \
>   	$(foreach f,$(subst $(quote),,$(dtsi_include_list) $(CONFIG_DEVICE_TREE_INCLUDES)), \
> @@ -400,7 +421,8 @@ cmd_dtc = mkdir -p $(dir ${dtc-tmp}) ; \
>   		-d $(depfile).dtc.tmp $(dtc-tmp) || \
>   		(echo "Check $(shell pwd)/$(pre-tmp) for errors" && false) \
>   		; \
> -	sed "s:$(pre-tmp):$(<):" $(depfile).pre.tmp $(depfile).dtc.tmp > $(depfile)
> +	sed "s:$(pre-tmp):$(<):" $(depfile).pre.tmp $(depfile).dtc.tmp > $(depfile) ; \
> +	$(cmd_dtc_diff)
>   
>   dtsi_include_list_deps := $(addprefix $(u_boot_dtsi_loc),$(subst $(quote),,$(dtsi_include_list)))
>   



More information about the U-Boot mailing list