From 2a0d4179716cbdc3295077dca9af5ea6cedb3bb5 Mon Sep 17 00:00:00 2001 From: SGCMarkus Date: Fri, 15 Sep 2023 19:08:00 +0200 Subject: [PATCH] kernel: Allow to limit the used .dtb files for the final DTB image On some devices too many .dtb files are generated. Instead of taking all of them, allow to only take selected .dtb files for the final DTB image. Example: Motorola Edge 40 Pro (rtwo, sm8550) generates the following: obj/DTB_OBJ/out/kaka-rumi.dtb obj/DTB_OBJ/out/kalama-rtwo-base-kalama-rtwo-evb1-overlay.dtb obj/DTB_OBJ/out/kalama-rtwo-base-kalama-rtwo-evt1-overlay.dtb obj/DTB_OBJ/out/kalama-rtwo-base-kalama-rtwo-na-vzw-evt2-overlay.dtb obj/DTB_OBJ/out/kalama-rtwo-base-kalama-rtwo-prc-dvt1b-overlay.dtb obj/DTB_OBJ/out/kalama-rtwo-base-kalama-rtwo-prc-pvt-overlay.dtb obj/DTB_OBJ/out/kalama-rtwo-base-kalama-rtwo-row-dvt1b-overlay.dtb obj/DTB_OBJ/out/kalama-rtwo-base.dtb obj/DTB_OBJ/out/kalama-v2-rtwo-base-kalama-rtwo-evb1-overlay.dtb obj/DTB_OBJ/out/kalama-v2-rtwo-base-kalama-rtwo-evt1-overlay.dtb obj/DTB_OBJ/out/kalama-v2-rtwo-base-kalama-rtwo-na-vzw-evt2-overlay.dtb obj/DTB_OBJ/out/kalama-v2-rtwo-base-kalama-rtwo-prc-dvt1b-overlay.dtb obj/DTB_OBJ/out/kalama-v2-rtwo-base-kalama-rtwo-prc-pvt-overlay.dtb obj/DTB_OBJ/out/kalama-v2-rtwo-base-kalama-rtwo-row-dvt1b-overlay.dtb obj/DTB_OBJ/out/kalama-v2-rtwo-base.dtb with only kalama-rtwo-base.dtb and kalama-v2-rtwo-base.dtb needed. Disabling compilation of the other kalama.dtb isn't possible, as this would also disable the compilation of the needed .dtbo files. Because they are earlier in alphabetical order, and the matching board ids, the bootloader ends up selecting those, instead of the correct ones. This results in USB (and possible other things) to not work. Change-Id: I486b6ec538a3e4906b5b8aa5ecb355b480b60de7 --- build/tasks/kernel.mk | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/build/tasks/kernel.mk b/build/tasks/kernel.mk index 8fbad87d..d032b8f9 100644 --- a/build/tasks/kernel.mk +++ b/build/tasks/kernel.mk @@ -67,6 +67,9 @@ # # TARGET_FORCE_PREBUILT_KERNEL = Optional, use TARGET_PREBUILT_KERNEL even if # kernel sources are present +# +# TARGET_MERGE_DTBS_WILDCARD = Optional, limits the .dtb files used to generate the +# final DTB image when using QCOM's merge_dtbs script. ifneq ($(TARGET_NO_KERNEL),true) ifneq ($(TARGET_NO_KERNEL_OVERRIDE),true) @@ -78,6 +81,8 @@ KERNEL_DEFCONFIG := $(TARGET_KERNEL_CONFIG) RECOVERY_DEFCONFIG := $(TARGET_KERNEL_RECOVERY_CONFIG) VARIANT_DEFCONFIG := $(TARGET_KERNEL_VARIANT_CONFIG) SELINUX_DEFCONFIG := $(TARGET_KERNEL_SELINUX_CONFIG) +# dtb generation - optional +TARGET_MERGE_DTBS_WILDCARD ?= * ## Internal variables DTC := $(HOST_OUT_EXECUTABLES)/dtc @@ -581,7 +586,7 @@ ifeq ($(BOARD_USES_QCOM_MERGE_DTBS_SCRIPT),true) $(hide) find $(DTBS_OUT) -type f -name "*.dtb*" | xargs rm -f mv $(DTB_OUT)/arch/$(KERNEL_ARCH)/boot/dts/vendor/qcom/*.dtb $(DTB_OUT)/arch/$(KERNEL_ARCH)/boot/dts/vendor/*/*.dtbo $(DTBS_BASE)/ PATH=$(abspath $(HOST_OUT_EXECUTABLES)):$${PATH} python3 $(BUILD_TOP)/vendor/lineage/build/tools/merge_dtbs.py $(DTBS_BASE) $(DTB_OUT)/arch/$(KERNEL_ARCH)/boot/dts/vendor/qcom $(DTBS_OUT) - cat $(shell find $(DTB_OUT)/out -type f -name "*.dtb" | sort) > $@ + cat $(shell find $(DTB_OUT)/out -type f -name "${TARGET_MERGE_DTBS_WILDCARD}.dtb" | sort) > $@ else cat $(shell find $(DTB_OUT)/arch/$(KERNEL_ARCH)/boot/dts -type f -name "*.dtb" | sort) > $@ endif # BOARD_USES_QCOM_MERGE_DTBS_SCRIPT