[PATCH v2 1/7] kbuild: Add target to build dtb overlay files

Ahmad Fatoum a.fatoum at pengutronix.de
Thu Mar 9 05:24:36 PST 2023


On 09.03.23 12:52, Sascha Hauer wrote:
> Device tree overlay files have the suffix dtso in source format
> and dtbo in binary format. Add the necessary targets to build dtbo
> files from dtso files and also dtbo.o files to include into the
> barebox binary.
> The overlay files shouldn't include the device tree snippets from
> CONFIG_EXTERNAL_DTS_FRAGMENTS which makes it necessary to specify
> these fragments as an argument to cmd_dtc.
> 
> Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
> ---
>  scripts/Makefile.build |  4 ++++
>  scripts/Makefile.lib   | 11 ++++++++++-
>  2 files changed, 14 insertions(+), 1 deletion(-)
> 
> diff --git a/scripts/Makefile.build b/scripts/Makefile.build
> index 216f03677b..33480a81b4 100644
> --- a/scripts/Makefile.build
> +++ b/scripts/Makefile.build
> @@ -258,12 +258,16 @@ intermediate_targets = $(foreach sfx, $(2), \
>  					$(filter %$(strip $(1)), $(targets))))
>  # %.asn1.o <- %.asn1.[ch] <- %.asn1
>  # %.dtb.o <- %.dtb.S <- %.dtb <- %.dts
> +# %.dtbo.o <- %.dtbo.S <- %.dtbo <- %.dtso
>  # %.dtb.pbl.o <- %.dtb.S <- %.dtb <- %.dts (Barebox only)
> +# %.dtbo.pbl.o <- %.dtbo.S <- %.dtbo <- %.dtso (Barebox only)
>  # %.lex.o <- %.lex.c <- %.l
>  # %.tab.o <- %.tab.[ch] <- %.y
>  targets += $(call intermediate_targets, .asn1.o, .asn1.c .asn1.h) \
>  	   $(call intermediate_targets, .dtb.o, .dtb.S .dtb.z .dtb) \
> +	   $(call intermediate_targets, .dtbo.o, .dtbo.S .dtbo.z .dtbo) \
>  	   $(call intermediate_targets, .dtb.pbl.o, .dtb.S .dtb.z .dtb) \
> +	   $(call intermediate_targets, .dtbo.pbl.o, .dtbo.S .dtbo.z .dtbo) \

I see now reason to allow building an overlay for PBL. Should we drop this?

>  	   $(call intermediate_targets, .lex.o, .lex.c) \
>  	   $(call intermediate_targets, .tab.o, .tab.c .tab.h)
>  
> diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
> index 6e0d92cf75..6af2fe07b2 100644
> --- a/scripts/Makefile.lib
> +++ b/scripts/Makefile.lib
> @@ -361,13 +361,19 @@ cmd_dt_S_dtb = $(srctree)/scripts/gen-dtb-s $(subst -,_,$(*F)) $< $(CONFIG_IMD)
>  $(obj)/%.dtb.S: $(obj)/%.dtb $(obj)/%.dtb.z $(srctree)/scripts/gen-dtb-s FORCE
>  	$(call if_changed,dt_S_dtb)
>  
> +$(obj)/%.dtbo.S: $(obj)/%.dtbo $(obj)/%.dtbo.z $(srctree)/scripts/gen-dtb-s FORCE
> +	$(call if_changed,dt_S_dtb)
> +
>  $(obj)/%.dtb.z: $(obj)/%.dtb FORCE
>  	$(call if_changed,$(suffix_y))
>  
> +$(obj)/%.dtbo.z: $(obj)/%.dtbo FORCE
> +	$(call if_changed,$(suffix_y))

Can we drop this and change scripts/gen-dtb-s to skip creating the compressed DTB
if we have a *.dtbo? While at, we should rename the symbol to __dtbo_. Otherwise,
we can have name clashes.

>  dts-frags = $(subst $(quote),,$(CONFIG_EXTERNAL_DTS_FRAGMENTS))
>  quiet_cmd_dtc = DTC     $@
>  # For compatibility between make 4.2 and 4.3
> -cmd_dtc = /usr/bin/env echo -e '$(pound)define $(subst -,_,$(*F))_dts 1\n'$(foreach f,$< $(dts-frags),'$(pound)include "$(f)"\n') | \
> +cmd_dtc = /usr/bin/env echo -e '$(pound)define $(subst -,_,$(*F))_dts 1\n'$(foreach f,$< $(2),'$(pound)include "$(f)"\n') | \
>  	$(CPP) $(dtc_cpp_flags) -x assembler-with-cpp -o $(dtc-tmp) - ; \
>  	$(objtree)/scripts/dtc/dtc -O dtb -o $@ -b 0 \
>  		-i $(srctree)/arch/$(SRCARCH)/dts $(DTC_FLAGS) \
> @@ -376,6 +382,9 @@ cmd_dtc = /usr/bin/env echo -e '$(pound)define $(subst -,_,$(*F))_dts 1\n'$(fore
>  	cat $(depfile).pre $(depfile).dtc > $(depfile)
>  
>  $(obj)/%.dtb: $(src)/%.dts FORCE
> +	$(call if_changed_dep,dtc,$(dts-frags))
> +
> +$(obj)/%.dtbo: $(src)/%.dtso $(DTC) FORCE
>  	$(call if_changed_dep,dtc)
>  
>  dtc-tmp = $(subst $(comma),_,$(dot-target).dts)

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |




More information about the barebox mailing list