KFHD System.img Recovery Tool

Search This thread

monster1612

Senior Member
Apr 21, 2014
432
162
Amazon Fire TV
Hi! Yes, I was typing by hand, not using the .bat file. So far as I know, batch files run on Windows. I'm running linux on the Raspberry Pi and don't know enough about it to run that way, so just used the bat file as a reference for all the correct fastboot instructions.

The instruction for flashing the system is pretty simple. Basically "fastboot blahblah flash system foldername\imagename.img"
There's not much choice about where it goes, just "system". Maybe you know more about it, if there's a different name than what's used in the tool.
I flashed the other files to their locations without issue. But they weren't 1.1GB like the system file is.

Apologies for the late reply, but try adding -S 256M in between the "flash" and "system" in that command. That should force fastboot to flash the image in parts.
 
  • Like
Reactions: ong14 and phonetool

phonetool

Senior Member
Apr 18, 2012
728
224
Apologies for the late reply, but try adding -S 256M in between the "flash" and "system" in that command. That should force fastboot to flash the image in parts.

Hmm, so that seemed like it wanted to work, but only gets 1 segment pushed across before it fails.

pi@raspberrypi:~/Downloads/KFHD_SRT_v2.1 $ fastboot -i 0x1949 flash -S 256M system images/system2.img
Invalid sparse file format at header magi
sending sparse 'system' (248248 KB)...
OKAY [ 19.784s]
writing 'system'...
FAILED (remote: : Sparsed Write)
finished. total time: 19.826s

Reading through the fastboot help file, looks like there's a format <partition> and erase <partition> command. If I blow away the DEMO system with one of those, there'll be nothing on the device, but maybe I can write the 1.1GB file to system then?

Thanks for your help!

edit:
Tried different parse sizes: 128M and 512M with same result as 256M.
Tried 1G and got "error: cannot load 'images/system2.img': Cannot allocate memory"
 
Last edited:

monster1612

Senior Member
Apr 21, 2014
432
162
Amazon Fire TV
Hmm, so that seemed like it wanted to work, but only gets 1 segment pushed across before it fails.

pi@raspberrypi:~/Downloads/KFHD_SRT_v2.1 $ fastboot -i 0x1949 flash -S 256M system images/system2.img
Invalid sparse file format at header magi
sending sparse 'system' (248248 KB)...
OKAY [ 19.784s]
writing 'system'...
FAILED (remote: : Sparsed Write)
finished. total time: 19.826s

Reading through the fastboot help file, looks like there's a format <partition> and erase <partition> command. If I blow away the DEMO system with one of those, there'll be nothing on the device, but maybe I can write the 1.1GB file to system then?

Thanks for your help!

edit:
Tried different parse sizes: 128M and 512M with same result as 256M.
Tried 1G and got "error: cannot load 'images/system2.img': Cannot allocate memory"
I actually looked into the image sparsing option for fastboot. From what it seems, you need to actually split the original image into sparse files in order to get fastboot to take them. It seems that this tool from an XDA user would be useful for that purpose. So basically, compress the file into 256MB sparse chunks as documented in the original post, then try the sparse-ified flash command again, but point it to system2.img_sparsechunk1 instead of system2.img. Also, if that command fails, just flash the sparse chunks one by one without the sparse parameter in each command.
 
  • Like
Reactions: phonetool

phonetool

Senior Member
Apr 18, 2012
728
224
I actually looked into the image sparsing option for fastboot. From what it seems, you need to actually split the original image into sparse files in order to get fastboot to take them. It seems that this tool from an XDA user would be useful for that purpose. So basically, compress the file into 256MB sparse chunks as documented in the original post, then try the sparse-ified flash command again, but point it to system2.img_sparsechunk1 instead of system2.img. Also, if that command fails, just flash the sparse chunks one by one without the sparse parameter in each command.

Thanks very much!
I'm going to read that link info now... back in a flash (pun intended)

edit:
Hmm... I'll need to figure out how to run the .exe in a Linux terminal and exactly what the syntax is for the relevant source and target folders. Simply typing in
pi@raspberrypi:~/Downloads/sparseconverter $ sparseconverter.exe
gets me:
bash: sparseconverter.exe: command not found
 
Last edited:

monster1612

Senior Member
Apr 21, 2014
432
162
Amazon Fire TV
Thanks very much!
I'm going to read that link info now... back in a flash (pun intended)

edit:
Hmm... I'll need to figure out how to run the .exe in a Linux terminal and exactly what the syntax is for the relevant source and target folders. Simply typing in
pi@raspberrypi:~/Downloads/sparseconverter $ sparseconverter.exe
gets me:
bash: sparseconverter.exe: command not found

