[GUIDE] How To Compile TWRP Recovery for QVGA And Other Unsupported Devices.

Search This thread

Aadi

Senior Member
May 27, 2012
468
290
infinityhacks.wordpress.com
How To Compile TWRP Recovery For QVGA And Other Unsupported Devices

Guys a humble request don't spam this thread. If you face any error reply to this thread or PM me i will help :D and after you build it please don't post your bugs here this thread is only for compiling and not for resolving bugs in your build. I can only help with the errors you face during compilation because i faced a lot ;).

I thank XDA members cybojenix, kD as i got an idea of how to make guides from them ;)
I would also thank Dees_troy for the sources.

I have worked hard in creating this guide so when you release your build please give proper credits :).

Minimum Requirements:-
1. RAM:- 4GB
2. HDD Space:- More than 18GB required for CM7 source code (I am going to use CM7 for this guide as CM9 is not yet supported for many devices).
3. Processor:- Equal to Core 2 Duo or Anything above it.
4. Internet Speed:- Minimum of 2 Mbps as we will be downloading files of large size.
5. Patience:- A lots of it needed to get success ;)

Ok Lets Start With Step 1:- Setting Up Your Computer For Development.

Getting Linux

Please note your PC/Laptop must satisfy the minimum requirements to continue. If it doesn't contact any person who is developing for your device to develop this.

For compiling you need Linux the most common and free Linux available for development is Ubuntu. Go ahead choose your version and download it.

If you wish to use Ubuntu 10.04 64-Bit for Development use this link

If you wish to use Ubuntu 10.10 64-Bit for Development use this link

If you wish to use Ubuntu 11.04 64-Bit for Development use this link

If you wish to use Ubuntu 11.10 64-Bit for Development use this link

If you wish to use Ubuntu 12.04 64-Bit for Development use this link

After downloading install it in a Virtual Machine or dual boot it alongside another OS you are using now. If you are using a Virtual Machine make sure you allocate more than 50GB of HDD space.

So far so good now that you have Linux installed :victory: you can proceed to the next step of setting up which is followed in the second post.
 
Last edited:

Aadi

Senior Member
May 27, 2012
468
290
infinityhacks.wordpress.com
Setting Up Your Laptop/PC For Development.

Note:- You may be asked for a password when using sudo command.

Installing Python-2.7.5:-
First and foremost is installing Python. For those who are wondering what Python is well here is the answer Python is a language like C,C++,Java which primarily centers around Linux.

1. Open Terminal by hitting Ctrl+Alt+T.
2. Type or copy paste these codes into terminal (I prefer typing though ;))
Code:
sudo apt-get install build-essential gcc
cd Downloads
wget http://www.python.org/ftp/python/2.7.5/Python-2.7.5.tgz
tar -xvzf Python-2.7.5.tgz
cd Python-2.7.5
./configure --prefix=/usr/local/python2.7
make
sudo make install
sudo ln -s /usr/local/python2.7/bin/python /usr/bin/python2.7
3. Python is now installed to make sure type this code in terminal
Code:
python
and it should produce an output like this
Code:
Python 2.7.2+ (default, Jul 20 2012, 22:15:08)
[GCC 4.6.1] on linux2
Type "help", "copyright", "credits" or " lincense" for more information.
>>>
4. If it shows something like that you are good to go.
5. Press Ctrl+D, close the terminal and proceed to install Java 6 JDK.

Installing Java 6 JDK:-
I have to thank cybojenix and kD for this part :D as it is theirs and i didn't write this part :D.

If you are using Ubuntu 12.04 follow these commands others skip this set of commands.

1. Download Java 6 JDK from here.
2. After Downloading copy that to the Downloads folder.
3. Open Terminal.
4. Type these commands one by one in the terminal
Code:
cd Downloads

chmod +x jdk-6u34-linux-x64.bin
sudo ./jdk-6u34-linux-x64.bin
sudo mv jdk1.6.0_34 /usr/lib/jvm/

sudo update-alternatives --install /usr/bin/java java /usr/lib/jvm/jdk1.6.0_34/bin/java 1
sudo update-alternatives --install /usr/bin/javac javac /usr/lib/jvm/jdk1.6.0_34/bin/javac 1
sudo update-alternatives --install /usr/bin/javaws javaws /usr/lib/jvm/jdk1.6.0_34/bin/javaws 1

sudo update-alternatives --config java
sudo update-alternatives --config javac
sudo update-alternatives --config javaws

If you are not using Ubuntu 12.04 follow these commands:-

1. Open terminal
2. Type these commands one by one in the Terminal.
Code:
sudo add-apt-repository ppa:ferramroberto/java
sudo apt-get update
sudo apt-get install sun-java6-jre sun-java6-bin sun-java6-jdk

If you had done those steps correctly then you must now have Java installed.
To check and make sure it is installed type this command in terminal.
Code:
java -version
and the output should be
Code:
java version "1.6.0_34"
Java(TM) SE Runtime Environment (build 1.6.0_34-b04)
Java HotSpot(TM) 64-Bit Server VM (build 20.9-b04, mixed mode)

If the output was some thing similar you are now ready to install GNU Make.
Close the Terminal and proceed.

Installing GNU Make 3.81

