Team Win Recovery Project or TWRP is an open-source custom touch recovery for Android which will bring advance features Like backup/restore encrypt/decrypt, fully touch experience, custom zip Installation etc. so if you want to compile it for your device then you can do it by following the below Instructions.
Requirement’s
- Linux PC
- high speed Internet ( to sync source)
Prepare Development Environment:
open terminal and type below code
git config --global user.name "your github username" git config --global user.email "your github email"
sudo -E apt-get -qq install bc build-essential zip curl libstdc++6 git wget python gcc clang libssl-dev repo rsync flex curl bison aria2 sudo curl --create-dirs -L -o /usr/local/bin/repo -O -L https://storage.googleapis.com/git-repo-downloads/repo sudo chmod a+rx /usr/local/bin/repo
Sync recovery source:
mkdir twrp cd twrp
for android 11 & 12 (replace respective branch)
repo init -u https://github.com/minimal-manifest-twrp/platform_manifest_twrp_aosp.git -b twrp-11
for android 10 and below (replace respective branch)
repo init -u https://github.com/minimal-manifest-twrp/platform_manifest_twrp_omni.git -b twrp-9.0
then sync (it will take around 4-5 hrs according your Internet speed) define j value according your system’s cpu core
repo sync -c -j8 --force-sync --no-clone-bundle --no-tags rm -rf .rep
done. now we have development environment, let’s start building
prepare your device tree and move it to twrp/device/ folder
ex. twrp/device/xiaomi/kenzo
Start build:
cd twrp export ALLOW_MISSING_DEPENDENCIES=true lunch twrp_kenzo-eng mka recoveryimage
Note:
- replace ‘kenzo’ with respective device makefile
- for android 10 or below replace ‘twrp’ tag with ‘omni’
- for AB device’s use ‘mka bootimage’
Additional flags:
#use prebuild kernel:
TARGET_PREBUILT_KERNEL := $(DEVICE_PATH)/prebuilt/Image.gz
use custom kernel or kernel Source:
create file with the name twrp.dependencies in tree folder and add below code:
[ { "remote": "github", "repository": "redmi/kernel_xiaomi_kenzo", "target_path": "kernel/redmi/kenzo", "revision": "R" } ]
Note: define correct location of kernel source in above code, then define in BoardConfig
#define in board config: TARGET_KERNEL_SOURCE := kernel/redmi/kenzo TARGET_KERNEL_CONFIG := kenzo_defconfig TARGET_KERNEL_CLANG_COMPILE := true
# use Properties
TARGET_SYSTEM_PROP += $(DEVICE_PATH)/system.prop
# Hide notch
ifneq ($(OF_HIDE_NOTCH),1) TW_Y_OFFSET := 100 TW_H_OFFSET := -100 endif
# twrp No Screen timeout
TW_NO_SCREEN_TIMEOUT := true
#Samsung custom bootimg.mk
BOARD_CUSTOM_BOOTIMG_MK := $(DEVICE_PATH)/bootimg.mk
#define device Resolution
TW_THEME := portrait_hdpi DEVICE_RESOLUTION := 1080x2340 TARGET_SCREEN_HEIGHT := 2340 TARGET_SCREEN_WIDTH := 1080
Download Sample tree:
- twrp sample tree: Download
- beginner can generate device tree using device tree generator..
test:
fastboot boot recovery.img