aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSzuWei Lin <szuweilin@google.com>2021-12-30 18:40:38 +0800
committerSzuWei Lin <szuweilin@google.com>2022-01-10 17:53:54 +0800
commitf346c9a7479e5400dc1cec281d6a31e79f064cad (patch)
tree19bac579c2c2da16d7996ba13f331b0fb2620462
parent3d8ca6c8ed1eed76443bc7432b0f0280b0b9ffc9 (diff)
downloadcommon-f346c9a7479e5400dc1cec281d6a31e79f064cad.tar.gz
Add targets for building boot.img with GKI
The patch adds 2 targets gki_arm64 and gki_x86_64 for building all boot.img with GKI. The new targets also output init_boot.img. The patch initials the new targets by including minimum modules as possible. With the patch, it is no need to build GKI from GSI targets, and will remove outputting GKI from GSI targets, such as gsi_$arch and aosp_$arch. Bug: 212486689 Test: lunch gki_arm64-userdebug; make dist Test: lunch gki_x86_64-userdebug; make bootimage dist Change-Id: I90ecfddbc080086b549545415506867633133a45
-rw-r--r--AndroidProducts.mk2
-rw-r--r--BoardConfigGkiCommon.mk62
-rw-r--r--gki_arm64.mk34
-rw-r--r--gki_arm64/BoardConfig.mk48
-rw-r--r--gki_common.mk111
-rw-r--r--gki_x86_64.mk33
-rwxr-xr-xgki_x86_64/BoardConfig.mk38
7 files changed, 328 insertions, 0 deletions
diff --git a/AndroidProducts.mk b/AndroidProducts.mk
index b002607..32ac42d 100644
--- a/AndroidProducts.mk
+++ b/AndroidProducts.mk
@@ -15,6 +15,8 @@
#
PRODUCT_MAKEFILES := \
+ $(LOCAL_DIR)/gki_arm64.mk \
+ $(LOCAL_DIR)/gki_x86_64.mk \
$(LOCAL_DIR)/gsi_arm.mk \
$(LOCAL_DIR)/gsi_arm64.mk \
$(LOCAL_DIR)/gsi_x86.mk \
diff --git a/BoardConfigGkiCommon.mk b/BoardConfigGkiCommon.mk
new file mode 100644
index 0000000..681b3b7
--- /dev/null
+++ b/BoardConfigGkiCommon.mk
@@ -0,0 +1,62 @@
+# Copyright (C) 2022 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+# Enable GKI 2.0 certification
+BOARD_GKI_SIGNING_KEY_PATH := build/make/target/product/gsi/testkey_rsa2048.pem
+BOARD_GKI_SIGNING_ALGORITHM := SHA256_RSA2048
+
+# Enable chained vbmeta for boot and init_boot images
+BOARD_AVB_ENABLE := true
+BOARD_AVB_ROLLBACK_INDEX := $(PLATFORM_SECURITY_PATCH_TIMESTAMP)
+
+BOARD_AVB_BOOT_KEY_PATH := external/avb/test/data/testkey_rsa4096.pem
+BOARD_AVB_BOOT_ALGORITHM := SHA256_RSA4096
+BOARD_AVB_BOOT_ROLLBACK_INDEX := $(PLATFORM_SECURITY_PATCH_TIMESTAMP)
+BOARD_AVB_BOOT_ROLLBACK_INDEX_LOCATION := 2
+
+BOARD_AVB_INIT_BOOT_KEY_PATH := external/avb/test/data/testkey_rsa4096.pem
+BOARD_AVB_INIT_BOOT_ALGORITHM := SHA256_RSA4096
+BOARD_AVB_INIT_BOOT_ROLLBACK_INDEX := $(PLATFORM_SECURITY_PATCH_TIMESTAMP)
+BOARD_AVB_INIT_BOOT_ROLLBACK_INDEX_LOCATION := 3
+
+# Sets boot SPL.
+BOOT_SECURITY_PATCH = $(PLATFORM_SECURITY_PATCH)
+
+# Boot image with ramdisk and kernel
+BOARD_BOOT_HEADER_VERSION := 4
+BOARD_MKBOOTIMG_ARGS += --header_version $(BOARD_BOOT_HEADER_VERSION)
+BOARD_USES_RECOVERY_AS_BOOT :=
+TARGET_NO_KERNEL := false
+BOARD_USES_GENERIC_KERNEL_IMAGE := true
+
+# Init boot image
+BOARD_RAMDISK_USE_LZ4 := true
+BOARD_INIT_BOOT_HEADER_VERSION := 4
+BOARD_MKBOOTIMG_INIT_ARGS += --header_version $(BOARD_INIT_BOOT_HEADER_VERSION)
+# TODO(b/212486689) Need to confirm the size
+BOARD_INIT_BOOT_IMAGE_PARTITION_SIZE := 8388608
+
+# Copy boot image in $OUT to target files. This is defined for targets where
+# the installed GKI APEXes are built from source.
+BOARD_COPY_BOOT_IMAGE_TO_TARGET_FILES := true
+
+# No system image
+BOARD_SYSTEMIMAGE_PARTITION_SIZE :=
+
+# No vendor_boot
+BOARD_MOVE_RECOVERY_RESOURCES_TO_VENDOR_BOOT :=
+
+# No recovery
+BOARD_EXCLUDE_KERNEL_FROM_RECOVERY_IMAGE :=
diff --git a/gki_arm64.mk b/gki_arm64.mk
new file mode 100644
index 0000000..9597d84
--- /dev/null
+++ b/gki_arm64.mk
@@ -0,0 +1,34 @@
+#
+# Copyright (C) 2022 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+#
+# TODO (b/212486689): The minimum system stuff for build pass.
+#
+$(call inherit-product, $(SRC_TARGET_DIR)/product/core_64_bit.mk)
+$(call inherit-product, $(SRC_TARGET_DIR)/product/runtime_libart.mk)
+
+#
+# Build GKI boot images
+#
+include device/generic/common/gki_common.mk
+$(call output-kernel,kernel/prebuilts/4.19/arm64,kernel/4.19)
+$(call output-kernel,kernel/prebuilts/5.10/arm64,kernel/5.10)
+
+
+PRODUCT_NAME := gki_arm64
+PRODUCT_DEVICE := gki_arm64
+PRODUCT_BRAND := Android
+PRODUCT_MODEL := GKI on ARM64
diff --git a/gki_arm64/BoardConfig.mk b/gki_arm64/BoardConfig.mk
new file mode 100644
index 0000000..c5d81b0
--- /dev/null
+++ b/gki_arm64/BoardConfig.mk
@@ -0,0 +1,48 @@
+# Copyright (C) 2022 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+TARGET_ARCH := arm64
+TARGET_ARCH_VARIANT := armv8-a
+TARGET_CPU_ABI := arm64-v8a
+TARGET_CPU_ABI2 :=
+TARGET_CPU_VARIANT := generic
+
+TARGET_2ND_ARCH := arm
+TARGET_2ND_ARCH_VARIANT := armv8-a
+TARGET_2ND_CPU_ABI := armeabi-v7a
+TARGET_2ND_CPU_ABI2 := armeabi
+TARGET_2ND_CPU_VARIANT := generic
+
+include device/generic/common/BoardConfigGkiCommon.mk
+
+BOARD_KERNEL-4.19-GZ_BOOTIMAGE_PARTITION_SIZE := 47185920
+BOARD_KERNEL-4.19-GZ-ALLSYMS_BOOTIMAGE_PARTITION_SIZE := 47185920
+BOARD_KERNEL-5.10_BOOTIMAGE_PARTITION_SIZE := 67108864
+BOARD_KERNEL-5.10-ALLSYMS_BOOTIMAGE_PARTITION_SIZE := 67108864
+BOARD_KERNEL-5.10-GZ_BOOTIMAGE_PARTITION_SIZE := 47185920
+BOARD_KERNEL-5.10-GZ-ALLSYMS_BOOTIMAGE_PARTITION_SIZE := 47185920
+BOARD_KERNEL-5.10-LZ4_BOOTIMAGE_PARTITION_SIZE := 53477376
+BOARD_KERNEL-5.10-LZ4-ALLSYMS_BOOTIMAGE_PARTITION_SIZE := 53477376
+
+BOARD_KERNEL_BINARIES := \
+ kernel-4.19-gz \
+ kernel-5.10 kernel-5.10-gz kernel-5.10-lz4 \
+
+ifneq (,$(filter userdebug eng,$(TARGET_BUILD_VARIANT)))
+BOARD_KERNEL_BINARIES += \
+ kernel-4.19-gz-allsyms \
+ kernel-5.10-allsyms kernel-5.10-gz-allsyms kernel-5.10-lz4-allsyms \
+
+endif
diff --git a/gki_common.mk b/gki_common.mk
new file mode 100644
index 0000000..b2b717d
--- /dev/null
+++ b/gki_common.mk
@@ -0,0 +1,111 @@
+#
+# Copyright (C) 2022 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+# The files will be copy from the source folder to the dist folder
+_output-kernel-info-files := \
+ prebuilt-info.txt \
+ manifest.xml \
+
+
+# Copy the files from the source folder to the dist folder
+#
+# Skip if the file is not existing.
+#
+# $(1): file list
+# $(2): the source folder
+# $(3): the dist folder
+define _output_kernel_files
+$(foreach f,$(1), \
+ $(if $(wildcard $(2)/$(f)), \
+ $(call dist-for-goals,dist_files,$(2)/$(f):$(3)/$(f))))
+endef
+
+
+# Output the release kernel prebuilt files to dist folder
+#
+# $(1): the source folder contains the kernel prebuilt files
+# $(2): the dist folder
+#
+# Notes:
+# For mainline kernel, it outputs -allsyms kernel as release kernel.
+#
+define _output-kernel-user
+$(if $(findstring mainline,$(1)), \
+ $(eval PRODUCT_COPY_FILES += \
+ $(foreach f,$(wildcard $(1)/kernel-*-allsyms), \
+ $(f):$(subst -allsyms,,$(notdir $(f))))), \
+ $(eval PRODUCT_COPY_FILES += \
+ $(call copy-files,$(filter-out *-allsyms,$(wildcard $(1)/kernel-*)),.)))
+endef
+
+
+# Output the debug kernel prebuilt files to dist folder
+#
+# $(1): the source folder contains the kernel prebuilt files
+# $(2): the dist folder
+#
+# Note:
+# For mainline kernel, it outputs -allsyms kernel as release kernel,
+# so there is no need to output -allsyms again.
+#
+define _output-kernel-debug
+$(if $(findstring mainline,$(1)),, \
+ $(eval PRODUCT_COPY_FILES += \
+ $(call copy-files,$(wildcard $(1)/kernel-*-allsyms),.)))
+endef
+
+
+# Output the kernel prebuilt files to dist folder
+#
+# $(1): the source folder contains the kernel prebuilt files
+# $(2): the dist folder
+#
+# Example:
+# $(call output-kernel,kernel/prebuilts/5.10/arm64,kernel/5.10)
+#
+define output-kernel
+$(call _output-kernel-user,$(1),$(2))
+$(if $(filter userdebug eng,$(TARGET_BUILD_VARIANT)), \
+ $(call _output-kernel-debug,$(1),$(2)))
+$(call _output_kernel_files,$(_output-kernel-info-files),$(1),$(2))
+endef
+
+#
+# Output boot.img and init-boot.img
+#
+$(call inherit-product, $(SRC_TARGET_DIR)/product/generic_ramdisk.mk)
+PRODUCT_BUILD_BOOT_IMAGE := true
+PRODUCT_BUILD_INIT_BOOT_IMAGE := true
+
+PRODUCT_BUILD_CACHE_IMAGE := false
+PRODUCT_BUILD_ODM_IMAGE := false
+PRODUCT_BUILD_VENDOR_DLKM_IMAGE := false
+PRODUCT_BUILD_ODM_DLKM_IMAGE := false
+PRODUCT_BUILD_PRODUCT_IMAGE := false
+PRODUCT_BUILD_RAMDISK_IMAGE := true
+PRODUCT_BUILD_SYSTEM_IMAGE := false
+PRODUCT_BUILD_SYSTEM_EXT_IMAGE := false
+PRODUCT_BUILD_SYSTEM_OTHER_IMAGE := false
+PRODUCT_BUILD_USERDATA_IMAGE := false
+PRODUCT_BUILD_VENDOR_IMAGE := false
+PRODUCT_BUILD_VENDOR_BOOT_IMAGE := false
+PRODUCT_BUILD_RECOVERY_IMAGE := false
+PRODUCT_BUILD_VBMETA_IMAGE := false
+PRODUCT_BUILD_DEBUG_BOOT_IMAGE := false
+PRODUCT_BUILD_DEBUG_VENDOR_BOOT_IMAGE := false
+
+MODULE_BUILD_FROM_SOURCE := true
+PRODUCT_EXPORT_BOOT_IMAGE_TO_DIST := true
diff --git a/gki_x86_64.mk b/gki_x86_64.mk
new file mode 100644
index 0000000..d01767b
--- /dev/null
+++ b/gki_x86_64.mk
@@ -0,0 +1,33 @@
+#
+# Copyright (C) 2022 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+#
+# TODO (b/212486689): The minimum system stuff for build pass.
+#
+$(call inherit-product, $(SRC_TARGET_DIR)/product/core_64_bit.mk)
+$(call inherit-product, $(SRC_TARGET_DIR)/product/runtime_libart.mk)
+
+#
+# Build GKI boot images
+#
+include device/generic/common/gki_common.mk
+$(call output-kernel,kernel/prebuilts/5.10/arm64,kernel/5.10)
+
+
+PRODUCT_NAME := gki_x86_64
+PRODUCT_DEVICE := gki_x86_64
+PRODUCT_BRAND := Android
+PRODUCT_MODEL := GKI on x86_64
diff --git a/gki_x86_64/BoardConfig.mk b/gki_x86_64/BoardConfig.mk
new file mode 100755
index 0000000..48a1499
--- /dev/null
+++ b/gki_x86_64/BoardConfig.mk
@@ -0,0 +1,38 @@
+# Copyright (C) 2022 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+TARGET_CPU_ABI := x86_64
+TARGET_ARCH := x86_64
+TARGET_ARCH_VARIANT := x86_64
+
+TARGET_2ND_CPU_ABI := x86
+TARGET_2ND_ARCH := x86
+TARGET_2ND_ARCH_VARIANT := x86_64
+
+include device/generic/common/BoardConfigGkiCommon.mk
+
+BOARD_KERNEL-5.4_BOOTIMAGE_PARTITION_SIZE := 67108864
+BOARD_KERNEL-5.10_BOOTIMAGE_PARTITION_SIZE := 67108864
+BOARD_KERNEL-5.10-ALLSYMS_BOOTIMAGE_PARTITION_SIZE := 67108864
+
+# Boot images
+BOARD_KERNEL_BINARIES := \
+ kernel-5.10 \
+
+ifneq (,$(filter userdebug eng,$(TARGET_BUILD_VARIANT)))
+BOARD_KERNEL_BINARIES += \
+ kernel-5.10-allsyms \
+
+endif