Note:- Any other version of make either lower or higher won't work for compiling TWRP.
1. Open Terminal
2. Type these codes in terminal.
Code:
wget -o make.tar.gz http://ftp.gnu.org/gnu/make/make-3.81.tar.gz
tar -xvzf make-3.81.tar.gz
cd make-3.81
./configure
sudo make install
3. That's it now you got make installed.
To check and make sure that Make is installed type this command in Terminal.
Code:
make -v
and it shoud give the output
Code:
GNU Make 3.81
Copyright (C) 2006 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

This Program built for x86_64-unknown-linux-gnu

If it was something smiliar to that you can close the terminal and proceed to the next step.

Ok now we got the big guns rolling it's now time for small guns without whom we can't compile yes I mean't the dependencies.

Open Terminal and apply these commands:-
Code:
sudo apt-get install git-core gnupg flex bison gperf  build-essential zip curl zlib1g-dev libc6-dev lib32ncurses5-dev  ia32-libs x11proto-core-dev libx11-dev lib32readline5-dev lib32z-dev  libgl1-mesa-dev g++-multilib mingw32 tofrodos python-markdown  libxml2-utils xsltproc gedit git schedtool
export USE_CCACHE=1

If you are using Ubuntu 10.10 apply this:-
Code:
sudo ln -s /usr/lib32/mesa/libGL.so.1 /usr/lib32/mesa/libGL.so

If you are using Ubuntu 11.04 apply this:-
Code:
sudo ln -s /usr/lib32/mesa/libGL.so.1 /usr/lib32/mesa/libGL.so
sudo apt-get install libx11-dev:i386

If you are using Ubuntu 12.04 apply this:-
Code:
sudo ln -s /usr/lib32/mesa/libGL.so.1 /usr/lib32/mesa/libGL.so
sudo apt-get install libx11-dev:i386
sudo apt-get install libncurses5-dev:i386 libx11-dev:i386 libreadline6-dev:i386 libgl1-mesa-glx:i386 zlib1g-dev:i386
sudo ln -s /usr/lib/i386-linux-gnu/mesa/libGL.so.1 /usr/lib/i386-linux-gnu/libGL.so

Good now you will have dependencies installed.

It is now time for SDK and ADB which will be continued in the next post.
 

Aadi

Senior Member
May 27, 2012
468
290
infinityhacks.wordpress.com
Installing SDK and ABD

Installing SDK:-

1. Download Android SDK from here.
2. Extract it to your home folder.
3. Rename the folder to sdk.
4. Open the Terminal and type these commands
Code:
cd sdk/tools
./android sdk
5. A window should popup and there will will be a list of Packages.
6. Install Android SDK Tools and Android SDK Platform-Tools.

Checking ADB:-

Since you installed Android SDK Tools and Android SDK Platform-Tools ADB must now be checked and configured.
1. Enable USB Debugging in your device and connect your phone to computer.
2. Now execute these commands in Terminal
Code:
cd sdk/platform-tools
./adb devices

It should give the output as
Code:
List of devices attached 0123456789ABCDEF device-name (Note the number-letter combination may vary)
If it does give like that skip Adding Permissions.

Or if it gives the output as
Code:
List of devices attached ????????????????? no permissions
Don't worry we have add permission to your device that's it.

Adding Permissions:-

1. Open Terminal
2. Execute this command.
Code:
sudo gedit /etc/udev/rules.d/51-android.rules
3. It should open text editor
4. Paste this line
Code:
SUBSYSTEM=="usb", ATTR{idVendor}=="xxxx", MODE="0666"
5. Replace Vendor ID with your Vendor id given in the list.
For e.g if your vendor is Acer you will replace "xxxx" with "0502"

Here is a list of Vendor ID's
Code:
Acer - 0502
ASUS - 0b05
Dell - 413c
Foxconn - 0489
Fujitsu - 04c5
Fujitsu Toshiba - 04c5
Garmin-Asus - 091e
Google - 18d1
Hisense - 109b
HTC - 0bb4
Huawei - 12d1
K-Touch - 24e3
KT Tech - 2116
Kyocera - 0482
Lenovo -17ef
LG - 1004
Motorola - 22b8
MTK - 0e8d
NEC - 0409
Nook - 2080
Nvidia - 0955
OTGV - 2257
Pantech - 10a9
Pegatron - 1d4d
Philips - 0471
PMC-Sierra - 04da
Qualcomm - 05c6
SK Telesys - 1f53
Samsung - 04e8
Sharp - 04dd
Sony - 054c
Sony Ericsson -	0fce
Teleepoch -	2340
Toshiba - 0930
ZTE - 19d2

6. Save and close the editor.
7. Execute this command in Terminal.
Code:
sudo gedit /etc/udev/rules.d/99-android.rules
8. Again paste this line
Code:
SUBSYSTEM=="usb", ATTR{idVendor}=="xxxx", MODE="0666"
Replace "xxxx" with Vendor ID.
9. Save it and close the file.
10. Execute these commands one by one in the Terminal
Code:
sudo chmod a+r /etc/udev/rules.d/99-android.rules
sudo chmod a+r /etc/udev/rules.d/51-android.rules

Now RESTART your Ubuntu and type these codes in the Terminal.
Code:
cd sdk
./adb devices

You must not get the output with ???????????????? no permission still if you get it please reply below I will help.

Now we need to edit .bashrc so that we can access adb from anywhere
Execute these codes in the Terminal.
Code:
cd
sudo gedit .bashrc
It should open text editor copy paste this line at the end.
Code:
export PATH=${PATH}:~/sdk/tools
export PATH=${PATH}:~/sdk/platform-tools

Save it and close it.
Now in terminal type adb devices it should give output List of devices attached.

That's it you got Ubuntu, Python, Java 6 JDK, GNU Make-3.81, SDK and ADB ready.

Now you are ready to start development go on to the next step to download source code.
 
Last edited:

Aadi

Senior Member
May 27, 2012
468
290
infinityhacks.wordpress.com
Intializing Repo And Download Source Code

Step 2:- Initializing Repository And Downloading Source Code

Initializing Repository

First step is to download the Repo which is essential to download the source code.

1. Open Terminal
2. Execute these commands one by one in Terminal
Code:
mkdir ~/bin
PATH=~/bin:$PATH
sudo apt-get install curl
curl https://dl-ssl.google.com/dl/googlesource/git-repo/repo > ~/bin/repo
chmod a+x ~/bin/repo

Downloading Source Code

After you have initialized the repo you are set to download the source code.

1. Open Terminal
2. Execute these commands one by one in Terminal
Code:
mkdir source
cd source
repo init -u git://github.com/Cyanogenmod/android.git -b gingerbread
sudo sysctl -w net.ipv4.tcp_window_scaling=0
repo sync -jx (Replace x with a number this number corresponds to number simultaneous download you want for e.g if you give 5 it will download 5 files at once so go on increase to whatever you like but be reasonable :D)
The Source Code is around 15GB - 17GB so have patience and more importantly HDD space.
.

The download will take hours if you are on slow connection like it will be a 2 days is 512kbps connection so if you are planning to develop please have a good internet connection with a reasonable fast speed. Every developer recommends more than 1Mbps and sometimes 4Mbps.

After downloading is finished go to source folder you must have many folders inside them. Also make a backup of the source folder just in case as we will modifying it so if something goes wrong you don't have to re-download it all again.

Go to the next step to start the actual development.
 
Last edited:

Aadi

Senior Member
May 27, 2012
468
290
infinityhacks.wordpress.com
Modding Files And Stuff

Step 3:- Modding Files And Folders To Make Your Device Supportable.

First up is to compile a build of ClockworkMod.

Building ClockworkMod:-

1. Open Terminal
2. Type these commands one by one in Terminal
Code:
. build/envsetup.sh
lunch (it should show you list of devices select your device with their serial number select your device by typing the serial number)
make clean
make -j4 recoveryimage

If you didn't receive an error you are ready to compile TWRP for your device.
If you do receive and error reply to the post I will help you.

Modifying Files And Folder:-

The original Dees_Troy's build folder isn't gonna work as your device resolution doesn't support it. So I have patched the build folder with some extra libs added to prelink map and patched recovery folder with gui changes for smooth compilation.

If you have experience with using git you can clone the repo or you can download it directly from github.

If you are going to clone execute these commands in terminal. (Thanks to cybojenix for this so that there will no manual copying).
Code:
cd source
rm -rf build/
rm -rf bootable/recovery/
git clone git://github.com/chainhacker/TWRP_Build -b 2.3 build
git clone git://github.com/chainhacker/TWRP_Recovery -b 2.3 bootable/recovery

If you are going to download directly use the following link make sure you are downloading 2.3 branch and extract it.
Here is the link for the patched build folder------>TWRP_Build
Here is the link for the patched recovery folder------>TWRP_Recovery
After you have done downloading from the above two files.
Replace the contents of source/build folder with the patched one.
Similarly replace the contents of source/bootable/recovery folder with the patched one.

I have 240x320 resolution already in the patched ones but if your device is not 240x320 and also not supported by TWRP download a theme made by other members which has your device's resolution or create a theme. I didn't create the theme though I resized the images and made changes in ui.xml. If you are interested in theming follow the official TWRP theming guide in their website.

If you did find a theme or created it rename the theme folder to your device resolution folder for e.g. If your device resolution is 320x240 you would rename the folder as 320x240.

Copy the theme folder into source/bootable/recovery/gui/devices.

That's it finished the basic requirements next up is configuring BoardConfig.mk.

Editing BoardConfig.mk:-

1. Navigate to source/device/your_vendor/your_device.
your_vendor:- Vendor of your device e.g for me it is lge.
your_device:- Your device name.
2. Find BoardConfig.mk and open it in a text editor.
3. Come to the last and add these line
Code:
#twrp
DEVICE_RESOLUTION:= [I]your_device_resolution[/I] (e.g If your resolution is 240x320 type it)
RECOVERY_GRAPHICS_USE_LINELENGTH := true
2. Save it and close it.

Yay you have finished everything only thing left out is compiling :D which is carried out in the next post.

