From 35f7ec4d72c97208e3326a4dce626c65481e8128 Mon Sep 17 00:00:00 2001 From: The-going <48602507+The-going@users.noreply.github.com> Date: Tue, 1 Feb 2022 21:04:08 +0300 Subject: [PATCH] scripts: add overlay compilation support --- arch/arm/boot/.gitignore | 2 ++ scripts/Makefile.dtbinst | 39 ++++++++++++++++++++++++++------------- scripts/Makefile.lib | 21 +++++++++++++++++++-- 3 files changed, 47 insertions(+), 15 deletions(-) diff --git a/arch/arm/boot/.gitignore b/arch/arm/boot/.gitignore index 8c759326b..e6ce8f6ad 100644 --- a/arch/arm/boot/.gitignore +++ b/arch/arm/boot/.gitignore @@ -4,3 +4,5 @@ zImage xipImage bootpImage uImage +*.dtb* +*.scr diff --git a/scripts/Makefile.dtbinst b/scripts/Makefile.dtbinst index 190d781e8..d7d937903 100644 --- a/scripts/Makefile.dtbinst +++ b/scripts/Makefile.dtbinst @@ -13,27 +13,40 @@ src := $(obj) PHONY := __dtbs_install __dtbs_install: +export dtbinst_root ?= $(obj) + include include/config/auto.conf include $(srctree)/scripts/Kbuild.include include $(src)/Makefile -dtbs := $(addprefix $(dst)/, $(dtb-y) $(if $(CONFIG_OF_ALL_DTBS),$(dtb-))) -subdirs := $(addprefix $(obj)/, $(subdir-y) $(subdir-m)) +dtbinst-files := $(sort $(dtb-y) $(if $(CONFIG_OF_ALL_DTBS), $(dtb-))) +dtboinst-files := $(dtbo-y) +script-files := $(scr-y) +readme-files := $(dtbotxt-y) +dtbinst-dirs := $(subdir-y) $(subdir-m) + +# Helper targets for Installing DTBs into the boot directory +quiet_cmd_dtb_install = INSTALL $< + cmd_dtb_install = mkdir -p $(2); cp $< $(2) + +install-dir = $(patsubst $(dtbinst_root)%,$(INSTALL_DTBS_PATH)%,$(obj)) + +$(dtbinst-files): %.dtb: $(obj)/%.dtb + $(call cmd,dtb_install,$(install-dir)) -__dtbs_install: $(dtbs) $(subdirs) - @: +$(dtboinst-files): %.dtbo: $(obj)/%.dtbo + $(call cmd,dtb_install,$(install-dir)) -quiet_cmd_dtb_install = INSTALL $@ - cmd_dtb_install = install -D $< $@ +$(script-files): %.scr: $(obj)/%.scr + $(call cmd,dtb_install,$(install-dir)) -$(dst)/%.dtb: $(obj)/%.dtb - $(call cmd,dtb_install) +$(readme-files): %: $(src)/% + $(call cmd,dtb_install,$(install-dir)) -$(dst)/%.dtbo: $(obj)/%.dtbo - $(call cmd,dtb_install) +$(dtbinst-dirs): + $(Q)$(MAKE) $(dtbinst)=$(obj)/$@ -PHONY += $(subdirs) -$(subdirs): - $(Q)$(MAKE) $(dtbinst)=$@ dst=$(patsubst $(obj)/%,$(dst)/%,$@) +PHONY += $(dtbinst-files) $(dtboinst-files) $(script-files) $(readme-files) $(dtbinst-dirs) +__dtbs_install: $(dtbinst-files) $(dtboinst-files) $(script-files) $(readme-files) $(dtbinst-dirs) .PHONY: $(PHONY) diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib index 3aa384cec..02b118ce7 100644 --- a/scripts/Makefile.lib +++ b/scripts/Makefile.lib @@ -336,6 +336,9 @@ quiet_cmd_gzip = GZIP $@ DTC ?= $(objtree)/scripts/dtc/dtc DTC_FLAGS += -Wno-interrupt_provider +# Overlay support +DTC_FLAGS += -@ -Wno-unit_address_format -Wno-simple_bus_reg + # Disable noisy checks by default ifeq ($(findstring 1,$(KBUILD_EXTRA_WARN)),) DTC_FLAGS += -Wno-unit_address_vs_reg \ @@ -405,8 +408,22 @@ endif $(obj)/%.dtb: $(src)/%.dts $(DTC) $(DT_TMP_SCHEMA) FORCE $(call if_changed_dep,dtb) -$(obj)/%.dtbo: $(src)/%.dts $(DTC) FORCE - $(call if_changed_dep,dtc) +quiet_cmd_dtco = DTCO $@ +cmd_dtco = mkdir -p $(dir ${dtc-tmp}) ; \ + $(CPP) $(dtc_cpp_flags) -x assembler-with-cpp -o $(dtc-tmp) $< ; \ + $(DTC) -O dtb -o $@ -b 0 \ + -i $(dir $<) $(DTC_FLAGS) \ + -d $(depfile).dtc.tmp $(dtc-tmp) ; \ + cat $(depfile).pre.tmp $(depfile).dtc.tmp > $(depfile) + +$(obj)/%.dtbo: $(src)/%.dts FORCE + $(call if_changed_dep,dtco) + +quiet_cmd_scr = MKIMAGE $@ +cmd_scr = mkimage -C none -A $(ARCH) -T script -d $< $@ + +$(obj)/%.scr: $(src)/%.scr-cmd FORCE + $(call if_changed,scr) dtc-tmp = $(subst $(comma),_,$(dot-target).dts.tmp) -- 2.35.3