[PATCH v2 1/2] dts: Add ability to build fallback DTBOs from arch/$(ARCH)/dts

Sumit Garg sumit.garg at linaro.org
Mon Oct 7 12:08:04 CEST 2024


Hi Marek,

On Sat, 5 Oct 2024 at 06:43, Marek Vasut <marex at denx.de> wrote:
>
> Currently the enablement of OF_UPSTREAM results on the build system
> searching for DTs only in dts/upstream/ . There are platforms which
> use U-Boot specific DTBOs applied on top of U-Boot control DT during
> SPL stage, and source DTs for these are located in arch/$(ARCH)/dtb.
>
> Add dedicated 'dtbos' target which builds only .dtbos and not .dtbs and
> in case CONFIG_OF_UPSTREAM_INCLUDE_LOCAL_FALLBACK_DTBOS is enabled, build
> this target for arch/$(ARCH)/dtb to generate local U-Boot specific DTBOs.
>
> Adjust top level Makefile so binman would search for .dtb and .dtbo in
> both OF_UPSTREAM specific paths and arch/$(ARCH)/dtb for the .dtbo case
> in case CONFIG_OF_UPSTREAM_INCLUDE_LOCAL_FALLBACK_DTBOS is enabled.
>
> Signed-off-by: Marek Vasut <marex at denx.de>
> ---
> Cc: "NXP i.MX U-Boot Team" <uboot-imx at nxp.com>
> Cc: Caleb Connolly <caleb.connolly at linaro.org>
> Cc: Christoph Niedermaier <cniedermaier at dh-electronics.com>
> Cc: Fabio Estevam <festevam at gmail.com>
> Cc: Heinrich Schuchardt <xypron.glpk at gmx.de>
> Cc: Jonas Karlman <jonas at kwiboo.se>
> Cc: Lothar Rubusch <l.rubusch at gmail.com>
> Cc: Michal Simek <michal.simek at amd.com>
> Cc: Nobuhiro Iwamatsu <iwamatsu at nigauri.org>
> Cc: Rasmus Villemoes <rasmus.villemoes at prevas.dk>
> Cc: Simon Glass <sjg at chromium.org>
> Cc: Stefano Babic <sbabic at denx.de>
> Cc: Sumit Garg <sumit.garg at linaro.org>
> Cc: Tom Rini <trini at konsulko.com>
> Cc: u-boot at dh-electronics.com
> Cc: u-boot at lists.denx.de
> ---
> V2: Gate this functionality behind CONFIG_OF_UPSTREAM_INCLUDE_LOCAL_FALLBACK_DTBOS
> ---
> NOTE: Depends on https://lore.kernel.org/u-boot/20241004001118.322531-1-marex@denx.de/
> ---
>  Makefile             |  4 ++++
>  dts/Kconfig          | 16 ++++++++++++++++
>  dts/Makefile         | 14 +++++++++++++-
>  scripts/Makefile.dts |  6 ++++++
>  4 files changed, 39 insertions(+), 1 deletion(-)
>
> diff --git a/Makefile b/Makefile
> index af24de4165e..a5258e8cb3f 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -1375,7 +1375,11 @@ of_list := "$(ext_dtb_list)"
>  of_list_dirs := $(dir $(EXT_DTB))
>  else
>  of_list := $(CONFIG_OF_LIST)
> +ifneq ($(CONFIG_OF_UPSTREAM_INCLUDE_LOCAL_FALLBACK_DTBOS),)
> +of_list_dirs := $(dt_dir) arch/$(ARCH)/dts
> +else
>  of_list_dirs := $(dt_dir)
> +endif
>  default_dt := $(if $(DEVICE_TREE),$(DEVICE_TREE),$(CONFIG_DEFAULT_DEVICE_TREE))
>  endif
>
> diff --git a/dts/Kconfig b/dts/Kconfig
> index 569d4be338e..385058b429f 100644
> --- a/dts/Kconfig
> +++ b/dts/Kconfig
> @@ -125,6 +125,22 @@ config OF_UPSTREAM_VENDOR
>         help
>           Select the vendor to build all devicetree files for.
>
> +config OF_UPSTREAM_INCLUDE_LOCAL_FALLBACK_DTBOS
> +       bool "Build local DTBOs as fallback for DTBOs missing upstream"
> +       default n
> +       depends on OF_UPSTREAM
> +       help
> +         Enable building DTBOs from arch/$(ARCH)/dts as a fallback for
> +         DTBOs which are not part of Linux kernel upstream yet. This is
> +         a stopgap measure to expedite OF_UPSTREAM switch for platforms
> +         which already have main DT in Linux kernel upstream, but still
> +         have leftover DTBOs in U-Boot tree.
> +
> +         Do not use this option, upstream your DTs and DTBOs instead.
> +         If the upstreaming is in progress, use with utmost caution.
> +
> +         If unsure, say N.
> +
>  choice
>         prompt "Provider of DTB for DT control"
>         depends on OF_CONTROL
> diff --git a/dts/Makefile b/dts/Makefile
> index d6c2c9daf31..32c749a043a 100644
> --- a/dts/Makefile
> +++ b/dts/Makefile
> @@ -11,12 +11,18 @@ DEVICE_TREE := unset
>  endif
>
>  ifeq ($(CONFIG_OF_UPSTREAM),y)
> +ifneq ($(CONFIG_OF_UPSTREAM_INCLUDE_LOCAL_FALLBACK_DTBOS),)

