From 9492ee3d1b30a5fdb8b5752cd8e4a7dda8b40755 Mon Sep 17 00:00:00 2001 From: bohu Date: Thu, 7 Mar 2019 10:03:41 -0800 Subject: [PATCH] emulator: support dynamic partitions BUG: 125540538 Change-Id: I9d486f57ac4ec11b1bbe9ab97890d12441c3054e Merged-In: I9d486f57ac4ec11b1bbe9ab97890d12441c3054e --- core/Makefile | 25 +++++++++------ target/board/BoardConfigEmuCommon.mk | 34 ++++++++++++++++----- target/board/generic/BoardConfig.mk | 2 +- target/board/generic_arm64/BoardConfig.mk | 2 +- target/board/generic_x86/BoardConfig.mk | 2 +- target/board/generic_x86_64/BoardConfig.mk | 3 +- target/board/generic_x86_arm/BoardConfig.mk | 2 +- target/product/aosp_arm.mk | 2 ++ target/product/aosp_arm64.mk | 2 ++ target/product/aosp_x86.mk | 2 ++ target/product/aosp_x86_64.mk | 2 ++ target/product/aosp_x86_arm.mk | 8 +---- 12 files changed, 57 insertions(+), 29 deletions(-) diff --git a/core/Makefile b/core/Makefile index c4cd57af6e..a2ef3fde05 100644 --- a/core/Makefile +++ b/core/Makefile @@ -4521,13 +4521,20 @@ dalvikfiles: $(INTERNAL_DALVIK_MODULES) ifeq ($(BUILD_QEMU_IMAGES),true) MK_QEMU_IMAGE_SH := device/generic/goldfish/tools/mk_qemu_image.sh +MK_COMBINE_QEMU_IMAGE_SH := device/generic/goldfish/tools/mk_combined_img.py SGDISK_HOST := $(HOST_OUT_EXECUTABLES)/sgdisk ifdef INSTALLED_SYSTEMIMAGE_TARGET INSTALLED_QEMU_SYSTEMIMAGE := $(PRODUCT_OUT)/system-qemu.img -$(INSTALLED_QEMU_SYSTEMIMAGE): $(INSTALLED_SYSTEMIMAGE_TARGET) $(MK_QEMU_IMAGE_SH) $(SGDISK_HOST) $(SIMG2IMG) - @echo Create system-qemu.img - (export SGDISK=$(SGDISK_HOST) SIMG2IMG=$(SIMG2IMG); $(MK_QEMU_IMAGE_SH) $(INSTALLED_SYSTEMIMAGE_TARGET)) +INSTALLED_SYSTEM_QEMU_CONFIG := $(PRODUCT_OUT)/system-qemu-config.txt +$(INSTALLED_SYSTEM_QEMU_CONFIG): $(INSTALLED_SUPERIMAGE_TARGET) $(INSTALLED_VBMETAIMAGE_TARGET) + @echo "$(PRODUCT_OUT)/vbmeta.img vbmeta 1" > $@ + @echo "$(INSTALLED_SUPERIMAGE_TARGET) super 2" >> $@ +$(INSTALLED_QEMU_SYSTEMIMAGE): $(INSTALLED_VBMETAIMAGE_TARGET) $(MK_COMBINE_QEMU_IMAGE_SH) $(SGDISK_HOST) $(SIMG2IMG) \ + $(INSTALLED_SUPERIMAGE_TARGET) $(INSTALLED_SYSTEM_QEMU_CONFIG) + @echo Create system-qemu.img now + (export SGDISK=$(SGDISK_HOST) SIMG2IMG=$(SIMG2IMG); \ + $(MK_COMBINE_QEMU_IMAGE_SH) -i $(INSTALLED_SYSTEM_QEMU_CONFIG) -o $@) systemimage: $(INSTALLED_QEMU_SYSTEMIMAGE) droidcore: $(INSTALLED_QEMU_SYSTEMIMAGE) @@ -4569,17 +4576,17 @@ odmimage: $(INSTALLED_QEMU_ODMIMAGE) droidcore: $(INSTALLED_QEMU_ODMIMAGE) endif -ifeq ($(BOARD_AVB_ENABLE),true) QEMU_VERIFIED_BOOT_PARAMS := $(PRODUCT_OUT)/VerifiedBootParams.textproto -MK_VERIFIED_BOOT_KERNEL_CMDLINE_SH := device/generic/goldfish/tools/mk_verified_boot_params.sh -$(QEMU_VERIFIED_BOOT_PARAMS): $(INSTALLED_QEMU_SYSTEMIMAGE) $(MK_VERIFIED_BOOT_KERNEL_CMDLINE_SH) $(INSTALLED_VBMETAIMAGE_TARGET) $(SGDISK_HOST) $(AVBTOOL) +MK_VBMETA_BOOT_KERNEL_CMDLINE_SH := device/generic/goldfish/tools/mk_vbmeta_boot_params.sh +$(QEMU_VERIFIED_BOOT_PARAMS): $(INSTALLED_VBMETAIMAGE_TARGET) $(INSTALLED_SYSTEMIMAGE_TARGET) \ + $(MK_VBMETA_BOOT_KERNEL_CMDLINE_SH) $(AVBTOOL) @echo Creating $@ - (export SGDISK=$(SGDISK_HOST) AVBTOOL=$(AVBTOOL); $(MK_VERIFIED_BOOT_KERNEL_CMDLINE_SH) $(INSTALLED_VBMETAIMAGE_TARGET) $(INSTALLED_QEMU_SYSTEMIMAGE) $(QEMU_VERIFIED_BOOT_PARAMS)) - + (export AVBTOOL=$(AVBTOOL); $(MK_VBMETA_BOOT_KERNEL_CMDLINE_SH) $(INSTALLED_VBMETAIMAGE_TARGET) \ + $(INSTALLED_SYSTEMIMAGE_TARGET) $(QEMU_VERIFIED_BOOT_PARAMS)) systemimage: $(QEMU_VERIFIED_BOOT_PARAMS) droidcore: $(QEMU_VERIFIED_BOOT_PARAMS) -endif + endif # ----------------------------------------------------------------- # The emulator package diff --git a/target/board/BoardConfigEmuCommon.mk b/target/board/BoardConfigEmuCommon.mk index 9ec71d0ec6..3ab5f12d5a 100644 --- a/target/board/BoardConfigEmuCommon.mk +++ b/target/board/BoardConfigEmuCommon.mk @@ -23,15 +23,35 @@ USE_OPENGL_RENDERER := true # Emulator doesn't support sparse image format. TARGET_USERIMAGES_SPARSE_EXT_DISABLED := true -# ~140 MB vendor image. Please adjust system image / vendor image sizes -# when finalizing them. The partition size needs to be a multiple of image -# block size: 4096. -BOARD_VENDORIMAGE_PARTITION_SIZE := 146800640 +ifeq ($(PRODUCT_USE_DYNAMIC_PARTITIONS),true) + # emulator is Non-A/B device + AB_OTA_UPDATER := false + + # emulator needs super.img + BOARD_BUILD_SUPER_IMAGE_BY_DEFAULT := true + + BOARD_EXT4_SHARE_DUP_BLOCKS := true + + # 3G + header + BOARD_SUPER_PARTITION_SIZE := 3229614080 + BOARD_SUPER_PARTITION_GROUPS := emulator_dynamic_partitions + BOARD_EMULATOR_DYNAMIC_PARTITIONS_PARTITION_LIST := \ + system \ + vendor + + # 3G + BOARD_EMULATOR_DYNAMIC_PARTITIONS_SIZE := 3221225472 +else ifeq ($(PRODUCT_USE_DYNAMIC_PARTITION_SIZE),true) + # Enable dynamic system image size and reserved 64MB in it. + BOARD_SYSTEMIMAGE_PARTITION_RESERVED_SIZE := 67108864 + BOARD_VENDORIMAGE_PARTITION_RESERVED_SIZE := 67108864 +else + BOARD_SYSTEMIMAGE_PARTITION_SIZE := 3221225472 + BOARD_VENDORIMAGE_PARTITION_SIZE := 146800640 +endif + BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE := ext4 BOARD_FLASH_BLOCK_SIZE := 512 DEVICE_MATRIX_FILE := device/generic/goldfish/compatibility_matrix.xml BOARD_SEPOLICY_DIRS += device/generic/goldfish/sepolicy/common - -# TODO(b/125540538): Remove when emulator uses dynamic partitions -BOARD_BUILD_SYSTEM_ROOT_IMAGE := true diff --git a/target/board/generic/BoardConfig.mk b/target/board/generic/BoardConfig.mk index b61a7fddce..8624ed72b3 100644 --- a/target/board/generic/BoardConfig.mk +++ b/target/board/generic/BoardConfig.mk @@ -29,8 +29,8 @@ TARGET_CPU_VARIANT := generic TARGET_CPU_ABI := armeabi-v7a TARGET_CPU_ABI2 := armeabi -include build/make/target/board/BoardConfigEmuCommon.mk include build/make/target/board/BoardConfigGsiCommon.mk +include build/make/target/board/BoardConfigEmuCommon.mk BOARD_USERDATAIMAGE_PARTITION_SIZE := 576716800 diff --git a/target/board/generic_arm64/BoardConfig.mk b/target/board/generic_arm64/BoardConfig.mk index 7d92b7dfa5..ecc547f5b0 100644 --- a/target/board/generic_arm64/BoardConfig.mk +++ b/target/board/generic_arm64/BoardConfig.mk @@ -52,8 +52,8 @@ TARGET_2ND_ARCH_VARIANT := armv8-a TARGET_2ND_CPU_VARIANT := generic endif -include build/make/target/board/BoardConfigEmuCommon.mk include build/make/target/board/BoardConfigGsiCommon.mk +include build/make/target/board/BoardConfigEmuCommon.mk BOARD_USERDATAIMAGE_PARTITION_SIZE := 576716800 diff --git a/target/board/generic_x86/BoardConfig.mk b/target/board/generic_x86/BoardConfig.mk index 650073e68b..83d7eccc7a 100644 --- a/target/board/generic_x86/BoardConfig.mk +++ b/target/board/generic_x86/BoardConfig.mk @@ -20,8 +20,8 @@ TARGET_ARCH_VARIANT := x86 TARGET_PRELINK_MODULE := false -include build/make/target/board/BoardConfigEmuCommon.mk include build/make/target/board/BoardConfigGsiCommon.mk +include build/make/target/board/BoardConfigEmuCommon.mk # Resize to 4G to accomodate ASAN and CTS BOARD_USERDATAIMAGE_PARTITION_SIZE := 4294967296 diff --git a/target/board/generic_x86_64/BoardConfig.mk b/target/board/generic_x86_64/BoardConfig.mk index 1426630443..07bbc071ac 100755 --- a/target/board/generic_x86_64/BoardConfig.mk +++ b/target/board/generic_x86_64/BoardConfig.mk @@ -23,9 +23,8 @@ TARGET_2ND_ARCH := x86 TARGET_2ND_ARCH_VARIANT := x86_64 TARGET_PRELINK_MODULE := false - -include build/make/target/board/BoardConfigEmuCommon.mk include build/make/target/board/BoardConfigGsiCommon.mk +include build/make/target/board/BoardConfigEmuCommon.mk BOARD_USERDATAIMAGE_PARTITION_SIZE := 576716800 diff --git a/target/board/generic_x86_arm/BoardConfig.mk b/target/board/generic_x86_arm/BoardConfig.mk index ab2089d114..6fae4113c1 100644 --- a/target/board/generic_x86_arm/BoardConfig.mk +++ b/target/board/generic_x86_arm/BoardConfig.mk @@ -30,8 +30,8 @@ TARGET_TRANSLATE_2ND_ARCH := true BUILD_BROKEN_DUP_RULES := true -include build/make/target/board/BoardConfigEmuCommon.mk include build/make/target/board/BoardConfigGsiCommon.mk +include build/make/target/board/BoardConfigEmuCommon.mk # Resize to 4G to accomodate ASAN and CTS BOARD_USERDATAIMAGE_PARTITION_SIZE := 4294967296 diff --git a/target/product/aosp_arm.mk b/target/product/aosp_arm.mk index 400fa6abf4..0fdd31377c 100644 --- a/target/product/aosp_arm.mk +++ b/target/product/aosp_arm.mk @@ -14,6 +14,8 @@ # limitations under the License. # +PRODUCT_USE_DYNAMIC_PARTITIONS := true + # The system image of aosp_arm-userdebug is a GSI for the devices with: # - ARM 32 bits user space # - 64 bits binder interface diff --git a/target/product/aosp_arm64.mk b/target/product/aosp_arm64.mk index aa6ec4d0d2..8ef2023e62 100644 --- a/target/product/aosp_arm64.mk +++ b/target/product/aosp_arm64.mk @@ -14,6 +14,8 @@ # limitations under the License. # +PRODUCT_USE_DYNAMIC_PARTITIONS := true + # The system image of aosp_arm64-userdebug is a GSI for the devices with: # - ARM 64 bits user space # - 64 bits binder interface diff --git a/target/product/aosp_x86.mk b/target/product/aosp_x86.mk index b16b5edde4..1c7194844a 100644 --- a/target/product/aosp_x86.mk +++ b/target/product/aosp_x86.mk @@ -14,6 +14,8 @@ # limitations under the License. # +PRODUCT_USE_DYNAMIC_PARTITIONS := true + # The system image of aosp_x86-userdebug is a GSI for the devices with: # - x86 32 bits user space # - 64 bits binder interface diff --git a/target/product/aosp_x86_64.mk b/target/product/aosp_x86_64.mk index f7e205691f..9dfa2f4804 100644 --- a/target/product/aosp_x86_64.mk +++ b/target/product/aosp_x86_64.mk @@ -14,6 +14,8 @@ # limitations under the License. # +PRODUCT_USE_DYNAMIC_PARTITIONS := true + # The system image of aosp_x86_64-userdebug is a GSI for the devices with: # - x86 64 bits user space # - 64 bits binder interface diff --git a/target/product/aosp_x86_arm.mk b/target/product/aosp_x86_arm.mk index b921c979e0..70aa64ee2d 100644 --- a/target/product/aosp_x86_arm.mk +++ b/target/product/aosp_x86_arm.mk @@ -14,6 +14,7 @@ # limitations under the License. # +PRODUCT_USE_DYNAMIC_PARTITIONS := true # aosp_x86 with arm libraries needed by binary translation. @@ -31,13 +32,6 @@ include $(SRC_TARGET_DIR)/product/full_x86.mk # Enable dynamic partition size PRODUCT_USE_DYNAMIC_PARTITION_SIZE := true -# Enable A/B update -AB_OTA_UPDATER := true -AB_OTA_PARTITIONS := system -PRODUCT_PACKAGES += \ - update_engine \ - update_verifier - # Needed by Pi newly launched device to pass VtsTrebleSysProp on GSI PRODUCT_COMPATIBLE_PROPERTY_OVERRIDE := true