[PATCH pmbootstrap] Add mtkclient as a flasher option
Export this patch
Since we're using mtkclient a lot anyways, it makes sense to add support for it to pmbootstrap.
This was originally implemented by JustSoup321, but they had issues submitting the patch, so I've cleaned it up for upstream submission.
Thanks for submitting this and cleaning it up hexaheximal, and thanks
for the initial implementation JustSoup321!
Lines in the commit message are too long and two minor things below,
I'll fix them up and merge it.
This is a really cool flash method :D
Reviewed-by: Oliver Smith <ollieparanoid@postmarketos.org>
Applied, thanks!
[1/1] Add mtkclient as a flasher option
commit: caf4d779e30ad7b051ad1076021b15cbc2711d8d
Best regards
Co-Authored-By: JustSoup321 <brandonboese@protonmail.com>
Signed-off-by: hexaheximal <hexaheximal@proton.me>
---
pmb/config/__init__.py | 27 +++++++++++++++++++++++++++
pmb/flasher/init.py | 4 ++++
pmb/flasher/variables.py | 9 +++++++++
3 files changed, 40 insertions(+)
diff --git a/pmb/config/__init__.py b/pmb/config/__init__.py
index 85e2f753..485ad52b 100644
--- a/pmb/config/__init__.py
+++ b/pmb/config/__init__.py
@@ -802,6 +802,11 @@ deviceinfo_attributes = [
"flash_rk_partition_kernel",
"flash_rk_partition_rootfs",
"flash_rk_partition_system", # deprecated
+ "flash_mtkclient_partition_kernel",
+ "flash_mtkclient_partition_rootfs",
+ "flash_mtkclient_partition_system", # deprecated
_system is deprecated in favor of _rootfs, no need to add it for new
flash methods. I'll remove it before merge.
+ "flash_mtkclient_partition_vbmeta",
+ "flash_mtkclient_partition_dtbo",
"generate_legacy_uboot_initfs",
"kernel_cmdline",
"generate_bootimg",
@@ -884,6 +889,7 @@ flash_methods = [
"none",
"rkdeveloptool",
"uuu",
+ "mtkclient",
I'll order these alphabetically before merge.
]
# These folders will be mounted at the same location into the native
@@ -1031,6 +1037,27 @@ flashers = {
"$IMAGE_SPLIT_BOOT"]
],
},
+ },
+ "mtkclient": {
+ "depends": ["mtkclient"],
+ "actions": {
+ "flash_rootfs": [["mtk", "w", "$PARTITION_ROOTFS",
+ "$IMAGE"]],
+ "flash_kernel": [["mtk", "w", "$PARTITION_KERNEL",
+ "$BOOT/boot.img$FLAVOR"]],
+ "flash_vbmeta": [
+ # Generate vbmeta image with "disable verification" flag
+ ["avbtool", "make_vbmeta_image", "--flags", "2",
+ "--padding_size", "$FLASH_PAGESIZE",
+ "--output", "/vbmeta.img"],
+ ["mtk", "w", "$PARTITION_VBMETA", "/vbmeta.img"],
+ ["rm", "-f", "/vbmeta.img"]
+ ],
+ "flash_dtbo": [["mtk", "w", "$PARTITION_DTBO",
+ "$BOOT/dtbo.img"]],
+ "flash_lk2nd": [["mtk", "w", "$PARTITION_KERNEL",
+ "$BOOT/lk2nd.img"]]
+ }
}
}
diff --git a/pmb/flasher/init.py b/pmb/flasher/init.py
index aff7808d..3569bcce 100644
--- a/pmb/flasher/init.py
+++ b/pmb/flasher/init.py
@@ -32,6 +32,10 @@ def install_depends(args):
pmaports_cfg = pmb.config.pmaports.read_config(args)
depends = pmaports_cfg.get("supported_heimdall_depends",
"heimdall,avbtool").split(",")
+ elif method == "mtkclient":
+ pmaports_cfg = pmb.config.pmaports.read_config(args)
+ depends = pmaports_cfg.get("supported_mtkclient_depends",
+ "mtkclient,android-tools").split(",")
pmb.chroot.apk.install(args, depends)
diff --git a/pmb/flasher/variables.py b/pmb/flasher/variables.py
index e00ed1d7..1625721b 100644
--- a/pmb/flasher/variables.py
+++ b/pmb/flasher/variables.py
@@ -31,6 +31,15 @@ def variables(args, flavor, method):
or args.deviceinfo["flash_rk_partition_system"] or None
_partition_vbmeta = None
_partition_dtbo = None
+ elif method.startswith("mtkclient"):
+ _partition_kernel = args.deviceinfo["flash_mtkclient_partition_kernel"]\
+ or "boot"
+ _partition_rootfs = args.deviceinfo["flash_mtkclient_partition_rootfs"]\
+ or args.deviceinfo["flash_mtkclient_partition_system"] or "userdata"
+ _partition_vbmeta = args.deviceinfo["flash_mtkclient_partition_vbmeta"]\
+ or None
+ _partition_dtbo = args.deviceinfo["flash_mtkclient_partition_dtbo"]\
+ or None
else:
_partition_kernel = args.deviceinfo["flash_heimdall_partition_kernel"]\
or "KERNEL"
--
2.39.2
pmbootstrap/patches/.build.yml: SUCCESS in 19m26s
[Add mtkclient as a flasher option][0] from [hexaheximal][1]
[0]: https://lists.sr.ht/~postmarketos/pmbootstrap-devel/patches/42621
[1]: mailto:hexaheximal@proton.me
✓ #1023263 SUCCESS pmbootstrap/patches/.build.yml https://builds.sr.ht/~postmarketos/job/1023263