From a98e79a91ad0ace1a517c2964e148e59cb2240d5 Mon Sep 17 00:00:00 2001 From: Alex Ray Date: Tue, 28 Dec 2021 15:30:41 +0100 Subject: [PATCH] ANDROID: ARM64: add option to build Image.gz/dtb combo Allows a defconfig to set a list of dtbs to concatenate with an Image.gz to create a Image.gz-dtb. Includes 8adb162 arm64: Fix correct dtb clean-files location Change-Id: I0b462322d5c970f1fdf37baffece7ad058099f4a Signed-off-by: Alex Ray [rishabhb] Use subdir to descend into device tree directories Signed-off-by: Rishabh Bhatnagar konrad: fast-forward it to msm-5.4 --- arch/arm64/Kconfig | 15 +++++++++++++++ arch/arm64/Makefile | 13 +++++++++++-- arch/arm64/boot/.gitignore | 2 ++ arch/arm64/boot/Makefile | 16 ++++++++++++++++ arch/arm64/boot/dts/Makefile | 20 +++++++++++++++++--- 5 files changed, 61 insertions(+), 5 deletions(-) diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig index af24982911d83..acde4c3c46a30 100644 --- a/arch/arm64/Kconfig +++ b/arch/arm64/Kconfig @@ -1756,6 +1756,21 @@ config DMI However, even with this option, the resultant kernel should continue to boot on existing non-UEFI platforms. +config BUILD_ARM64_APPENDED_DTB_IMAGE + bool "Build a concatenated Image.gz/dtb by default" + depends on OF + help + Enabling this option will cause a concatenated Image.gz and list of + DTBs to be built by default (instead of a standalone Image.gz.) + The image will built in arch/arm64/boot/Image.gz-dtb + +config BUILD_ARM64_APPENDED_DTB_IMAGE_NAMES + string "Default dtb names" + depends on BUILD_ARM64_APPENDED_DTB_IMAGE + help + Space separated list of names of dtbs to append when + building a concatenated Image.gz-dtb. + endmenu choice diff --git a/arch/arm64/Makefile b/arch/arm64/Makefile index 2835816d699c9..883db6bb514b8 100644 --- a/arch/arm64/Makefile +++ b/arch/arm64/Makefile @@ -145,9 +145,15 @@ endif # Default target when executing plain make boot := arch/arm64/boot -KBUILD_IMAGE := $(boot)/$(KBUILD_TARGET) -all: $(KBUILD_TARGET) +ifeq ($(CONFIG_BUILD_ARM64_APPENDED_DTB_IMAGE),y) +# Warning! Uncompressed kernel + appended DTB + DTBO WILL NOT WORK! +KBUILD_IMAGE := $(KBUILD_TARGET)-dtb +else +KBUILD_IMAGE := $(KBUILD_TARGET) +endif + +all: $(KBUILD_IMAGE) Image: vmlinux $(Q)$(MAKE) $(build)=$(boot) $(boot)/$@ @@ -158,6 +164,9 @@ Image.%: Image zinstall install: $(Q)$(MAKE) $(build)=$(boot) $@ +$(KBUILD_TARGET)-dtb: vmlinux scripts dtbs + $(Q)$(MAKE) $(build)=$(boot) $(boot)/$@ + PHONY += vdso_install vdso_install: $(Q)$(MAKE) $(build)=arch/arm64/kernel/vdso $@ diff --git a/arch/arm64/boot/.gitignore b/arch/arm64/boot/.gitignore index 8dab0bb6ae667..34e35209fc2ed 100644 --- a/arch/arm64/boot/.gitignore +++ b/arch/arm64/boot/.gitignore @@ -1,2 +1,4 @@ Image +Image-dtb Image.gz +Image.gz-dtb diff --git a/arch/arm64/boot/Makefile b/arch/arm64/boot/Makefile index c6bd6844b1951..bede67a4d1855 100644 --- a/arch/arm64/boot/Makefile +++ b/arch/arm64/boot/Makefile @@ -14,6 +14,8 @@ # Based on the ia64 boot/Makefile. # +include $(srctree)/arch/arm64/boot/dts/Makefile + OBJCOPYFLAGS_Image :=-O binary -R .note -R .note.gnu.build-id -R .comment -S targets := Image Image.bz2 Image.gz Image.lz4 Image.lzma Image.lzo @@ -33,6 +35,14 @@ rtic_mp.dtb: vmlinux FORCE endif +DTB_NAMES := $(subst $\",,$(CONFIG_BUILD_ARM64_APPENDED_DTB_IMAGE_NAMES)) +ifneq ($(DTB_NAMES),) +DTB_LIST := $(addsuffix .dtb,$(DTB_NAMES)) +else +DTB_LIST := $(dtb-y) +endif +DTB_OBJS := $(addprefix $(obj)/dts/,$(DTB_LIST)) + $(obj)/Image: vmlinux FORCE $(call if_changed,objcopy) @@ -51,6 +61,12 @@ $(obj)/Image.lzma: $(obj)/Image FORCE $(obj)/Image.lzo: $(obj)/Image FORCE $(call if_changed,lzo) +$(obj)/Image-dtb: $(obj)/Image $(DTB_OBJS) FORCE + $(call if_changed,cat) + +$(obj)/Image.gz-dtb: $(obj)/Image.gz $(DTB_OBJS) FORCE + $(call if_changed,cat) + install: $(CONFIG_SHELL) $(srctree)/$(src)/install.sh $(KERNELRELEASE) \ $(obj)/Image System.map "$(INSTALL_PATH)" diff --git a/arch/arm64/boot/dts/Makefile b/arch/arm64/boot/dts/Makefile index 75d1b87da5d7f..7505fb3ccd659 100644 --- a/arch/arm64/boot/dts/Makefile +++ b/arch/arm64/boot/dts/Makefile @@ -31,7 +31,21 @@ subdir-y += xilinx subdir-y += zte dtstree := $(srctree)/$(src) -vendor := $(dtstree)/vendor -ifneq "$(wildcard $(vendor)/Makefile)" "" - subdir-y += vendor + +dtb-$(CONFIG_OF_ALL_DTBS) := $(patsubst $(dtstree)/%.dts,%.dtb, $(foreach d,$(subdir), $(wildcard $(dtstree)/$(d)/*.dts))) + +always := $(dtb-y) + +targets += dtbs + +DTB_NAMES := $(subst $\",,$(CONFIG_BUILD_ARM64_APPENDED_DTB_IMAGE_NAMES)) +ifneq ($(DTB_NAMES),) +DTB_LIST := $(addsuffix .dtb,$(DTB_NAMES)) +else +DTB_LIST := $(dtb-y) endif +targets += $(DTB_LIST) + +dtbs: $(addprefix $(obj)/, $(DTB_LIST)) + +clean-files := dts/*.dtb *.dtb