Introduction to Modding: Rooting and Custom ROMs
credits to The_ERROR of xda for compiling this
1. Basics of Unix-like system
- * su, root, rooting - what is it, why we need it
- * sh, bash, busybox - what BusyBox is, basic list of commands from BusyBox, bash, sh
Also referred to as substitute user - a command for changing the account in the current terminal (usually black screen with blinking cursor). Default account is root account. So if you insert into terminal 'su' and hit enter, you will become root user.
Root alias superuser or poweruser is special user account for system administration. Similar to windows having its administrator account, unix-like systems have a root account. With this, you can do anything and if you run a command to delete the whole system, unix will just do it! No asking, no confirming. So, watch your steps!
Rooting is just enabling power of root for applications and other purposes.
After rooting is done, you will see a new app called superuser in app drawer. This app can delegate applications to use su (root) feature. When an app asks this from first use, a popup window will appear asking if the application should be allowed to use root permission.
is a command-line interpreter or shell that provides a traditional user interface for the Unix operating system and for Unix-like systems. So simply, it is some interface, which can execute command(s), which you have entered. Many shells exist, but in scope of android you can (as far as I know) use only sh (standard - Bourne-shell) or bash (compiled in BusyBox or separately on XDA). Both are basically same, but bash has much more features and it is more comfortable.
How do I know if I'm root or normal user? It's simple. Root's shell is ended with # (usually it's shell looks like "bash-3.2# _") and user's ends with $ (usually bash-3.2$ _). In terminal emulator you also can have only [path]($|#) (for root for example "/etc # _")
also called "The Swiss Army Knife of Embedded Linux" is a tool which brings into Android basic tools known from unix system, but is much more smaller than standard tools is. But this "packing" has limited functions in comparison to standard tools in unix-system (missing special modes of tool, color output and so on). Many application use this. For example busybox grep (filtering of text) is needed for application called Market enabler.
list of commands is really wide, so it's not possible explain all, so I pickup only top few. (hint: if you want what some command do, just search on google for "man <command_name>" for example man mv or enter command here
- cd - change directory - same like in windows. You can switch directory. example: cd /sdcard
- ls - list of files in actual directory (have few switches like for example: ls -l /sdcard/*.png (detailed listing)
- cat - print file into standard output (like more in windows) Example: cat /sdcard/data.txt
- vi - editing of file. But on limited phone keyboard (no keyboard) it is little harder Read more about vi
- cp - copy of one or more file. Example: cp /sdcard/bike.jpg /sdcard/media/bike-wallpaper.jpg
- mv - moving/rename files, Example: mv /sdcard/bike.jpg /sdcard/media/renamed-moved-bike.jpg
- rm - delete file (rm -R for recursive, or for delete whole folder), Example: rm -R /sdcard/wallpaper-bad/*
- find - search for files, Example find / -name "best-chopper-ever.avi"
- mkdir - make directory - creates directory, Example: mkdir mynewdir
- chmod - changes access of files
- less - similar like cat, but you can scroll in it and it doesn't produce any output. Example: less /sdcard/funnytext.txt
Please, take due note that main pages are documentation of unix tools. For BusyBox's tool help, just enter BusyBox <command_name> -h.
2. Android platform and its specifics
- * adb shell
- * Android SDK
- * Tools for Android adb shell - Terminal Emulator, ADB shell from Android SDK and how to use it
ADB - Android Debug Bridge is a versatile tool that lets you manage the state of an emulator instance or Android-powered device. It is a client-server program that includes three components:
- * A client, which runs on your development machine. You can invoke a client from a shell by issuing an adb command. Other Android tools such as the ADT plugin and DDMS also create adb clients.
- * A server, which runs as a background process on your development machine. The server manages communication between the client and the adb daemon running on an emulator or device.
- * A daemon, which runs as a background process on each emulator or device instance.
Generally, it can be compared with standard cmd prompt in windows (you can write commands which will be executed locally, for example in Terminal Emulator) or it can be just like SSH in unix-like system (you connect to terminal through adb client (in Android SDK) and commands will be run remotely.
Android software development kit is a complex set of tools for developing apps on Android. It includes a fully usable emulator of Android OS on your PC, where you can do everything. You can install/delete apps, browse web page in embedded web browser, play games or make your own application in Eclipse (widely used IDE for development). Of course, with emulator you can use also GPS or camera.
Android SDK tools
- * Fully emulated Android device
- * Android Development Tools Plugin (Eclipse IDE)
- * Android Virtual Devices (AVDs)
- * Hierarchy Viewer
- * layoutopt
- * Draw 9-patch
- * Dalvik Debug Monitor Service (ddms)
- * Android Debug Bridge (adb)
- * Android Asset Packaging Tool (aapt)
- * Android Interface Description Language (aidl)
- * sqlite3
- * Traceview
- * mksdcard
- * dx
- * UI/Application Exerciser Monkey
- * monkeyrunner
- * Android
- * zipalign
Tools for work with Android adb shell
You have two ways to connect into ADB service - locally and remotely.
- Locally - for local access you will need some application which can connect to local adb shell.
Terminal Emulator (free) - probably most commonly used app from market, which works and looks like standard unix shell.
ConnectBot (free) - same as Terminal Emulator, but it can be also used for connecting via SSH or telnet
- Remotely- For remote connection you need phone configuration adjustment:
Home desktop -> [menu button] -> Settings -> Applications -> Development -> USB debugging [ON].
Also you need connect your phone via USB (or finds on market some widget/app, witch enable using ADB also via wi-fi)
adb tool from Android SDK
After downloading Android SDK, extract the archive anywhere (in example I extracted it in c:/AndroidSDK). Then follow instructions on developer.android.com for installation of SDK Platform-tools (contains adb). After installation click on start menu and in Run... (in Windows7 in search bar) enter 'cmd' and press Ok or [enter]. Then write in cmd line:
now you can enter following command to connect to phone's adb shell if you don't have more connected device (virtual or real-one)
cd c:\AndroidSDK\android-sdk-windows\tools [enter]
If you have more then one, you need explicitly say which one should be used for connection. So list connected devices with
which shows you serial number of connected devices. Than use
3. Custom recovery
adb -s <serial-number> shell
- * What is custom recovery
- * Tools which custom recovery provide - NAND backup/restore, formatting of SDcard, partitioning (ext1,ext2, ext3), wiping, flashing of Custom ROM, ...
- * Is it safe to install? - potential problems, backup/restore of original recovery
- * How this whole thing works - installation description (not how-to install, just explanation of what is done during installation)
What is custom recovery
Recovery is an image (binary data) stored in internal memory. This image contains something like a "program" or "tool", which can boot-up independently from the Android system. This tool is part of phone system, and in PC terminology recovery can by compared to BIOS with some added features. This recovery state can be reached on all phones, but if you don't have a custom recovery, it will do a so-called HW reset and automatically restart itself into standard boot mode.
Tools which custom recovery provides
- * USB-MS Toggle :mounts sdcard as mass storage
It just mounts your phone as USB-mass storage (USB disk) so you can access it through your PC
Absolutely GREAT feature. With NAND you can copy an image of your actual system (phone's memory). It means that you can backup the whole system with all configuration, customization, wallpapers, system's tweaks... just everything. This image will be written to your SD card which you are then free to copy around and back up on your computer
This tool is designed for installation of custom ROMs or tweaks. If you are instructed to install via custom recovery, then you should use this menu. Never unzip the file because it contains meta-information about itself with some validate-checks so if you edit it, or unpack and pack back, it won't work. And remember to place the file in the root (main folder) of your sdcard.
Wipe data/factory reset: wipes data & cache
- wipes user data (contacts, apps, configuration, ...) and cache (caches of applications)
- wipes cache only
Wipe Dalvik cache : Wipes Dalvik cache in all possible locations if moved by apps2sd
- wipes Dalvik cache
Wipe SD:ext : Wipes Apps2sd ext partition
- if you used Partition SDcard option, you can wipe it here
Wipe Battery Stats (remember to fully charge your phone before doing this)
- If you think, that your battery life is too short, you can try delete battery stats. Than let phone fully charge. (more)
Wipe rotate settings
- wipe sensor settings (acceleration, ...)
Wipe .android secure : Wipes froyo native .android_secure on sdcard
- wipe information about moved apps
Partition SD: Partitions sdcard for apps2sd (this formats card so all data will be lost)
- will create ext2 partition (you will be asked for size of ext2 and cache)
SD:ext2 to ext3 : converts apps2sd ext2 partition to ext3 (requires kernel support for ext3)
SD:ext3 to ext4 : same as above but ext3 to ext4 (requires kernel support for ext4)
ext2 - file system for the Linux kernel (no journal, fast but not recovery of I/O error)
ext3 - file system for the Linux kernel (journal, slower than ext2 because of journal, but provides recovery on I/O error)
ext4 - file system for the Linux kernel (journal, enhanced version of ext3)
Gui automatically mounts folders
4. Custom ROM (generally)
- * What is a Custom ROM?
- * Is it safe to install custom ROMs? - potential problems
- * What do I need to install?
- * What can custom ROM provide - kernel, update, performance, customization, theme, ....
- * what is ...
o deodexed, zipaglined, png-optimized
o JIT, HW:acceleration, VM.Heap Size, stagefright
o apps2sd + dalvik2sd
o custom kernel (recompiled, ...)
What is a Custom ROM?
Custom ROM is a modification of the manufacturer's ROM or ROM compiled from Android sources. "Change/s" ranges from adding/removing default applications up to including kernels, cpu over/under-clocking, enable/disable features (ROOT, HW acceleration, ...), themes (frameworks, color, ...), keyboards and many other features.
A Custom ROM is usually distributed as a signed ZIP package that includes an installation script for custom recovery. This ZIP is flashed via custom recovery tool.
Is it safe to install a custom ROM?
Yes, it is. If you are not satisfied, you can just restore your old ROM using a NAND backup. And yes, you can also use backup tools like Astro or Titanium Backup to backup your apps and restore these in your new ROM (NOTE: In this case it's strongly recommended that both ROM should have same or very similar source/base ROM).
What do I need to install one?
1) Rooted phone
2) Installed custom recovery
3) Signed .ZIP file of ROM compatible with recovery
#) RECOMMENDED: NAND backup of your actual ROM
What does custom ROM bring
Custom ROM brings almost every feature you can imagine.
OS optimization for games, long battery life, calling, texting, playing videos,...
awesome look - changed icons, colors, animations, wallpapers, menu, ....
reconstructed framework - restart button, reorganized menu, shorts, gestures, etc
allow tweaking - overclok/underclok your device, ROOT, ....
It's really not possible describe here every possibility what you can do/get with custom ROM.
what is ...
png files takes less memory, are loads fasterJIT -
just-in-time compilation also known as dynamic translation, is a method to improve the runtime performance of computer programs, but it takes some time to convert into it on start.HW:acceleration -
using of HW acceleration for rendering GUI. Increases battery consumption.VM.Heap Size -
maximum memory an application can consumestagefright -
In Android 2.2 new media framework that supports local file playback and HTTP progressive streaming