Sunday, November 27, 2011

Rooting An Android Phone From Scratch - My Experiments with Truth!!


Hello Friends. From past 3 days I was on an rooting rampage with my HTC Tattoo android phone. I was a fan of Android before I ever rooted my phone and now I am in love with it since I have rooted it. The real power of any operating system lies when you have the command of the super user. This is what rooting is all about.


Rooting a device needs two things. First the right set of files for rooting and second the courage to play with a 12,000 Rs phone that you brought by saving your earnings( the cost of phone may vary depending upon the heaviness of your surname). These days I started small development work on android to learn its basics. I am looking forward to dive deep into this mobile OS. From past few days I was very much troubled with the word "rooting" and was getting really restless about it. Finally I decided on 23-11-2011 to finally sit down,leave all work and start my work on android rooting. So i started with working on android SDK first. Working of Android SDK is fairly simple and is just like the linux command line( in-fact it is a unix command line). After getting an overview of the basics of android-windows-sdk , I switched on to look for various commands and mode of working of it. Then I moved ahead to root my android phone. And finally after a struggle of 3 days I finally rooted my phone and installed a custom ROM. Oops I forgot to define what is rooting.

Rooting means to gain permissions of a superuser or the root user in any Unix based OS. This is a universal definition for a unix based Os which contains a special super user called root.
So to gain privilege of root is called rooting.
Android sdk also contains a a superb tool calld Android Debug Bridhe(ADB). It is a tool that is used to send commands to the android device using a laptop/PC. We will be extensively using it in this experiment.

Well there are lots of excellent rooting tutorials and videos available on the internet for free. You can find lots of useful resources. I will recommend you to check the threads of xda-developers forum which has some of the finest posts on rooting android phone. The main reason for creating this post is to let my readers gain intrest in exploring things. The fun of gadgets is not just in using them. The real fun lies in technically playing with them. So I am creating this post to encourage my readers to explore their android devices ( rather spoil!! ) and feel its power.
I still tried to remain a bit different from various soruces I found on the internet and which I used to root my phone. What I have done here is I have created a single folder called tattoo.rar which can be downloaded from here - DOWNLOAD. 
This file can be directly downloaded and unzipped to any drive. Then by using the set of commands below you can get root privilege to your phone and later on install a higher version of Android ROM on it.

Before we begin we will have to download the android sdk. It can be downloaded from HERE. Once you have downloaded it, unzip it to any drive, say C drive. Open the folder and run SDKmanager.exe . If you are running it for the first time then it will show you a list of packages that you can install from the list.
You will have to install just one package for the time being. That is Android-sdk platform tools.

Once you have finished installing the pakage the next thing you can do is set the class path in environment variables. This is an optional step but it can speed up your process of working.
To set up the environment variables Right click on My Computer, Go to properties, then Advance System Settings , then Environment Variables. In System Variables, look for PATH. Double click on it to edit it. Then add the following path in it :

;c:\android-sdk-windows\tools;c:\android-sdk-windows\platform-tools

Now you are all set. To check what you have done, open command prompt type adb. Yo will see a list of options.
Now coming back to the downloaded file, tattoo.rar. Unzip it to any folder of your choice. Suppose I unzipped it in my c drive.
Now start command prompt and change directory to c:/tattoo
Your prompt should look something like this : c:/tattoo>

Now plug your HTC tattoo to USB. At the command prompt type the following command;
adb devices
If it shows a device listed, it means your device is connected and responding.
Let us proceed. Now execute the following commands in the same sequence as mentioned.