Psssst.......
After you have compiled your first successful build here are few other things that you could add to BoardConfig.mk
Note:- You can add this after finishing first successful build of recovery till then avoid these.
Code:
RECOVERY_SDCARD_ON_DATA := true -- this enables proper handling of /data/media on devices that have this folder for storage (most Honeycomb and devices that originally shipped with ICS like Galaxy Nexus)
BOARD_HAS_NO_REAL_SDCARD := true -- disables things like sdcard partitioning
TW_INCLUDE_DUMLOCK := true -- includes HTC Dumlock for devices that need it
TARGET_RECOVERY_GUI := true -- uses gui format instead of ui.xml
TARGET_RECOVERY_PIXEL_FORMAT := "RGB_565" -- to change the colour
TARGET_USE_CUSTOM_LUN_FILE_PATH :=/sys/devices/platform/usb_mass_storage/lun0/file 
TW_CUSTOM_POWER_BUTTON := 107 -- to get a power button on the home screen of recovery
TW_EXTERNAL_STORAGE_PATH := "/sdcard" -- default external storage path
TW_EXTERNAL_STORAGE_MOUNT_POINT := "sdcard" -- default external mount point
TW_FLASH_FROM_STORAGE := true -- enables you to flash zips form the sdcard (You don't neeed o add this it is activated by default)
TW_HAS_DOWNLOAD_MODE := false -- to enable download or more precisely enabling usb mass storage
TW_HAS_NO_RECOVERY_PARTITION := true -- do this only if you device has no partion to recovery
TW_INCLUDE_CRYPTO := false
TW_INCLUDE_JB_CRYPTO := false
TW_NEVER_UNMOUNT_SYSTEM := true -- always keeps the system mounted
TW_NO_BATT_PERCENT := false -- shows battery percentage
TW_NO_REBOOT_BOOTLOADER := true --- disables rebooting into bootloader
TW_NO_USB_STORAGE := false -- disabled usb storage
TW_SDEXT_NO_EXT4 := false
 
Last edited:

Aadi

Senior Member
May 27, 2012
468
290
infinityhacks.wordpress.com
Compiling Recovery

Step 4:- Compiling Recovery

Finally you have come to the final part of the guide which is compiling recovery.

1. Open Terminal.
2. Execute these commands in Terminal
Code:
. build/envsetup.sh
lunch (Again select your device)
make -j4 recoveryimage
.

That's it when it is finished grab recovery.img from:
out/target/product/your_product_name/recovery.img

Flash it in your device test it fix the bugs and release it.

Wait if you don't want flash and just see how it looks so that you can flash another recovery if it is not working do these
I am not resposible if your device gets bricked in fastboot mode but mostly it won't happen though :p
1. Copy the recovery.img to sdk/platform-tools
2. Boot your device into fastboot mode.
3. Open Terminal
4. Execute these commands one by one in Terminal
Code:
fastboot devices (wait for your device to show up int terminal)
fastboot boot recovery.img

You can test out all the features except flash zip, backup and restore.

Victory :victory: you have successfully compiled TWRP recovery for your device go ahead have fun and enjoy.

If you really like my work express your gratitude by pressing the Thanks button. See you soon in another thread :D ;) :victory: :laugh: :fingers-crossed: :cool:
 

Joe4899

Senior Member
Oct 20, 2012
64
16
Does it make any difference if I want to compile it for an ARMV6 device?

Gesendet von meinem Skate mit Tapatalk 4 Beta
 

Joe4899

Senior Member
Oct 20, 2012
64
16
So that's me again :laugh: Wanted to compile TWRP 2.6.0.0 for cm10.1 so I have set up everything so far but get an error when I try to compile

build/core/base_rules.mk:130: *** external/fuse/lib: MODULE.TARGET.STATIC_LIBRARIES.libfuse already defined by bootable/recovery/fuse.

Seems to be really stupid, so far I understand is the libfuse defined twice in recovery and base_rules.mk so think (thought :mad:) it's an easy part - just to remove this libfuse from one of them... But I can't find something with "libfuse", "static libraries" or anything like that in base_rules.mk
 

Aadi

Senior Member
May 27, 2012
468
290
infinityhacks.wordpress.com
So that's me again :laugh: Wanted to compile TWRP 2.6.0.0 for cm10.1 so I have set up everything so far but get an error when I try to compile



Seems to be really stupid, so far I understand is the libfuse defined twice in recovery and base_rules.mk so think (thought :mad:) it's an easy part - just to remove this libfuse from one of them... But I can't find something with "libfuse", "static libraries" or anything like that in base_rules.mk

I have never tried compiling 2.6.0.0 because Dees_Troy is evaluating my theme for my device such that it gets official support so if you are ready to use CM7 and TWRP 2.3.3.0 you can follow my guide and i can help you with the errors but any other version please ask Dees_Troy for the solution. :)
 

andrea210701

Senior Member
Aug 1, 2012
644
294
How I compile twrp if my phone is not officially/unofficially supported?is it possible?

Sended from my ascend g330 using tapatalk 4 [VIP]
 

maximik1980

Member
Feb 18, 2013
14
2
Minsk
Error detected :)

Hi, Chain Hacker.
Does it matter how to write address after "git://"?
I mean this:
Code:
[B]repo init -u git://github.com/Cyanogenmod/android.git -b gingerbread[/B]
Should it be like this:
Code:
[B]repo init -u git://github.com/Cyanogen[COLOR="Red"]M[/COLOR]od/android.git -b gingerbread[/B]

