[Guide] How To Setup And Use Fastboot

What, If Any Other Tutorials Would You Like Me To Make?

  • Tutorial on setting up and using ADB

    Votes: 434 51.5%
  • Creating flashable .zips to be used in recovery

    Votes: 486 57.7%
  • Whatever I want!

    Votes: 195 23.1%
  • Nothing! I make terrible useless guides!

    Votes: 34 4.0%

  • Total voters
    843
Search This thread

demkantor

Inactive Recognized Contributor
Nov 10, 2011
6,861
3,763
mpls
Introduction:
I have found that many people are unaware how to use fastboot, which if you have ever owned an HTC phone or something from the Nexus line you know how important it can be.
About a year ago I got sick of answering questions about fastboot so I made a guide, but it was device specific. Not too bad but I was constantly giving the links to it for other phones... of course more questions just popped up.
So here i am making a comprehensive yet easy to follow (I hope) guide on how to set up and use fastboot. I will cover the basics for Windows and Liunx (sorry Apple users, just cant stand the product/company)

I plan to make a series of guides for XDA-University Thus far there is this guide and:
[Guide] How To Create Recovery Flashable .zips / update.zips

First a short explanation:
Fastboot, like ADB, is a tool to communicate from PC to Android phone. There are times when it is a must to use, and times when it is just helpful.
ADB is used within your recovery or within your OS, but when you are in bootloader mode and need to communicate with your phone then you need fastboot.

And you may ask why would i ever need this?
Well many reasons. Main one is knowledge, learning the ins and outs of fastboot, like learning ADB, can get you out of many jams.
And if you want to unlock your bootloader this is done through fastboot. Granted HTC's unlock is... well crap, but for a Nexus this is how its done.
One other reason I have to stress is learning for safety reasons, This is about the safest way possible to flash firmware to your phone (ie Radio, Hboot, Recovery)

Lastly you may want to know the limitations,
There are many of course, this isnt JTAG, it will not resurrect a hard brick, but it often save peoples phones from 'soft bricks' and lots of time when know how and when to use it.
Think of fastboot as the program that takes over when ADB cant be used, it works with firmware more than software.

So where do i get fastboot? There are a few ways but most often I would recommend getting it from the Android SDK as it is will be up to date.
or you can use THIS HANDY TOOL created by @shimp208

I will go over the Download and Installation Process in the Next Post
Then i will go over useful commands.
*Just a note, This guide is to always be considered under construction as I plan to continue to make additions such as more commands and pictures
I will continue to attempt to clarifiy when needed and add what I have missed. I have yet to drop any project or guide I have made on XDA and will help where I can
As always I encourage questions I may miss something or be vague, it is best to understand fully then not ask.
 
Last edited:

demkantor

Inactive Recognized Contributor
Nov 10, 2011
6,861
3,763
mpls
Setting up fastboot on Windows and Linux

What is Fastboot?
Fastboot is a protocol designed to flash signed/unsigned partitions to android phones directly into the phones flash memory. If you are familiar with ADB think of it in the same way.
If you're not, just understand it is a tool designed to help flash images such as recoveries, bootloaders, kernels, etc. to your android phone. For the most part you can not use much of fastboot unless you are rooted and have an engineering SPL (Hboot/Bootloader)
If using a Nexus device you in a sense have an engineering bootloader already so don't need to worry about it like HTC folks need. But Some Nexus lines will have different bootloaders with different capabilities.
This however is not a tutorial to root your phone so i will not explain this. I will though go over SOME basics as in unlocking your bootloader to allow it to be rooted.
How do I get fastboot for Windows?

Fastboot.exe can be downloaded to your computer from Google's SDK found
HERE download the proper package depending on what system you are using.
also
you will need the proper drivers to allow your PC and phone to communicate. You will find these in your devices specific forum or possibly you can use PdaNet


Okay i got it, whats next?
After you downloaded the SDK package to your PC see where it is located, somewhere like this for Windows
C:\android\android-sdk-windows\platform-tools
Of course put it where you like, just know where fastboot.exe lies

*If you want to skip the SDK, you can get ADB and Fastboot by themselves with THIS HANDY LITTLE TOOL created by shimp208
Note: After you have ADB and Fastboot you will may want to finish following this guide to add a path in environmental variables.


For Windows:
Although not necessary, but to make it easier i really suggest doing these steps:
left click the Windows (start) button > right click on computer > choose properties > go to advanced system settings > advanced tab > environmental variables > in the first box (user variables for _____) click new > name it
> the value is the path from earlier
C:\android\android-sdk-windows\platform-tools
(yours may differ from this so double check it!) > in the second box (system variables) find a variable named
if one doesn't exist make one > double click on it > at the very end of the variable value add the same line as before but with a ; in front of it. like this:
;C:\android\android-sdk-windows\platform-tools
alright click ok and you are done!
EnviromentalVariables.jpg


Why did I just do all that?
Well this allows you to open a command line from anywhere on your computer without changing directories to use fastboot. Pretty much we told your PC that when you type
or
into CMD where to find it. As you learn how useful fastboot and adb are this will help a lot as CDing to where you want to be is wasted time.

So I still don't know what to do or how to do it!
All right lets start simple, click the windows button and in the search field type
you will notice a window pop up that looks suspiciously like DOS. View attachment 1980110
Here you will see a blinking cursor after your directory, lets try this type
Code:
fastboot
a whole bunch of probably unfamiliar stuff should now pop up View attachment 1386065 (for the most part this is a list of commands that can be used in fastboot) if you get something like
fastboot is not recognized as internal or external command operable program or batch file
then we need to troubleshoot, but for now i will assume it worked.
Now try typing
Code:
fastboot devices
...and nothing will happen, Why? because there isn't a device attached. Make sure you have android debugging turned on in your phone (not really needed for fastboot but you do need for ADB), plug it into your computer and boot into fastboot mode. On many phones hold volume down while powering on, if this wont bring you to bootloader mode then see your device specific forum, if needed choose fastboot. Again try typing
Code:
fastboot devices
this time you should have a list of attached devices, this is displayed as the serial number to each. Being many commands will "do" things to your phone try typing
Code:
fastboot reboot
If your phone is now back and running your existing OS, congratulations! :good: You now at least have fastboot set up and working properly. Now lets try a few things out and see why this can be so helpful!


How do I get fastboot for Linux?

To get fastboot installed on your Linux box first download appropriate SDK package From Here
*Not all Linux distros are the same and I don't consider myself a Linux guru, I will explain what I know about the few distributions I've used but remember if something don't work look up specifics for yours HERE
After SDK is downloaded extract contents into home folder, maybe in a folder called Android, your choice.
Now we need to make sure we have the latest java JDK installed found HERE or if you prefer you can get it from the terminal
Code:
sudo apt-get update
sudo apt-get install openjdk-6-jdk
or if using Ubuntu, the software center. (I have heard people complain about JDK7 so to be safe stick with JDK 6 for now)
**I have a 64bit machine so I needed the 32bit libraries, you may not need this. If you do run this from terminal
Code:
sudo apt-get install ia32-libs
**As pointed out to me by trevd, if you are using Ubuntu 12.10 or newer you should simply open a terminal and run these two commands
Code:
sudo apt-get install android-tools-fastboot
and
Code:
sudo apt-get install android-tools-fastboot
If you never plan on developing for android or using other tools that come with the SDK
then this should be all you need. And you may also skip the JDK install. As most people will never attempt to create
an app or ROM or mod their phone in a way that they would need more than this, these simple commands should suffice.


Downloading Fastboot
ummm.. isn't that what I just did? Possibly, but as far as I know ADB, fastboot and everything else in platform-tools wont automatically download with the SDK.
Other have told me it does, so feel free to navigate to the platform-tools folder and see if you see these applications.
If you skipped installing the SDK and just installed fastboot and ADB from the command line you can skip down to creating a path. So if you got them, skip this, if you don't, do this:
From in a terminal type
Code:
cd ~/android-sdk-linux/tools
./android
**note depending on what you named the folder the downloaded and extracted SDK is in you may need to change your cd command to something else.
Now a new window will pop up, Click on "Available Packages" and you will be see two boxes. One is Android Repository and the other is Third-party Add-ons.
Click on "Android Repository" then click on Install Selected. now click on "Accept All" and then click on the Install button.
Personally I like downloading all that is possible here, you may have limited space or bandwidth so all you 'need' is the contents of platform-tools.
If you want to download some API's later go for it, they aren't needed unless you are developing.