My bad - I forgot you're on the pi, so windows executables don't work without WINE or something along those lines. Whoops. :p


Thanks for doing the sparsing! If my hunch is correct, the img2simg tool within the Android image repack tools package might work with these images on Linux. I haven't tested it though, so feel free to experiment.
 
  • Like
Reactions: phonetool

bgrove7

New member
Nov 3, 2017
1
0
Holy cow, you saved my butt. Trying to root and load a normal Andriod OS to my wife's Kindle and i got it stuck in a boot loop.
I used @chickeninfemo idea here of using linux to get into fastboot. After that i was able to move to windows, apply the correct drivers and flash the system.img, boot.img and recovery.img as you had mentioned in your instructions to downgrade.

Thank you again
 

phonetool

Senior Member
Apr 18, 2012
728
224
Awesome!! Thanks very much!
My bad - I forgot you're on the pi, so windows executables don't work without WINE or something along those lines. Whoops. :p



Thanks for doing the sparsing! If my hunch is correct, the img2simg tool within the Android image repack tools package might work with these images on Linux. I haven't tested it though, so feel free to experiment.
I learned yesterday that some executables do run on linux, but others are windows only. Thought it was worth trying to see if it would go. Haven't yet tried wine on the pi.

Meanwhile... I tried to flash the three sparsed system.img chunks and got an error each time. :(

Code:
pi@raspberrypi:~/Downloads/KFHD_SRT_v2.1 $ fastboot -i 0x1949 flash -S 256M system images/sparsesystem/system.img_sparsechunk1
sending 'system' (262140 KB)...
OKAY [ 14.995s]
writing 'system'...
FAILED (remote: : Sparsed Write)
finished. total time: 15.044s
pi@raspberrypi:~/Downloads/KFHD_SRT_v2.1 $ fastboot -i 0x1949 flash -S 256M system images/sparsesystem/system.img_sparsechunk2
sending 'system' (262141 KB)...
OKAY [ 14.911s]
writing 'system'...
FAILED (remote: : Sparsed Write)
finished. total time: 17.158s
pi@raspberrypi:~/Downloads/KFHD_SRT_v2.1 $ fastboot -i 0x1949 flash -S 256M system images/sparsesystem/system.img_sparsechunk3
sending 'system' (248513 KB)...
OKAY [ 14.149s]
writing 'system'...
FAILED (remote: : Sparsed Write)
finished. total time: 19.190s
The files would send over to the Fire ok, but then the write to system would fail.

Fastboot also has an 'update' instruction that will flash an 'update.zip' file. Is it possible to get the system.img compressed into a zip and use that function? As it is, the system.img reports as 1.1GB, but the compressed & sparsed files total out at about 3/4 that. Maybe a compressed image would be small enough on its own for the download and write?
Really, really appreciate the help here! Thanks very much for all the suggestions!

edit:
Aaaaaaand now after a reboot, the DEMO OS seems to be borked and the unit won't boot up. It tries to- says it's starting the demo software, but then fails, reboots, and drops into Kindle Fire System Recovery. The only two options are 'reboot' or 'reset to factory defaults'. Tried both to no avail.
 
Last edited:

monster1612

Senior Member
Apr 21, 2014
432
162
Amazon Fire TV
Do you have your jem's bootloader unlocked?
Pretty sure you can't unlock the bootloader - thus the need for the freedom-boot exploit flash when coming from stock OS.

Hi!
I'm sort of in uncharted territory here, the jem is an old store demo unit with demo OS on it. I don't know if I can unlock the bootloader in this state. All I have available is fastboot.
If you run fastboot -i 0x1949 getvar product, you get something along the lines of "Jem-PVT-prod-04" as output, right?
 

litmouse27

New member
Feb 7, 2018
3
0
please help

here is my story - have a kindle fire 8.9 won't boot stuck on logo screen - tried to restore no luck - downloaded v2.1 and unzip and ran but keeping getting error "'ping' is not recognized as an internal or external command,operable program or batch file." then no device found I would really like to try to get this working again. Any help would be much appreciated . I don't know awhole lot when it comes to the kindle fire software or how to reload things just when it works I love them...

kindle fire 8.9
windows 10 64bit
 

mattpr

New member
Jan 1, 2019
2
1
here is my story - have a kindle fire 8.9 won't boot stuck on logo screen - tried to restore no luck - downloaded v2.1 and unzip and ran but keeping getting error "'ping' is not recognized as an internal or external command,operable program or batch file." then no device found I would really like to try to get this working again. Any help would be much appreciated . I don't know awhole lot when it comes to the kindle fire software or how to reload things just when it works I love them...

kindle fire 8.9
windows 10 64bit

Open SR Tool.bat in a "plain text editor" (notepad, notepad++, etc) and delete the ping command at the bottom of the file (line 209). I am guessing this is there to provide the developer with some usage statistics...but it is crashing the script for you because the script isn't finding the windows ping command. I don't use windows and am not a batch script guy...so don't have more to add on that...but it should remove the error without breaking the core functionality.

OYvDqPw.png


This tool is just a batch script wrapping fastboot commands for convenience. The author has bundled fastboot, adb executable files and required libraries for convenience for users that don't have these already installed on their system.

In terms of device not found...that may be related to to the script erroring on ping...or it could be that the device isn't connected or in fastboot mode. I have read there are some issues with fastboot and USB 3...so make sure to use a USB 2 port or connect the kindle to a USB 2 hub plugged into a USB 3 port on your computer if you don't have USB 2 ports.
 

englishbob2

New member
Oct 14, 2013
3
0
Static boot logo problem

Hello, I'm hoping someone can help me get my Kindle back. :)
I've been happily running CM on my kindle and tried last night to restore the Amazon OS using this tool. Before running the tool I had ADB working and could boot into TWRP and fastboot mode just fine. I used the files from version 2.1 OS 8.1.4 of this tool.

I didn't run the tool on Windows 10, rather I can the commands from Linux and flashed the system.img using the fastboot command in the script. I then clear the user data and cache. I did not downgrade, i.e. I did not run the commands 'fastboot -i 0x1949 flash boot boot.img' and
'fastboot -i 0x1949 flash recovery recovery.img'.

All the commands completed without error.

After rebooting, the kindle is stuck on a static Kindle Fire logo. I can no longer get into TWRP by holding down the buttons on the kindle when powering on and I cannot get into fastboot using either windows 10 with the Kindle Drivers installed and driver signing turned off or from Linux. In linux the command shows 'waiting for device'. When I plug the usb cable nothing hapens and the command 'lsusb' does not show any new USB device.

What are my options at this point? Do I need to make a Factory cable or is there something else I can try through the command line?
 

mattpr

New member
Jan 1, 2019
2
1
What are my options at this point? Do I need to make a Factory cable or is there something else I can try through the command line?

I assume you are using Kindle Fire HD 8.9...just making sure since the images (system, boot, recovery) linked in the first post here are for that device.

Try this...

- connect a known good USB cable between the kindle and your computer.
- turn OFF your kindle by holding the power button until the screen goes black.
- execute command: fastboot getvar product
- you should see "< waiting for any device >"
- turn on the kindle and see if fastboot reports the device. If so, then the device is going through fastboot mode during startup.

In my case the KF was entering fastboot briefly on bootup and so I could run fastboot commands, then turn on the device and get stuff running.

In my case after the first fastboot command, the next fastboot command would not execute (hang) so I would power off the KF, enter a fastboot command (get waiting for device) and then turn the KF on. This allowed me to (slowly) flash the linked system image as well as the bootloader and recovery images linked in the first post. Make sure to flash all three and to erase user data and cache.

If that doesn't work then try different USB cable and port. There may be some issues with USB3 ports...so you can also try USB2 ports (via USB2 hub if necessary).

If you can't get fastboot mode, then you might need to order a "factory cable" for about 10 bucks to force it into fastboot mode.
 
  • Like
Reactions: englishbob2

englishbob2

New member
Oct 14, 2013
3
0
Wow! That was quick!

I assume you are using Kindle Fire HD 8.9...just making sure since the images (system, boot, recovery) linked in the first post here are for that device.

Try this...

- connect a known good USB cable between the kindle and your computer.
- turn OFF your kindle by holding the power button until the screen goes black.
- execute command: fastboot getvar product
- you should see "< waiting for any device >"
- turn on the kindle and see if fastboot reports the device. If so, then the device is going through fastboot mode during startup.

In my case the KF was entering fastboot briefly on bootup and so I could run fastboot commands, then turn on the device and get stuff running.

In my case after the first fastboot command, the next fastboot command would not execute (hang) so I would power off the KF, enter a fastboot command (get waiting for device) and then turn the KF on. This allowed me to (slowly) flash the linked system image as well as the bootloader and recovery images linked in the first post. Make sure to flash all three and to erase user data and cache.

If that doesn't work then try different USB cable and port. There may be some issues with USB3 ports...so you can also try USB2 ports (via USB2 hub if necessary).

If you can't get fastboot mode, then you might need to order a "factory cable" for about 10 bucks to force it into fastboot mode.

Wow, that was quick. Thankyou very much! I was using a different cable. I'd originally flashed upstairs using one cable and had gone downstairs and was using a different cable.

Using the 'upstairs' cable it immediately sprung into fastboot mode and I reflashed system, boot and recovery; wiped and rebooted and I'm running the stock OS again!

Many, many thanks for a) replying so quickly and b) providing clear instructions on how to fix the problem!

