[Kindle Fire General] kinfauns:
Windows cmd, fastboot and adb

OK, so what are these commands?

To get started, click on the Start Menu to begin. Then, depending on the version of Windows, either use "Run…" or "Search" and type "cmd" to open up a command line window that will look a lot like...

​

The last line in this example is called a prompt and it's followed by a blinking cursor.

The prompt tells you where you are in the directory structure. When the "cmd" program first starts up, that location is your Windows user's home directory by default. In the above example, my username is "kinfauns" and my home directory by the same name is in the "Users" directory located on the "C:" drive. The "C:\Users\kinfauns" part of the prompt is the directory path and it uniquely describes the location of the home directory owned by the "kinfauns" user.

The blinking cursor indicates the program's readiness to accept a new command. Each time you execute a command, a new prompt/cursor will appear at the bottom, telling you that it's ready for you to type another.

Now type "dir" (without the quotes) and press Enter, and you'll see the names of all the folders in your home directory. The "dir" command just prints out a content listing of the directory indicated by the prompt. If you open up your home folder in Windows Explorer and look inside, you'll see everything in that folder shown in the list you got from the "dir" command. The "dir" command implicitly operated on the current directory shown in the prompt, but you can also provide an explicit argument to tell it what directory to list. For example, "dir C:\Users" lists all the users directories. Providing an argument after the command name will be important for the next command...

The "cd" command is used to change the current working directory. We need to get to the KFU directory, so we can use "C:\kfu" as an argument to the "cd" command. Type "cd C:\kfu" and press Enter to change to that directory. No output was provided, but the new prompt has a different directory path to confirm the "cd" command has executed successfully. You can try "dir" here to list the contents of the "C:\kfu" directory, but it's not necessary to first list it if you know what's in there already. In this case, we'll "cd" into the "C:\kfu\tools" directory, but you won't have to provide the full path. Since "C:\kfu" is already the current working directory, "cd tools" is equivalent to the "cd C:\kfu\tools" command. The one other key component to navigating the directory structure is the ".." directory. The ".." directory refers to the parent of the current directory, so "cd .." will take you back up to "C:\kfu" and another "cd .." will take you up to the "C:\" directory.

Now you'll be able to navigate through the directories and you should have a fair idea about how to construct a directory path (this will come in handy later). The fastboot and adb executables are in the "C:\kfu\tools" directory, so you'll have to get there using what you learned to be able to use them in the next section. There are just a few more tips that might come in handy...

Shift-right-click on/within a folder and select "Open command window here" to open a command line window with that directory path as the current working directory.

File/folder names or directory paths containing spaces must be enclosed in double quotes.

Drag and drop a file or folder from the Windows Explorer windows into the Command Prompt window. The complete, absolute path of the object will be pasted into the Command Prompt window automatically.

Utilize the "Tab" key to complete a file/folder name without typing it in its entirety (e.g. Try typing "cd C:\kfu\to" and then hit the "Tab" key).

For more information on Windows cmd commands, bleepingcomputer.com has a nice introductory tutorial and ss64.com has a full reference page of commands.

How about those fastboot commands?

Just to review, fastboot is a command line tool used to erase or flash partitions on Android devices. To use fastboot commands, the Kindle Fire must be put into fastboot mode by one of the following three methods...

Set the bootmode to 4002 and reboot

Connect a factory cable and reboot

Issue a fastboot command during FFF's temporary fastboot mode

Fastboot mode can be confirmed in Windows Device Manager as "Android Phone -> Android ADB Interface" when the proper drivers have loaded.

You can also verify the Kindle Fire is in fastboot mode by issuing...

fastboot getvar product

and it will confirm by returning "product: kindle" as the output. Alternatively,

fastboot devices

returning "0123456789ABCDEF	fastboot" also means the device is in fastboot mode, but this does not seem to stop the FFF temporary fastboot countdown, so the first command is probably more useful to remember.

When using the stock bootloader (plain "kindle fire" boot logo), the fastboot command must always specify the custom vendor ID used by the Kindle Fire. For example, the commands above must be slightly altered to...

fastboot -i 0x1949 getvar product
fastboot -i 0x1949 devices

and likewise, all of the following commands will need the "-i 0x1949" switch when using the stock bootloader. The FFF bootloader's vendor ID has been changed to one that is normally recognized by fastboot, so the "-i 0x1949" switch can be omitted.

Now onto some more useful fastboot commands...

fastboot oem idme bootmode 4000
fastboot oem idme bootmode 4002
fastboot oem idme bootmode 5001

Using one of these commands will change the bootmode to normal (4000), fastboot (4002) or recovery (5001). Then issuing...

fastboot reboot

will reboot the device into the respective bootmode.

Use one of the following to wipe a partition on the device...

fastboot erase bootloader
fastboot erase recovery
fastboot erase boot
fastboot erase system
fastboot erase cache
fastboot erase userdata
fastboot erase media

You must be very deliberate when using these commands. The fastboot erase command will immediately start erasing the partition and it will not be recoverable if you change your mind. Erasing the bootloader, boot, or system partitions (especially the bootloader) can seriously brick your device if they are not replaced. In most cases, it's probably best and safest to flash a new image on top of the existing data, but they are listed here for reference. The last two commands are probably more useful than the others. Erasing the data partition is roughly equivalent to a factory reset and the last command will erase the sdcard partition.