Adding a Path
Just like in windows changing directories can be brutally annoying so lets add a path. Open a Terminal and type:
Code:
nano ~/.bashrc
or you can use gedit, whatever you have/like to use (sudo gedit ~/.bashrc)
At the end of this text (or at the begining add the following
Code:
Android tools
export PATH=~/android-sdk-linux/platform-tools:~/android-sdk-linux/tools:$PATH
**again be sure this is your path (neat trick, find fastboot from within platform-tools, right click on it, go to properties, highlight the location/path and copy/paste this)
Now click save, this will make so you no longer need to type ./adb all the time
I have been told a reboot is needed here but I don't think so, just type this into a command line:
Code:
source ~/.bashrc


Drivers? I don't need no stinking drivers!
True, sorta, but more than likely we will need to add the android rules so your device can communicate with PC. Open a Terminal and Type
Code:
gksudo gedit /etc/udev/rules.d/51-android.rules
now add the following lines:
Code:
SUBSYSTEM=="usb", ATTRS{idVendor}=="0bb4", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="0502", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="12d1", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="1004", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="22b8", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="04e8", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="0fce", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="0489", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="18d1", SYMLINK+="android_adb", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="04e8", MODE="0666", GROUP="plugdev"
Depending on your device this should be all you need and then some, feel free to check out THIS for the most up to date vendor list.
View attachment 1980099
Now for a test!
So plug your phone into PC via usb, have it in fastboot mode (from within bootloader) and open a new terminal, type:
Code:
fastboot devices
If you see a string of #s and letters then success! :good: you are ready to learn the ins and outs of fastboot!
 
Last edited:

demkantor

Inactive Recognized Contributor
Nov 10, 2011
6,861
3,763
mpls
Using Fastboot To Unlock Your Bootloader

Do You need to unlock your bootloader?
For many phones this is necessary to root, for others it is a poor way to root your phone as you may not have full access.
Many HTC model phones can be rooted with various exploits, sometimes removing the radio secure flags completely.
If you have one of these devices than I recommend this, as true radio s-off is far superior to an unlocked bootloader.
But other phones, including the Nexus line, will be fine just unlocking and do not need to worry, Although some phones like the Nexus One can profit from a new bootloader altogether.
To begin the rooting process you simply need to unlock your bootloader with this command from a terminal/CMD
Code:
fastboot oem unlock
and the reverse of course is
Code:
fastboot oem lock

Be prepared for a full wipe of your phone when unlocking the bootloader!

But quickly if you have an HTC and choose to unlock your bootloader to root your phone follow these step:
Select your phone from the list HERE (you will need to create a log in)
there will be some legal mumbojumbo to click through (just saying you void your warranty but you knew this!)
you may need HTC sync found HERE as well as the proper RUU for your phone, the HTCDev site will inform you.
After which the site will move you through the steps to gain fastboot access, but if you followed my guide above just skip it all.
next you will need to get the identifier token, this is unique to your device and really just getting probably voids your warranty,
even if you stopped the guide here. to do so, open terminal/CMD and type
Code:
fastboot oem get_identifier_token
copy and paste this information into the prompt at the bottom of the page. Now wait for an email to get your token....
once you get the email with the token you can now follow their steps to unlock your bootloader...
really if at all possible i recommend not to do this method of rooting. But if you do, follow these same next steps that the Nexus devices will be doing...


Now that your bootloader is unlocked:
We will flash a custom recovery to your phone, then a custom already rooted ROM. To flash the recovery go to your device specific forum HERE and find the developers section.
Look for a custom recovery option and consider reading up on it there.
Different Android phones will have different custom recovery options depending on the developers for it. The most common is ClockworkMod, there are both touch and none touch recovery options.
some others are TWRP, 4EXT, AmonRa and Cannibal. Find out what your options are, pick one and download it.
If possible check the MD5Sum, Windows use: THIS and Linux use a terminal and type
Code:
md5sum <filename>
of course replace <filename> with the file name.
View attachment 1980095
If you prefer, GTK Hash is a nice program as well.
Now this should be an image not a zip, so if the extension is .img your good, if its in a .zip or .jar or whatever extract the image.
Take this image and (for simplistic sake) name it
**if using windows be sure to pay attention if your file extensions are hidden, don't name it recovery.img.img!
So be sure your phone is in fastboot mode and connected to PC, open a terminal/cmd in the same location that recovery.img is in
(cd to that directory or windows users can hold shift > right click in the folder it's in > choose open command here)
Code:
fastboot erase recovery
fastboot flash recovery recovery.img
**erase recovery is not necessary but i am OCD about wiping...
now if you get an okay! then your good :good:
Code:
sending 'recovery' (4930 KB)...
OKAY [  0.521s]
writing 'recovery'...
OKAY [  0.489s]
finished. total time: 1.10s
If not let me know what the output is and ill help you fix it. (I will also make a troubleshooting section in my final post)

Great! Now Let's Flash a ROM
In that same developers section for your phone, you should pick out a ROM of your licking. If possible i would suggest an older version of CyanogeMod as these builds tend to be quite stable.
Also some phones may have newer ROMs requiring you to do various things to your phone. Such as changing radios or bootloaders or other things we haven't gotten to yet.
So for now try to read the OP of the ROM you like and make sure you meet all requirements.
So Im not going deep into how to flash a ROM from recovery as this is not part of a fastboot guide.
But pretty much just pick a ROM and anything else you may need (gapps, kernel, etc) and put on root of SDcard (no other folder)
Then boot to recovery, wipe all you can (I'll teach you fastboot wiping soon!) and then flash ROM + whatever else you need to and then reboot.

Another Issue With HTC's Unlocked Bootloaders
Well if this not yet another reason to try to gain true radio s-off for your phone...
From with in that ROM that you flashed you also need to unzip and extract the kernel (boot.img) this will need to be flashed through fastboot.
Once all the above steps are completed reboot into fastboot mode, if your recovery doesn't have a quick way to do so just open a terminal/cmd and type:
Code:
adb reboot-bootloader
from here you will need to then open a terminal/cmd in the same location as that boot.img is and type:
Code:
fastboot flash boot boot.img
If it says okay you are finally done!!! Well done with flashing your first ROM but can you flash a ROM in fastboot? I mean do you need recovery at all?
There are ways, and ill teach ya in the next post!
 
Last edited:

demkantor

Inactive Recognized Contributor
Nov 10, 2011
6,861
3,763
mpls
Flashing a ROM through Fastboot

So Why Do I Need To Do This?
You don't, normally you would flash a ROM through recovery, but why not have another way? Maybe your recovery partition on your phone is corrupt?
Maybe you just want to say "I learned something new!" whatever your reason here are the simple steps:

To start:
We need to download the ROM of choice to your computer. Once complete find the folder that ROM is in and open terminal/cmd to that directory
(quickest way for windows; just hold shift and right click within that folder > open command window here) of course make sure your phone is plugged into computer and in fastboot mode.

Lets see how quick and easy this really is...
In the command line type:
Code:
fastboot devices
Seeing your serial number means we know all is good
Now lets type these commands:
Code:
fastboot erase system -w
fastboot erase boot
fastboot update superawesomerom.zip
Of course replace <superawesomerom.zip> with the correct file name

and last but not least:
Code:
fastboot reboot

*Its been a little while since i did this but the phone might automatically reboot after flash so no need to run the reboot command

As your phone boots into the new ROM, pat yourself on the back...

A Note on Erasing/Formatting
You may have noticed earlier that I had you erase your recovery before flashing a new one,
now here I had you erase system and boot, you may be wondering why.
I find that a large amount of complaints in developer threads are due to people not properly wiping before a flash.
Of course there is times when a 'dirty' flash is fine, but if you're ever not sure, wipe as cleanly as possible.
fastboot allows for about the cleanest of wipes by the way. And each partition can be done separately too.
Code:
fastboot erase system
fastboot erase data
fastboot erase cache
can all be done individually, but to do these all in one command
Code:
fastboot erase system -w
If possible I recommend to do these steps before flashing a ROM, and now that you know you can do this all within fastboot mode i suggest to try it out, its quick and painless!
Don't forget to wipe your kernel too! (fastboot erase boot)

~Important~ If your device uses an emulated SD card (as in no removable micro SD but an SD partition on phone)
Then be careful wiping data/userdata as this will erase all contents of internal SD - you are forewarned!

What about just flashing a single partition?
Sure this can be done, hell you can restore a nandroid if you want!
well first you need to make a nandroid back up (unfortunately fastboot cant make a nandroid for you :crying: ) Put it some where on your computer.
Personally I only keep maybe 2 or 3 nandroids on my phone's SD card as why waste space. I do however keep almost all my nandroids on my computer separated into different folders for different phones. So my path to a nandroid backup would be something like:
android/htcg2/nandroids/<nameofnandroid>
But here's the catch, most newer recoveries do tar backups I believe TWRP uses .win, these can not be flashed in their current form!
However most older recoveries use yaffs2 format for their backups, these will always work. Pretty much if you get a backup with various partitions as .img you're good to go!
**Hypothetically speaking here: you installed a new recovery and want to flash a nandroid made in old recovery but the two recoveries used different formats...
Well you can flash the images with fastboot, then make a new nandroid and you got them back!
...Maybe I'm stretching... oh well, here's how to!

Now the obvious stuff:
Have phone plugged into PC via USB and in fastboot mode, open terminal/cmd and change directories to that folder where your nandroid is in (or again just hold shift and right click > open command window here if using windows)
Now in terminal/cmd type:

Code:
fastboot devices
all is good when serial number is displayed, now type:
Code:
fastboot erase system -w
fastboot erase boot
*This isn't 100% necessary but I'm a firm believer in wiping before any flash, even a backup
Code:
fastboot flash userdata data.img
fastboot flash system system.img
fastboot flash boot boot.img
fastboot reboot
(of course change the image names if needed)
And you did it! :good: now you are almost a pro at using fastboot!
keep playing around, you'll get the hang of it and will quickly see that this is one of the best tools in the Android SDK.
It makes things much faster and easier and in many cases safer than the alternatives. Any questions... feel free to ask!
Happy Flashing!
 
Last edited:

demkantor

Inactive Recognized Contributor
Nov 10, 2011
6,861
3,763
mpls
What About Flashing Firmware?

Flashing any firmware to your phone can be dangerous but if possible the best and safest way is with fastboot.
Hypothetically you flash a new Hboot through recovery and this Hboot was corrupt in some way, if the flash takes you will have a bricked phone, hard bricked, only JTAG can bring it back.
But with fastboot you get to input your command to terminal/cmd an see the output, if something goes wrong, just DO NOT REBOOT until you fix the problem.
And again, checking MD5sums is nice when flashing software but a must when flashing firmware.
I will again recommend THIS for windows and using the terminal for Linux

Okay, Time To flash A New Bootloader!
Some phones will not allow bootloader flashes unless you remove the radio secure flags, if you have a phone like this check the developers thread for a how to.
To begin, find the appropriate bootloader (sometimes referred to as an Hboot or SPL) for your phone,
Now download and check MD5sum, have your phone in fastboot mode and open a terminal/cmd in the location your Hboot.img is stored.
Code:
fastboot devices
fastboot flash hboot hboot.img
and of course replace 'hboot.img' with whatever you titled your image
**Do not reboot if you see 'sending.... failed' need to see the 'okay!'
I am not trying to scare you as these instances are so rare, but knowing what to do ahead of time is just common sense.

Not all devices use the same terminology for partitions, so if the above does not work than consider changing to this command:
Code:
fastboot flash bootloader bootloader.img
Again replacing <bootloader.img> with the name of your image

Now flashing a new bootloader will more than likely repartition your phone, so from here you probably should flash a new recovery, then flash a new ROM.
Be prepared to do all this before flashing a new Hboot!

I'm ready to flash a new radio!
Flashing a radio can also be dangerous, but again the safest way to do so is within fastboot. So if possible always flash radios in fastboot mode!
**I am not referring to the FM radio in your car, rather your cellular Radio, you know where you get reception... don't ask me how to add a FM radio to your phone!
Also know OEMs commonly use baseband and radio as interchangeable terms, for the most part this is the exact same thing

First things first, know why you are flashing a new Radio. Is it because you have poor reception? Poor data speeds? Poor battery life?
Yes a new radio can cure all this, but NO ONE can tell you which radio is best for your phone, not even someone living in the same city.
The best radio for my phone will not for sure be the best for yours, even if you live down the road from me. Don't ask what Radio is best! and only flash a radio meant for your device!

Now that that's out of the way, lets do the same steps as before:
Download appropriate radio
Extract if needed (should be in .img format)
For simplistic sake name it 'radio.img'
Plug in phone to PC and open a terminal/cmd in the same location as your radio.img
Code:
fastboot devices
fastboot flash radio radio.img
fastboot reboot-bootloader
Again only reboot if all goes well (It will if you follow all direction)
Upon rebooting your bootloader you will notice your radio version has changed, congrats! You're becoming a pro! :D

*note, occasionally OEMs package another image called rcdata.img along with a firmware release, if they do I also recommend to flash this along with the radio
Code:
fastboot flash rcdata rcdata.img
**another note, if possible try to match the ril libraries between your ROM and radio, this is device specific and you will need to see your developers thread for this info.
It is not always possible or necessary to do so, but many do say it help quite a lot
Flashing a Kernel
Earlier I went over flashing kernels as part of HTC Unlocked Bootloader Flashing, the process is the same for anyone else as well.
Locate the Kernel you want to flash
navigate to the folder it is in (should be in .img format and lets name it boot.img)
Code:
fastboot flash boot boot.img

But lets say you are a developer and have worked on a new kernel for your device, a quick and easy way to test it out may be to fastboot load the kernel:
Code:
fastboot erase boot
fastboot boot kernel ramdisk
As usual replace file/image names accordingly
If you do not want to erase the current kernel, just skip erasing.
But I would just have a working kernel.img handy and erase, this way I know there are no residual effects from previous kernel - choice is yours

Code:
fastboot flash:raw boot kernel ramdisk 
fastboot reboot
Test it out and see how things go! Good luck! :good:

As always, if you have questions or comments feel free to leave them here!
Happy Flashing!
 
Last edited:

demkantor

Inactive Recognized Contributor
Nov 10, 2011
6,861
3,763
mpls
What Are Some Other Things That Fastboot Can Do?

A Whole lot really... This guide would be forever long going through all of this. But I'm trying to progressively go through as many options as I can in order from simple to complicated.
I mainly am making this guide for beginners but I want the Advanced Android user to learn something too! Hope we can all learn from each other!

RUUs or HTC's ROM Utility Updates
This can be a way of returning to stock or updating to an official OEM update.
To do this make sure your bootloader is locked
(as far as I know RUU's fail if unlocked, but depending on phone engineering SPLs or having radio s-off can be safe - but not always so check device forum)
So boot into fastboot mode, open cmd/terminal in location of RUU then
If needed:
Code:
fastboot oem lock
then to get into RUU mode
Code:
fastboot oem rebootRUU
Then you will flash the zip, change command to correspond to proper name
Code:
fastboot flash zip rom.zip
If it gets stuck and you see a message like flush immediately! just do the above command again, often first try fails for some reason
Always know if you need to or should be flashing an RUU, some people do more damage to their phone just because they thought they were bricked and tried 'everything'
And if you're looking for OTA's (over the air updates) or RUU's for your phone HERE is a great source!

Some Useful Information About Your Phone
Lets say you want something basic like your device's model number, type:
Code:
fastboot getvar mid
the return output is your model number. Some phones are locked into only allowing new versions of an OS to be flashed, to check yours type:
Code:
fastboot getvar cid
If your return value looks like this then you have superCID, meaning you are allowed to flash older and newer versions of Android OS. And depending on phone you can just use this command:
Code:
fastboot oem changeCid
or possibly a common cid (SuperCID)
Code:
fastboot writecid 11111111
If you want to get a bunch of info quickly try this:
Code:
fastboot getvar all
Here you will receive an output of much of your devices specifics, such as bootloader and radio versions, devices name and if its locked, IMEI # and so on.

What about trouble shooting?
There have been various devices over the years which have used inferior parts. like the HTC DZ/G2 or Glacier.
These phones, like some others, had two different emmc's installed; one worked great and one was prone to failure.
I found the easiest way to check which emmc was in the phone was with a few fastboot commands:
Code:
fastboot oem list_partition_emmc
fastboot oem check_emmc
fastboot oem check_emmc_mid
Of course this couldn't prevent a phone from the mysterious random hard brick, but it could tell you if your hardware was prone to failure or not.
There are also a serious of tests that can be performed depending on the bootloader you have installed:
Code:
fastboot oem list_partition all
fastboot oem partition_test all
Both of these commands you can substitute 'all' for 'system' 'cache' or whatever if you just need info or test a single partition.
You may have noticed that some of these commands require knowledge of hex editing, which of course no one is good at :p but the info is there if you want to search for it! So here is some more!

Code:
fastboot oem heaptable
fastboot oem imgcrc
The second command here will run a checksum for your hboot, recovery, boot, and system partitions.
I find it helpful to know the value of what the should be when phone is working good and can use this against another checksum if i have issues down the road.
System and boot will change of course, but recovery and hboot wont unless i flash a new recovery or bootloader, this can help check for bad blocks.
Speaking of bad blocks, lets look for some:
Code:
fastboot oem rbchk
Now having some bad blocks in your nand is not always going to cause your phone to be unusable, sometimes its a partition thing too.

Some of these commands don't do anything...
True, various devices and bootloaders will allow for various fastboot commands. two tests you can do to see what yours supports
or
typing just this into a terminal/cmd will give you an output of available commands for your device. I hope to add a bunch more soon but i need to finish my papers and studying for finals!

A Bit More Helpful Tips For Booting
Sometimes you may have issues booting, earlier we went over booting a kernel you made yourself as well as flashing a kernel
What about just booting a kernel without flashing it to your device?
Code:
fastboot boot boot.img
The above, when executed properly, will boot a kernel from pc on your phone without flashing directly. There are times we need to force boot or just test.
What may be even handier is to boot a recovery without flashing it, this is done in the same manner as above and can let you use a recovery on your device without installing it.
Plug phone into PC, connect with USB cable and have phone in fastboot mode, now open CMD/Terminal in the same directory as your recovery image
Code:
fastboot boot recovery.img
Of course name image correctly to fit command or vise versa
Now you are in recovery of choice within your device without it being flashed to your recovery partition. There is a time and a place for everything, can you think of ways this may help you? Sure you can!
as always... Happy Flashing!
 
Last edited:

demkantor

Inactive Recognized Contributor
Nov 10, 2011
6,861
3,763
mpls
Is There Anything Fun I can Do With Fastboot?

How would you like to go from this:
splash.jpg to this andcloud.jpg to this matrix.jpg to this blueandroidhood.jpg to this stampedwood.jpg
Or really just about anything you want?

Of course I'm referring to the splash screen, the one that appears when you first boot your device, before the bootanimation.
This is a static image put there by the OEMs and often is real boring. True some phones have some neat ones, others little gifs, but really why not change it if we can?

Well in order to do this we need to know where our device in question stores the splash screen. If it has its own partition, your rooted, and your bootloader has fastboot capabilities we are good to go!
...well almost, remember when i talked about s-off earlier? This is low level firmware stuff, at least the way many device see it. Having root access doesn't mean we can do anything unfortunately.
I would suggest checking your phones forum to see if anyone know specifics to your device and where this partition is stored, if you need help other than from this guide feel free to post and ill see what i can do!

Ok, so I'll use HTC as an example here, we are rooted, we have an engineering bootloader, and security flags are removed. Now we need to find partition location.
Code:
mmcblk1p2 - "sd-ext"
mmcblk1p1 - "sdcard"
mmcblk0p31 - "misc" 
mmcblk0p29 - "pdata"
mmcblk0p27 - "devlog"
mmcblk0p26 - "modem_st2"
mmcblk0p25 - "modem_st1"
mmcblk0p24 - "cache"
mmcblk0p23 - "userdata"
mmcblk0p22 - "system"
mmcblk0p21 - "recovery"
mmcblk0p20 - "boot"
mmcblk0p19 - "adsp"
mmcblk0p18 - "radio_config"
mmcblk0p17 - "radio"
mmcblk0p16 - "misc" 
mmcblk0p14 - "splash1"
mmcblk0p12 - "bootloader" hboot
So this device keeps the splash screen in mmcblk0p14, this is very important to know and will change with most devices.
We will know extract original splash before we change it. Again I cant stress how important it is to know what you're doing when using dd commands!
So open a terminal/cmd
Code:
adb shell
su
dd if=/dev/block/mmcblk0p14 of=/mnt/sdcard/splash.img
This will now pull the original splash and place it on your sd card named splash.img
***remember the above command differs for every phone!!
Now that we have this, keep a copy somewhere just in case.
You can now use a tool like FFmpeg to extract the image, use gimp to make a new one, and follow this simple guide if your confused. Or ask here and I can help.
You may have noticed none of the above used fastboot... huh, and here this is a fastboot guide! :eek:
Ok we'll just say you have a new splash image all ready and you want to flash it, but how? In the case of this phone fastboot is the way to go
Code:
fastboot flash splash1 splash.img
fastboot reboot
And done! :good: way to easy I know, put you're a pro at fastboot now so what did you expect!

And for future reference you can use dd commands to flash to your phone as well, but the don't call the "disk destroyers" for nothing!
Also its possible to flash in recovery, to the best of my knowledge I'm the only one to create flashable .zips for this (not bragging just saying I'd like to see more)
HERE Is an Aroma flashabe I made for the HTC Doubleshot
HERE Is an Aroma flashable I made for the HTC Vision
Both recovery flashable.zips allow the user to flash one of many custom splash screens and bootanimations with the easy UI Aroma brings
It is not as safe as fastboot, but I have never seen an issue when the code is done right.
I plan to make more for other phones as I have time, want one for your phone? Go through my scripts, feel free to copy and paste, I need no credit, just glad to see more people with more options!
If you need help making them, again just ask. I prefer in this thread over pm though as my inbox fills to quick...


Old stuff... in the process of editing to make things more clear....
Come one, like the previous stuff isn't fun! :cool:
Well many aren't aware that they can change the splash screen on their phone or tablet, this is just another partition most often like system, or cache.
Yes some phones will have it built into params or locked elsewhere in the firmware but often fastboot is a simple way of flashing a new splash screen.
To find out a list of your device's partitions i would advise to check you sites development thread here in XDA. But we can quickly do it as well with some simple ADB commands.
This guide does not go over ADB and for a better understanding search out one of many guides in XDA and elsewhere. (I am considering making one here as i have yet to see a comprehensive yet easy to follow guide)

Having said this, here are a few things you need to know. If you followed this guide and have fastboot working, ADB should also work just fine.
Know that fastboot is to be used in bootloader mode and ADB is used when booted into the OS or in most recoveries.
So now boot to your OS, make sure debugging is turned on, android 2.x and older this is found under settings>applications. 4.x and up it will be under developer options in settings.
Now connect your PC and phone via USB (wireless options are also a possibility here) You should notice a symbol in your status bar confirming debugging is on. (unless disabled) open a terminal/CMD and type:
Code:
adb devices
If you see your serial number lets proceed, if not post in this thread and i'll help.
Code:
adb shell
cat /proc/partitions
This will list all your partitions and their size, but this wont give you what each partition stores. There are different ways to do this for different devices, so you may need to try a few commands
Code:
ls -l /dev/block
ls -l /dev/block/platform/sdhci-tegra.3/by-name
the last command is for a device with a tegra 3 processor, of course will only work if yours has one (you may need to type 'su' to get commands to work)
you can also try:
Code:
df
busybox df -hm
Really all this isn't 100% necessary as someone probably found this out for you already. If not we just need to know the location and proper size of the image to flash.
I will help further if requested but as of know I'm going to assume we have this.

Alright lets flash the new splash screen already!
So we have a new image in .img format and it is the proper size. we will name it splash.img And as most phones that allow flashing a new splash we will call the partition its it splash1
**If your phone is different than whats listed here commands may very or not be allowed without changing bootloaders.
Back in fastboot mode, plug in phone... the usual
Code:
fastboot flash splash1 splash.img
fastboot reboot

Now that initial boot screen (before animation is replaced!) congrats!

**As you can see this section is poorly written, it is hard to universally apply a command to all phones as this command differs between them.
There are dd commands to flash just about anything, including splash screens, but dd commands can be dangerous and I would not recommend them to anyone who doesn't fully understand what they are doing.
Feel free to post with any questions!
 
Last edited:

demkantor

Inactive Recognized Contributor
Nov 10, 2011
6,861
3,763
mpls
Troubleshooting and FAQs

Some Common Questions and Answers
Q: When I open terminal/cmd and type fastboot devices i just get a blank line...
A: Well there are a number of reasons why this could happen, but here are the things you should check:
*Is the device powered on in fastboot mode?
*Is the USB cable in good shape (not a junky .99 cable)
*Do you have the proper drivers installed (Windows) Android Rules (Linux)?
*Do you have fastboot.exe on PC?
*Have you set up a path in environmental variables (Windows) or the path in .bashrc (Linux)?
****If not then what if you open the terminal/cmd in the location of adb/fastboot?

Q: When I type in command fastboot <whatever command> I get < waiting for device >
A: Then you are either not in fastboot mode on phone, bad connection to PC, missing drivers (or android rules) - fastboot is installed and working just your devices isn't communicating

Q: When I type in command fastboot <whatever command> an error message like
Code:
...
(bootloader) [ERR] Command error !!!
OKAY [  0.016s]
finished. total time: 0.016s
A: This means the fastboot command you are trying to use isn't supported by your current bootloader, to find the list of commands available to you type in one of these two commands:
Code:
fastboot
fastboot oem ?
Q: When I type in a command to flash <XXX> it starts to work but then I get this error:
FAILED (remote: Download size too large) finished. total time: 0.002s
A: Chances are this is not the proper image for your device or your are trying to flash to the wrong partition, double check that this is the correct .img (md5sums help)
Q: When I tried to flash <XXX> I keep getting this error
Code:
sending 'recovery' (3518 KB)... OKAY
writing 'recovery'... INFOsignature checking...
FAILED (remote: signature verify fail)
A: This is because you don't have the proper permissions, you are trying to flash an unsigned image to a write protected partition. You will need to unlock bootloader or flash and engineering SPL, or find an OEM image.
This error is very device specific in the sense that I would need to know more about what you are trying to flash and what bootloader you have to answer properly

Q: When I tried to flash <XXX> or fastboot boot <XXX> I keep getting this error
Code:
downloading 'whatever here'....
FAILED (status malformed (1 bytes))
finished. total time: 0.000s
A: This is often because of a few things:
first, make sure you have a high quality USB cable, and USB port is good. Just because the cable works for charging does not mean it is a good cable.
second way I've seen this issue, user is in bootloader mode but not fastboot mode. yes I often say this is one in the same, but double check, some devices specifically have a fastboot mode within bootloader!

*Note I have found many errors are due to not running fastboot with elevated privileges, try running fastboot as administrator (Windows) or su/sudo (Linux)

As people post errors or questions I will try to add more Q&As
Happy Flashing!
 
Last edited:

trevd

Inactive Recognized Developer
Jul 19, 2011
895
1,271
Hull
Samsung Galaxy Tab 4
Nice Guide

Hi There

Nice guide there, good to see some of the more advanced stuff like booting over usb covered :good:

Couple of things

Fairly sure you don't need java or ia32-libs to run fastboot on linux but I suppose it doesn't hurt to install it :D . Also if you're running the last 2 version ubuntu , 12.10 or 13.04 ( or any ubuntu flavoured Linux ) then fastboot can be installed through apt.

Code:
sudo apt-get install android-tools-fastboot

adb is in there as well

Code:
sudo apt-get install android-tools-adb

EDIT: Also you don't have to do the erase command before doing the boot command as you can use it just to boot a kernel on it's own which would be very difficult if you just used erase to erase the ramdisk, the following are both valid

Code:
fastboot boot kernel
fastboot boot kernel ramdisk.img

Thanks
 
Last edited:

demkantor

Inactive Recognized Contributor
Nov 10, 2011
6,861
3,763
mpls
Thanks for the reply!
I'll be sure to add that in, I read a bit about this but I've just used old fashion install on all my Linux distros I've used. I'll be sure to add as many new Linux user choose ubuntu and apt get is just way easier.
I haven't had a chance to edit through everything yet, last day of finals were today and I needed some study breaks, hence a quickly written guide. I have lots more to add, and looking over some of my write up I'm far from clear on some pieces.
So yeah any input is much appreciated and I'll be cleaning this up soon!

Sent from my Nexus 7 using xda premium
 

knifey_au

Member
Jun 20, 2013
27
2
Encounter Bay, SA

can i use fastboot to flash firmware onto my phone and bypass getprop("ro.product.name") in the updater-script? or somehow flash an unsigned update.zip?

edit: thanks for this great guide, if you could just tell me which bits of the guide you think would be relevant to me that would be awesome. i just don't want to do something off my own bat and then it be absolutely redundant.
 
Last edited:

demkantor

Inactive Recognized Contributor
Nov 10, 2011
6,861
3,763
mpls
sure, fastboot should bypass the ro.product.name (but this is also easy to take out of the updater-script) and it allows to flash unsigned zips as well.
maybe explain to me in a little more detail what you want to accomplish and I could help you do it.
The reason i ask is that flashing firmware is very dangerous and flashing the wrong firmware can easily give you a brick. If all security flasgs are removed on your device you can flash whatever you want in fastboot (for the most part) but that wont mean you should. Let me know what it is you want to flash and hopefully i can tell you if it is safe to do or not.
 
  • Like
Reactions: russellvone

knifey_au

Member
Jun 20, 2013
27
2
Encounter Bay, SA
sure, fastboot should bypass the ro.product.name (but this is also easy to take out of the updater-script) and it allows to flash unsigned zips as well.
maybe explain to me in a little more detail what you want to accomplish and I could help you do it.
The reason i ask is that flashing firmware is very dangerous and flashing the wrong firmware can easily give you a brick. If all security flasgs are removed on your device you can flash whatever you want in fastboot (for the most part) but that wont mean you should. Let me know what it is you want to flash and hopefully i can tell you if it is safe to do or not.

I want to update my KIS LITE (v790 with 256mb ram) with a KIS LITE firmware from ZTE website. It's for a different country/telco, the product names match but the one in the update has productname_telco instead of the stock productname on my phone which i bought directly from china. I'm pretty sure it's all compatible, i have a rooted phone, and i changed the build.prop to match productname_telco but it still errors out updating in recovery at the product name check. (weird???) if i change the zip which is quite easy, it's unsigned and won't update. i'm trying to update specifically to "Greece KIS LITE SD card upgrading instruction & software package(Cosmote)-213550B0197ZTE Kis LiteV1.0.0B01\update.zip"
 

demkantor

Inactive Recognized Contributor
Nov 10, 2011
6,861
3,763
mpls
@knifey_au
ok so I downloaded and took a look at the file you want to flash
Code:
assert(getprop("ro.product.device") == "roamer2" ||
getprop("ro.build.product") == "roamer2");
assert(getprop("ro.product.name") == "P752D01_Cosmote_GR");
these are the three lines that need to be the same in build prop, but in truth if you havent a custom recovery than it may still see your product info in your recovery as you have the stock kernel=stock recovery

and these are all the lines in the new build.prop you are trying to flash
Code:
# begin build properties
# autogenerated by buildinfo.sh
ro.build.id=GRK39F
ro.build.display.id=ZTE Kis LiteV1.0.0B01
ro.build.version.incremental=20130427.041932.31486
ro.build.version.sdk=10
ro.build.version.codename=REL
ro.build.version.release=2.3.6
ro.build.date=Sat Apr 27 04:30:41 CST 2013
ro.build.date.utc=1367008241
ro.build.type=user
ro.build.user=
ro.build.host=zte
ro.build.tags=release-keys
ro.product.model=ZTE Kis Lite
ro.product.brand=ZTE
ro.product.name=P752D01_Cosmote_GR
ro.product.device=roamer2
ro.product.board=roamer2
ro.product.cpu.abi=armeabi-v7a
ro.product.cpu.abi2=armeabi
ro.product.manufacturer=ZTE
ro.product.locale.language=el
ro.product.locale.region=GR
ro.wifi.channels=
ro.board.platform=msm7k
# ro.build.product is obsolete; use ro.product.device
ro.build.product=roamer2
# Do not try to parse ro.build.description or .fingerprint
ro.build.description=P752D01_Cosmote_GR-user 2.3.6 GRK39F 20130427.041932.31486 release-keys
ro.build.fingerprint=ZTE/P752D01_Cosmote_GR/roamer2:2.3.6/GRK39F/20130427.041932.31486:user/release-keys
# end build properties
#
# system.prop for surf
#

rild.libpath=/system/lib/libril-qc-1.so
rild.libargs=-d /dev/smd0
persist.rild.nitz_plmn=
persist.rild.nitz_long_ons_0=
persist.rild.nitz_long_ons_1=
persist.rild.nitz_long_ons_2=
persist.rild.nitz_long_ons_3=
persist.rild.nitz_short_ons_0=
persist.rild.nitz_short_ons_1=
persist.rild.nitz_short_ons_2=
persist.rild.nitz_short_ons_3=
ril.subscription.types=NV,RUIM
DEVICE_PROVISIONED=1
debug.sf.hw=1
debug.composition.7x27A.type=mdp
debug.composition.7x25A.type=mdp
dalvik.vm.heapsize=40m

#
# system props for the cne module
#
persist.cne.UseCne=none
persist.cne.bat.range.low.med=30
persist.cne.bat.range.med.high=60
persist.cne.loc.policy.op=/system/etc/OperatorPolicy.xml
persist.cne.loc.policy.user=/system/etc/UserPolicy.xml
persist.cne.bwbased.rat.sel=false
persist.cne.snsr.based.rat.mgt=false
persist.cne.bat.based.rat.mgt=false
persist.cne.rat.acq.time.out=30000
persist.cne.rat.acq.retry.tout=0
persist.cne.fmc.mode=false
persist.cne.fmc.init.time.out=30
persist.cne.fmc.comm.time.out=130
persist.cne.fmc.retry=false

#
# system props for the MM modules
#
media.stagefright.enable-player=true
media.stagefright.enable-meta=false
media.stagefright.enable-scan=true
media.stagefright.enable-http=true
media.stagefright.enable-fma2dp=true
media.stagefright.enable-aac=true
media.stagefright.enable-qcp=true

#
# system prop for opengles version
#
ro.opengles.version=131072

#
# system props for the data modules
#
ro.use_data_netmgrd=true
persist.data.ds_fmc_app.mode=0

#
# system props for IMS module
#
persist.ims.regmanager.mode=0

#
# system prop for requesting Master role in incoming Bluetooth connection.
#
ro.bluetooth.request.master=true

#
# system prop for Bluetooth FTP profile
#
ro.qualcomm.bluetooth.ftp=false

#
# system prop for Bluetooth SAP profile
#
ro.qualcomm.bluetooth.sap=false

#
# system prop for Bluetooth Auto connect for remote initated connections
#
ro.bluetooth.remote.autoconnect=true

#
#system property for Bluetooth discoverability timeout in seconds
#0: Always discoverable
debug.bt.discoverable_time=0

#
# System prop to enable/disable OMH. Enabled by default
#
persist.omh.enabled=1

#System prop to enable ehrpd capability
ro.config.ehrpd=true

# System property for cabl
ro.qualcomm.cabl=1

#
#System prop to determine availability of
#analog fm path
#
ro.fm.analogpath.supported=true

#
#System property for FM transmitter
#
ro.fm.transmitter=false
#
#System property for single instance recording
#
ro.fm.mulinst.recording.support=false
#
#System property for msm
#
ro.hw_plat=7x27a

#
#System property for Power Saving
#
persist.radio.add_power_save=1

#
# ADDITIONAL_BUILD_PROPERTIES
#
ro.com.google.clientidbase=android-zte
ro.com.google.clientidbase.yt=android-zte
ro.com.google.clientidbase.am=android-tmobile-{country}
ro.com.google.clientidbase.ms=android-tmobile-{country}
ro.com.google.clientidbase.gmm=android-zte
ro.build.baseband_version=P752D01_Cosmote_GRB01
ro.build.sw_internal_version=COS_GR_P752D01V1.0.0B01
ro.build.baseband_version=P752D01_EUROPEB01
ro.build.sw_internal_version=P752D01_EUROPEV1.0.0B07
ro.build.baseband_version=P752D03B01
ro.build.software_version=GENERIC_P752D03V1.0.0B01
ro.build.sw_internal_version=GENERIC_P752D03V1.0.0B01
ro.camera.intrplt.2mpto3mp=true
ro.build.baseband_version=V766B01
ro.build.software_version=GB_P752A10V0.0.0B01
ro.build.sw_internal_version=GB_P752A10V0.0.0B01
ro.config.ringtone=COSMOTE_1_BACKRINGTONE_A_2.mp3
ro.config.notification_sound=F1_New_SMS.ogg
persist.sys.timezone=Europe/Athens
ro.config.notification_sound=OnTheHunt.ogg
ro.config.alarm_alert=Alarm_Classic.ogg
ro.setupwizard.mode=OPTIONAL
ro.com.google.gmsversion=2.3_r11
persist.sys.usb.enable_switch=1
persist.sys.usb.linux_switch=1
persist.sys.usb.switch_pid=0x1351
persist.sys.usb.linux_pid=0x1351
persist.sys.usb.default.pid=0x83
ro.com.google.clientidbase=android-zte
ro.com.google.clientidbase.yt=android-zte
ro.com.google.clientidbase.am=android-zte
ro.com.google.clientidbase.ms=android-zte
ro.com.google.clientidbase.gmm=android-zte
ro.camera.intrplt.2mpto3mp=true
net.bt.name=Android
dalvik.vm.stack-trace-file=/data/anr/traces.txt
not sure what your current android version is but this one is 2.3.6 and should be fairly easy to build a custom recovery for your phone allowing you to flash nonstock .zips
just follow clockwork or twrp guide on how to create your own

and there is no firmware in this package, just kernel, ROM, and recovery so it should be safe enough to flash as long as you have a backup of original.
best of luck!
 

knifey_au

Member
Jun 20, 2013
27
2
Encounter Bay, SA
i downloaded so many new updates trying to get one to flash that i actually forgot to check the version. i'm trying to upgrade from 2.3.6. now i feel dumb. i'll try and find the right update and actually check the version number this time. *facepalm. i'll get back to you.
 

knifey_au

Member
Jun 20, 2013
27
2
Encounter Bay, SA
i downloaded so many new updates trying to get one to flash that i actually forgot to check the version. i'm trying to upgrade from 2.3.6. now i feel dumb. i'll try and find the right update and actually check the version number this time. *facepalm. i'll get back to you.

how do i get to the version number in the update.zip? Never mind i got it.

All the KIS lite downloads from ZTE are 2.3.6. Which is a pitty, since the 512mb version of the v790 is supposed to have ICS and go a lot faster with it. nfi if ram is the only thing they changed though so i'm not going to try and install KIS firmware on KIS lite when I don't know if it will bork things up. Unless you want to look at the phillipenes download for the v790 from ZTE website and tell me if you think it will work for the kis lite.
 
Last edited:

demkantor

Inactive Recognized Contributor
Nov 10, 2011
6,861
3,763
mpls
Hate to say it but it will doubtfully work without a lot of modifications, as handy as fastboot is it won't help with this.
Unfortunately if your phone doesn't have any custom ICS ROMs your best bet in getting one is to create a devices tree and then make it yourself. Simply flashing it from another device will probably leave you in a boot loop at the least and possibly a brick

Sent from my Nexus 4 using xda premium
 
  • Like
Reactions: russellvone

Top Liked Posts

  • There are no posts matching your filters.
  • 178
    Introduction:
    I have found that many people are unaware how to use fastboot, which if you have ever owned an HTC phone or something from the Nexus line you know how important it can be.
    About a year ago I got sick of answering questions about fastboot so I made a guide, but it was device specific. Not too bad but I was constantly giving the links to it for other phones... of course more questions just popped up.
    So here i am making a comprehensive yet easy to follow (I hope) guide on how to set up and use fastboot. I will cover the basics for Windows and Liunx (sorry Apple users, just cant stand the product/company)

    I plan to make a series of guides for XDA-University Thus far there is this guide and:
    [Guide] How To Create Recovery Flashable .zips / update.zips

    First a short explanation:
    Fastboot, like ADB, is a tool to communicate from PC to Android phone. There are times when it is a must to use, and times when it is just helpful.
    ADB is used within your recovery or within your OS, but when you are in bootloader mode and need to communicate with your phone then you need fastboot.

    And you may ask why would i ever need this?
    Well many reasons. Main one is knowledge, learning the ins and outs of fastboot, like learning ADB, can get you out of many jams.
    And if you want to unlock your bootloader this is done through fastboot. Granted HTC's unlock is... well crap, but for a Nexus this is how its done.
    One other reason I have to stress is learning for safety reasons, This is about the safest way possible to flash firmware to your phone (ie Radio, Hboot, Recovery)

    Lastly you may want to know the limitations,
    There are many of course, this isnt JTAG, it will not resurrect a hard brick, but it often save peoples phones from 'soft bricks' and lots of time when know how and when to use it.
    Think of fastboot as the program that takes over when ADB cant be used, it works with firmware more than software.

    So where do i get fastboot? There are a few ways but most often I would recommend getting it from the Android SDK as it is will be up to date.
    or you can use THIS HANDY TOOL created by @shimp208

    I will go over the Download and Installation Process in the Next Post
    Then i will go over useful commands.
    *Just a note, This guide is to always be considered under construction as I plan to continue to make additions such as more commands and pictures
    I will continue to attempt to clarifiy when needed and add what I have missed. I have yet to drop any project or guide I have made on XDA and will help where I can
    As always I encourage questions I may miss something or be vague, it is best to understand fully then not ask.
    84
    Setting up fastboot on Windows and Linux

    What is Fastboot?
    Fastboot is a protocol designed to flash signed/unsigned partitions to android phones directly into the phones flash memory. If you are familiar with ADB think of it in the same way.
    If you're not, just understand it is a tool designed to help flash images such as recoveries, bootloaders, kernels, etc. to your android phone. For the most part you can not use much of fastboot unless you are rooted and have an engineering SPL (Hboot/Bootloader)
    If using a Nexus device you in a sense have an engineering bootloader already so don't need to worry about it like HTC folks need. But Some Nexus lines will have different bootloaders with different capabilities.
    This however is not a tutorial to root your phone so i will not explain this. I will though go over SOME basics as in unlocking your bootloader to allow it to be rooted.
    How do I get fastboot for Windows?

    Fastboot.exe can be downloaded to your computer from Google's SDK found
    HERE download the proper package depending on what system you are using.
    also
    you will need the proper drivers to allow your PC and phone to communicate. You will find these in your devices specific forum or possibly you can use PdaNet


    Okay i got it, whats next?
    After you downloaded the SDK package to your PC see where it is located, somewhere like this for Windows
    C:\android\android-sdk-windows\platform-tools
    Of course put it where you like, just know where fastboot.exe lies

    *If you want to skip the SDK, you can get ADB and Fastboot by themselves with THIS HANDY LITTLE TOOL created by shimp208
    Note: After you have ADB and Fastboot you will may want to finish following this guide to add a path in environmental variables.


    For Windows:
    Although not necessary, but to make it easier i really suggest doing these steps:
    left click the Windows (start) button > right click on computer > choose properties > go to advanced system settings > advanced tab > environmental variables > in the first box (user variables for _____) click new > name it
    > the value is the path from earlier
    C:\android\android-sdk-windows\platform-tools
    (yours may differ from this so double check it!) > in the second box (system variables) find a variable named
    if one doesn't exist make one > double click on it > at the very end of the variable value add the same line as before but with a ; in front of it. like this:
    ;C:\android\android-sdk-windows\platform-tools
    alright click ok and you are done!
    EnviromentalVariables.jpg


    Why did I just do all that?
    Well this allows you to open a command line from anywhere on your computer without changing directories to use fastboot. Pretty much we told your PC that when you type
    or
    into CMD where to find it. As you learn how useful fastboot and adb are this will help a lot as CDing to where you want to be is wasted time.

    So I still don't know what to do or how to do it!
    All right lets start simple, click the windows button and in the search field type
    you will notice a window pop up that looks suspiciously like DOS. View attachment 1980110
    Here you will see a blinking cursor after your directory, lets try this type
    Code:
    fastboot
    a whole bunch of probably unfamiliar stuff should now pop up View attachment 1386065 (for the most part this is a list of commands that can be used in fastboot) if you get something like
    fastboot is not recognized as internal or external command operable program or batch file
    then we need to troubleshoot, but for now i will assume it worked.
    Now try typing
    Code:
    fastboot devices
    ...and nothing will happen, Why? because there isn't a device attached. Make sure you have android debugging turned on in your phone (not really needed for fastboot but you do need for ADB), plug it into your computer and boot into fastboot mode. On many phones hold volume down while powering on, if this wont bring you to bootloader mode then see your device specific forum, if needed choose fastboot. Again try typing
    Code:
    fastboot devices
    this time you should have a list of attached devices, this is displayed as the serial number to each. Being many commands will "do" things to your phone try typing
    Code:
    fastboot reboot
    If your phone is now back and running your existing OS, congratulations! :good: You now at least have fastboot set up and working properly. Now lets try a few things out and see why this can be so helpful!


    How do I get fastboot for Linux?

    To get fastboot installed on your Linux box first download appropriate SDK package From Here
    *Not all Linux distros are the same and I don't consider myself a Linux guru, I will explain what I know about the few distributions I've used but remember if something don't work look up specifics for yours HERE
    After SDK is downloaded extract contents into home folder, maybe in a folder called Android, your choice.
    Now we need to make sure we have the latest java JDK installed found HERE or if you prefer you can get it from the terminal
    Code:
    sudo apt-get update
    sudo apt-get install openjdk-6-jdk
    or if using Ubuntu, the software center. (I have heard people complain about JDK7 so to be safe stick with JDK 6 for now)
    **I have a 64bit machine so I needed the 32bit libraries, you may not need this. If you do run this from terminal
    Code:
    sudo apt-get install ia32-libs
    **As pointed out to me by trevd, if you are using Ubuntu 12.10 or newer you should simply open a terminal and run these two commands
    Code:
    sudo apt-get install android-tools-fastboot
    and
    Code:
    sudo apt-get install android-tools-fastboot
    If you never plan on developing for android or using other tools that come with the SDK
    then this should be all you need. And you may also skip the JDK install. As most people will never attempt to create
    an app or ROM or mod their phone in a way that they would need more than this, these simple commands should suffice.


    Downloading Fastboot
    ummm.. isn't that what I just did? Possibly, but as far as I know ADB, fastboot and everything else in platform-tools wont automatically download with the SDK.
    Other have told me it does, so feel free to navigate to the platform-tools folder and see if you see these applications.
    If you skipped installing the SDK and just installed fastboot and ADB from the command line you can skip down to creating a path. So if you got them, skip this, if you don't, do this:
    From in a terminal type
    Code:
    cd ~/android-sdk-linux/tools
    ./android
    **note depending on what you named the folder the downloaded and extracted SDK is in you may need to change your cd command to something else.
    Now a new window will pop up, Click on "Available Packages" and you will be see two boxes. One is Android Repository and the other is Third-party Add-ons.
    Click on "Android Repository" then click on Install Selected. now click on "Accept All" and then click on the Install button.
    Personally I like downloading all that is possible here, you may have limited space or bandwidth so all you 'need' is the contents of platform-tools.
    If you want to download some API's later go for it, they aren't needed unless you are developing.


    Adding a Path
    Just like in windows changing directories can be brutally annoying so lets add a path. Open a Terminal and type:
    Code:
    nano ~/.bashrc
    or you can use gedit, whatever you have/like to use (sudo gedit ~/.bashrc)
    At the end of this text (or at the begining add the following
    Code:
    Android tools
    export PATH=~/android-sdk-linux/platform-tools:~/android-sdk-linux/tools:$PATH
    **again be sure this is your path (neat trick, find fastboot from within platform-tools, right click on it, go to properties, highlight the location/path and copy/paste this)
    Now click save, this will make so you no longer need to type ./adb all the time
    I have been told a reboot is needed here but I don't think so, just type this into a command line:
    Code:
    source ~/.bashrc


    Drivers? I don't need no stinking drivers!
    True, sorta, but more than likely we will need to add the android rules so your device can communicate with PC. Open a Terminal and Type
    Code:
    gksudo gedit /etc/udev/rules.d/51-android.rules
    now add the following lines:
    Code:
    SUBSYSTEM=="usb", ATTRS{idVendor}=="0bb4", MODE="0666"
    SUBSYSTEM=="usb", ATTRS{idVendor}=="0502", MODE="0666"
    SUBSYSTEM=="usb", ATTRS{idVendor}=="12d1", MODE="0666"
    SUBSYSTEM=="usb", ATTRS{idVendor}=="1004", MODE="0666"
    SUBSYSTEM=="usb", ATTRS{idVendor}=="22b8", MODE="0666"
    SUBSYSTEM=="usb", ATTRS{idVendor}=="04e8", MODE="0666"
    SUBSYSTEM=="usb", ATTRS{idVendor}=="0fce", MODE="0666"
    SUBSYSTEM=="usb", ATTRS{idVendor}=="0489", MODE="0666"
    SUBSYSTEM=="usb", ATTRS{idVendor}=="18d1", SYMLINK+="android_adb", MODE="0666"
    SUBSYSTEM=="usb", ATTRS{idVendor}=="04e8", MODE="0666", GROUP="plugdev"
    Depending on your device this should be all you need and then some, feel free to check out THIS for the most up to date vendor list.
    View attachment 1980099
    Now for a test!
    So plug your phone into PC via usb, have it in fastboot mode (from within bootloader) and open a new terminal, type:
    Code:
    fastboot devices
    If you see a string of #s and letters then success! :good: you are ready to learn the ins and outs of fastboot!
    69
    Using Fastboot To Unlock Your Bootloader

    Do You need to unlock your bootloader?
    For many phones this is necessary to root, for others it is a poor way to root your phone as you may not have full access.
    Many HTC model phones can be rooted with various exploits, sometimes removing the radio secure flags completely.
    If you have one of these devices than I recommend this, as true radio s-off is far superior to an unlocked bootloader.
    But other phones, including the Nexus line, will be fine just unlocking and do not need to worry, Although some phones like the Nexus One can profit from a new bootloader altogether.
    To begin the rooting process you simply need to unlock your bootloader with this command from a terminal/CMD
    Code:
    fastboot oem unlock
    and the reverse of course is
    Code:
    fastboot oem lock

    Be prepared for a full wipe of your phone when unlocking the bootloader!

    But quickly if you have an HTC and choose to unlock your bootloader to root your phone follow these step:
    Select your phone from the list HERE (you will need to create a log in)
    there will be some legal mumbojumbo to click through (just saying you void your warranty but you knew this!)
    you may need HTC sync found HERE as well as the proper RUU for your phone, the HTCDev site will inform you.
    After which the site will move you through the steps to gain fastboot access, but if you followed my guide above just skip it all.
    next you will need to get the identifier token, this is unique to your device and really just getting probably voids your warranty,
    even if you stopped the guide here. to do so, open terminal/CMD and type
    Code:
    fastboot oem get_identifier_token
    copy and paste this information into the prompt at the bottom of the page. Now wait for an email to get your token....
    once you get the email with the token you can now follow their steps to unlock your bootloader...
    really if at all possible i recommend not to do this method of rooting. But if you do, follow these same next steps that the Nexus devices will be doing...


    Now that your bootloader is unlocked:
    We will flash a custom recovery to your phone, then a custom already rooted ROM. To flash the recovery go to your device specific forum HERE and find the developers section.
    Look for a custom recovery option and consider reading up on it there.
    Different Android phones will have different custom recovery options depending on the developers for it. The most common is ClockworkMod, there are both touch and none touch recovery options.
    some others are TWRP, 4EXT, AmonRa and Cannibal. Find out what your options are, pick one and download it.
    If possible check the MD5Sum, Windows use: THIS and Linux use a terminal and type
    Code:
    md5sum <filename>
    of course replace <filename> with the file name.
    View attachment 1980095
    If you prefer, GTK Hash is a nice program as well.
    Now this should be an image not a zip, so if the extension is .img your good, if its in a .zip or .jar or whatever extract the image.
    Take this image and (for simplistic sake) name it
    **if using windows be sure to pay attention if your file extensions are hidden, don't name it recovery.img.img!
    So be sure your phone is in fastboot mode and connected to PC, open a terminal/cmd in the same location that recovery.img is in
    (cd to that directory or windows users can hold shift > right click in the folder it's in > choose open command here)
    Code:
    fastboot erase recovery
    fastboot flash recovery recovery.img
    **erase recovery is not necessary but i am OCD about wiping...
    now if you get an okay! then your good :good:
    Code:
    sending 'recovery' (4930 KB)...
    OKAY [  0.521s]
    writing 'recovery'...
    OKAY [  0.489s]
    finished. total time: 1.10s
    If not let me know what the output is and ill help you fix it. (I will also make a troubleshooting section in my final post)

    Great! Now Let's Flash a ROM
    In that same developers section for your phone, you should pick out a ROM of your licking. If possible i would suggest an older version of CyanogeMod as these builds tend to be quite stable.
    Also some phones may have newer ROMs requiring you to do various things to your phone. Such as changing radios or bootloaders or other things we haven't gotten to yet.
    So for now try to read the OP of the ROM you like and make sure you meet all requirements.
    So Im not going deep into how to flash a ROM from recovery as this is not part of a fastboot guide.
    But pretty much just pick a ROM and anything else you may need (gapps, kernel, etc) and put on root of SDcard (no other folder)
    Then boot to recovery, wipe all you can (I'll teach you fastboot wiping soon!) and then flash ROM + whatever else you need to and then reboot.

    Another Issue With HTC's Unlocked Bootloaders
    Well if this not yet another reason to try to gain true radio s-off for your phone...
    From with in that ROM that you flashed you also need to unzip and extract the kernel (boot.img) this will need to be flashed through fastboot.
    Once all the above steps are completed reboot into fastboot mode, if your recovery doesn't have a quick way to do so just open a terminal/cmd and type:
    Code:
    adb reboot-bootloader
    from here you will need to then open a terminal/cmd in the same location as that boot.img is and type:
    Code:
    fastboot flash boot boot.img
    If it says okay you are finally done!!! Well done with flashing your first ROM but can you flash a ROM in fastboot? I mean do you need recovery at all?
    There are ways, and ill teach ya in the next post!
    55
    Flashing a ROM through Fastboot

    So Why Do I Need To Do This?
    You don't, normally you would flash a ROM through recovery, but why not have another way? Maybe your recovery partition on your phone is corrupt?
    Maybe you just want to say "I learned something new!" whatever your reason here are the simple steps:

    To start:
    We need to download the ROM of choice to your computer. Once complete find the folder that ROM is in and open terminal/cmd to that directory
    (quickest way for windows; just hold shift and right click within that folder > open command window here) of course make sure your phone is plugged into computer and in fastboot mode.

    Lets see how quick and easy this really is...
    In the command line type:
    Code:
    fastboot devices
    Seeing your serial number means we know all is good
    Now lets type these commands:
    Code:
    fastboot erase system -w
    fastboot erase boot
    fastboot update superawesomerom.zip
    Of course replace <superawesomerom.zip> with the correct file name

    and last but not least:
    Code:
    fastboot reboot

    *Its been a little while since i did this but the phone might automatically reboot after flash so no need to run the reboot command

    As your phone boots into the new ROM, pat yourself on the back...

    A Note on Erasing/Formatting
    You may have noticed earlier that I had you erase your recovery before flashing a new one,
    now here I had you erase system and boot, you may be wondering why.
    I find that a large amount of complaints in developer threads are due to people not properly wiping before a flash.
    Of course there is times when a 'dirty' flash is fine, but if you're ever not sure, wipe as cleanly as possible.
    fastboot allows for about the cleanest of wipes by the way. And each partition can be done separately too.
    Code:
    fastboot erase system
    fastboot erase data
    fastboot erase cache
    can all be done individually, but to do these all in one command
    Code:
    fastboot erase system -w
    If possible I recommend to do these steps before flashing a ROM, and now that you know you can do this all within fastboot mode i suggest to try it out, its quick and painless!
    Don't forget to wipe your kernel too! (fastboot erase boot)

    ~Important~ If your device uses an emulated SD card (as in no removable micro SD but an SD partition on phone)
    Then be careful wiping data/userdata as this will erase all contents of internal SD - you are forewarned!

    What about just flashing a single partition?
    Sure this can be done, hell you can restore a nandroid if you want!
    well first you need to make a nandroid back up (unfortunately fastboot cant make a nandroid for you :crying: ) Put it some where on your computer.
    Personally I only keep maybe 2 or 3 nandroids on my phone's SD card as why waste space. I do however keep almost all my nandroids on my computer separated into different folders for different phones. So my path to a nandroid backup would be something like:
    android/htcg2/nandroids/<nameofnandroid>
    But here's the catch, most newer recoveries do tar backups I believe TWRP uses .win, these can not be flashed in their current form!
    However most older recoveries use yaffs2 format for their backups, these will always work. Pretty much if you get a backup with various partitions as .img you're good to go!
    **Hypothetically speaking here: you installed a new recovery and want to flash a nandroid made in old recovery but the two recoveries used different formats...
    Well you can flash the images with fastboot, then make a new nandroid and you got them back!
    ...Maybe I'm stretching... oh well, here's how to!

    Now the obvious stuff:
    Have phone plugged into PC via USB and in fastboot mode, open terminal/cmd and change directories to that folder where your nandroid is in (or again just hold shift and right click > open command window here if using windows)
    Now in terminal/cmd type:

    Code:
    fastboot devices
    all is good when serial number is displayed, now type:
    Code:
    fastboot erase system -w
    fastboot erase boot
    *This isn't 100% necessary but I'm a firm believer in wiping before any flash, even a backup
    Code:
    fastboot flash userdata data.img
    fastboot flash system system.img
    fastboot flash boot boot.img
    fastboot reboot
    (of course change the image names if needed)
    And you did it! :good: now you are almost a pro at using fastboot!
    keep playing around, you'll get the hang of it and will quickly see that this is one of the best tools in the Android SDK.
    It makes things much faster and easier and in many cases safer than the alternatives. Any questions... feel free to ask!
    Happy Flashing!
    44
    What About Flashing Firmware?

    Flashing any firmware to your phone can be dangerous but if possible the best and safest way is with fastboot.
    Hypothetically you flash a new Hboot through recovery and this Hboot was corrupt in some way, if the flash takes you will have a bricked phone, hard bricked, only JTAG can bring it back.
    But with fastboot you get to input your command to terminal/cmd an see the output, if something goes wrong, just DO NOT REBOOT until you fix the problem.
    And again, checking MD5sums is nice when flashing software but a must when flashing firmware.
    I will again recommend THIS for windows and using the terminal for Linux

    Okay, Time To flash A New Bootloader!
    Some phones will not allow bootloader flashes unless you remove the radio secure flags, if you have a phone like this check the developers thread for a how to.
    To begin, find the appropriate bootloader (sometimes referred to as an Hboot or SPL) for your phone,
    Now download and check MD5sum, have your phone in fastboot mode and open a terminal/cmd in the location your Hboot.img is stored.
    Code:
    fastboot devices
    fastboot flash hboot hboot.img
    and of course replace 'hboot.img' with whatever you titled your image
    **Do not reboot if you see 'sending.... failed' need to see the 'okay!'
    I am not trying to scare you as these instances are so rare, but knowing what to do ahead of time is just common sense.

    Not all devices use the same terminology for partitions, so if the above does not work than consider changing to this command:
    Code:
    fastboot flash bootloader bootloader.img
    Again replacing <bootloader.img> with the name of your image

    Now flashing a new bootloader will more than likely repartition your phone, so from here you probably should flash a new recovery, then flash a new ROM.
    Be prepared to do all this before flashing a new Hboot!

    I'm ready to flash a new radio!
    Flashing a radio can also be dangerous, but again the safest way to do so is within fastboot. So if possible always flash radios in fastboot mode!
    **I am not referring to the FM radio in your car, rather your cellular Radio, you know where you get reception... don't ask me how to add a FM radio to your phone!
    Also know OEMs commonly use baseband and radio as interchangeable terms, for the most part this is the exact same thing

    First things first, know why you are flashing a new Radio. Is it because you have poor reception? Poor data speeds? Poor battery life?
    Yes a new radio can cure all this, but NO ONE can tell you which radio is best for your phone, not even someone living in the same city.
    The best radio for my phone will not for sure be the best for yours, even if you live down the road from me. Don't ask what Radio is best! and only flash a radio meant for your device!

    Now that that's out of the way, lets do the same steps as before:
    Download appropriate radio
    Extract if needed (should be in .img format)
    For simplistic sake name it 'radio.img'
    Plug in phone to PC and open a terminal/cmd in the same location as your radio.img
    Code:
    fastboot devices
    fastboot flash radio radio.img
    fastboot reboot-bootloader
    Again only reboot if all goes well (It will if you follow all direction)
    Upon rebooting your bootloader you will notice your radio version has changed, congrats! You're becoming a pro! :D

    *note, occasionally OEMs package another image called rcdata.img along with a firmware release, if they do I also recommend to flash this along with the radio
    Code:
    fastboot flash rcdata rcdata.img
    **another note, if possible try to match the ril libraries between your ROM and radio, this is device specific and you will need to see your developers thread for this info.
    It is not always possible or necessary to do so, but many do say it help quite a lot
    Flashing a Kernel
    Earlier I went over flashing kernels as part of HTC Unlocked Bootloader Flashing, the process is the same for anyone else as well.
    Locate the Kernel you want to flash
    navigate to the folder it is in (should be in .img format and lets name it boot.img)
    Code:
    fastboot flash boot boot.img

    But lets say you are a developer and have worked on a new kernel for your device, a quick and easy way to test it out may be to fastboot load the kernel:
    Code:
    fastboot erase boot
    fastboot boot kernel ramdisk
    As usual replace file/image names accordingly
    If you do not want to erase the current kernel, just skip erasing.
    But I would just have a working kernel.img handy and erase, this way I know there are no residual effects from previous kernel - choice is yours

    Code:
    fastboot flash:raw boot kernel ramdisk 
    fastboot reboot
    Test it out and see how things go! Good luck! :good:

    As always, if you have questions or comments feel free to leave them here!
    Happy Flashing!