1. Let's say you have everything unpacked into C:\Tattoo
2. In your terminal (on your PC) type:
- adb shell "mkdir /data/local/bin" (if it returns an error it means that the directory already exists, just proceed)
- adb push m7 /data/local/bin/
- adb push su /data/local/bin/
- adb push flash_image /data/local/bin/
- adb push tattoo-hack.ko /data/local/bin/
- adb push recovery.img /sdcard
- adb push boot.img /sdcard
3. We have every needed file on the phone now. Type now (we are still in your terminal):
- adb shell
$ cd /data/local/bin
$ chmod 766 m7 (I don't retain this step as mandatory, so if this process fails, just proceed)
$ while ./m7 ; do : ; done
lots of text until you see something like "wrote shell code", press enter 2 or 3 times enter to see:
#
4. Then perform this:
- # export LD_LIBRARY_PATH=/system/lib
- # export PATH=/system/bin
- # insmod ./tattoo-hack.ko
- # mount -o rw,remount /dev/block/mtdblock5 /data
- # mount -o rw,remount /dev/block/mtdblock3 /system
- # cat ./su > /system/bin/su
- # chmod 4755 /system/bin/su
- # chmod 755 ./flash_image


Successful execution of these commands will root your device and you can now have full rights on your HTC tattoo phone.
Now how to check if rooting is successful or not. To check it, switch off your phone. Now press the "Home" key and then power it own. You will see a recovery screen similar to the one in figure.


As you can see you are now presented with certain boot options which were previously not available for you. Now along with rooting the device with the set of commands mentioned above, we also flashed the SD card so that it becomes capable of installing custom ROM's. Custom ROM's are developed using a perticular version of android with a different interface. Installing a custom ROM can enhance your mobile performance. You can find lots of custom ROM available on the internet. I would recommend to check out this page - Custom ROM. It has whole list of custom ROM's for HTC Tattoo.
I chose a custom ROM based on Android 2.3 Gingerbred so as to upgrade my old Android 1.6 pre-installed OS. This is the biggest advantage of rooting. You can install higher versions of OS even if the manufacturer is not producing updates. All you have to do is simply download a custom ROM and copy it in the SD card. Dont copy in any folder, just inside the card in zip format. Now in the above image you will find an option "install zip from SD card". Once you click on it you will be presented with a screen similar to the one shown below :


You can see the two zip custom ROMs available on my SD card which I had copied. Now I can select any one of them and install it on my phone. Once the installation is complete, reboot your phone and you are ALLLLL DDOONNEE !!

Finally you will have a new version of android installed on your phone.



SPECIAL NOTE : Rooting has certain advantages but it has disadvantages too. There can be several components which might not function properly. So before installing any custom ROM make sure it has all the basic common functions. Like in my case the Camera is not working but the battery usage and speed has increased greatly. Also there are numerous One-Click Root applications available for android devices who can automatically root your phone but I would recommend that you go for this manual approach it will give  better understanding.

Hope you enjoyed reading this tutorial. If you too have a HTC Tattoo and you are bored of Dounut then dont wait, just jump to GingerBred. I bet you will love it.
Do Leave your comments and suggestions.

DARKLORD!!

9 comments:

  1. bro mine is andrios versoin of 2.1 eclair can do this......?

    ReplyDelete
  2. yes it can be rooted by this technique as well...This techniques works prior to version 2.2

    ReplyDelete
  3. hey bro i also found some other way here wats your opnion on this..http://techfoke.blogspot.com/2011/11/how-to-root-all-android-device-in-1.html

    ReplyDelete
  4. @sai charan : Bro thats a tool based technique.. There are lots of tools available for rooting android phones...You can go for either the tool based or manual method(discussed above) .. Both will solve the purpose. But if you are new to android and running short of time then you can root your phone using that tool. The manual way is for those who have some exposure to android SDK..

    ReplyDelete
  5. hii salam kenal iya dari vira .. :)
    jangan lupa mapir keweb vira iya di http://www.rumahkiat.com/ vira mau berbagi pengalaman nih.:)
    wah bagus juga iya blog ka2 ... ^_^ good luck iya.....
    SALAM BLOGER INDONESIA..:)

    ReplyDelete
  6. I like this blog and how you explained how to gain root access the traditional way. I find android sdk helpful for rooting but also helpful for developing applications too. Great blog
    For background information on rooting check out http://da-best-tech.blogspot.com/

    ReplyDelete
  7. This is one of the powerful post.Your blog Information is useful.I am so gland to get this type of post.This is one of the classic post.Android app developers

    ReplyDelete