Rather than use the fastboot erase commands above, the fastboot flash command can be used to overwrite the partitions...

fastboot flash bootloader \path\to\u-boot.bin
fastboot flash recovery \path\to\recovery.img
fastboot flash boot \path\to\boot.img
fastboot flash system \path\to\system.img
fastboot flash userdata \path\to\userdata.img

Most users will most likely only need to utilize the first two of these commands to flash a new bootloader and recovery, but the others may still be useful if there's ever a reason to flash them separately.

Just in case you are unsure about what the "\path\to" part of the command means, it refers to the directory location of the file you are flashing. Let's say you want to flash a new recovery image and have the recovery.img file in the C:\kfu\software folder. You would replace the "\path\to" part with "C:\kfu\software" in the command to look like...

fastboot flash recovery C:\kfu\software\recovery.img

The file name at the end is also a generic example and should be changed to the actual name of the downloaded file.

The Kindle Fire can also be booted directly from a boot image on your computer without first flashing it to the device...

fastboot boot \path\to\boot.img

Because a recovery image is just another boot image, this feature is useful for testing out another recovery without overwriting the one currently installed. For instance, if you have CWMR installed, but you just want to take a look at the new TWRP release, use "fastboot boot" to boot from that image. It won't affect your CWMR installation and the next restart into recovery will boot into CWMR. Note: This will not work with TWRP 2.0.0 because that distribution is a boot image that automatically flashes the recovery image contained within the boot image. TWRP 2.1.0 and above will behave as previously described.

For even more fastboot commands, take a look at...

fastboot help

What about the adb commands?

As noted before, adb commands can be sent to the Kindle Fire when it is either booted into the OS or recovery. First check the Windows Device Manger to make sure "Android Phone -> Android Composite ADB Interface" appears in the list and then verify adb is working properly with the following command...

adb devices

To manage communications between the computer and the device, adb utilizes the services of a background server (daemon). When an adb command is issued, it checks to see that the server is running and starts one as necessary. After this server starts running, adb will output a line with a 16 digit alphanumeric identifier and a short description for each devices that responds to the query (e.g. "3A8F010600000001 recovery"). If you don't see this identifier, then the device drivers are probably not installed or not loading properly... see the previous post about device drivers.

Like fastboot in the previous section, adb can also be used to change the bootmodes on a rooted device...

adb shell idme bootmode 4000
adb shell idme bootmode 4002
adb shell idme bootmode 5001

These adb shell commands will change the bootmode to normal (4000), fastboot (4002) or recovery (5001). Then the device can be restarted with

adb reboot

These adb commands copy files and folders to and from the device...

adb push <source on host> <destination on device>
adb pull <source on device> <destination on host>

The arguments enclosed in angle brackets (<>) must be replaced with the path to files and folders as appropriate. To copy a file or folder from the host computer to the Kindle Fire, use the "adb push" command. To illustrate by example, let's say there's a folder full of mp3 files, "C:\mp3" on the computer and you want to copy some or all of them to the Kindle Fire's Music folder.

adb push C:\mp3\track1.mp3 /sdcard/Music/
adb push C:\mp3\track1.mp3 /sdcard/Music/newtrack.mp3
adb push C:\mp3 /sdcard/Music

The first command copies the track1.mp3 file to the Music folder on the Kindle Fire. The second command copies the same file with a new name on the device. The last one copies the entire contents of the mp3 folder to the Music folder. Note that Windows uses the backslash as a separator while the Kindle Fire uses the Unix/Linux conventions with the forward slash.

Conversely, "adb pull" copies a file or folder from the Kindle Fire to the host computer.

adb pull /sdcard/Music/track1.mp3 C:\mp3
adb pull /sdcard/Music/track1.mp3 C:\mp3\newtrack.mp3
adb pull /sdcard/Music C:\mp3

These commands are equivalent to the "adb push" examples, but move the files and folders in the opposite direction.

Another useful command is used to sideload an app onto the device...

adb install \path\to\App.apk

Some of the most powerful adb commands are actually Linux commands. One such example to change the bootmode of the device was covered earlier in this section. "adb shell" commands in this form...

adb shell <Linux command>

actually execute a Linux command directly on the device. The entire range of available Linux commands cannot be covered here because of the limited scope of this document. Just be aware that any commands in this form are really Linux commands being run through adb. For more information on Linux shell commands, An Introduction to the Linux Command Shell For Beginners is a good place to start.

Most users will be able to get by with the commands covered here, but adb has many other useful commands as well. Be sure to take a look at the built-in help for other useful adb commands...

adb help

How do I put all these commands together?

A supplement to this guide has been posted with details on how to root a stock device and install a custom ROM. The how-to guide outlines the use of these adb and fastboot commands in real-world tasks to modify the Kindle Fire.

Kindle Fire For Beginners - Supplemental How-To Guide

How can I thank you for this guide?

Hit the "Thanks" button and share your positive experiences in this thread. If you feel like you have more to give, consider donating a few minutes of your time to new users who come here looking for help. None of us were born with this knowledge and we all need a hand up from time to time. Be kind and generous when you post. Thanks for reading!