So I've recently rooted my phone and tried a ROM or two. I find it really handy that you can use TWRP recovery to install another ROM from the SD card, you don't need to have it connected to a PC.
However, on my device (HTC One S) I need to flash a different boot.img file for every ROM as well, so I still need to hook my phone up to my PC to switch ROMs. If I don't do this, it just gets stuck on the loading screen. Then I must use the command
fastboot flash boot boot.img
from the folder where boot.img is located.
Is it possible to flash this boot image with TWRP or any other way without using fastboot over USB?
Answer
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.
No comments:
Post a Comment