How to Compile/Port twrp From Source Step by Step Guide

Port twrp Recovery From Source Code-
A Complete Guide to port twrp recovery From Source Code is , you can port/Compile twrp Recovery From Source Code by Following bellow Guide,

a Complete and step by Step by step Guide to port/Compile twrp recovery from Souce Code is here, you must have some basic knowledge to Complete The Process,
Initial requirements:
1)Linux, I suggest Ubuntu 64bit
2)Willpower
3)A brain of course

Chapter 1: Setting up Build Environment
First requirement is Java. The version you need depends on what Android version you want to compile

Open the terminal and type: java -version
From Gingerbred to Kitkat you have to use openjdk 6
For Lollipop and MM you can use openjdk 7 or opendjk8

Notice: for openjdk8 before start the compilation with "make recoveryimage"
Type: export EXPERIMENTAL_USE_JAVA8=true and press enter.

Code:
If you have the wrong version type: sudo apt-get purge openjdk-\* icedtea-\* icedtea6-\*
Follow the on-scren instructions to remove it.
Now install the jdk you need
For Openjdk 6
For Openjdk 7
Code:
Type the following commands:
sudo add-apt-repository ppa:openjdk/ppa
sudo apt-get update && sudo apt-get install openjdk-7-jdk
Next requirement are libraries and build tools
Open a fresh terminal prompt, copy and paste this:
Code:
sudo apt-get install git ccache automake lzop bison gperf build-essential zip curl zlib1g-dev zlib1g-dev:i386 g++-multilib python-networkx libxml2-utils bzip2 libbz2-dev libbz2-1.0 libghc-bzlib-dev squashfs-tools pngcrush schedtool dpkg-dev liblz4-tool make optipng
Now let's get a copy of "repo", it is a program that lets you communicate with git servers and download the source code.

Code:
1)mkdir ~/bin -This command creates the bin folder that will contain the repo command
2) curl http://commondatastorage.googleapis.com/git-repo-downloads/repo > ~/bin/repo -This command downloads the repo command in the bin folder
3) chmod a+x ~/bin/repo -Give the repo command right permissions
4)sudo nano ~/.bashrc At the very bottom(Use page down key) add this line: export PATH=~/bin:$PATH
Then press Ctrl+O and Enter to save and Ctrl+X to exit.
After that type: source ~/.bashrc
-With these commands you add repo to .bashrc file that allows you to call the command from every path.
Chapter 2: Repo sync Android sources
At this point you are almost ready to compile whatever you want but first you need Sources.
These are divided in:
-Android base sources
-Device sources
Let's obtain the first one
If you want to compile ROMs such as CyanogenMod you MUST repo sync the entire sources but if you want to compile only the TWRP recovery you CAN sync minimal sources

Full Sources
NOTICE: replace "BRANCH" with the version of android you want
Omnirom Sources
Available Android branches:
  • android-6.0
  • android-5.1
  • android-5.0
  • android-4.4
  • android-4.3
Open a fresh terminal and type the following commands.
  1. mkdir ~/NameOfTheFolder It's your choice
  2. cd ~/NameOfTheFolder
  3. repo init -u git://github.com/omnirom/android.git -b BRANCH
  4. repo sync -jN N=numbers of parallel downloads, it depends on your connection Example: repo sync -j2
CyanogenMod Sources
Available Android branches:

  • cm-13.0
  • cm-12.1
  • cm-12.0
  • cm-11.0
Open a fresh terminal and type the followng commands.
  1. mkdir ~/NameOfTheFolder It's your choice
  2. cd ~/NameOfTheFolder
  3. repo init -u git://github.com/CyanogenMod/android.git -b BRANCH
  4. repo sync -jN N=numbers of parallel downloads, it depends on your connection Example: repo sync -j2
Minimal Sources
NOTICE: replace "BRANCH" with the version of android you want
Thanks to @lj50036 for the minimal manifests
Omnirom Minimal Sources
Available branches:
  • twrp-6.0
  • twrp-5.1
  • twrp-4.4
Open a fresh terminal and type the followng commands.
  1. mkdir ~/NameOfTheFolder It's your choice
  2. cd ~/NameOfTheFolder
  3. repo init -u git://github.com/lj50036/platform_manifest_twrp_omni.git -b BRANCH
  4. repo sync -jN N=numbers of parallel downloads, it depends on your connection Example: repo sync -j2
CyanogenMod Minimal Sources
Available branches:

  • twrp-13.0
  • twrp-12.1
Open a fresh terminal and type the following commands.
  1. mkdir ~/NameOfTheFolder It's your choice
  2. cd ~/NameOfTheFolder
  3. repo init -u git://github.com/lj50036/platform_manifest_twrp_cm.git -b BRANCH
  4. repo sync -jN N=numbers of parallel downloads, it depends on your connection Example: repo sync -j2
The download of the sources will take a bit ^
 Device sources are divided in
1)Kernel
2)Device Tree
3)Vendors
Sorry, I can't help here cause every device has its own sources
For further informations consult this page: https://www.google.it/url?sa=t&rct=j...6ltZvbVyzW9ybw it is for CM but it is valid for almost everything.

About TWRP device tree flags this thread is very very useful, thanks to @MSF Jarvis
http://forum.xda-developers.com/andr...ig-mk-t3333970
NOTICE
If you repo synced CyanogenMod Full sources you don't have TWRP sources so go here, select the branch you want and download it.
https://github.com/omnirom/android_bootable_recovery
Extract the archive in /home/username/NameOfTheFolder/bootable
Rename the folder to "recovery-twrp" without quotes ----> Warning: Be sure that in NameOfTheFolder/device/vendor/devicename/Boardconfig.mk there is RECOVERY_VARIANT := twrp
Chapter 3: TWRP compilation
I'm going to use a device as example
Once you had your sources organised as follow:
/home/username/NameOfTheFolder/device/vendor/devicename
/home/username/NameOfTheFolder/kernel/vendor/devicename
/home/username/NameOfTheFolder/vendor/vendor/devicename

Device Tree
Kernel
Vendor files

Notice: You can use @lj50036 minimal device tree to compile TWRP, remember to adapt it to your phone.
https://github.com/lj50036/android_d...endor_codename
Download and extract it in /home/username/NameOfTheFolder/device/vendor/ them rename the folder to your devicename

Open a fresh terminal and type the following commands:

Code:

  1. cd ~/NameOfTheFolder

  2. source build/envsetup.sh

  3. lunch

  4. Type the number of your device and press enter. For example in my case the number 16 is my device

  5. mka recoveryimage ---> This command will start the compilation of the recovery.


I hope I have been clear, Enjoy  
So This is a Complete Guide to Compile twrp From Source code if you have any question let us know via Comment,
Search tag-
port twrp from source, port recovery form source code, compile twrp recovery from source code, install twrp recovery on your device, source code port guide, how to port recovery for snapdragon device, port twrp for spd devices, port twrp for qualcomm devices, port twrp custom recovery for snapdragon devices, compile recovery for latest mtk devices,
Previous
Next Post »