From: Marek Vasut <ma...@denx.de> Currently the U-Boot SPL build uses the same DTBs that were generated during U-Boot proper build, and calls 'fdtgrep' on those DTBs to filter out uninteresting nodes and properties. Those U-Boot proper DTBs are built from DTS which are first preprocessed by CPP, but that CPP is invoked in U-Boot proper build context and effectively ignores the CONFIG_SPL_BUILD macro. In case the CONFIG_SPL_BUILD macro is used in any .dts file, the content of the macro is removed by CPP.
Fix this by building a separate set of DTBs for the SPL, which are preprocessed by CPP with -DCONFIG_SPL_BUILD set. Use the same way for the other PLs. Signed-off-by: Marek Vasut <ma...@denx.de> Signed-off-by: Fabio Estevam <feste...@denx.de> --- dts/Makefile | 5 ++++- scripts/Makefile.lib | 11 +++++++++++ scripts/Makefile.xpl | 7 ++++++- 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/dts/Makefile b/dts/Makefile index 86bf8dc2156..53cab9a37a4 100644 --- a/dts/Makefile +++ b/dts/Makefile @@ -32,7 +32,10 @@ else DTB := $(dt_dir)/$(DEVICE_TREE).dtb endif -$(obj)/dt-$(SPL_NAME).dtb: dts/dt.dtb $(objtree)/tools/fdtgrep FORCE +$(obj)/dt-$(SPL_NAME).tmp.dtb: $(patsubst %.dtb,%.dts,$(DTB)) FORCE + $(call if_changed,dtc) + +$(obj)/dt-$(SPL_NAME).dtb: $(obj)/dt-$(SPL_NAME).tmp.dtb $(objtree)/tools/fdtgrep FORCE mkdir -p $(dir $@) $(call if_changed,fdtgrep) diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib index 83fd5ff6c31..8d6f67caee2 100644 --- a/scripts/Makefile.lib +++ b/scripts/Makefile.lib @@ -202,6 +202,16 @@ endif dtsi_include_list = $(strip $(u_boot_dtsi_options_debug) \ $(notdir $(firstword $(u_boot_dtsi_options)))) +ifeq ($(CONFIG_SPL_BUILD),y) +dtc_cpp_xpl_flags = -DCONFIG_XPL_BUILD -DCONFIG_SPL_BUILD +else ifeq ($(CONFIG_TPL_BUILD),y) +dtc_cpp_xpl_flags = -DCONFIG_XPL_BUILD -DCONFIG_TPL_BUILD +else ifeq ($(CONFIG_VPL_BUILD),y) +dtc_cpp_xpl_flags = -DCONFIG_XPL_BUILD -DCONFIG_VPL_BUILD +else +dtc_cpp_xpl_flags = +endif + # Modified for U-Boot upstream_dtsi_include = $(addprefix -I, $(srctree)/dts/upstream/src/ \ $(sort $(dir $(wildcard $(srctree)/dts/upstream/src/$(ARCH)/*/*))) \ @@ -214,6 +224,7 @@ dtc_cpp_flags = -Wp,-MD,$(depfile).pre.tmp -nostdinc \ -I$(srctree)/arch/$(ARCH)/dts/include \ -I$(srctree)/include \ $(upstream_dtsi_include) \ + $(dtc_cpp_xpl_flags) \ -D__ASSEMBLY__ \ -undef -D__DTS__ diff --git a/scripts/Makefile.xpl b/scripts/Makefile.xpl index 43f27874f9f..ff19cb22f94 100644 --- a/scripts/Makefile.xpl +++ b/scripts/Makefile.xpl @@ -590,11 +590,16 @@ endif SPL_OF_LIST_TARGETS = $(patsubst %,dts/%.dtb,$(subst ",,$(CONFIG_SPL_OF_LIST))) SHRUNK_ARCH_DTB = $(addprefix $(obj)/,$(SPL_OF_LIST_TARGETS)) +SPL_TMP_OF_LIST_TARGETS = $(patsubst %,dts/%.spl.dtb,$(subst ",,$(CONFIG_SPL_OF_LIST))) +SHRUNK_ARCH_TMP_DTB = $(addprefix $(obj)/,$(SPL_TMP_OF_LIST_TARGETS)) $(sort $(dir $(SHRUNK_ARCH_DTB))): $(shell [ -d $@ ] || mkdir -p $@) .SECONDEXPANSION: -$(SHRUNK_ARCH_DTB): $$(patsubst $(obj)/dts/%, $(dt_dir)/%, $$@) $(dir $(SHRUNK_ARCH_DTB)) +$(SHRUNK_ARCH_TMP_DTB): $$(patsubst %.spl.dtb,%.dts,$$(patsubst $(obj)/dts/%, $(dt_dir)/%, $$@)) $(dir $(SHRUNK_ARCH_TMP_DTB)) + $(call if_changed,dtc) + +$(SHRUNK_ARCH_DTB): $$(patsubst %.dtb,%.spl.dtb,$$@) $(dir $(SHRUNK_ARCH_DTB)) $(call if_changed,fdtgrep) targets += $(SPL_OF_LIST_TARGETS) -- 2.34.1