From: Tim Zimmermann Date: Fri, 25 Jun 2021 06:54:26 +0000 (-0400) Subject: g12: Flash DTB/DTBO/VBMeta/Super images with releasetools X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=1149fc88ff82e93d396edd11132b55c98a5ee063;p=GitHub%2FLineageOS%2FG12%2Fandroid_device_amlogic_g12-common.git g12: Flash DTB/DTBO/VBMeta/Super images with releasetools Co-authored-by: Jan Altensen Co-authored-by: Tim Zimmermann Change-Id: Ieda7bf879fe1fd7ac1f8fcf12183f8a5eda20e43 --- diff --git a/BoardConfigCommon.mk b/BoardConfigCommon.mk index 4038ea6..b31b3b0 100644 --- a/BoardConfigCommon.mk +++ b/BoardConfigCommon.mk @@ -115,6 +115,9 @@ PRODUCT_FULL_TREBLE_OVERRIDE := true TARGET_RECOVERY_FSTAB := $(COMMON_PATH)/init-files/fstab.amlogic TARGET_RECOVERY_PIXEL_FORMAT := "BGRA_8888" +## Releasetools +TARGET_RELEASETOOLS_EXTENSIONS := $(COMMON_PATH)/releasetools + ## Vendor SPL VENDOR_SECURITY_PATCH := 2020-10-05 diff --git a/build/tasks/2ndbootloader.mk b/build/tasks/2ndbootloader.mk index 7600d76..26433eb 100644 --- a/build/tasks/2ndbootloader.mk +++ b/build/tasks/2ndbootloader.mk @@ -22,6 +22,7 @@ DTBTOOL := $(HOST_OUT_EXECUTABLES)/dtbToolAmlogic$(HOST_EXECUTABLE_SUFFIX) DTBTMP := $(PRODUCT_OUT)/tmp_dt DTBDIR := $(PRODUCT_OUT)/obj/KERNEL_OBJ/arch/arm64/boot/dts/amlogic DTCDIR := $(PRODUCT_OUT)/obj/KERNEL_OBJ/scripts/dtc/ +TARGET_FLASH_DTB_PARTITION ?= true TARGET_DTBO_NAME ?= android_p_overlay_dt @@ -35,19 +36,20 @@ endef $(INSTALLED_2NDBOOTLOADER_TARGET): $(INSTALLED_KERNEL_TARGET) $(DTBTOOL) | $(ACP) $(MINIGZIP) ifeq ($(words $(TARGET_DTB_NAME)),1) - $(hide) $(ACP) $(DTBDIR)/$(TARGET_DTB_NAME).dtb $(DTBTARGET); - $(hide) $(call aml-compress-dtb, $(DTBTARGET)) - $(hide) $(ACP) $(DTBTARGET) $@; + $(hide) $(ACP) $(DTBDIR)/$(TARGET_DTB_NAME).dtb $(DTBTARGET) else - $(hide) mkdir -p $(DTBTMP); + $(hide) mkdir -p $(DTBTMP) $(foreach aDts, $(TARGET_DTB_NAME), \ $(ACP) $(DTBDIR)/$(strip $(aDts)).dtb $(DTBTMP)/$(strip $(aDts)).dtb; \ ) $(hide) $(DTBTOOL) -o $(DTBTARGET) -p $(DTCDIR) $(DTBTMP) + $(hide) rm -rf $(DTBTMP) +endif $(hide) $(call aml-compress-dtb, $(DTBTARGET)) - $(hide) $(ACP) $(DTBTARGET) $@; - $(hide) rm -rf $(DTBTMP); +ifeq ($(TARGET_FLASH_DTB_PARTITION),true) + $(hide) $(call add-radio-file,$(DTBTARGET)) endif + $(hide) $(ACP) $(DTBTARGET) $@ $(BOARD_PREBUILT_DTBOIMAGE): $(INSTALLED_KERNEL_TARGET) $(MKDTBOIMG) $(MKDTBOIMG) create $@ $(foreach dtbo, $(TARGET_DTBO_NAME), \ diff --git a/releasetools/releasetools.py b/releasetools/releasetools.py new file mode 100644 index 0000000..291204b --- /dev/null +++ b/releasetools/releasetools.py @@ -0,0 +1,36 @@ +#!/bin/env python3 +# +# Copyright (C) 2020-2021 The LineageOS Project +# +# SPDX-License-Identifier: Apache-2.0 +# + +import common +import re + +def FullOTA_InstallEnd(info): + OTA_InstallEnd(info) + return + +def IncrementalOTA_InstallEnd(info): + OTA_InstallEnd(info) + return + +def AddImage(info, folder, basename, dest): + name = basename + data = info.input_zip.read(folder + basename) + common.ZipWriteStr(info.output_zip, name, data) + info.script.AppendExtra('package_extract_file("%s", "%s");' % (name, dest)) + +def PrintInfo(info, dest): + info.script.Print("Patching {} image unconditionally...".format(dest.split('/')[-1])) + +def OTA_InstallEnd(info): + PrintInfo(info, "/dev/block/by-name/dtbo") + AddImage(info, "IMAGES/", "dtbo.img", "/dev/block/by-name/dtbo") + PrintInfo(info, "/dev/block/by-name/vbmeta") + AddImage(info, "IMAGES/", "vbmeta.img", "/dev/block/by-name/vbmeta") + if 'RADIO/dtb.img' in info.input_zip.namelist(): + PrintInfo(info, "/dev/dtb") + AddImage(info, "RADIO/", "dtb.img", "/dev/dtb") + return