By the way, it's a very good manual for those who are just starting to understand how to compile :cool:
 
Last edited:

Aadi

Senior Member
May 27, 2012
468
290
infinityhacks.wordpress.com
Hi, Chain Hacker.
Does it matter how to write address after "git://"?
I mean this:
Code:
[B]repo init -u git://github.com/Cyanogenmod/android.git -b gingerbread[/B]
Should it be like this:
Code:
[B]repo init -u git://github.com/Cyanogen[COLOR="Red"]M[/COLOR]od/android.git -b gingerbread[/B]

By the way, it's a very good manual for those who are just starting to understand how to compile :cool:

No i doesnt matter at all the only thing that is case sensitive are the words after cyanogenmod as they must be written as it is so it is your wish whether you are gonna write Cyanogenmod or CyanogenMod :) and by the way thanks for the complement ;) :) :D

Sent from my LG-P350 using Tapatalk 2
 

maximik1980

Member
Feb 18, 2013
14
2
Minsk
TWRP Recovery size...

Hi again...
I've managed to compile a TWRP-Recovery 2.6.0.1 based on CM9 for my Huawei Ascend Y101 (8186).
But I had to change recovery partition size in BoardConfig.mk (originally it was BOARD_RECOVERYIMAGE_PARTITION_SIZE := 0x00500000, I changed it to 0x00600000), because without these changes it wasn't possible to build a recovery.img ("recovery.img is too large... etc.")
When I flashed it on my device, the TWRP recovery started and worked perfectly, but I wasn't able to boot my device. But it's not a problem for me, I understand why it wasn't able to boot very good.

The question is the following: is it possible to decrease somehow the source files' sizes of TWRP recovery (maybe images, don't know...) in order to compile the recovery.img that would be less than 4.85 MB (actually it's size is 5*095*424, it's more than my recovery partition....... :( )
By the way, the size of a CWM-recovery (cm9) that I've compiled is 4*489*216, so it fits like a glove :good: and works fine...
Thanks in advance. I understand that you compiled a TWPR recovery based on CM7, but I don't see much differences...:cool:
 

Aadi

Senior Member
May 27, 2012
468
290
infinityhacks.wordpress.com
Hi again...
I've managed to compile a TWRP-Recovery 2.6.0.1 based on CM9 for my Huawei Ascend Y101 (8186).
But I had to change recovery partition size in BoardConfig.mk (originally it was BOARD_RECOVERYIMAGE_PARTITION_SIZE := 0x00500000, I changed it to 0x00600000), because without these changes it wasn't possible to build a recovery.img ("recovery.img is too large... etc.")
When I flashed it on my device, the TWRP recovery started and worked perfectly, but I wasn't able to boot my device. But it's not a problem for me, I understand why it wasn't able to boot very good.

The question is the following: is it possible to decrease somehow the source files' sizes of TWRP recovery (maybe images, don't know...) in order to compile the recovery.img that would be less than 4.85 MB (actually it's size is 5*095*424, it's more than my recovery partition....... :( )
By the way, the size of a CWM-recovery (cm9) that I've compiled is 4*489*216, so it fits like a glove :good: and works fine...
Thanks in advance. I understand that you compiled a TWPR recovery based on CM7, but I don't see much differences...:cool:

The difference is no on the source dude so relax. You have to modify your kernel and change the compression method to lzma. Contact Dees_Troy for this because i dont know how to change it. You can chat with him through IRC. :)
 

Top Liked Posts

  • There are no posts matching your filters.
  • 14
    Compiling Recovery

    Step 4:- Compiling Recovery

    Finally you have come to the final part of the guide which is compiling recovery.

    1. Open Terminal.
    2. Execute these commands in Terminal
    Code:
    . build/envsetup.sh
    lunch (Again select your device)
    make -j4 recoveryimage
    .

    That's it when it is finished grab recovery.img from:
    out/target/product/your_product_name/recovery.img

    Flash it in your device test it fix the bugs and release it.

    Wait if you don't want flash and just see how it looks so that you can flash another recovery if it is not working do these
    I am not resposible if your device gets bricked in fastboot mode but mostly it won't happen though :p
    1. Copy the recovery.img to sdk/platform-tools
    2. Boot your device into fastboot mode.
    3. Open Terminal
    4. Execute these commands one by one in Terminal
    Code:
    fastboot devices (wait for your device to show up int terminal)
    fastboot boot recovery.img

    You can test out all the features except flash zip, backup and restore.

    Victory :victory: you have successfully compiled TWRP recovery for your device go ahead have fun and enjoy.

    If you really like my work express your gratitude by pressing the Thanks button. See you soon in another thread :D ;) :victory: :laugh: :fingers-crossed: :cool:
    11
    How To Compile TWRP Recovery For QVGA And Other Unsupported Devices

    Guys a humble request don't spam this thread. If you face any error reply to this thread or PM me i will help :D and after you build it please don't post your bugs here this thread is only for compiling and not for resolving bugs in your build. I can only help with the errors you face during compilation because i faced a lot ;).

    I thank XDA members cybojenix, kD as i got an idea of how to make guides from them ;)
    I would also thank Dees_troy for the sources.

    I have worked hard in creating this guide so when you release your build please give proper credits :).

    Minimum Requirements:-
    1. RAM:- 4GB
    2. HDD Space:- More than 18GB required for CM7 source code (I am going to use CM7 for this guide as CM9 is not yet supported for many devices).
    3. Processor:- Equal to Core 2 Duo or Anything above it.
    4. Internet Speed:- Minimum of 2 Mbps as we will be downloading files of large size.
    5. Patience:- A lots of it needed to get success ;)

    Ok Lets Start With Step 1:- Setting Up Your Computer For Development.

    Getting Linux

    Please note your PC/Laptop must satisfy the minimum requirements to continue. If it doesn't contact any person who is developing for your device to develop this.

    For compiling you need Linux the most common and free Linux available for development is Ubuntu. Go ahead choose your version and download it.

    If you wish to use Ubuntu 10.04 64-Bit for Development use this link

    If you wish to use Ubuntu 10.10 64-Bit for Development use this link

    If you wish to use Ubuntu 11.04 64-Bit for Development use this link

    If you wish to use Ubuntu 11.10 64-Bit for Development use this link

    If you wish to use Ubuntu 12.04 64-Bit for Development use this link

    After downloading install it in a Virtual Machine or dual boot it alongside another OS you are using now. If you are using a Virtual Machine make sure you allocate more than 50GB of HDD space.

    So far so good now that you have Linux installed :victory: you can proceed to the next step of setting up which is followed in the second post.
    9
    Modding Files And Stuff

    Step 3:- Modding Files And Folders To Make Your Device Supportable.

    First up is to compile a build of ClockworkMod.

    Building ClockworkMod:-

    1. Open Terminal
    2. Type these commands one by one in Terminal
    Code:
    . build/envsetup.sh
    lunch (it should show you list of devices select your device with their serial number select your device by typing the serial number)
    make clean
    make -j4 recoveryimage

    If you didn't receive an error you are ready to compile TWRP for your device.
    If you do receive and error reply to the post I will help you.

    Modifying Files And Folder:-

    The original Dees_Troy's build folder isn't gonna work as your device resolution doesn't support it. So I have patched the build folder with some extra libs added to prelink map and patched recovery folder with gui changes for smooth compilation.

    If you have experience with using git you can clone the repo or you can download it directly from github.

    If you are going to clone execute these commands in terminal. (Thanks to cybojenix for this so that there will no manual copying).
    Code:
    cd source
    rm -rf build/
    rm -rf bootable/recovery/
    git clone git://github.com/chainhacker/TWRP_Build -b 2.3 build
    git clone git://github.com/chainhacker/TWRP_Recovery -b 2.3 bootable/recovery

    If you are going to download directly use the following link make sure you are downloading 2.3 branch and extract it.
    Here is the link for the patched build folder------>TWRP_Build
    Here is the link for the patched recovery folder------>TWRP_Recovery
    After you have done downloading from the above two files.
    Replace the contents of source/build folder with the patched one.
    Similarly replace the contents of source/bootable/recovery folder with the patched one.

    I have 240x320 resolution already in the patched ones but if your device is not 240x320 and also not supported by TWRP download a theme made by other members which has your device's resolution or create a theme. I didn't create the theme though I resized the images and made changes in ui.xml. If you are interested in theming follow the official TWRP theming guide in their website.

    If you did find a theme or created it rename the theme folder to your device resolution folder for e.g. If your device resolution is 320x240 you would rename the folder as 320x240.

    Copy the theme folder into source/bootable/recovery/gui/devices.

    That's it finished the basic requirements next up is configuring BoardConfig.mk.

    Editing BoardConfig.mk:-

    1. Navigate to source/device/your_vendor/your_device.
    your_vendor:- Vendor of your device e.g for me it is lge.
    your_device:- Your device name.
    2. Find BoardConfig.mk and open it in a text editor.
    3. Come to the last and add these line
    Code:
    #twrp
    DEVICE_RESOLUTION:= [I]your_device_resolution[/I] (e.g If your resolution is 240x320 type it)
    RECOVERY_GRAPHICS_USE_LINELENGTH := true
    2. Save it and close it.

    Yay you have finished everything only thing left out is compiling :D which is carried out in the next post.

    Psssst.......
    After you have compiled your first successful build here are few other things that you could add to BoardConfig.mk
    Note:- You can add this after finishing first successful build of recovery till then avoid these.
    Code:
    RECOVERY_SDCARD_ON_DATA := true -- this enables proper handling of /data/media on devices that have this folder for storage (most Honeycomb and devices that originally shipped with ICS like Galaxy Nexus)
    BOARD_HAS_NO_REAL_SDCARD := true -- disables things like sdcard partitioning
    TW_INCLUDE_DUMLOCK := true -- includes HTC Dumlock for devices that need it
    TARGET_RECOVERY_GUI := true -- uses gui format instead of ui.xml
    TARGET_RECOVERY_PIXEL_FORMAT := "RGB_565" -- to change the colour
    TARGET_USE_CUSTOM_LUN_FILE_PATH :=/sys/devices/platform/usb_mass_storage/lun0/file 
    TW_CUSTOM_POWER_BUTTON := 107 -- to get a power button on the home screen of recovery
    TW_EXTERNAL_STORAGE_PATH := "/sdcard" -- default external storage path
    TW_EXTERNAL_STORAGE_MOUNT_POINT := "sdcard" -- default external mount point
    TW_FLASH_FROM_STORAGE := true -- enables you to flash zips form the sdcard (You don't neeed o add this it is activated by default)
    TW_HAS_DOWNLOAD_MODE := false -- to enable download or more precisely enabling usb mass storage
    TW_HAS_NO_RECOVERY_PARTITION := true -- do this only if you device has no partion to recovery
    TW_INCLUDE_CRYPTO := false
    TW_INCLUDE_JB_CRYPTO := false
    TW_NEVER_UNMOUNT_SYSTEM := true -- always keeps the system mounted
    TW_NO_BATT_PERCENT := false -- shows battery percentage
    TW_NO_REBOOT_BOOTLOADER := true --- disables rebooting into bootloader
    TW_NO_USB_STORAGE := false -- disabled usb storage
    TW_SDEXT_NO_EXT4 := false
    6
    Setting Up Your Laptop/PC For Development.

    Note:- You may be asked for a password when using sudo command.

    Installing Python-2.7.5:-
    First and foremost is installing Python. For those who are wondering what Python is well here is the answer Python is a language like C,C++,Java which primarily centers around Linux.

    1. Open Terminal by hitting Ctrl+Alt+T.
    2. Type or copy paste these codes into terminal (I prefer typing though ;))
    Code:
    sudo apt-get install build-essential gcc
    cd Downloads
    wget http://www.python.org/ftp/python/2.7.5/Python-2.7.5.tgz
    tar -xvzf Python-2.7.5.tgz
    cd Python-2.7.5
    ./configure --prefix=/usr/local/python2.7
    make
    sudo make install
    sudo ln -s /usr/local/python2.7/bin/python /usr/bin/python2.7
    3. Python is now installed to make sure type this code in terminal
    Code:
    python
    and it should produce an output like this
    Code:
    Python 2.7.2+ (default, Jul 20 2012, 22:15:08)
    [GCC 4.6.1] on linux2
    Type "help", "copyright", "credits" or " lincense" for more information.
    >>>
    4. If it shows something like that you are good to go.
    5. Press Ctrl+D, close the terminal and proceed to install Java 6 JDK.

    Installing Java 6 JDK:-
    I have to thank cybojenix and kD for this part :D as it is theirs and i didn't write this part :D.

    If you are using Ubuntu 12.04 follow these commands others skip this set of commands.

    1. Download Java 6 JDK from here.
    2. After Downloading copy that to the Downloads folder.
    3. Open Terminal.
    4. Type these commands one by one in the terminal
    Code:
    cd Downloads
    
    chmod +x jdk-6u34-linux-x64.bin
    sudo ./jdk-6u34-linux-x64.bin
    sudo mv jdk1.6.0_34 /usr/lib/jvm/
    
    sudo update-alternatives --install /usr/bin/java java /usr/lib/jvm/jdk1.6.0_34/bin/java 1
    sudo update-alternatives --install /usr/bin/javac javac /usr/lib/jvm/jdk1.6.0_34/bin/javac 1
    sudo update-alternatives --install /usr/bin/javaws javaws /usr/lib/jvm/jdk1.6.0_34/bin/javaws 1
    
    sudo update-alternatives --config java
    sudo update-alternatives --config javac
    sudo update-alternatives --config javaws

    If you are not using Ubuntu 12.04 follow these commands:-

    1. Open terminal
    2. Type these commands one by one in the Terminal.
    Code:
    sudo add-apt-repository ppa:ferramroberto/java
    sudo apt-get update
    sudo apt-get install sun-java6-jre sun-java6-bin sun-java6-jdk

    If you had done those steps correctly then you must now have Java installed.
    To check and make sure it is installed type this command in terminal.
    Code:
    java -version
    and the output should be
    Code:
    java version "1.6.0_34"
    Java(TM) SE Runtime Environment (build 1.6.0_34-b04)
    Java HotSpot(TM) 64-Bit Server VM (build 20.9-b04, mixed mode)

    If the output was some thing similar you are now ready to install GNU Make.
    Close the Terminal and proceed.

    Installing GNU Make 3.81

    Note:- Any other version of make either lower or higher won't work for compiling TWRP.
    1. Open Terminal
    2. Type these codes in terminal.
    Code:
    wget -o make.tar.gz http://ftp.gnu.org/gnu/make/make-3.81.tar.gz
    tar -xvzf make-3.81.tar.gz
    cd make-3.81
    ./configure
    sudo make install
    3. That's it now you got make installed.
    To check and make sure that Make is installed type this command in Terminal.
    Code:
    make -v
    and it shoud give the output
    Code:
    GNU Make 3.81
    Copyright (C) 2006 Free Software Foundation, Inc.
    This is free software; see the source for copying conditions.
    There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
    
    This Program built for x86_64-unknown-linux-gnu

    If it was something smiliar to that you can close the terminal and proceed to the next step.

    Ok now we got the big guns rolling it's now time for small guns without whom we can't compile yes I mean't the dependencies.

    Open Terminal and apply these commands:-
    Code:
    sudo apt-get install git-core gnupg flex bison gperf  build-essential zip curl zlib1g-dev libc6-dev lib32ncurses5-dev  ia32-libs x11proto-core-dev libx11-dev lib32readline5-dev lib32z-dev  libgl1-mesa-dev g++-multilib mingw32 tofrodos python-markdown  libxml2-utils xsltproc gedit git schedtool
    export USE_CCACHE=1

    If you are using Ubuntu 10.10 apply this:-
    Code:
    sudo ln -s /usr/lib32/mesa/libGL.so.1 /usr/lib32/mesa/libGL.so

    If you are using Ubuntu 11.04 apply this:-
    Code:
    sudo ln -s /usr/lib32/mesa/libGL.so.1 /usr/lib32/mesa/libGL.so
    sudo apt-get install libx11-dev:i386

    If you are using Ubuntu 12.04 apply this:-
    Code:
    sudo ln -s /usr/lib32/mesa/libGL.so.1 /usr/lib32/mesa/libGL.so
    sudo apt-get install libx11-dev:i386
    sudo apt-get install libncurses5-dev:i386 libx11-dev:i386 libreadline6-dev:i386 libgl1-mesa-glx:i386 zlib1g-dev:i386
    sudo ln -s /usr/lib/i386-linux-gnu/mesa/libGL.so.1 /usr/lib/i386-linux-gnu/libGL.so

    Good now you will have dependencies installed.

    It is now time for SDK and ADB which will be continued in the next post.
    6
    Installing SDK and ABD

    Installing SDK:-

    1. Download Android SDK from here.
    2. Extract it to your home folder.
    3. Rename the folder to sdk.
    4. Open the Terminal and type these commands
    Code:
    cd sdk/tools
    ./android sdk
    5. A window should popup and there will will be a list of Packages.
    6. Install Android SDK Tools and Android SDK Platform-Tools.

    Checking ADB:-

    Since you installed Android SDK Tools and Android SDK Platform-Tools ADB must now be checked and configured.
    1. Enable USB Debugging in your device and connect your phone to computer.
    2. Now execute these commands in Terminal
    Code:
    cd sdk/platform-tools
    ./adb devices

    It should give the output as
    Code:
    List of devices attached 0123456789ABCDEF device-name (Note the number-letter combination may vary)
    If it does give like that skip Adding Permissions.

    Or if it gives the output as
    Code:
    List of devices attached ????????????????? no permissions
    Don't worry we have add permission to your device that's it.

    Adding Permissions:-

    1. Open Terminal
    2. Execute this command.
    Code:
    sudo gedit /etc/udev/rules.d/51-android.rules
    3. It should open text editor
    4. Paste this line
    Code:
    SUBSYSTEM=="usb", ATTR{idVendor}=="xxxx", MODE="0666"
    5. Replace Vendor ID with your Vendor id given in the list.
    For e.g if your vendor is Acer you will replace "xxxx" with "0502"

    Here is a list of Vendor ID's
    Code:
    Acer - 0502
    ASUS - 0b05
    Dell - 413c
    Foxconn - 0489
    Fujitsu - 04c5
    Fujitsu Toshiba - 04c5
    Garmin-Asus - 091e
    Google - 18d1
    Hisense - 109b
    HTC - 0bb4
    Huawei - 12d1
    K-Touch - 24e3
    KT Tech - 2116
    Kyocera - 0482
    Lenovo -17ef
    LG - 1004
    Motorola - 22b8
    MTK - 0e8d
    NEC - 0409
    Nook - 2080
    Nvidia - 0955
    OTGV - 2257
    Pantech - 10a9
    Pegatron - 1d4d
    Philips - 0471
    PMC-Sierra - 04da
    Qualcomm - 05c6
    SK Telesys - 1f53
    Samsung - 04e8
    Sharp - 04dd
    Sony - 054c
    Sony Ericsson -	0fce
    Teleepoch -	2340
    Toshiba - 0930
    ZTE - 19d2

    6. Save and close the editor.
    7. Execute this command in Terminal.
    Code:
    sudo gedit /etc/udev/rules.d/99-android.rules
    8. Again paste this line
    Code:
    SUBSYSTEM=="usb", ATTR{idVendor}=="xxxx", MODE="0666"
    Replace "xxxx" with Vendor ID.
    9. Save it and close the file.
    10. Execute these commands one by one in the Terminal
    Code:
    sudo chmod a+r /etc/udev/rules.d/99-android.rules
    sudo chmod a+r /etc/udev/rules.d/51-android.rules

    Now RESTART your Ubuntu and type these codes in the Terminal.
    Code:
    cd sdk
    ./adb devices

    You must not get the output with ???????????????? no permission still if you get it please reply below I will help.

    Now we need to edit .bashrc so that we can access adb from anywhere
    Execute these codes in the Terminal.
    Code:
    cd
    sudo gedit .bashrc
    It should open text editor copy paste this line at the end.
    Code:
    export PATH=${PATH}:~/sdk/tools
    export PATH=${PATH}:~/sdk/platform-tools

    Save it and close it.
    Now in terminal type adb devices it should give output List of devices attached.

    That's it you got Ubuntu, Python, Java 6 JDK, GNU Make-3.81, SDK and ADB ready.

    Now you are ready to start development go on to the next step to download source code.