# recovery env setup CHIP_REVISION_UPPER := $(shell echo $(CHIP_REVISION) | tr a-z A-Z) RECOVERY_OBJ := $(TARGET_OUT_INTERMEDIATES)/RECOVERY_OBJ_$(CHIP_REVISION_UPPER) RECOVERY_KERNEL_CONFIG := $(PRODUCT_TYPE)/$(CHIP_VERSION)/$(PRODUCT_TYPE)_$(CHIP_VERSION)_defconfig KERNEL_ARCH_ARM64_CONFIGS := $(TARGET_KERNEL_DIR)/arch/$(TARGET_ARCH)/configs RECOVERY_KERNEL_DEBUG_CONFIGS := $(KERNEL_ARCH_ARM64_CONFIGS)/$(PRODUCT_TYPE)_$(CHIP_VERSION)_$(CHIP_REVISION)_recovery_debug_defconfig ifneq ($(wildcard $(RECOVERY_KERNEL_DEBUG_CONFIGS)),) $(shell rm -f $(RECOVERY_KERNEL_DEBUG_CONFIGS)) endif RECOVERY_KERNEL_TMP_CONFIGS := $(PRODUCT_TYPE)_$(CHIP_VERSION)_$(CHIP_REVISION)_recovery_tmp_defconfig # Recovery build, amend recovery defconfig by default RECOVERY_KERNEL_AMEND_CONFIGS += $(KERNEL_ARCH_ARM64_CONFIGS)/plugin/recovery_defconfig # Config ammend RECOVERY_KERNEL_AMEND_CONFIGS += $(KERNEL_ARCH_ARM64_CONFIGS)/$(PRODUCT_TYPE)/$(CHIP_VERSION)/chip_revision/$(CHIP_REVISION)_defconfig ifeq ($(strip $(HUANGLONG_TEE)), true) RECOVERY_KERNEL_AMEND_CONFIGS += $(KERNEL_ARCH_ARM64_CONFIGS)/plugin/tee_defconfig endif RECOVERY_KERNEL_AMEND_CONFIGS += $(RECOVERY_DRIVER_DEFCONFIG_FILE) $(CUSTOM_RECOVERY_DEFCONFIG_FILE) # recovery flag configs RECOVERY_KERNEL_FLAGS := ARCH=$(TARGET_ARCH) CROSS_COMPILE=$(CROSS_COMPILE_TOOLCHAIN) \ CC=clang HOSTCC=clang CLANG_TRIPLE=aarch64-linux-gnu- \ $(MSP_FLAG) $(DIR_CONFIG) $(TP_CONFIG) RECOVERY_KERNEL_CFLAGS := $(RECOVERY_DRIVER_CFLAGS) ifeq ($(strip $(PRODUCT_USE_DYNAMIC_PARTITIONS)), true) RECOVERY_KERNEL_FLAGS += CONFIG_DP_PARTITION_SUPPORT=y RECOVERY_KERNEL_CFLAGS += -DCONFIG_DP_PARTITION_SUPPORT ifeq ($(strip $(BOARD_AVB_ENABLE)), true) RECOVERY_KERNEL_FLAGS += CONFIG_AVB_SUPPORT=y endif endif RECOVERY_KERNEL_AFLAGS := $(RECOVERY_KERNEL_CFLAGS) RECOVERY_DEPENDECIES ?= fastbootd INSTALLED_DTBOIMAGE_TARGET ?= $(PRODUCT_OUT)/dtbo.img INSTALLED_RECOVERYIMAGE_TARGET ?= $(PRODUCT_OUT)/recovery.img # recovery objs SECURE_TOOL := vendor/tools/host/huanglong/sign_tools/SecureTool/bin/SecureTool VERIFIED_BOOT_CFG_DIR := vendor/tools/host/huanglong/sign_config/verified_boot_cfg $(RECOVERY_OBJ)/.config: $(TARGET_KERNEL_DIR)/arch/$(TARGET_ARCH)/configs/$(RECOVERY_KERNEL_CONFIG) PATH=$(KERNEL_TOOLS_PATH) $(MAKE) -C $(TARGET_KERNEL_DIR) \ O=$(PWD)/$(RECOVERY_OBJ) $(RECOVERY_KERNEL_FLAGS) \ CFLAGS_KERNEL="$(RECOVERY_KERNEL_CFLAGS)" AFLAGS_KERNEL="$(RECOVERY_KERNEL_AFLAGS)" $(RECOVERY_KERNEL_CONFIG) ifneq ($(RECOVERY_KERNEL_AMEND_CONFIGS),) $(hide) $(foreach cf,$(strip $(RECOVERY_KERNEL_AMEND_CONFIGS)),$(shell cat $(cf) >> $(RECOVERY_KERNEL_DEBUG_CONFIGS))) PATH=$(KERNEL_TOOLS_PATH) $(MAKE) -C $(SDK_DIR_KERNEL)/scripts BASED_FILE=$(PWD)/$(RECOVERY_OBJ)/.config \ $(DIR_CONFIG) INPUT_FILE=$(RECOVERY_KERNEL_DEBUG_CONFIGS) INPUT_CONFIG="$(RECOVERY_DRIVER_CONFIG)" \ OUTPUT_FILE=$(KERNEL_ARCH_ARM64_CONFIGS)/$(RECOVERY_KERNEL_TMP_CONFIGS) kconfig-dynamic PATH=$(KERNEL_TOOLS_PATH) $(MAKE) -C $(TARGET_KERNEL_DIR) \ O=$(PWD)/$(RECOVERY_OBJ) $(RECOVERY_KERNEL_FLAGS) \ CFLAGS_KERNEL="$(RECOVERY_KERNEL_CFLAGS)" AFLAGS_KERNEL="$(RECOVERY_KERNEL_AFLAGS)" $(RECOVERY_KERNEL_TMP_CONFIGS) $(hide) rm -rf $(KERNEL_ARCH_ARM64_CONFIGS)/$(RECOVERY_KERNEL_TMP_CONFIGS) $(hide) rm -rf $(RECOVERY_KERNEL_DEBUG_CONFIGS) $(hide) wait endif $(RECOVERY_OBJ)/recovery.img: $(RECOVERY_OBJ)/.config $(INSTALLED_RECOVERYIMAGE_TARGET) $(INSTALLED_DTBOIMAGE_TARGET) $(PRODUCT_OUT)/ramdisk.img |$(MKBOOTIMG) PATH=$(KERNEL_TOOLS_PATH) $(MAKE) -C $(TARGET_KERNEL_DIR) \ O=$(PWD)/$(RECOVERY_OBJ) SDK_CFGFILE=$(SDK_CFG_DIR)/$(SDK_RECOVERY_CFG) $(RECOVERY_KERNEL_FLAGS) \ CFLAGS_KERNEL="$(RECOVERY_KERNEL_CFLAGS)" AFLAGS_KERNEL="$(RECOVERY_KERNEL_AFLAGS)" \ CONFIG_INITRAMFS_SOURCE=$(PWD)/$(TARGET_RECOVERY_ROOT_OUT) Image modules $(ACP) -f $(RECOVERY_OBJ)/arch/$(TARGET_ARCH)/boot/Image $@ $(MKBOOTIMG) --kernel $(RECOVERY_OBJ)/recovery.img --ramdisk $(PRODUCT_OUT)/ramdisk.img --base $(BOARD_RECOVERY_BASE) \ --pagesize $(BOARD_RECOVERY_PAGESIZE) --recovery_dtbo $(DTB_OUT_DIR)/$(TARGET_DTB_FILE_NAME) --os_version 10 --header_version 1 -o $(RECOVERY_OBJ)/recovery-header.img $(ACP) -f $(RECOVERY_OBJ)/recovery-header.img $@ ifeq ($(strip $(BOARD_AVB_ENABLE)), true) $(hide) mkdir -p $(SECURE_OBJ_DIR)/ ifneq ($(findstring $(CHIP_VERSION), "hi3751v811"),) $(hide) $(SECURE_TOOL) common --cfg $(VERIFIED_BOOT_CFG_DIR)/verified_boot_recovery_sign_hi3751v811.cfg \ -k $(SECURE_RSA_KEY_DIR)/ -r $(RECOVERY_OBJ)/ -o $(SECURE_OBJ_DIR)/ else # CHIP_VERSION != hi3751v811 $(hide) $(SECURE_TOOL) common --cfg $(VERIFIED_BOOT_CFG_DIR)/verified_boot_recovery_sign.cfg \ -k $(SECURE_RSA_KEY_DIR)/ -r $(RECOVERY_OBJ)/ -o $(SECURE_OBJ_DIR)/ endif $(hide) $(ACP) -f $(SECURE_OBJ_DIR)/recovery_Sign.img $@ endif ifeq ($(strip $(PRODUCT_TYPE)),tv) .PHONY: recoveryimg recovery_dependencies input_bins input_libs else .PHONY: recoveryimg recovery_dependencies endif recovery_dependencies: $(RECOVERY_DEPENDECIES) |$(ACP) $(hide) mkdir -p $(TARGET_RECOVERY_ROOT_OUT)/system/etc $(hide) mkdir -p $(TARGET_RECOVERY_ROOT_OUT)/vendor/lib64/modules $(ACP) -f $(TARGET_RECOVERY_FSTAB) $(TARGET_RECOVERY_ROOT_OUT)/system/etc/recovery.fstab -$(ACP) -f $(NTFS_KO) $(TARGET_RECOVERY_ROOT_OUT)/vendor/lib64/modules/tntfs.ko -$(ACP) -f $(BASEPARAM_BIN) $(TARGET_RECOVERY_ROOT_OUT)/system/etc/baseparam.img @echo "Target extra recovery_dependencies done" ifeq ($(strip $(PRODUCT_TYPE)),tv) input_bins: android_ir_user virtualkeypad $(hide) mkdir -p $(TARGET_RECOVERY_ROOT_OUT)/vendor/bin $(ACP) $(TARGET_OUT_VENDOR_EXECUTABLES)/android_ir_user $(TARGET_RECOVERY_ROOT_OUT)/vendor/bin $(ACP) $(TARGET_OUT_VENDOR_EXECUTABLES)/virtualkeypad $(TARGET_RECOVERY_ROOT_OUT)/vendor/bin $(hide) chmod 755 $(TARGET_RECOVERY_ROOT_OUT)/vendor/bin/android_ir_user $(hide) chmod 755 $(TARGET_RECOVERY_ROOT_OUT)/vendor/bin/virtualkeypad $(hide) mkdir -p $(TARGET_RECOVERY_ROOT_OUT)/vendor/etc $(ACP) $(SOC_PLATFORM_PATH)/modules/ir_user/source/etc/input/key.xml $(TARGET_RECOVERY_ROOT_OUT)/vendor/etc/key.xml $(ACP) $(VIRTUALKEYPAD_FILE) $(TARGET_RECOVERY_ROOT_OUT)/vendor/etc/key_pad.xml input_libs: libcust libuapi_securec libuapi_common libuapi_pdm libuapi_gpio libuapi_lsadc libuapi_pmoc libuapi_ir libuapi_panel \ libuapi_vo libuapi_memory libuapi_flash libuapi_rm libdftevent $(hide) mkdir -p $(TARGET_RECOVERY_ROOT_OUT)/vendor/lib64 $(ACP) $(TARGET_OUT_VENDOR)/lib64/libcust.so $(TARGET_RECOVERY_ROOT_OUT)/vendor/lib64/ $(ACP) $(TARGET_OUT_VENDOR)/lib64/libuapi_securec.so $(TARGET_RECOVERY_ROOT_OUT)/vendor/lib64/ $(ACP) $(TARGET_OUT_VENDOR)/lib64/libuapi_common.so $(TARGET_RECOVERY_ROOT_OUT)/vendor/lib64/ $(ACP) $(TARGET_OUT_VENDOR)/lib64/libuapi_pdm.so $(TARGET_RECOVERY_ROOT_OUT)/vendor/lib64/ $(ACP) $(TARGET_OUT_VENDOR)/lib64/libuapi_gpio.so $(TARGET_RECOVERY_ROOT_OUT)/vendor/lib64/ $(ACP) $(TARGET_OUT_VENDOR)/lib64/libuapi_lsadc.so $(TARGET_RECOVERY_ROOT_OUT)/vendor/lib64/ $(ACP) $(TARGET_OUT_VENDOR)/lib64/libuapi_pmoc.so $(TARGET_RECOVERY_ROOT_OUT)/vendor/lib64/ $(ACP) $(TARGET_OUT_VENDOR)/lib64/libuapi_ir.so $(TARGET_RECOVERY_ROOT_OUT)/vendor/lib64/ $(ACP) $(TARGET_OUT_VENDOR)/lib64/libuapi_panel.so $(TARGET_RECOVERY_ROOT_OUT)/vendor/lib64/ $(ACP) $(TARGET_OUT_VENDOR)/lib64/libuapi_vo.so $(TARGET_RECOVERY_ROOT_OUT)/vendor/lib64/ $(ACP) $(TARGET_OUT_VENDOR)/lib64/libuapi_memory.so $(TARGET_RECOVERY_ROOT_OUT)/vendor/lib64/ $(ACP) $(TARGET_OUT_VENDOR)/lib64/libuapi_flash.so $(TARGET_RECOVERY_ROOT_OUT)/vendor/lib64/ $(ACP) $(TARGET_OUT_VENDOR)/lib64/libuapi_rm.so $(TARGET_RECOVERY_ROOT_OUT)/vendor/lib64/ $(ACP) $(TARGET_OUT_VENDOR)/lib64/libdftevent.so $(TARGET_RECOVERY_ROOT_OUT)/vendor/lib64/ @echo "Target extra input dependencies done" endif $(IMAGES_OUT)/recovery_$(CHIP_REVISION).img: $(RECOVERY_OBJ)/recovery.img |$(ACP) $(hide) mkdir -p $(IMAGES_OUT) $(ACP) -f $< $@ $(hide) $(call assert-max-image-size,$(IMAGES_OUT)/recovery_$(CHIP_REVISION).img,$(BOARD_RECOVERYIMAGE_PARTITION_SIZE)) ROOTFS_CHARGER := $(TARGET_ROOT_OUT)/charger $(ROOTFS_CHARGER): $(hide) mkdir -p $(TARGET_ROOT_OUT) $(hide) ln -sf /system/bin/charger $(TARGET_ROOT_OUT)/charger @echo "Install: ln -sf /system/bin/charger root/charger" $(INSTALLED_RECOVERYIMAGE_TARGET): $(ROOTFS_CHARGER) ifeq ($(strip $(PRODUCT_TYPE)),tv) recoveryimage: recovery_dependencies input_bins input_libs else recoveryimage: recovery_dependencies endif # final images recoveryimg: recoveryimage $(IMAGES_OUT)/recovery_$(CHIP_REVISION).img ifeq (,$(filter true, $(TARGET_NO_KERNEL) $(TARGET_NO_RECOVERY))) # add to droidcore dependency droidcore: recoveryimg endif