Since CONFIG_OF_UPSTREAM_INCLUDE_LOCAL_FALLBACK_DTBOS already has a
dependency on CONFIG_OF_UPSTREAM via Kconfig, can we avoid the nested
ifeq sequence here? This will avoid a redundant local_dtbos
assignment...

> +local_dtbos := local-dtbos
> +else
> +local_dtbos :=
> +endif
>  ifeq ($(CONFIG_ARM64),y)
>  dt_dir := dts/upstream/src/arm64
>  else
>  dt_dir := dts/upstream/src/$(ARCH)
>  endif
>  else
> +local_dtbos :=

...here.

With that fixed, feel free to add:

Reviewed-by: Sumit Garg <sumit.garg at linaro.org>

-Sumit

>  dt_dir := arch/$(ARCH)/dts
>  endif
>
> @@ -40,7 +46,7 @@ endif
>
>  targets += dt.dtb
>
> -$(DTB): arch-dtbs
> +$(DTB): arch-dtbs $(local_dtbos)
>         $(Q)test -e $@ || (                                             \
>         echo >&2;                                                       \
>         echo >&2 "Device Tree Source ($@) is not correctly specified."; \
> @@ -53,6 +59,12 @@ PHONY += arch-dtbs
>  arch-dtbs:
>         $(Q)$(MAKE) $(build)=$(dt_dir) dtbs
>
> +ifneq ($(CONFIG_OF_UPSTREAM_INCLUDE_LOCAL_FALLBACK_DTBOS),)
> +PHONY += local-dtbos
> +local-dtbos:
> +       $(Q)$(MAKE) $(build)=arch/$(ARCH)/dts dtbos
> +endif
> +
>  ifeq ($(CONFIG_SPL_BUILD),y)
>  obj-$(CONFIG_OF_EMBED) := dt-spl.dtb.o
>  # support "out-of-tree" build for dtb-spl
> diff --git a/scripts/Makefile.dts b/scripts/Makefile.dts
> index 1fe142f2bbf..3ab67b3c247 100644
> --- a/scripts/Makefile.dts
> +++ b/scripts/Makefile.dts
> @@ -21,4 +21,10 @@ PHONY += dtbs
>  dtbs: $(addprefix $(obj)/, $(dtb-y))
>         @:
>
> +ifneq ($(CONFIG_OF_UPSTREAM_INCLUDE_LOCAL_FALLBACK_DTBOS),)
> +PHONY += dtbos
> +dtbos: $(addprefix $(obj)/, $(filter-out %.dtb,$(dtb-y)))
> +       @:
> +endif
> +
>  clean-files := *.dtb *.dtbo */*.dtb */*.dtbo *_HS
> --
> 2.45.2
>


More information about the U-Boot mailing list