Everything about ADB – Android Debug Bridge for Beginners

 

TUTORIAL – EVERYTHING ABOUT ADB – Fully Illustrated



1. WHAT IS ADB?

ADB or Android Debug Bridge is a command line program which is used to communicate with your Android phone (or an emulator used by programmers). The use of Adb for Android phone users ranges from using it as a tool to get the logcat- A realtime log of the Android system, which allows one to know the cause of any errors. It is very helpful to app hackers to know exctly what block of code does what, and to modify apps accordingly

2. HOW TO USE ADB – Running adb.exe

adb.exe is part of a package of tools called Android SDK or Software Development Kit. For users, the main applications useful for them are adb.exe, fastboot.exe and aapt.exe.

2.1 Installing adb.exe (Windows)

  1. First, download the Android SDK package(exe file) from here The installer will prompt you to download and install the JDK (Java Development Kit) if you dont have it already installed
  • Next install the exe file and note the location where you install it to.
  • After install is over, use Windows explorer and navigate to the folder where you installed the SDK.
  • Double-click the SDK Manager.exe/SDK Setup.exe file at the root of the Android SDK directory.
  • This will open up the SDK Installation window, where you can choose from a list of packages to install
  • If you want to use only adb.exe and fastboot.exe, choose to install only the “Android SDK Tools” from the list (See fig 1 below)
  • That’s it, adb.exe is now installed

 

Fig1:

Take a note of where you install it. It usually installs to a folder named Android-sdk-windows. Once you have it installed, you can copy the entire folder on a portable usb key/CD and use it on any other PC without a need to install it. I recommend that you make it a part of your Android CD (with rooting tools, unrooting tools, gold card etc).

2.2 Using adb.exe-Preparing your PC for running adb.exe quickly

Adding Adb to your Windows Path
Once installed, you should add the location of adb.exe to the* Windows Environment Path variable. To do that, go the subfolder of Android-sdk-windows where adb.exe can be found. Click on the Windows Explorer path displayed on Top, and copy the path to the Clipboard

Go to Start Menu, and Right click Computer, Choose Properties

Choose Advanced System Settings and then Environment variables

Now, add the Location you copied to the Clipboard earlier, to the end of the current path, after adding a “;”(without the quotes) to the end of the current path.

So, in my case, the current path shows:
c:droidzonewindows; c:droidzoneblahblah

It now becomes:
c:droidzonewindows; c:droidzoneblahblah;C:SoftwarePhoneandroid-sdk-windowstools

Hit Enter to everything.

From now, whenever you open a Command prompt in Windows, you will be able to execute Adb and Fastboot from there without needing to navigate to the folder where they are installed.

Default Elementary Adb commands

Ok, now that you’ve got adb all setup and prepared your computer to use it, you’re ready to learn some basic adb commands. I’ll be teaching some of them in this section.


Understanding how adb and the shell works

Let’s first check if adb is working by asking it to communicate with our phone. Connect the phone with a usb cable to the PC. Note that you should have installed the HTC drivers already (They come with HTC Sync). Another important point to note is that you should have enabled USB Debugging on your phone (Menu>Settings>Applications>Development>USB Debugging)

From your Windows Start Menu, Click on Run, then type the following and press enter. That should open a command shell:

 

Code:
cmd[/code]

Once there, type out the following:

 

Code:
adb devices[/code]

This will display a list showing the connected phones with their serial numbers (and emulators-But let us not worry about what these are, right now)

Great, now we have confirmation that adb is working! We're now ready to issue our basic commands.

First thing to note is the basic command to enter the Android custom linux shell. Like Windows has cmd.exe to enter the dos shell, the graphical eyecandy with Sense overlay that you see on your device has a custom linux kernel running, so basically the language of its shell is the Linux shell language.

Accessing the Linux terminal (adb shell) is what we do to issue commands. To enter the shell of our device, the basic command is:

 

Code:
adb shell[/code]

Immediately, you will get a prompt like this:

Code:
sh-3.2#[/code]

Now we can type out any (most) linux commands and these will be executed in our device.

The file system on Android is laid out over MTD partitions in your device's NAND (Internal memory), and the SD card. The Nand is strictly organized in a Linux system with Linux file permissions and ownership rights (Just know that these exist, for now)

So, right now, you will be dropped in the "root" of the filesystem, from where you can navigate to other places.

 

Note! An important difference between Linux and Windows is that while Windows uses the Backslash (), Linux/Android uses the forward slash (/) to depict directory hierarchies. Another one you shouldnt forget is that in Linux/Android, a file named boot.img is different from Boot.img, BOOT.IMG and BoOt.img, while on Windows, they are all the same.

 

My tutorial is about adb commands, and not linux, so I'll give only a short summary of elementary linux commands below. I will expand the list and explanation for this at a later date if you require it:

pwd-Shows the current working directory
cp-copy a file
mv-move a file (copy a file and then delete the original file)
chmod-set file permissions
chown-set file ownerships
rm-delete a file
cd-change directory
rmdir-delete a directory


Elementary Adb commands

Installing applications with adb
You can install any apk from your PC to the phone very easily. Open a cmd shell, and then type in:

Code:
adb install[/code]

followed by a space. Now drag an apk file in Windows explorer to the shell we have opened. Immediately, the path of the file becomes inserted in our prompt that it becomes:

 

Code:
adb install C:DesktopTitaniumBackup.apk[/code]

assuming that the file TitaniumBackup.apk was present in the location C:Desktop. Hit enter and you will notice that it gets installed.

Transferring files to the sdcard without connecting the device as Disk drive:

 

Code:
adb push C:DesktopTitaniumBackup.apk /sdcard/[/code]

will trasfer the file C:DesktopTitaniumBackup.apk to the root (main) directory of your sdcard. Likewise, you can transfer any file from the PC to any location on your device.

Eg: I want to transfer a file called wallpaper.zip to a location /data/local. The command would be:

 

Code:
adb push C:Desktopwallpaper.zip /data/local/[/code]
More elementary adb commands:

Getting a file from your phone to your PC:

To get a file /system/etc/init.d/01data to your PC, you would type out the following:

 

Code:
adb pull /system/etc/init.d/01data[/code]

which will transfer the spcified file to the location on your pc where you have opened the cmd.exe shell.

Mounting the system partition as Read Write to transfer files to your /system partition:

Method 1:

 

Code:
adb remount[/code]

Method 2:
This can also be accomplished with the more advanced mount command in the adb shell. First we need to know the mount point of the partitions.

Type:

Code:
adb shell
mount[/code]

For me, it displays:

Code:
rootfs / rootfs rw,relatime 0 0
tmpfs /dev tmpfs rw,relatime,mode=755 0 0
devpts /dev/pts devpts rw,relatime,mode=600 0 0
proc /proc proc rw,relatime 0 0
sysfs /sys sysfs rw,relatime 0 0
/sys/kernel/debug /sys/kernel/debug debugfs rw,relatime 0 0
none /acct cgroup rw,relatime,cpuacct 0 0
tmpfs /mnt/asec tmpfs rw,relatime,mode=755,gid=1000 0 0
tmpfs /mnt/obb tmpfs rw,relatime,mode=755,gid=1000 0 0
tmpfs /app-cache tmpfs rw,relatime,size=8192k,mode=755,gid=1000 0 0
none /dev/cpuctl cgroup rw,relatime,cpu 0 0
/dev/block/mtdblock3 /system yaffs2 ro,relatime 0 0
/dev/block/mtdblock4 /cache yaffs2 rw,nosuid,nodev,relatime 0 0
/dev/block/mtdblock5 /system/data yaffs2 rw,nosuid,nodev,noatime,nodiratime 0 0
/dev/block/mmcblk0p2 /data ext4 rw,nosuid,nodev,noatime,nodiratime,commit=50,bar
rier=0,stripe=64,data=ordered,noauto_da_alloc 0 0
/dev/block/vold/179:1 /mnt/sdcard vfat rw,dirsync,nosuid,nodev,noexec,relatime,u
id=1000,gid=1015,fmask=0702,dmask=0702,allow_utime=0020,codepage=cp437,iocharset
=iso8859-1,shortname=mixed,utf8,errors=remount-ro 0 0
/dev/block/vold/179:1 /mnt/secure/asec vfat rw,dirsync,nosuid,nodev,noexec,relat
ime,uid=1000,gid=1015,fmask=0702,dmask=0702,allow_utime=0020,codepage=cp437,ioch
arset=iso8859-1,shortname=mixed,utf8,errors=remount-ro 0 0
tmpfs /mnt/sdcard/.android_secure tmpfs ro,relatime,size=0k,mode=000 0 0
sh-3.2#[/code]

Note that the entry for system partition shows:
/dev/block/mtdblock3 /system yaffs2 ro,relatime 0 0

The ro means that /system is mounted as RO-i.e Read Only. The whole line means that the Nand MTD block device on /dev/block/mtdblock3 is mounted on the mount point /system, to use technical jargon.

We need to mount it as RW (Read Write)
The command is:

Code:
mount -o rw,remount /dev/block/mtdblock3 /system[/code]
This essentially mounts the /system as Read Write so that you can write to it (Normally you cant write to the /system partition), which is what "adb remount " also does. However the commands above can be executed from a Terminal Emulator application too. Next: Getting an Adb logcat [/code]
Getting an adb logcat

Many a time, you might have heard people telling you to get a logcat to report your error with a Rom installation.

What is a logcat?

A logcat is a report from the Android logging system, which takes place in the background the whole time your phone is on. It starts the moment you switch on the phone, and continues till you shut it down completely. This log is extremely useful for finding out what went wrong with your system. It is useful to find out why your phone is having bootloops or force closes. It is infact useful for all errors!

How to get the logcat?
Basically, you can view the logcat log with the following command:

[/code]

Code:

 

adb logcat[/code]
[/code]
But that means getting overwhelmed by an endless haze of output flowing at a rate that you cant read and will overwhelm your command shell's capacity very soon. So the system we normally use is to output the log to a file from which we can read later. This is done by the following command:

[/code]

Code:
adb logcat > log.txt[/code]
[/code]
My Technique As a Rom developer and apk patcher, I have to constantly check for errors in my system. So I've devised an ingenous method to easily log logcat, and view them readily. I use a combo of commands executed in succession:

[/code]

Code:
adb kill-server
echo "" > log.txt
start log.txt
adb logcat > log.txt[/code]

These commands essentially create a blank file named log.txt in the same path as the command shell you've opened. Then, it opens the file log.txt (which is blank at this point of time. Then it logs logcat output to that file. Once you refresh the opened file, it will show the output of logcat to this point of time. Refresh it once again, and it updates once more. You should install Notepad++ and associate .txt files with it, to get best results. Instead of executing these four commands, you can download the batch file getlog.cmd and extract it from the zip file to the folder containing adb.exe. Once you type in the following command (from anywhere in Windows), you will achieve the same result as typing the four commands as above! Ingenious, eh?

Default Summary of other adb commands
[/code]
 


 

[/code]

The following is the exhaustive list of commands supported by adb. You can obtain this list by the following command:

Code:
adb /?[/code]
Code:
C:Users>adb /?
Android Debug Bridge version 1.0.26

-d - directs command to the only connected USB devic
e
returns an error if more than one USB device is
present.
-e - directs command to the only running emulator.
returns an error if more than one emulator is r
unning.
-s <serial number> - directs command to the USB device or emulator w
ith
the given serial number. Overrides ANDROID_SERI
AL
environment variable.
-p <product name or path> - simple product name like 'sooner', or
a relative/absolute path to a product
out directory like 'out/target/product/sooner'.

If -p is not specified, the ANDROID_PRODUCT_OUT

environment variable is used, which must
be an absolute path.
devices - list all connected devices
connect <host>:<port> - connect to a device via TCP/IP
disconnect <host>:<port> - disconnect from a TCP/IP device

device commands:
adb push <local> <remote> - copy file/dir to device
adb pull <remote> [<local>] - copy file/dir from device
adb sync [ <directory> ] - copy host->device only if changed
(see 'adb help all')
adb shell - run remote shell interactively
adb shell <command> - run remote shell command
adb emu <command> - run emulator console command
adb logcat [ <filter-spec> ] - View device log
adb forward <local> <remote> - forward socket connections
forward specs are one of:
tcp:<port>
localabstract:<unix domain socket name>
localreserved:<unix domain socket name>
localfilesystem:<unix domain socket name>
dev:<character device name>
jdwp:<process pid> (remote only)
adb jdwp - list PIDs of processes hosting a JDWP transport

adb install [-l] [-r] [-s] <file> - push this package file to the device and i
nstall it
('-l' means forward-lock the app)
('-r' means reinstall the app, keeping its data
)
('-s' means install on SD card instead of inter
nal storage)
adb uninstall [-k] <package> - remove this app package from the device
('-k' means keep the data and cache directories
)
adb bugreport - return all information from the device
that should be included in a bug report.

adb help - show this help message
adb version - show version num

DATAOPTS:
(no option) - don't touch the data partition
-w - wipe the data partition
-d - flash the data partition

scripting:
adb wait-for-device - block until device is online
adb start-server - ensure that there is a server running
adb kill-server - kill the server if it is running
adb get-state - prints: offline | bootloader | device
adb get-serialno - prints: <serial-number>
adb status-window - continuously print device status for a specifie
d device
adb remount - remounts the /system partition on the device re
ad-write
adb reboot [bootloader|recovery] - reboots the device, optionally into the boo
tloader or recovery program
adb reboot-bootloader - reboots the device into the bootloader
adb root - restarts the adbd daemon with root permissions
adb usb - restarts the adbd daemon listening on USB
adb tcpip <port> - restarts the adbd daemon listening on TCP on th
e specified port
networking:
adb ppp <tty> [parameters] - Run PPP over USB.
Note: you should not automatically start a PPP connection.
<tty> refers to the tty for PPP stream. Eg. dev:/dev/omap_csmi_tty1
[parameters] - Eg. defaultroute debug dump local notty usepeerdns

adb sync notes: adb sync [ <directory> ]
<localdir> can be interpreted in several ways:

- If <directory> is not specified, both /system and /data partitions will be u
pdated.

- If it is "system" or "data", only the corresponding partition
is updated.[/code]

I will add notes for these if you require them.

 


You are reading this post on Joel G Mathew’s tech blog. Joel's personal blog is the Eyrie, hosted here.

How to unroot the HTC Desire

How to Unroot the HTC Desire

Other Descriptions:

How to Revert to Stock

What to do before taking my phone back to the service centre?

How to restore my phone after a failed OTA update on a Rooted phone

My phone is stuck at the HTC Quietly brilliant screen/My boot animation keeps looping, What to do?


Courtesy:
To EddyOS for the Tutorial on getting the PB99IMG from the RUU

I didnt find any newbie friendly guides for unrooting the HTC Desire, on XDA. Even some external ones arent that easy to follow, unless you have a very good idea about what is going on.

The main purpose of this post is to benefit people who have got an SLCD bricked device on their hands with nothing displayed except a blank screen, and cannot remember the key sequences necessary to activate the unrooting process, or to run the OTA Update and get to Android recovery. You will note that I have added the time taken at each step in the process. This will benefit people with SLCD bricks waiting anxiously without seeing anything on screen.

For a complete guide on Unbricking an HTC Desire, please see my thread here.

There are two methods of unrooting an HTC Desire.
Methods:

  1. Get the latest RUU for your region from Shipped Roms. This is an exe file. You can run this file directly from PC. Then connect your device when so prompted.
  2. The second method is to flash the rom.zip directly from the Android bootloader interface, after renaming the Rom.zip (which is actually obtained from the RUU) to PB99IMG.zip [See EddyOS’s excellent step-by-step guide for dummies, in the FAQ below]

Method1 does not need any explanation (If necessary, I will add illustrations of this process later along with error codes)
Method2 is illustrated below.

Note: The following post illustrates the actual steps necessary to unroot your HTC Desire by running the PB99IMG.zip. This is also the method to upgrade the software with the RUU, the last method to fix bootloops cause by a bad boot, and also the way to unbrick an SLCD bricked Desire. Note that another simple method exists to unroot the device, and that is by directly running the exe file of the RUU from Windows. Though simple, this is slightly riskier, since complications with Windows drivers, or a sudden power surge or PC reboot can semibrick/brick your device. The following method using PB99IMG.zip eliminates those problems.

Unrooting is just one of the steps necessary to unbrick an SLCD bricked HTC Desire. The process is a pain for these users because they cant see anything on the screen and left pressing keys in sequence, whose function they can only guess. Also they need to wait specific amounts of time before pressing the sequences.

I’m making visible the steps which the Android system proceeds through, when you run a PB99IMG.zip to unroot your Android device. I’ve also included the time taken before each step while running the WWE 2.29 RUU as PB99IMG.zip. The time isnt much different for other ROMs. To be sure, just give it about 30secs more than the time I’ve noted.

Initial steps:

  1. Create a goldcard if you want to convert a branded Desire to unbranded, or vice versa, or to make a Desire of one region (CID) accept software written for a phone of another region.
  2. After creating the goldcard, format it as FAT32. If more than one partition exist, delete the rest, and format one as Primary and FAT32.
  3. Put the file PB99IMG.zip into the root of the goldcard. Note that the name must be PB99IMG.zip and not PB99IMG.zip.zip. Windows has a tendency to rename it as the latter.
  4. If you dont already have the PB99IMG.zip, you can get it by running the RUU, and while the RUU is loaded (dont start the RUU upgrade. Just click on the exe, and when the welcome screen of RUU shows up,) search in your Temp folder for the file rom.zip. Hint: To quickly navigate to Temp, Type the following into the Run window: %TEMP% [If you still get this step confused, see EddyOS’s excellent tutorial on this, in the FAQ below]
  5. To run the PB99IMG.zip, just reboot with Vol- and power button pressed.

I’m describing the whole boot process below for Reference, though.

Hboot mode (Vol- & Power key. Key them pressed for a 5-6 secs

FOR INSTALLING ANY RUU AS PB99IMG.ZIP

Press Vol- , then w/o releasing it, press Power button + Vol –

After 3-4 secs, the following screen shows up momentarily:

· Fastboot
· Recovery
· Clear Storage
· Simlock
This shows the above few options for 2-3 seconds, and then directly checks for PB99IMG.ZIP. It displays:
SD Checking…
Loading…
PB99DIAG.ZIP
Pb99DIAG.nbh
PB99IMG.ZIP
When it finds PB99IMG.zip, it starts to load it (13 secs after you press the Vol- & power key)
It gives the next options after 2min 20seconds (for the WWE 2.29 RUU) from the initial key press of Vol- and Power key.
Parsing………………….[SD zip]
1. Bootloader
2. Radio V2
3. Radio_Cust
4. Boot
5. Recovery
6. System
7. Userdata
8. Splash1
9. Splash2

Do you want to update device?
<Vol Up> Yes
<Vol Down> No
So, net key sequences involved:
· Back+Power
· Power again
· Vol Up
If we chose No, next option:
Do you want to reboot device?
<Vol Up> Yes
<Vol Down> No

If you pressed Yes, then:
Update is in progress..
Do not power off your device.
1. Bootloader –OK
2. Radio V2 –OK
3. Radio_Cust –OK
4. Boot –OK
5. Recovery-Unzipping/Updating
6. System
7. Userdata
8. Splash1
9. Splash2
It cycles through each of these in turn. For me, it took exactly 2 min 17 secs for time when I chose to apply update, to when update was completed.

(Note: At times, it may update the bootloader and reboot. If you have an SLCD screen, when the device reboots, you may not see anything onscreen (black). At this point, it is notable that the device boots to Fastboot instead of Bootloader, so you will need to press Power button again to get it to resume the update process. Once it completes, you will be presented the options to reboot the device. So you just need to Press Vol + after some time)

It displays:
Update complete
So you want to reboot device?
<Vol Up> Yes
<Vol Down> No

Congratulations. Your phone is now officially unrooted.
On rebooting, HTC screen shows up for a few seconds.
Then a green Down arrow in a green circle shows up for another 5-6 seconds.
Then, HTC screen again.
Finally, HTC screen disappears and the HTC Quietly brilliant logo shows.
Your device now boots into the Android phone.
Total time taken: 6min 30 seconds.

If the Rom is incompatible with your SLCD device, at the reboot stage, you will hear the momentary vibration. Then after about 10-20secs, you will hear the HTC Quietly Brilliant tone. The phone will boot, and the keys light up after about a min, indicating that the Android system has booted up. Since the Rom is incompatible, there’s still nothing on screen. To shutdown the booted up phone, press power key, then swipe your finger vertically up-down like you do to unlock your phone normally, which is exactly what you’re doing. Then keep Power button pressed until the phone vibrates. This means it is presenting you with the Power menu. At this point press the trackball once, then once more. The phone will now shutdown. At this point you can flash your SLCD compatible update.zip (OTA) and unbrick it.

FASTBOOT mode

Back+Power key:
4 options:
· Bootloader (For running PB99IMG.zip)->Choose with Power key (This loads the Bootloader/Hboot mode)
· Reboot
· Reboot bootloader
· Power down

Bootloader (Hboot mode) or PB99IMG update mode.

Performs the following check on the PB99IMG.zip:
1. Bootloader
2. Radio V2
3. Radio_Cust
4. Boot
5. Recovery
6. System
7. Userdata
8. Splash1
9. Splash2
Do you want to start update?
Vol Up: Yes
Vol Down: No
So, net key sequences involved:
· Back+Power
· Power again
· Vol Up

If we chose No, next option:

Do you want to reboot device?
<Vol Up> Yes
<Vol Down> No

No brings up the following options:

  • · Fastboot
  • · Recovery
  • · Clear Storage
  • · Simlock

 


You are reading this post on Joel G Mathew’s tech blog. Joel's personal blog is the Eyrie, hosted here.

How to Unbrick a Desire

 

Elementary Frequently asked questions have been included at the latter part of this post..

If this thread helps you understand more about your device or solve your problems, don’t forget to Rate and Vote for this thread. That will make sure that other people who face the same problems find it easily, without having to sift through hundreds of useless posts.


Caution! CREATING A GOLD CARD IS THE MOST IMPORTANT AND PRIMARY STEP TO DO BEFORE YOU ROOT OR UNROOT YOUR DEVICE, WHETHER IT IS BRANDED OR UNBRANDED.

IF YOU EVER WANT TO RETURN YOUR PHONE FOR WARRANTY, THIS IS ESSENTIAL, AND CAN GET YOU OUT OF MOST CASES OF SLCD BRICKS.

What was my problem (a.k.a What is an SLCD bricked Desire? a.k.a Why is there nothing on my Desire screen after running an RUU/flashing an incompatible ROM)?

I had an SLCD Desire. When I ran Alpharev on it, it did S-OFF. When I ran the RUU (which was incompatible for my SLCD, and actually meant for an AMOLED Desire), I effectively unrooted it, though not restoring it to the factory state (which is the function of an RUU). Because the version of RUU was incompatible with SLCD displays, I ended up with No Display on Screen (Black screen) and a phone without a working Recovery. The only way I know the phone’s hardware is ok is because on pressing power button it vibrates.

Steps to try unbricking an SLCD bricked Desire:

Symptoms: Powering on the device just makes a vibration without anything on screen.

Previous History: You may or may not have done an S-OFF, then tried flashing an incompatible RUU for your device. You might have had an SLCD Desire, then flashed an RUU meant for an AMOLED Desire


If you had made a Goldcard earlier, you’re in luck. You can restore your device with a generic SLCD RUU available for your device, by either running the RUU or by flashing the rom.zip from the RUU.exe file (Tip. This file gets extracted to %TEMP% folder when you run an RUU)

Things you need to know before you try solving your problem:

 

  • Know how to use adb from the command prompt. If you dont have adb or dont know how to use it, read this. (Courtesy: VanillaTbone )
  • Be familiar and identify the RUU for your device on shipped-roms site. [An RUU (ROM Upgrade utility) is an application released by the manufacturer to upgrade/install ROMs). Installing RUUs essentially unroots the phone and reverts it to stock (what you got when you bought the phone. An RUU is usually flashed and the rooting process reversed when you want to return your phone to service for warranty purpose]
  • How to create and use a goldcard. (Just download this tool (Credits and All Rights by [email protected]), and run it.)
  • How to navigate to the temporary folder of your Windows PC (Hint: In the run box, type %TEMP%
  • How to turn your device on into Recovery mode and Fastboot without seeing the screen (Please see below)
  • Understand the various options and sequences of keypresses required to perform an RUU update with a PB99IMG.zip, and the various options and sequences to enter the Android Bootloader, Hboot, Recovery menus (This complete guide can guide you through the process of performing a RUU, OTA update, and the various options of Hboot and Recovery without seeing anything on screen.)


Simple search on XDA can unravel more details about these simple mysteries.

Now, the steps to go about solving your problem: (All methods used to unbrick the Desire, essentially try to unroot it with an original manufacturer’s version of files and revert to stock. In fact, the methods are same as the ones to Unroot your device. The only problem is that the issue is compounded because you cant see anything on your screen. Ironically, the problem of SLCD bricks happen when you try to unroot and the solution itself is to unroot it! )

  1. Find out if you have a generic unbranded HTC Desire, or a branded one. A branded Desire has a special Code (Customer ID) which prevents you from flashing a ROM meant for any other brand and also blocks a Generic WWE RUU. If you’re from India, it is branded with HTC_038. If you’re unbranded, things are looking much easier for you, as generic WWE RUUs for SLCD are easily available. Run the following code from the sdk folder to find out if your device is branded
    Code:
     fastboot oem gencheckpt[/code]
    
  2. This displays the CustID Code as HTC__ (and a number). If these numbers are the same as included in the cidnum value in the file android-info.txt, your device is unbranded. I have noted the following cidnums are unbranded: HTC__001, HTC__E11, HTC__N34, HTC__203, HTC__102, HTC__K18, HTC__405, HTC__Y13, HTC__A07, HTC__304, HTC__016, HTC__032. I'm not sure whether it is an exclusive list. To find out if an RUU is compatible for your ROM, the value displayed by fastboot oem gencheckpt has to be included in the cidnum list of the RUU. If it isnt included, you will need to use a goldcard to bypass the cidnum checks done by the RUU.
  3. Check if you have made a goldcard (A goldcard is a normal microsd card modified to become special while your device was in working condition. It will allow you to restore your device using a generic RUU or an OTA or allow you to switch between software meant for different regions). The purpose of a goldcard is that when apparently incompatible ROMs are flashed with a goldcard inside the device, the flashing process skips certain checks like the Customer ID check (and hence no CID error). Note however that you cannot ordinarily install software of a lower version just because you have a goldcard. Note also that it is the software version which is important, and not the Bootloader version. Note that if you want to downgrade your software to a lower version, it is easiest to use Teppic74's utility (Link1 or Link2), and downgrade to his version of the RUU (1.21), then upgrade to your version of RUU. If your device is SLCD, always make sure the software you're about to flash does support an SLCD screen. As a general rule of thumb, flashing any version <2.0 may be dangerous. Teppic74 assures us that the version 1.21 his utility comes with, is compatible with SLCDs.
  4. If you dont have a goldcard, you might try to create one at this point. (This may work only for some people. In fact I found that I could not get adb to interact with my device in Hboot/Recovery mode) Try to see if Recovery can be booted up. Poweroff phone, then power it on by pressing Vol- and Poweron key, then wait 30sec and press Vol Down and Poweron button again. At this time, phone mightget detected (if the recovery is working) in Windows (as shown by the icon in the bottom right of taskbar and a notification sound.Type:


    Code:
    adb devices[/code]
    

    If this displays a code SH**** after "List of devices", you're in luck. You can issue an adb command and get a CID of your device, following which you can create a goldcard.

    After creating a goldcard (See the start of the post for how to do it) , it will allow you to run a generic SLCD RUU. Check this link for a latest RUU.

  5. Note that you can flash an RUU in three ways. One is to just run it from Windows. . The Second is to run the RUU, and monitor your TEMP folder for changes. A directory starting with weird characters in its name appears while the RUU is run. Within that you may find a rom.zip file, which can be flashed onto your device with Fastboot.exe. The advantage is that in most bricked cases, even if the recovery wont run, Fastboot will.
  6. If you dont have a goldcard, and adb doesnt show the device in Recovery mode, it means Recovery is corrupted too. In this case, check if the device can interact with adb in FastBoot mode. Power off device. Then Poweron by pressing Back key and Power on key. Again try adb devices command. If it shows the device, follow the steps of previous step. Some people ask you just power on the device and wait for 3-7 mins and then to check if the device interacts with adb. Note that if adb successfully displays the device serial code, you can successfully create a goldcard.
  7. You can also create a goldcard by putting your microsd card into a friend's phone and following the steps needed to create a gold card, provided that your friend's phone was purchased in the same country. Note that you have to do this with YOUR goldcard. You cant have him create a goldcard, and use his CID. But you can have him mail his goldcard to you, again if you have the same brand of device from the same country.
  8. If adb doesnt show your device in either Fastboot (previous step) or in Recovery, then you're in trouble. The only way to unbrick your softbricked device is to get a Generic RUU for your device (Check shipped roms site, or search XDA), and flash it. There is also a method if you have the original OTA zip for your device. Note that the generic ROM wont flash (without a gold card) if you have a branded device. Check teppic74's posts on XDA for this method.

For those, who have searched forum after forum for any solution, note the following:

IF YOU SOFT BRICKED AN SLCD BRANDED DESIRE WHICH HAD AN UPDATED VERSION OF HBOOT BY FLASHING AN INCOMPATIBLE RUU, AND IF THE DISPLAY WONT TURN ON NOW, YOU CANNOT RESTORE THE PHONE TO WORKING CONDITION UNLESS YOU HAVE A CORRECT RUU FOR THE UPDATED HBOOT, OR A GOLDCARD. Dont waste your time looking for more solutions online. You wont find them. There is a method for downgrading an updated HBoot to a lower version. I can't assure you that it works on a bricked Desire though.

AN INDIAN HTC DESIRE IS A BRANDED DEVICE. IT IS BRANDED AS HTC_038. IT IS ALSO AN SLCD DEVICE IN MOST CASES. So, before Rooting an Indian HTC Desire, keep a gold card ready.

Dont worry about Warranty being lost if it is a new phone. HTC has to repair it according to their Warranty policy.

FREQUENTLY ASKED QUESTIONS (FAQ)

1. What is an RUU?

RUU stands for ROM upgrade utility. These are officially released by HTC for upgrading ROMs. Many ROMs have been leaked over the years, and they have been hosted at Shipped-Roms. Running an RUU essentially reverts the ROM on your device to stock (what came on the phone when you bought it), unrooting it in the process.

2. Is running an RUU safe?

It depends. If your device is an SLCD, running anything less than version 2.x has the potential to brick your device unless it is specifically certified to work with your device.

3. What do I need to do before I run an RUU?

  1. Decide that you definitely want to unroot your phone
  2. Create a goldcard. Never mind whether you think your phone is unbranded. You never know. I did not know when I ran an RUU, that my phone was actually branded, though it wasn't locked to an operator. I ended up bricking this phone, but creating this thread.
  3. Install the pc drivers for HTC Sync. But Exit from HTC Sync app or uninstall the app. Dont uninstall the HTC driver though.
  4. Connect the device to pc. Put the goldcard in the device, and run the RUU.

4. How to Unroot your HTC Desire to stock.
This is a repetition of the above FAQ. Unrooting essentially involves running the RUU, either as .exe from PC, or as a PB99img.zip from phone.

I've dedicated a whole thread on How to Unroot your Desire Safely. Read about it here.

Whatever you do, DO NOT turn off the device manually unless the software tells you to. If something goes wrong, dont switch off phone. Keep the phone on while trying a solution. Newer RUUs dont usually wreck a phone, and with a goldcard, you can always recover. But, the flash SHOULD NOT be interrupted by switching off or disconnecting the cable.

Always start with a battery with >50% power (full recommended).

5.
What is PB99IMG.zip? How do I use it?

It is the actual ROM in zip format.This is a part of the RUU. The RUU is an exe file, and when you run this file, it creates a folder in your Temp folder(Type %TEMP% in your Run Window, and press Enter). Delete all the files and folders in your Temp and then run the RUU. You will see two folders created when you run RUU. One of them (name starts with { curly brackets). Within that is another folder which contains many files, one of them is rom.zip. You need to put it in the root of your sdcard, and rename it to PB99IMG.zip. Then, when you start phone by Back Button + Power button (Fastboot), this file is automatically found by the device and prompts you to update ROM with this file. Note that you may need a gold card. Note also that in Windows, if you try renaming the file, it may get renamed to PB99IMG.zip.zip. Delete the extra trailing extension.

I've dedicated a whole thread on How to Unroot your Desire Safely with PB99IMG.zip. Read about it here.

6. Why do I need to create a goldcard?

When an RUU is run, there are many checkpoints which need to be passed before your ROM can be updated. One is the version check. Ordinarily, you cannot upgrade to a lower version. Another is the CID check (cidnum variable). CID is different for different regions. There are some regions which have unbranded devices (the WWE edition). Branded phones cannot be normally upgraded to a ROM meant for another region, including the unbranded WWE RUU.

Note that I've written normally
CID check and (But not the
software version check ) can be bypassed by putting a goldcard in the phone while running the RUU or upgrading from the PB99IMG.zip. The software version check cannot be bypassed. You can downgrade however with Teppic74's utility, and then upgrade with the RUU of your choice.

6.1 What else do I need to know about a goldcard?

A goldcard is a modification of the sector bytes of the sdcard, replacing the initial bytes of its Sector 0 (Offsets 00000000 - 00000170 ) with a certain code. Once a phone is booted into FastBoot, the device automatically checks the memory card for a few files. One of them is PB99IMG.zip in case of the Desire. This file is the upgrade utility/RUU in zip format. If this is found on th card, the system will automatically check the integrity of the file and prompt the user to upgrade his system ROM.

If the file PB99IMG.zip is presented in a Goldcard at the time of Fastboot, the upgrade will ignore CID checks (Ignores the region code locked on your device). Thus you can essentially debrand (flash software meant for another region) a phone with a goldcard and a PB99IMG.zip. The other way of course as I've already described is by simply running an RUU while the phone is booted/in Fastboot with a goldcard in. But I've had weird problems with RUUs. PB99IMG.zip method of unrooting can work even when battery is very low, does not need a connection to a pc at the time, and hence is a lot safer, since you wont brick your phone just because your power went off/computer crashed!

Note that Running an RUU=Flashing the PB99IMG.zip. They are the same thing, PB99IMG.zip is a zip file obtain by extracting the zip from an RUU exe file.

6.2 Can I use a Goldcard as my usual Sd-card?

You can, but it is better not to. A goldcard is your magic ring, a device to use if all else fails, an almost sure way of unbricking your phone. If you keep it in your phone all the time, you increase the chances of corruption. I advice you to keep your goldcard safe and secure someplace. Let's hope you don't need to use it, but if woe betide, you have to, then you can get your system back.

6.3 Is a goldcard destroyed when formatted or partitioned?

Definitely Not. Formatting does not write to the Sector 0 offsets used by a goldcard. Note however that defective partitioning or formatting can interfere with the ability of the Android system to "view" the files on the goldcard. The PB99IMG.zip may not work. But it can immediately be corrected by formatting the card to FAT32 and recreating the file.

6.4 Do I need to have the goldcard formatted by the phone?

Not really, though this has been recommended.

6.5 Can I use a goldcard from someone else?

Yes you may.
It is true that if someone else can read the CID of YOUR sd card (from his phone) and give it to you, with the CID code, you can make it a goldcard without a phone. Once you have a CID code, the other steps don't need a phone. Note that CID is unique to the card and not to the phone/region of the phone. You can have anyone anywhere read the CID code of his/card amd mail it to you. You can make it a goldcard without your phone. See also 6.6 below.

6.6 Can I create a Goldcard without a phone?

You can if you have Linux. You need a Laptop card reader slot and Linux. Once in Linux, navigate to a folder like /sys/block/mmcblk0/device/cid

I havent tested it out in a LiveCD. Check it out and tell me.

Programmers have tried writing applications to interface the sdcard in USB mode to get its CID number, but it needs a PCI slot or device-a phone-Either Android/Windows Mobile. A PC application may be specifically written for a PCI based card reader to read the CID, but such an application would be hardware specific for the particular brand of PCI card reader. You cant use it unless you are a programmer and know to do that. As far as I know there are currently no Windows programs that do that.

To clarify, Once again,

The only thing you need from your memory card to create a goldcard, is its unique CID number (which is inserted by the manufacturer of the card)

The CID is unique to a memory card. It is not specific to the device
You can get the CID of the sdcard from:

  • Any Android phone which can connect and use the adb command.
  • An Android phone with the GoldCard Helper market app.
  • A Linux operating system running on a Notebook with PCI slot which can read a memory card. Note: YOU CANNOT GET CID FROM LINUX FROM A USB CARD READER of a PC/Laptop. You need the PCI card slot.
  • You can even get the CID from a Garmin proprietory OS or a Windows mobile based phone. There are utilities available online using these, which can be seen in a Google search.
  • Do not try to get CID from any PC via USB cable. It can display a CID code but not the correct one. It is said that "USB lies about the CID".


6.7 I am not interested in Rooting/Debranding. Do I need to create a Goldcard?

No. Not until you you think of rooting it.

6.8 I have an unbranded device. Do I need a goldcard?

First, be 100% sure that yours is an unbranded device. Just because you bought it from HTC and because there is no branding does not mean you have an unbranded Desire. There may not be visible branding, but it may be branded with HTC.

In short, Create a goldcard whether you have a branded or unbranded Desire. You cant do harm by making a 1Gb (Any size greater than around 256 Mb) card a goldcard. But in case you inadvertently brick your system, a goldcard is the way you may get it back!

7. What if my device is not recognized in Recovery? (Cannot get adb in recovery)

It's a driver issue. You need to install a driver. First make sure that HTC Sync has been installed with all its drivers. Go to Computer, Rightclick and choose Properties>Device Manager. You can see an error code in one of the devices. Right Click it and choose Update Driver. Next, Choose, Choose from a list of Devices. Choose Android device. Windows gives a list of three drivers. Choose the one labelled adb interface. Windows says that the driver may not be compatible. Ignore and choose Ok. When you click Done, Unplug the usb cable and reconnect it. You can now get Adb in Recovery.

8. How to recover from an Alpharev Joker Loop (a.k.a How to Recover from a Corrupted Recovery/Boot)

I got a boot loop at the Alpharev Joker today while trying out Data2SD on my Desire. Basically, the Stock rooted Teppic rom was working fine for 15-20 reboots, then suddenly a lot of force closes happened. On rebooting, The Joker started to appear and disappear. In short, Boot was corrupted. I tried getting into Clockworkmod Recovery. It was corrupted too. I tried searching for an explanation. Got none.

The Solution:

Copied my Nandroid backup files (*.img) to Tools folder
Then,fastboot flash boot boot.img
fastboot reboot
It rebooted and got me into Android home, then promptly restarted..Which meant half the problem is over. Tried to get into recovery again, but Joker looped.
fastboot flash recovery recovery-clockwork-2.5.0.7-bravo.img

fastboot shutdown
fastboot reboot-bootloader
It worked! I got back my recovery

Alternately, try flashing either Clockworkmod or Amon-Ra recovery from Fastboot, and then install a Custom ROM

9. You said I can run PB99IMG.zip in Fastboot/Recovery by pressing a combination of keys, waiting for some time etc. What is actually happening?

When you press Vol- and Power, your device boots to Hboot and checks for certain system files in the root of your system, One of them is PB99IMG.zip, which is actually a part of the RUU which comes as a Windows executable file (exe). If PB99IMG.zip is found in the root of your sdcard, the system automatically checks it, and prompts you to use it to update your system. We know what the prompts are, and by asking you to wait for some time and press Vol, Power keys etc, we're walking you through the various prompts which you cannot see on your screen because the SLCD is bricked

10. My system was rooted and I then applied an OTA update. It's now giving me bootloops. What should I do?

Try the following:
Wipe the phone from Recovery menu.
Access recovery by pressing Vol- and Power button till system boots up.
Press Vol- to select Recovery, press Power button to choose recovery .
When the red triangle is shown, press Both Vol+ and Power button together.
Choose: Wipe data/factory reset, and then Choose: Reboot system.
If it still gives an error, you may need to apply an RUU.

FREQUENTLY ASKED QUESTIONS (FAQ) Continued..

11. How to unroot to my region's software if the only RUU available online is incompatible with my SLCD phone.

This is especially important for Indian Desire users. You can safely run any RUU>2.0 version. Below that, you need to confirm with those who have run it, whether its safe for SLCD. If you create a goldcard, though, you can get back to your manufacturer version of the software even after bricking it. Be careful here.

Method:

  1. Get the OTA update for your region. Save it to pc as "update.zip"
  2. Use an SLCD-unsupported RUU (supposing that only that version is available from your carrier). This will temporarily brick the phone.
  3. Put the OTA as update.zip in the root folder of sdcard,
  4. Use the key combinations for running the update.zip (without seeing anything on screen) from the Android recovery
  5. The OTA restores system to an SLCD-compatible Froyo version.


It's a bit tricky, but workable for those who dont have the proper RUUs

12. What do I do if my phone does not get detected by Windows?

You could try uninstalling all HTC Drivers (uninstall+delete) from Programs & Features in Win, and the Device manager. Then reboot pc, dc from internet and connect the phone. Your phone should get connected, but you should be prompted for driver install. If instead of getting prompted, you find that the driver gets automatically installed, you should manually repeat the above process to remove the drivers. Restart once again.

Now install HTC Sync once again, uninstall HTC Sync program alone (keeping the drivers and driver installation in place). Now connect phone in Recovery and Fastboot. The right drivers should now get installed. Format the sdcard as FAT32, try the Downgrade tool once again. This process should take care of any driver issues.

13. What is a USB Brick and how do I fix it?
Read this post by Rudolfje. The fix is here

14. What is True Bricking and "Semi-Bricking"?
Note that the term "Semi-Bricking" is a neologism. I use it to refer to the state of a phone where you are unable to restore it to a usable state either because of flashing an incompatible rom for an slcd phone leading to the phone being unusable, and further you cannot flash an RUU because a gold card is unavailable and a CID-appropriate RUU is unavailable

A true bricking means you are not able to reset it even with an RUU. This happens because of flashing an Radio incompatible for the SPL (Second Program Loader). So, remember: Don't flash a radio until you understand fully the process of flashing and it is absolutely essential. If you flash a radio meant for another device, your device is Bricked! You cant fix it yourself!

 


You are reading this post on Joel G Mathew’s tech blog. Joel's personal blog is the Eyrie, hosted here.