Best wishes for 2019!
 

leomogar

Member
Oct 12, 2013
8
0
Hi! I'm triying to bring back to life a KFHD 8.9 which is in a boot loop, it has TWRP and cyanogenmod, I installed adb drivers from Amazon website but can't get adb to find it.
I'd really appreciate any help.

Thanks in advance
 

Top Liked Posts

  • There are no posts matching your filters.
  • 36
    THIS IS NOT A CUSTOM RECOVERY!!!
    KINDLE FIRE HD 8.9 ONLY!!! USE AT YOUR OWN RISK!!


    This is an update to the KFHD_SRTool, now for use with the Kindle Fire HD 8.9
    This is ONLY for use with 8.9" models, not for use with 7" unless you replace system.img with your own backup.
    A factory cable is not needed to enable fastboot on this model. Even if the device is in a loop and ADB can not recognize it. I have personally put my device in a loop to confirm it works. To enable fastboot use option 1 from the tool

    Instructions:
    1. Download and unzip the tool of your choice from the link below (I have confirmed you can downgrade from 8.1.4 to 8.1.3)
    2. Run SR Tool

    That's it, wait for the tool to finish. Be patient this can take a few minutes. To exit fastboot use option 6 or hold down the power button for 10-20 seconds. When you reboot the first time it may seem to loop once but this is normal and will boot up. Once again be patient, especially if you chose to erase cache and userdata. The system needs to rebuild those partitions. Hope this helps some of you in the community. Again sorry for the size of the download, this is why I made this a separate tool instead of combining it with the HD7 version.

    Downloads:
    KFHD_SRTv2.1- 8.1.4
    KFHD_SRTv2.0- 8.1.3
    KFHD_SRTv1.3- 8.1.2

    UPDATES:
    12-24-12
    System v8.1.4
    12-12-12:
    System backup from v8.1.3 KFHD_SRTool_v2.0
    Option menu has changed
    New options: Install of GoogleServicesFramework.apk, enable fastboot with device powered on or off.
    Option 4 removed due to new option of enable fastboot

    DOWNGRADE:
    I no longer own this device so I cannot make backups of newer system versions, for the time being here are instructions for downgrading to 8.1.4:
    1.) Download boot and recovery imgs(these are backups from 8.1.4) from this LINK and place in the folder where you have access to fastboot or inside the KFHD_SRTool_v2.1 folder
    2.) Use KFHD_SRTool_v2.1 to flash system.img.
    3.) Erase userdata and cache
    4.) Open a cmd prompt from the folder where you placed the previously downloaded .img's.
    Use these cmds:
    Code:
    fastboot -i 0x1949 flash boot boot.img
    fastboot -i 0x1949 flash recovery recovery.img
    5- Reboot.


    Thanks to mdblaze for bringing to my attention that a factory cable is not needed with this device
    Again Thanks to kinfauns for the how to on backing up and restoring system software.
    5
    Onemeilia:
    would you be able to post an unmodified system image for restore back to stock?
    Is it already there and I'm missing something?

    There is no way to make a system.img backup without being rooted. If you use the option with su binary/superuser.apk only, it is as close to stock as you can get. To get to completely stock you would just need to move superuser.apk from system/app folder to data/app folder, then go to system/xbin folder and delete the su files. After this do a factory reset and you'll be back to stock.
    3
    Thank you for adding the 8.9 to your tool onemeila. I appreciate the work you've done.

    I can confirm this does work to fix an hd stuck on the kindle fire logo. Thanks again.
    3
    I'm caught in the same issue, and like an idiot, I didn't back up my recovery, is there anyway I can get back to it? can someone else just back up their recovery and I could flash that?

    Yes you should be able to flash the stock recovery and boot.img's from anyone. Heres a link for those from 8.1.4:
    https://docs.google.com/folder/d/0B4lZEJI5lYeMckl3aGZlY05VTWs/edit?usp=sharing
    2
    Is this one version 8.1.2 or 8.1.3?
    Need a rootable.

    The backup was done right out of the box after root, so it would be as close to factory as possible. It should be 8.1.2, but 8.1.3 is rootable also. I lost root after the update and was still able to root.