Welcome to XDA

Search to go directly to your device's forum

Register an account

Unlock full posting privileges

Ask a question

No registration required
Post Reply

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

OP Aadi

25th May 2013, 11:35 AM   |  #1  
Aadi's Avatar
OP Senior Member
Flag Chennai
Thanks Meter: 268
 
448 posts
Join Date:Joined: May 2012
More
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 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.

Quote:

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



Quote:

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

Quote:

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 you can proceed to the next step of setting up which is followed in the second post.
Last edited by Aadi; 25th May 2013 at 05:01 PM.
The Following 8 Users Say Thank You to Aadi For This Useful Post: [ View ]
25th May 2013, 12:28 PM   |  #2  
Aadi's Avatar
OP Senior Member
Flag Chennai
Thanks Meter: 268
 
448 posts
Join Date:Joined: May 2012
More
Setting Up Your Laptop/PC For Development.


Quote:

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:-
Quote:

I have to thank cybojenix and kD for this part as it is theirs and i didn't write this part .

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

Quote:

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.
The Following 5 Users Say Thank You to Aadi For This Useful Post: [ View ]
25th May 2013, 01:52 PM   |  #3  
Aadi's Avatar
OP Senior Member
Flag Chennai
Thanks Meter: 268
 
448 posts
Join Date:Joined: May 2012
More
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 by Aadi; 25th May 2013 at 03:37 PM.
The Following 5 Users Say Thank You to Aadi For This Useful Post: [ View ]
25th May 2013, 03:36 PM   |  #4  
Aadi's Avatar
OP Senior Member
Flag Chennai
Thanks Meter: 268
 
448 posts
Join Date:Joined: May 2012
More
Tutorial 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)
Quote:

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 by Aadi; 25th May 2013 at 05:13 PM.
The Following 5 Users Say Thank You to Aadi For This Useful Post: [ View ]
25th May 2013, 04:34 PM   |  #5  
Aadi's Avatar
OP Senior Member
Flag Chennai
Thanks Meter: 268
 
448 posts
Join Date:Joined: May 2012
More
Tutorial 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.

Quote:

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.
Quote:

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:= your_device_resolution (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 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
Quote:

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 by Aadi; 26th May 2013 at 05:23 AM.
The Following 6 Users Say Thank You to Aadi For This Useful Post: [ View ]
25th May 2013, 05:00 PM   |  #6  
Aadi's Avatar
OP Senior Member
Flag Chennai
Thanks Meter: 268
 
448 posts
Join Date:Joined: May 2012
More
Tutorial 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
Quote:

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 you have successfully compiled TWRP recovery for your device go ahead have fun and enjoy.

Quote:

If you really like my work express your gratitude by pressing the Thanks button. See you soon in another thread

The Following 6 Users Say Thank You to Aadi For This Useful Post: [ View ]
25th May 2013, 05:16 PM   |  #7  
Aadi's Avatar
OP Senior Member
Flag Chennai
Thanks Meter: 268
 
448 posts
Join Date:Joined: May 2012
More
Angry Reserved
reserved just in case
Last edited by Aadi; 11th July 2013 at 07:30 AM.
The Following 2 Users Say Thank You to Aadi For This Useful Post: [ View ]
11th July 2013, 07:36 AM   |  #8  
Aadi's Avatar
OP Senior Member
Flag Chennai
Thanks Meter: 268
 
448 posts
Join Date:Joined: May 2012
More
Thumbs up Contributions
You can Contribute to this guide by suggesting improvements and stuff are welcome PM about the contribution and i will add by giving credits to the person contributed
The Following 3 Users Say Thank You to Aadi For This Useful Post: [ View ]
12th July 2013, 03:28 PM   |  #9  
Joe4899's Avatar
Member
Thanks Meter: 15
 
61 posts
Join Date:Joined: Oct 2012
More
Does it make any difference if I want to compile it for an ARMV6 device?

Gesendet von meinem Skate mit Tapatalk 4 Beta
12th July 2013, 05:44 PM   |  #10  
Aadi's Avatar
OP Senior Member
Flag Chennai
Thanks Meter: 268
 
448 posts
Join Date:Joined: May 2012
More
Quote:
Originally Posted by Joe4899

Does it make any difference if I want to compile it for an ARMV6 device?

Gesendet von meinem Skate mit Tapatalk 4 Beta

Nope it won't make any difference it is just the same even if your device is ARMv6 or ARMv7. Make sure your device is supported by CM

The Following User Says Thank You to Aadi For This Useful Post: [ View ]
Post Reply Subscribe to Thread
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes