From 2131227516ceeec0ccaf3e97a2de924348dd10ad Mon Sep 17 00:00:00 2001 From: David Ng Date: Fri, 27 Jul 2012 18:39:48 -0700 Subject: [PATCH] build: Add support for device tree in boot.img Add support for optional device tree image (dt.img) to boot and recovery images. Some devices use kernel device tree and this adds the device tree image as a section within the boot/recovery images. Change-Id: I91431ef2f4b86485895678916e39a8572be878eb Build: add DT image variable to Makefile DT image variable is currently present in generate_extra_images.mk.This file is moved to build/tasks to support persist image generation during parallel make. As build/tasks is called at the end of Makefile, DT image variable is not available for other images generation like boot and recovery. Adding this variable in Makefile ensures the variable is defined before usage Change-Id: I21f675d8ce648dc1cf1f4f3aede33278300e08c9 CRs-fixed: 548299 Fix case where boot/recovery.img were being built with wrong params. The boot and recovery images now get built using the same params during ota package generation as during a normal build. Change-Id: I93d46e11a4245288f0e87c87a2e4bf45ac5aff69 Fix the extra dt.img compilation issue. Add support for optional device tree image (dt.img) for device that doesnt have TARGET_BOOTIMAGE_USE_EXT2 Change-Id: I6e07b3ca6d049a8ebdad7ea304b4f39e7c846151 releasetools: Store and use the dt image file through target files Target files packages may be used for signing images separate from the build process. Store the device tree image file in the target files package so it can be used during the signing process. Change-Id: Ie8507121fa9c4ba57ecffeab05bd859ae5f5b788 --- core/Makefile | 25 +++++++++++++++++++++---- tools/releasetools/common.py | 5 +++++ 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/core/Makefile b/core/Makefile index 2416e8b7a2..41381f3ef0 100644 --- a/core/Makefile +++ b/core/Makefile @@ -1347,6 +1347,12 @@ INTERNAL_MKBOOTIMG_VERSION_ARGS := \ --os_version $(PLATFORM_VERSION_LAST_STABLE) \ --os_patch_level $(PLATFORM_SECURITY_PATCH) +ifeq ($(strip $(BOARD_KERNEL_SEPARATED_DT)),true) + INSTALLED_DTIMAGE_TARGET := $(PRODUCT_OUT)/dt.img + INTERNAL_BOOTIMAGE_ARGS += --dt $(INSTALLED_DTIMAGE_TARGET) + BOOTIMAGE_EXTRA_DEPS := $(INSTALLED_DTIMAGE_TARGET) +endif + # Define these only if we are building boot ifdef BUILDING_BOOT_IMAGE INSTALLED_BOOTIMAGE_TARGET := $(BUILT_BOOTIMAGE_TARGET) @@ -1367,7 +1373,7 @@ define build_boot_board_avb_enabled $(call build_boot_from_kernel_avb_enabled,$(1),$(kernel)) endef -$(INSTALLED_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(AVBTOOL) $(INTERNAL_BOOTIMAGE_FILES) $(BOARD_AVB_BOOT_KEY_PATH) +$(INSTALLED_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(AVBTOOL) $(INTERNAL_BOOTIMAGE_FILES) $(BOARD_AVB_BOOT_KEY_PATH) $(BOOTIMAGE_EXTRA_DEPS) $(call pretty,"Target boot image: $@") $(call build_boot_board_avb_enabled,$@) @@ -1390,7 +1396,7 @@ define build_boot_supports_vboot $(call assert-max-image-size,$(1),$(call get-bootimage-partition-size,$(1),boot)) endef -$(INSTALLED_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_FILES) $(VBOOT_SIGNER) $(FUTILITY) +$(INSTALLED_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_FILES) $(VBOOT_SIGNER) $(FUTILITY) $(BOOTIMAGE_EXTRA_DEPS) $(call pretty,"Target boot image: $@") $(call build_boot_supports_vboot,$@) @@ -1412,7 +1418,7 @@ define build_boot_novboot $(call assert-max-image-size,$1,$(call get-bootimage-partition-size,$(1),boot)) endef -$(INSTALLED_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_FILES) +$(INSTALLED_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_FILES) $(BOOTIMAGE_EXTRA_DEPS) $(call pretty,"Target boot image: $@") $(call build_boot_novboot,$@) @@ -2703,6 +2709,11 @@ ifndef BOARD_RECOVERY_MKBOOTIMG_ARGS BOARD_RECOVERY_MKBOOTIMG_ARGS := $(BOARD_MKBOOTIMG_ARGS) endif +ifeq ($(strip $(BOARD_KERNEL_SEPARATED_DT)),true) + INTERNAL_RECOVERYIMAGE_ARGS += --dt $(INSTALLED_DTIMAGE_TARGET) + RECOVERYIMAGE_EXTRA_DEPS := $(INSTALLED_DTIMAGE_TARGET) +endif + $(INTERNAL_RECOVERY_RAMDISK_FILES_TIMESTAMP): $(MKBOOTFS) \ $(INTERNAL_ROOT_FILES) \ $(INSTALLED_RAMDISK_TARGET) \ @@ -2807,7 +2818,7 @@ UNMOUNTED_NOTICE_VENDOR_DEPS+= $(INSTALLED_BOOTIMAGE_TARGET) endif # BOARD_USES_RECOVERY_AS_BOOT ifndef BOARD_CUSTOM_BOOTIMG_MK -$(INSTALLED_RECOVERYIMAGE_TARGET): $(recoveryimage-deps) +$(INSTALLED_RECOVERYIMAGE_TARGET): $(recoveryimage-deps) $(RECOVERYIMAGE_EXTRA_DEPS) $(call build-recoveryimage-target, $@, \ $(if $(filter true, $(BOARD_EXCLUDE_KERNEL_FROM_RECOVERY_IMAGE)),, $(recovery_kernel))) else @@ -6509,6 +6520,9 @@ endif ifdef BOARD_KERNEL_PAGESIZE echo "$(BOARD_KERNEL_PAGESIZE)" > $(zip_root)/$(PRIVATE_RECOVERY_OUT)/pagesize endif +ifeq ($(strip $(BOARD_KERNEL_SEPARATED_DT)),true) + $(hide) $(ACP) $(INSTALLED_DTIMAGE_TARGET) $(zip_root)/$(PRIVATE_RECOVERY_OUT)/dt +endif endif # not (BUILDING_VENDOR_BOOT_IMAGE and BOARD_USES_RECOVERY_AS_BOOT) endif # INSTALLED_RECOVERYIMAGE_TARGET defined or BOARD_USES_RECOVERY_AS_BOOT is true @# Components of the boot image @@ -6539,6 +6553,9 @@ endif ifdef BOARD_KERNEL_PAGESIZE echo "$(BOARD_KERNEL_PAGESIZE)" > $(zip_root)/BOOT/pagesize endif +ifeq ($(strip $(BOARD_KERNEL_SEPARATED_DT)),true) + $(hide) $(ACP) $(INSTALLED_DTIMAGE_TARGET) $(zip_root)/BOOT/dt +endif endif # INSTALLED_VENDOR_BOOTIMAGE_TARGET == "" && BOARD_USES_GENERIC_KERNEL_IMAGE != true endif # BOARD_USES_RECOVERY_AS_BOOT not true $(hide) $(foreach t,$(INSTALLED_RADIOIMAGE_TARGET),\ diff --git a/tools/releasetools/common.py b/tools/releasetools/common.py index 8e89e23515..3c075eb8c8 100644 --- a/tools/releasetools/common.py +++ b/tools/releasetools/common.py @@ -1771,6 +1771,11 @@ def _BuildBootableImage(image_name, sourcedir, fs_config_file, cmd.append("--pagesize") cmd.append(open(fn).read().rstrip("\n")) + fn = os.path.join(sourcedir, "dt") + if os.access(fn, os.F_OK): + cmd.append("--dt") + cmd.append(fn) + if partition_name == "recovery": args = info_dict.get("recovery_mkbootimg_args") if not args: