View Single Post
Old May 17th, 2011, 07:04 AM   #1 (permalink)
SUroot
ROM Developer
Thread Author (OP)
 
SUroot's Avatar
 
Join Date: May 2010
Location: Riddlesden, West Yorkshire, UK
Posts: 23,926
 
Device(s): SGS3 (Current) HTC Desire (Retired)
Carrier: 3 UK

Thanks: 1,923
Thanked 5,320 Times in 3,994 Posts
Default [FAQ] ADB and FASTBOOT for Windows (Updated 1st June 2011)

This is a very basic FAQ. Its not aimed at new users or advanced users explicitly. It is very much a work in progress and will need to be updated to add more information.

As I understand what I have put in this FAQ, it would be useful if you could comment on anything that is not clear or explained in this thread.

Please note, adb and fastboot are NOT the same. They are both command line tools but the similarity ends there. This FAQ contains information about both

Contents:


What is adb shell?
How do I set up my Windows PC to use adb and fastboot?
How do I get into adb shell?
How do I use adb (examples)?
What other adb examples / commands are there?
What is fastboot?
How do I use Fastboot?
Why would I flash a Hboot?
Why use fastboot to flash radio?

What is adb shell?
adb shell is a linux command line tool (because android is based on linux) used to send commands to your android device. For S-ON devices, this is crucial for modifying files in the /system partition (where the rom sits) as you cannot modify anything in /system when the rom is running without S-OFF (e.g removing system apps).

From Google:

Android Debug Bridge (adb) is a versatile tool 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.

How do I set up my Windows PC to use adb and fastboot?

  • Download SDK Tools only
  • Open the .rar file, then drag and drop the folder "android-sdk-windows" to the C: drive
  • Right click My computer > Properties > Advanced > Environment Variables
  • under system variables click "path" and click "edit"
  • at the end of the line add a sem semi colon ";" and without a space put C:\android-sdk-windows\tools - It should look like ;C:\android-sdk-windows\tools then click ok.

*Thanks to Rastaman-fb for this.

As I am rooted using unrevoked already, I have got the hboot drivers installed. I haven't tested this on a clean machine. If this does not work for you / does not connect to the device, please install the Hboot Drivers - follwing the steps in the rooting guide pre-requisites section here

How do I get into adb shell?
Once set up like above, open a command prompt (Start > Run > type "cmd" and press [ok]).

From here, type "adb shell" and press Enter.

Code:
adb shell


How do I use adb (examples)?
If you are modifying /system, it is best to boot into recovery, connect the phone via usb and start adb shell as instructed above. If you are S-ON, you can only modify system whilst in recovery anyway. S-OFF users can use the app root explorer***

To modify /system, you must mount system.

So after starting adb shell, type "mount /system" and press enter. e.g.

Code:
adb shell
mount /system
From here, you can now replace existing / install new system apps. Lets say for example, you have a Gmail.apk (different version to installed) on your c: drive (c:\Gmail.apk) that you want to replace in /system/app. You need to have mounted system, then exited adb shell before "pushing" the apk.

The command is adb push and is case sensitive. The destination name, if it differs to the source name will cause the file to be renamed to the destination name, so take care.

From start to finish this would be:

Code:
adb shell
mount /system
exit
adb push c:\Gmail.apk /system/app/Gmail.apk
You can do similar with install for new apks.

You can also list the system/apps to check it is there.

Code:
adb shell
mount /system
exit
adb install c:\Gmail.apk /system/app/Gmail.apk
ls /system/app
You can also push new frameworks that you may have themed.

Code:
adb shell
mount /system
exit
adb push c:\framework-res.apk /system/framework/framework-res.apk
ls /system/app
You can also pull apps using adb pull and using the same concept, you need to designate where to pull it too.

Code:
adb shell
mount /system
exit
adb pull /system/app/Gmail.apk c:\
But I prefer to use the filename to ensure it is definitely in the correct place.

Code:
adb pull /system/app/Gmail.apk c:\Gmail.apk
adb pull can be useful if you want to edit the .apk on your PC

Please note if you are still in command prompt, you only need to mount /system once.

***It's worth noting, if you are S-OFF and intend using ADB whilst android is running (although may as well use a terminal emulator on the phone) You must mount /system as read / write.

eg:

Code:
mount -o rw,remount /dev/block/mtdblock3 /system
What other adb examples / commands are there?
Code:
adb devices
Prints a list of all attached emulator/device instances.

Code:
adb help
Prints a list of supported adb commands.

Code:
adb shell
Issues a shell command in the target emulator/device instance and then exits the remote shell.

Code:
adb push
Copies a specified file from your development computer to an emulator/device instance

Code:
adb pull
Copies a specified file from an emulator/device instance to your development computer.

Code:
adb install
Pushes an Android application (specified as a full path to an .apk file) to the data file of an emulator/device.

Code:
adb logcat
This lists all the things in command line format that your phone is doing. It can be very useful to determine if you have a boot loop as you will see the same lines of code looping on the screen. If you have installed a theme, it may even be able to identify if a specific image is missing from your framework-res.apk

A full list of commands can be found here

There is an application from PC you can use here:

About QtADB

I have not tested this myself though, so I cannot recommend it personally. Give it a try and let me know. I will test it in due course.

What is fastboot?
Fastboot is 2 things. It is a mode on the phone, which looks a little like Bootloader. You can access it by holding back whilst turning on the phone (from off, Back+power)

It is also a way of flashing radios, Splash screens, recovery and Hboots in a command line method from a PC much like adb. You can only use this method to flash if you are S-OFF

How do I use Fastboot?
If you are simply flashing recovery, radio, hboot, fastboot commands are best. For Splash Screens, I tend to use Android Flasher as it converts the .bmp image for you.

The thread is here on XDA But I use this version: Android Flasher for no particular reason other than I know it works for me.

It is simple to use. You open the app, tell it that you want to flash a splash screen and click the begin button. Browse to the file and bingo. Done. You need to have the phone in fastboot mode as previously mentioned.

**Please note that you can only flash .img files via fastboot. However, Fastboot flasher will convert splash screen images from .bmp files to .img for you (as it isn't usually straight forward) so if you have a splash image already in .img format, flash it using manual commands. I recommend using fastboot commands for everything where possible.

It is very important when fastboot flashing, to ensure the process is not interupted by power loss, usb disconnects

Fastboot commands (Via command prompt similar to adb).

Code:
fastboot flash radio c:\radio.img
...assuming your radio is called radio.img and is on c:\

Code:
fastboot flash recovery c:\recovery.img
Code:
fastboot flash splash1 c:\splash.img
Code:
fastboot flash hboot c:\hboot.img
and so on...

***please note the command for radio or recovery will always start:
Code:
fastboot flash radio
Code:
fastboot flash recovery
Where the third word is telling what and to where is being flashed. Only the fourth string will change and this is dependant on your file name and location

Why would I flash a Hboot?
If you have decided to flash an alpharev partition table, you would flash this as a hboot to change the internal memory NAND partitions.

Why use fastboot to flash radio?
There are a couple of reasons for this.

1) You are s-off, so you may have changed your partition table / layout. Flashing a radio.zip via recovery means that the .zip file will unpack the radio.img in the /cache partition. This requires over 25MB /cache available to do so. If there is not enough space, you could have big problems.

2) Its better. It removes the additional layer of software (i.e recovery) on your phone to go wrong.



*as mentioned earlier, this is a work in progress and will need a lot of work to get all the info you may need. Please do feel free to comment in this thread as to what is required.

Thanks to all past and present who have contributed to this.
SUroot is offline  
Last edited by SUroot; May 11th, 2012 at 10:07 AM.
Reply With Quote
The Following 21 Users Say Thank You to SUroot For This Useful Post:
Abdur (November 8th, 2011), Aggi (January 7th, 2012), alshop (July 23rd, 2011), dan55 (June 30th, 2012), ernolander (October 4th, 2011), Exiled_SouL (June 12th, 2011), Fishyweb (August 24th, 2011), Flumme (May 13th, 2012), GrenW (May 17th, 2011), jdash (May 29th, 2012), kewlbuddy (May 17th, 2011), MandaNick (May 24th, 2011), mollymalone (December 26th, 2011), Rastaman-FB (May 17th, 2011), shauny13 (May 17th, 2011), sirpaa (September 14th, 2012), SumoTaz (June 18th, 2011), TheCrackInTime (May 24th, 2011), tipa (December 2nd, 2011), Tyseyh (November 13th, 2011), Usta (May 17th, 2011)