Wednesday, February 29, 2012

Tech Blog: How to extract system.img

Tech Blog: How to extract system.img: "To extract .img files, visit http://code.google.com/p/unyaffs/ I have compiled it under ubuntu 64 (attached). Unyaffs works on system.img but on no other .img file"
To extract boot.img use attached extract-kernel.pl and extract-ramdisk.pl
# extract-kernel.pl boot.img
# extract-ramdisk.pl boot.img

Should work for recovery.img.

Rebuild system.img

You just need "to loopback mount an image on your linux box and format it with YAFFS".

But it is useless as because Hero's SPL does not allow flashing system.img directly. You should use an update.zip package for that. (read below)

Rebuild boot.img

After extracting your boot.img using attached extract-*.pl and tweaking it, in same folder run:
# mkbootfs boot.img-ramdisk | gzip > ramdisk-boot
# mkbootimg --kernel boot.img-kernel --ramdisk ramdisk-boot --cmdline "no_console_suspend=1 console=null" -o newBoot.img --base 0x19200000

Creating an update.zip package
Creating an update.zip package is quite easy in fact. For example, to add a (valid) test.apk package to your rom:

- create an empty folder
- create folder structure for test.apk (/system/app) and copy the test.apk
- create folder structure for update-script (/META-INF/com/google/android)
- edit /META-INF/com/google/android/update-script
- put in it:

- compress the content to zip (not the folder itself)

Now you are going to sign the zip file. Download attached testsign.zip and copy it in your /tools folder. Extract it here. It should create a sign subfolder with a testsign.jar file in it.

Then, from folder, do:

java -classpath /tools/sign/testsign.jar" testsign file.zip file-signed.zip

Ok, now your zip file is ready to be deployed using cyanogen recovery image.

To find more command to use in update-script, look at other's.

Modify .apk package
Seems it is easy to uncompress an .apk package (zip) an to modify files in it and then compress it. But after all: you must sign it like update.zip packages.


Porting an other device's rom

- extract the system.img
- extract boot.img
- replace boot.img-kernel with the one from your stock Hero rom one.
- rebuild boot.img
- build update.zip package (look someone's hero custom rom to see how to do it)
- sign and flash
'via Blog this'

No comments:

Post a Comment