3 KiB
twrpdtgen-sprd
Create a TWRP-compatible device tree only from an Android recovery image (or a boot image if the device uses non-dynamic partitions A/B) of your device's stock ROM. The generic path has been confirmed for Android 4.4 through Android 16.
Unisoc vendor_boot
This fork also recognizes Android vendor_boot v3/v4 images and generates a
Unisoc/SPRD TWRP tree. It extracts the vendor ramdisk, DTB, vendor command
line, ramdisk table, and bootconfig directly from the input image.
- The generated Unisoc vendor_boot product is
twrp_<codename>, neveromni_<codename>. BoardConfig.mkincludesBOARD_USES_SPRD_HARDWARE := trueand the stock vendor_boot parameters.prop.defaultis read from the stock ramdisk. Android 14 and newer selectstwrp-14.1with the-ap2alunch variant; Android 13 and earlier selectstwrp-12.1.- The generated vendor ramdisk keeps the stock DTB, first-stage fstab, kernel
modules, recovery fstab, ueventd configuration, and a TWRP fstab with a
slot-aware
vendor_bootentry.
The generated README records the selected source branch and exact lunch target. When a factory image exposes a generic Unisoc identity rather than the device codename, provide the intended tree location explicitly:
python3 -m twrpdtgen your_vendor_boot.img \
--manufacturer Manufacturer --codename Codename
Requires Python 3.8 or greater
Installation
For this Unisoc vendor_boot fork, unpack the archive and install the local project rather than the unmodified PyPI release:
python3 -m pip install .
Then run the installed command, or use python3 -m twrpdtgen from the project
directory:
twrpdtgen /path/to/vendor_boot.img -o output
If the stock properties expose a generic Unisoc codename, supply the intended device-tree identity:
twrpdtgen /path/to/vendor_boot.img -o output \
--manufacturer Manufacturer --codename Codename
The generated README.md identifies the required TWRP source branch and
lunch target. Use Linux or WSL with cpio installed; LZ4-compressed ramdisks
also require lz4.
The upstream release remains available with:
pip3 install twrpdtgen
Instructions
python3 -m twrpdtgen <path to image>
When an image is provided, if everything goes well, there will be a device tree at output/manufacturer/codename
You can also use the module in a script, with the following code:
from twrpdtgen.device_tree import DeviceTree
# Get image info
device_tree = DeviceTree(image_path)
# Dump device tree to folder
device_tree.dump_to_folder(output_path)
License
#
# Copyright (C) 2022 The Android Open Source Project
#
# SPDX-License-Identifier: Apache-2.0
#