From 3e35c26bf2f10e6b11b5d919c9d5c069388c0e68 Mon Sep 17 00:00:00 2001 From: Bowgo Tsai Date: Thu, 29 Jul 2021 23:35:33 +0800 Subject: [PATCH] Adding vendor_boot-test-harness.img boot-test-harness.img is used to allow adb root on user build images. It also sets properties: ro.audio.silent=1 & ro.test_harness=1. GKI 2.0 devices will use BOARD_PREBUILT_BOOTIMAGE so boot-test-harness.img will not be generated. Therefore, we have to introduce the vendor_boot-test-harness.img as an alternative for boot-test-harness.img. In the future, we'll simplify the flow as: + If a device has a /vendor_boot partition, builds vendor_boot-(test-harness|debug).img. + Otherwise, builds boot-(test-harness|debug).img. boot-(test-harness|debug).img needs to be kept for some clients to gracefully transit to using vendor_boot-(test-harness|debug).img. Bug: 194654549 Test: make then `unpack_bootimg --boot_img $OUT/vendor_boot-test-harness.img` Test: Check the ramdisk content in ./out/vendor_ramdisk Change-Id: If3a1393b4ff3e69bb9b62f3b843b7858437d47bf Merged-In: If3a1393b4ff3e69bb9b62f3b843b7858437d47bf (cherry picked from commit 87f60017b964997e877c8c322f6228c08dcb81ff) --- core/Makefile | 42 ++++++++++++++++++++++++++++++++++++++++++ core/main.mk | 5 +++++ 2 files changed, 47 insertions(+) diff --git a/core/Makefile b/core/Makefile index 0d2328cb9..2d56edb9e 100644 --- a/core/Makefile +++ b/core/Makefile @@ -2645,6 +2645,48 @@ endif # TARGET_NO_KERNEL endif # INSTALLED_BOOTIMAGE_TARGET endif # BOARD_BUILD_SYSTEM_ROOT_IMAGE is not true +ifeq ($(BUILDING_VENDOR_BOOT_IMAGE),true) +ifeq ($(BUILDING_RAMDISK_IMAGE),true) +# ----------------------------------------------------------------- +# vendor test harness ramdisk, which is a vendor ramdisk combined with +# a test harness ramdisk. + +INTERNAL_VENDOR_TEST_HARNESS_RAMDISK_TARGET := $(call intermediates-dir-for,PACKAGING,vendor_boot-test-harness)/vendor_ramdisk-test-harness.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_TEST_HARNESS_RAMDISK_TARGET): $(INTERNAL_RECOVERY_RAMDISK_FILES_TIMESTAMP) +$(INTERNAL_VENDOR_TEST_HARNESS_RAMDISK_TARGET): PRIVATE_ADDITIONAL_DIR := $(TARGET_RECOVERY_ROOT_OUT) +endif +endif + +# The vendor test harness ramdisk combines vendor ramdisk and test harness ramdisk. +$(INTERNAL_VENDOR_TEST_HARNESS_RAMDISK_TARGET): $(INTERNAL_VENDOR_RAMDISK_TARGET) $(INSTALLED_TEST_HARNESS_RAMDISK_TARGET) +$(INTERNAL_VENDOR_TEST_HARNESS_RAMDISK_TARGET): $(MKBOOTFS) | $(COMPRESSION_COMMAND_DEPS) + $(MKBOOTFS) -d $(TARGET_OUT) $(TARGET_VENDOR_RAMDISK_OUT) $(TARGET_TEST_HARNESS_RAMDISK_OUT) $(PRIVATE_ADDITIONAL_DIR) | $(COMPRESSION_COMMAND) > $@ + +# ----------------------------------------------------------------- +# vendor_boot-test-harness.img. +INSTALLED_VENDOR_TEST_HARNESS_BOOTIMAGE_TARGET := $(PRODUCT_OUT)/vendor_boot-test-harness.img + +ifneq ($(BOARD_AVB_VENDOR_BOOT_KEY_PATH),) +$(INSTALLED_VENDOR_TEST_HARNESS_BOOTIMAGE_TARGET): $(AVBTOOL) $(BOARD_AVB_VENDOR_BOOT_TEST_KEY_PATH) +endif + +# Depends on vendor_boot.img and vendor_ramdisk-test-harness.cpio$(RAMDISK_EXT) to build the new vendor_boot-test-harness.img +$(INSTALLED_VENDOR_TEST_HARNESS_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INSTALLED_VENDOR_BOOTIMAGE_TARGET) +$(INSTALLED_VENDOR_TEST_HARNESS_BOOTIMAGE_TARGET): $(INTERNAL_VENDOR_TEST_HARNESS_RAMDISK_TARGET) +$(INSTALLED_VENDOR_TEST_HARNESS_BOOTIMAGE_TARGET): $(INTERNAL_VENDOR_RAMDISK_FRAGMENT_TARGETS) + $(call pretty,"Target vendor_boot test harness image: $@") + $(MKBOOTIMG) $(INTERNAL_VENDOR_BOOTIMAGE_ARGS) $(BOARD_MKBOOTIMG_ARGS) --vendor_ramdisk $(INTERNAL_VENDOR_TEST_HARNESS_RAMDISK_TARGET) $(INTERNAL_VENDOR_RAMDISK_FRAGMENT_ARGS) --vendor_boot $@ + $(call assert-max-image-size,$@,$(BOARD_VENDOR_BOOTIMAGE_PARTITION_SIZE)) + $(if $(BOARD_AVB_VENDOR_BOOT_KEY_PATH),$(call test-key-sign-vendor-bootimage,$@)) + +endif # BUILDING_RAMDISK_IMAGE +endif # BUILDING_VENDOR_BOOT_IMAGE + # Creates a compatibility symlink between two partitions, e.g. /system/vendor to /vendor # $1: from location (e.g $(TARGET_OUT)/vendor) # $2: destination location (e.g. /vendor) diff --git a/core/main.mk b/core/main.mk index d9c9732a8..cc19544ce 100644 --- a/core/main.mk +++ b/core/main.mk @@ -1527,6 +1527,9 @@ vendorbootimage: $(INSTALLED_VENDOR_BOOTIMAGE_TARGET) .PHONY: vendorbootimage_debug vendorbootimage_debug: $(INSTALLED_VENDOR_DEBUG_BOOTIMAGE_TARGET) +.PHONY: vendorbootimage_test_harness +vendorbootimage_test_harness: $(INSTALLED_VENDOR_TEST_HARNESS_BOOTIMAGE_TARGET) + .PHONY: vendorramdisk vendorramdisk: $(INSTALLED_VENDOR_RAMDISK_TARGET) @@ -1592,6 +1595,7 @@ droidcore-unbundled: $(filter $(HOST_OUT_ROOT)/%,$(modules_to_install)) \ $(INSTALLED_VENDORIMAGE_TARGET) \ $(INSTALLED_VENDOR_BOOTIMAGE_TARGET) \ $(INSTALLED_VENDOR_DEBUG_BOOTIMAGE_TARGET) \ + $(INSTALLED_VENDOR_TEST_HARNESS_BOOTIMAGE_TARGET) \ $(INSTALLED_VENDOR_RAMDISK_TARGET) \ $(INSTALLED_VENDOR_DEBUG_RAMDISK_TARGET) \ $(INSTALLED_ODMIMAGE_TARGET) \ @@ -1811,6 +1815,7 @@ else ifeq ($(TARGET_BUILD_UNBUNDLED),$(TARGET_BUILD_UNBUNDLED_IMAGE)) $(INSTALLED_TEST_HARNESS_RAMDISK_TARGET) \ $(INSTALLED_TEST_HARNESS_BOOTIMAGE_TARGET) \ $(INSTALLED_VENDOR_DEBUG_BOOTIMAGE_TARGET) \ + $(INSTALLED_VENDOR_TEST_HARNESS_BOOTIMAGE_TARGET) \ $(INSTALLED_VENDOR_RAMDISK_TARGET) \ $(INSTALLED_VENDOR_DEBUG_RAMDISK_TARGET) \ )