diff --git a/core/Makefile b/core/Makefile index eb0835529..f1e59478a 100644 --- a/core/Makefile +++ b/core/Makefile @@ -210,10 +210,28 @@ $(INSTALLED_SDK_BUILD_PROP_TARGET): $(INSTALLED_BUILD_PROP_TARGET) echo "$$x"generic >> $@.tmp; done $(hide) mv $@.tmp $@ +# ----------------------------------------------------------------- +# declare recovery ramdisk files +ifeq ($(BUILDING_RECOVERY_IMAGE),true) +INTERNAL_RECOVERY_RAMDISK_FILES_TIMESTAMP := $(call intermediates-dir-for,PACKAGING,recovery)/ramdisk_files-timestamp +endif + # ----------------------------------------------------------------- # Declare vendor ramdisk fragments INTERNAL_VENDOR_RAMDISK_FRAGMENTS := +ifeq (true,$(BOARD_INCLUDE_RECOVERY_RAMDISK_IN_VENDOR_BOOT)) + ifneq (,$(filter recovery,$(BOARD_VENDOR_RAMDISK_FRAGMENTS))) + $(error BOARD_VENDOR_RAMDISK_FRAGMENTS must not contain "recovery" if \ + BOARD_INCLUDE_RECOVERY_RAMDISK_IN_VENDOR_BOOT is set) + endif + INTERNAL_VENDOR_RAMDISK_FRAGMENTS += recovery + VENDOR_RAMDISK_FRAGMENT.recovery.STAGING_DIR := $(TARGET_RECOVERY_ROOT_OUT) + VENDOR_RAMDISK_FRAGMENT.recovery.FILES := $(INTERNAL_RECOVERY_RAMDISK_FILES_TIMESTAMP) + BOARD_VENDOR_RAMDISK_FRAGMENT.recovery.MKBOOTIMG_ARGS += --ramdisk_type RECOVERY + .KATI_READONLY := VENDOR_RAMDISK_FRAGMENT.recovery.STAGING_DIR +endif + # Validation check and assign default --ramdisk_type. $(foreach vendor_ramdisk_fragment,$(BOARD_VENDOR_RAMDISK_FRAGMENTS), \ $(if $(and $(BOARD_VENDOR_RAMDISK_FRAGMENT.$(vendor_ramdisk_fragment).KERNEL_MODULE_DIRS), \ @@ -1032,12 +1050,6 @@ endif # my_installed_prebuilt_gki_apex not defined my_apex_extracted_boot_image := my_installed_prebuilt_gki_apex := -# ----------------------------------------------------------------- -# declare recovery ramdisk files -ifeq ($(BUILDING_RECOVERY_IMAGE),true) -INTERNAL_RECOVERY_RAMDISK_FILES_TIMESTAMP := $(call intermediates-dir-for,PACKAGING,recovery)/ramdisk_files-timestamp -endif - # ----------------------------------------------------------------- # vendor boot image ifeq ($(BUILDING_VENDOR_BOOT_IMAGE),true) @@ -1052,10 +1064,14 @@ INTERNAL_VENDOR_RAMDISK_FILES := $(filter $(TARGET_VENDOR_RAMDISK_OUT)/%, \ INTERNAL_VENDOR_RAMDISK_TARGET := $(call intermediates-dir-for,PACKAGING,vendor_boot)/vendor_ramdisk.cpio$(RAMDISK_EXT) +# Exclude recovery files in the default vendor ramdisk if including a standalone +# recovery ramdisk in vendor_boot. ifeq (true,$(BOARD_MOVE_RECOVERY_RESOURCES_TO_VENDOR_BOOT)) +ifneq (true,$(BOARD_INCLUDE_RECOVERY_RAMDISK_IN_VENDOR_BOOT)) $(INTERNAL_VENDOR_RAMDISK_TARGET): $(INTERNAL_RECOVERY_RAMDISK_FILES_TIMESTAMP) $(INTERNAL_VENDOR_RAMDISK_TARGET): PRIVATE_ADDITIONAL_DIR := $(TARGET_RECOVERY_ROOT_OUT) endif +endif $(INTERNAL_VENDOR_RAMDISK_TARGET): $(MKBOOTFS) $(INTERNAL_VENDOR_RAMDISK_FILES) | $(COMPRESSION_COMMAND_DEPS) $(MKBOOTFS) -d $(TARGET_OUT) $(TARGET_VENDOR_RAMDISK_OUT) $(PRIVATE_ADDITIONAL_DIR) | $(COMPRESSION_COMMAND) > $@ @@ -2448,9 +2464,14 @@ INTERNAL_VENDOR_DEBUG_RAMDISK_TARGET := $(call intermediates-dir-for,PACKAGING,v $(INTERNAL_VENDOR_DEBUG_RAMDISK_TARGET): DEBUG_RAMDISK_FILES := $(INTERNAL_DEBUG_RAMDISK_FILES) $(INTERNAL_VENDOR_DEBUG_RAMDISK_TARGET): VENDOR_RAMDISK_DIR := $(TARGET_VENDOR_RAMDISK_OUT) +# Exclude recovery files in the default vendor ramdisk if including a standalone +# recovery ramdisk in vendor_boot. ifeq (true,$(BOARD_MOVE_RECOVERY_RESOURCES_TO_VENDOR_BOOT)) +ifneq (true,$(BOARD_INCLUDE_RECOVERY_RAMDISK_IN_VENDOR_BOOT)) +$(INTERNAL_VENDOR_DEBUG_RAMDISK_TARGET): $(INTERNAL_RECOVERY_RAMDISK_FILES_TIMESTAMP) $(INTERNAL_VENDOR_DEBUG_RAMDISK_TARGET): PRIVATE_ADDITIONAL_DIR := $(TARGET_RECOVERY_ROOT_OUT) endif +endif INTERNAL_VENDOR_DEBUG_RAMDISK_FILES := $(filter $(TARGET_VENDOR_DEBUG_RAMDISK_OUT)/%, \ $(ALL_GENERATED_SOURCES) \ @@ -4850,8 +4871,12 @@ $(BUILT_TARGET_FILES_PACKAGE): \ ifneq (,$(INSTALLED_RECOVERYIMAGE_TARGET)$(filter true,$(BOARD_USES_RECOVERY_AS_BOOT))$(filter true,$(BOARD_MOVE_RECOVERY_RESOURCES_TO_VENDOR_BOOT))) @# Components of the recovery image $(hide) mkdir -p $(zip_root)/$(PRIVATE_RECOVERY_OUT) +# Exclude recovery files in the default vendor ramdisk if including a standalone +# recovery ramdisk in vendor_boot. +ifneq (true,$(BOARD_INCLUDE_RECOVERY_RAMDISK_IN_VENDOR_BOOT)) $(hide) $(call package_files-copy-root, \ $(TARGET_RECOVERY_ROOT_OUT),$(zip_root)/$(PRIVATE_RECOVERY_OUT)/RAMDISK) +endif ifdef INSTALLED_KERNEL_TARGET ifneq (,$(filter true,$(BOARD_USES_RECOVERY_AS_BOOT))) cp $(INSTALLED_KERNEL_TARGET) $(zip_root)/$(PRIVATE_RECOVERY_OUT)/ diff --git a/core/board_config.mk b/core/board_config.mk index 9ae597e33..be37292c7 100644 --- a/core/board_config.mk +++ b/core/board_config.mk @@ -108,6 +108,8 @@ _board_strip_readonly_list += BOARD_KERNEL_MODULE_INTERFACE_VERSIONS # contains a kernel or not. # - BOARD_MOVE_RECOVERY_RESOURCES_TO_VENDOR_BOOT controls whether ramdisk # recovery resources are built to vendor_boot. +# - BOARD_INCLUDE_RECOVERY_RAMDISK_IN_VENDOR_BOOT controls whether recovery +# resources are built as a standalone recovery ramdisk in vendor_boot. # - BOARD_MOVE_GSI_AVB_KEYS_TO_VENDOR_BOOT controls whether GSI AVB keys are # built to vendor_boot. # - BOARD_COPY_BOOT_IMAGE_TO_TARGET_FILES controls whether boot images in $OUT are added @@ -115,6 +117,7 @@ _board_strip_readonly_list += BOARD_KERNEL_MODULE_INTERFACE_VERSIONS _board_strip_readonly_list += BOARD_USES_GENERIC_KERNEL_IMAGE _board_strip_readonly_list += BOARD_EXCLUDE_KERNEL_FROM_RECOVERY_IMAGE _board_strip_readonly_list += BOARD_MOVE_RECOVERY_RESOURCES_TO_VENDOR_BOOT +_board_strip_readonly_list += BOARD_INCLUDE_RECOVERY_RAMDISK_IN_VENDOR_BOOT _board_strip_readonly_list += BOARD_MOVE_GSI_AVB_KEYS_TO_VENDOR_BOOT _board_strip_readonly_list += BOARD_COPY_BOOT_IMAGE_TO_TARGET_FILES @@ -835,6 +838,10 @@ else # BUILDING_VENDOR_BOOT_IMAGE $(error Should not set BOARD_VENDOR_RAMDISK_FRAGMENTS if \ BOARD_BOOT_HEADER_VERSION is less than 4) endif + ifeq (true,$(BOARD_INCLUDE_RECOVERY_RAMDISK_IN_VENDOR_BOOT)) + $(error Should not set BOARD_INCLUDE_RECOVERY_RAMDISK_IN_VENDOR_BOOT if \ + BOARD_BOOT_HEADER_VERSION is less than 4) + endif endif endif # BUILDING_VENDOR_BOOT_IMAGE @@ -842,6 +849,13 @@ ifneq ($(words $(BOARD_VENDOR_RAMDISK_FRAGMENTS)),$(words $(sort $(BOARD_VENDOR_ $(error BOARD_VENDOR_RAMDISK_FRAGMENTS has duplicate entries: $(BOARD_VENDOR_RAMDISK_FRAGMENTS)) endif +ifeq (true,$(BOARD_INCLUDE_RECOVERY_RAMDISK_IN_VENDOR_BOOT)) + ifneq (true,$(BOARD_MOVE_RECOVERY_RESOURCES_TO_VENDOR_BOOT)) + $(error Should not set BOARD_INCLUDE_RECOVERY_RAMDISK_IN_VENDOR_BOOT if \ + BOARD_MOVE_RECOVERY_RESOURCES_TO_VENDOR_BOOT is not set) + endif +endif + # If BOARD_USES_GENERIC_KERNEL_IMAGE is set, BOARD_USES_RECOVERY_AS_BOOT must not be set. # Devices without a dedicated recovery partition uses BOARD_MOVE_RECOVERY_RESOURCES_TO_VENDOR_BOOT to # build recovery into vendor_boot.