Android - Flash boot.img without using fastboot USB

What needs to be done is to bundle the boot.img and construct a new zip file suitable for flashing via ClockworkMod or TWRP.

Pre-requisites:

  • a Linux environment that has the usual development packages, such as Java installed. (It can also apply to other platforms, just be careful that the instructions here indicating the path used below, uses a forward slash /, so flip that around to be a back slash \ for Windows environment especially!)
  • adb command line tool installed.
  • `testsign.jar' tool, for signing the zip file so that the recovery can authenticate and verify it is a valid archive otherwise recovery will report corrupt archive or similar.
  • update-binary command line application, that is internal for usage with the flashable script. (This can be found with any flashable zip, the important thing is to extract that binary and deposited in the structure of the directory as shown)
  • zip command line tool.

Assuming your directory is called workdir, for discussion, lets call this the working directory, copy the boot.img into that directory, and create the following directory structure - META-INF/com/google/android, this is important! And within the META-INF/com/google/android, copy the binary application called update-binary into that directory. So the directory structure should be like this:

+ workdir/
     +
     |
     +--+ boot.img
     |
     |
     +--+ META-INF/
              +
              |
              +--+ com/
                    +
                    |
                    +--+ google/
                           +
                           |
                           +--+ android/
                                   +
                                   |
                                   +--> update-binary
                                   |
                                   +--> updater-script

As for the updater-script, copy the contents of the following below:

ui_print("Please wait, boot.img being flashed...");
show_progress(0.1, 0);
assert(package_extract_file("boot.img", "/tmp/boot.img"),
       write_raw_image("/tmp/boot.img", "boot"),
       delete("/tmp/boot.img"));
show_progress(0.1, 10);
ui_print("It is now safe to reboot! :)");

Remember: Do not get confused here, the updater-script as shown, should be left alone and as-is, so do not try flip the forward-slash to a back slash if doing this under Windows environment.

Go back to the parent of the directory structure, i.e. outside of workdir and do the following, we're going to create a zip file from this:

zip -r my_custom_flashable_boot_unsigned.zip workdir/ which is a recursive function, this will zip up everything into the file called my_custom_flashable_boot_unsigned.zip.

Finally, to sign the zip file, issue this:

java -classpath testsign.jar testsign my_custom_flashable_boot_unsigned.zip my_custom_flashable_boot_signed.zip

Then its a matter of pushing that across the SDCard as in adb push my_custom_flashable_boot_signed.zip /sdcard/ and manually go into recovery and specify that zip archive (i.e. my_custom_flashable_boot_signed.zip) in which it will perform the flashing for you.


If you have the flash_image binary, then you can do it on device via terminal emulator (flash boot, then the rest using recovery).

Syntax: flash_image boot /sdcard/boot.img

Self Promotion Time

I have an app that provides a GUI for the binary. Find it here.

If you don't have that binary, it can be installed (Google it - you have to download it then copy it to the /system/bin folder.

This doesn't work on all devices, however it's the only way that springs to mind.