g12: Flash DTB/DTBO/VBMeta/Super images with releasetools
authorTim Zimmermann <tim@linux4.de>
Fri, 25 Jun 2021 06:54:26 +0000 (02:54 -0400)
committerNolen Johnson <johnsonnolen@gmail.com>
Tue, 27 Jul 2021 21:18:15 +0000 (17:18 -0400)
Co-authored-by: Jan Altensen <info@stricted.net>
Co-authored-by: Tim Zimmermann <tim@linux4.de>
Change-Id: Ieda7bf879fe1fd7ac1f8fcf12183f8a5eda20e43

BoardConfigCommon.mk
build/tasks/2ndbootloader.mk
releasetools/releasetools.py [new file with mode: 0644]

index 4038ea666c45af44720a4b938c16524e5913003f..b31b3b0d2ad8cc6b9f0475b1a9e3ebf41b4f645d 100644 (file)
@@ -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
 
index 7600d76b81c510d8890efa50eb43c7d19d75b6dc..26433eba120e5c278b604a8c6094853bd9117d38 100644 (file)
@@ -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 (file)
index 0000000..291204b
--- /dev/null
@@ -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