WHATSAPP CHANNELS by Tembe; Panci Follow Now!

Search Suggest

How To Setup And Use Fastboot

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:

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.

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.
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

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

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
fastboot oem unlock
and the reverse of course is
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
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
md5sum <filename>
of course replace <filename> with the file name.
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)
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 :
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:
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:
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!

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:
fastboot devices
Seeing your serial number means we know all is good
Now lets type these commands:
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:
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.
fastboot erase system
fastboot erase data
fastboot erase cache
can all be done individually, but to do these all in one command
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:
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:
fastboot devices
all is good when serial number is displayed, now type:
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
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!

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.
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:
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
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!

*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
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)
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:
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
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!

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:
fastboot oem lock
then to get into RUU mode
fastboot oem rebootRUU
Then you will flash the zip, change command to correspond to proper name
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:
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:
fastboot getvar cid
cid: 11111111
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:
fastboot oem changeCid
or possibly a common cid (SuperCID)
fastboot writecid 11111111
If you want to get a bunch of info quickly try this:
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:
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:
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!
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:
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
fastboot oem ?
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?
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
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!


Post a Comment

In between our time repairing phones, we will always give our best to revise and update the post / tutorial whenever we find that there is a mistake in the writings, or a file is missing. So please kindly do let us know. Please read the disclaimer section first before you following the tutorial or downloading any file from us. We hope you understand our policy. Thank You.