Skip to content

Common Tree

Ahmed Shahin edited this page Jan 9, 2025 · 9 revisions

Common TWRP Tree Guide 📜

When working on many TWRP trees, I noticed there were lots of unified targets, so I decided to create a common tree for all devices. Here's how you can use it! 🌱

How to Use It 🛠️

  1. Add the following line in BoardConfig.mk:

include device/android/common/BoardConfigCommon.mk

  1. Add this to your twrp_"codename".mk:

$(call inherit-product, device/android/common/device.mk)

You don't need to call inherit anything – everything is already installed. 🔧


AB devices

If your device use AB add this to twrp_"codename".mk

ENABLE_VIRTUAL_AB := true


Samsung devices

If your device samsung add this to BoardConfig.mk.mk

BOARD_VENDOR := samsung


Header Version 🏷️

For Recovery or Boot:

BOARD_BOOTIMG_HEADER_VERSION := 2

For Vendor Boot:

BOARD_BOOT_HEADER_VERSION := 4


Set the Build Target 🏗️

If your device uses boot as recovery, add this line:

BOARD_STORE_RAMDISK_IN_BOOT := true

If it uses vendor boot, add this:

BOARD_STORE_RAMDISK_IN_VENDORBOOT := true

If your device uses the recovery partition, continue without adding these lines. ✅


Kernel Offsets 🖥️

For Boot:

Define the following:

BOARD_RAMDISK_OFFSET := BOARD_KERNEL_TAGS_OFFSET := BOARD_KERNEL_BASE :=

For Vendor Boot:

Add these definitions:

BOARD_KERNEL_OFFSET := BOARD_RAMDISK_OFFSET := BOARD_KERNEL_TAGS_OFFSET := BOARD_DTB_OFFSET := BOARD_KERNEL_BASE :=

For Recovery:

Add only this:

BOARD_KERNEL_BASE := BOARD_RAMDISK_OFFSET := BOARD_KERNEL_TAGS_OFFSET :=


Hardware Setup 🔧

If you're using a Snapdragon SoC, set this:

BOARD_USES_QCOM_HARDWARE := true

If you're using an MTK SoC, set this:

BOARD_USES_MTK_HARDWARE := true

If you're using UniSoC, set this:

BOARD_USES_SPRD_HARDWARE := true


Prebuilt Kernel & DTB 🏗️

You need to add the kernel and dtb in your tree's prebuilt folder.

Make sure the kernel is named kernel and the dtb is named dtb.img. 🧰


Configuration for System Reboot Fix 🔄

Add this to your BoardConfig.mk to fix system reboot:

TW_NO_FASTBOOT_BOOT := true


Set Image Sizes 🧮

You need to set the image sizes depending on your setup:

If you're using Vendor Boot, use this:

BOARD_VENDOR_BOOTIMAGE_PARTITION_SIZE :=

If you're using Recovery, use this:

BOARD_RECOVERYIMAGE_PARTITION_SIZE :=

If you're using Boot, use this:

BOARD_BOOTIMAGE_PARTITION_SIZE :=


Tree models

for samsung that use recovery https://github.com/GitFASTBOOT/android_device_samsung_gta9p-twrp.git for any device use boot https://github.com/GitFASTBOOT/android_device_tecno_lh8n_twrp.git


Now you're ready to work with a unified TWRP tree! 🚀 Feel free to adjust it according to your device specifications.


Let me know if you'd like to download it or have any adjustments!

Clone this wiki locally