How to unpack evo boot image? - EVO 4G Q&A, Help & Troubleshooting

I'm trying to figure out how to unpack and repack the evo's boot image. I found the "HOWTO: Unpack, Edit, and Repack Boot Images" thread in another forum using the search function but when I tried to use the scripts to unpack the boot.img file I received an error as follows:
Found a secondary file after the ramdisk image. According to the spec (mkbootimg.h) this file can exist, but this script is not designed to deal with this scenario.
The HOWTO thread I found mentioned that this was likely a second stage loader but indicated that it has not been seen on any system to date. This second stage loader had apparently only been defined in the mkbootimg.h file but not implemented as of the time this how to was written.
Can anyone provide a link to instructions on how to extract and repack the boot.img for the EVO? I'd like to make a few changes to the default.prop in the ramdisk of the default boot.img file and instructions would be greatly appreciated.

I use dsixda's kitchen
http://forum.xda-developers.com/showthread.php?t=633246
that allowed me to unpack it. I remember the error you speak of but I forget what script I was using

elegantai said:
I use dsixda's kitchen
http://forum.xda-developers.com/showthread.php?t=633246
that allowed me to unpack it. I remember the error you speak of but I forget what script I was using
Click to expand...
Click to collapse
This worked for me perfectly.
Thanks very much for the pointer!

Related

[How to] Rom cooking

Original post:
Hello,
I am new to android but not to linux. I used to tweak my winmo phone rom.
I have backed up my device with nandroid. I just need some explanations:
- why isn't the radio extracted?
- how can I "extract" does .img files to modify and then rebuild them?
I found some informations of what the .img files contain here: ROM Partitions it should be the same for Hero
I have found some informations on how to push updates to the rom by looking at modaco updates. It seems quite simple to delete/copy files on the hero rom using an update-sript file. I am however curious about the RSA cert and if some files need to be signed.
Any information welcomed.
Regards
Click to expand...
Click to collapse
How to
Extract NAND image files
To extract .img files, I have found unyaffs from 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 but haven't tried as custom recovery images on the forum are great.
Rebuild system.img
Seems 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 <workdir>
- create folder structure for test.apk (<workdir>/system/app) and copy the test.apk
- create folder structure for update-script (<workdir>/META-INF/com/google/android)
- edit <workdir>/META-INF/com/google/android/update-script
- put in it:
Code:
show_progress 0.1 0
copy_dir PACKAGE:system SYSTEM:
set_perm_recursive 0 0 0755 0644 SYSTEM:app
show_progress 0.1 10
- compress the <workdir> content to zip (not the <workdir> folder itself)
Now you are going to sign the zip file. Download attached testsign.zip and copy it in your <SDK>/tools folder. Extract it here. It should create a sign subfolder with a testsign.jar file in it.
Then, from <workdir> folder, do:
java -classpath <SDK>/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.
ODEX files
- What are those Odex files? Answer.
- How to get rid of them?
Odex files depend on framework they are made for. To deodex an odex file use that how to
Then you may create a classes.dex file by executing the smali program on the "out" folder. You then rename it to classes.dex and add it to the .apk.
- How to create them?
Use dexopt-wrapper on device.
Porting an other device's rom
Well, that part is easy
- 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
It should run place and make calls but probably won't have Wifi, BT, trackball support. If you make those work: tell me, but I think we should wait to be able to compile a 2.6.29 kernel to have those.
Tools
Androsign script (linux)
I wrote that androsign script to quick sign zip files. Just put it in your <SDK>/tools folder, then chmod +x. If you have put the tools folder in your PATH, you can call it directly like this:
androsign /dev/folder1/folder2/update.zip (or any zip/apk file)
It will output an update-signed.zip (or app-signed.apk etc) in the same folder than original file was in.
Notes
Note1: thanks
Thanks to every guy that helped me found all that.
Note1: sharing
I searched for hours, so I am more than happy to share it to save someone's time. I am just disappointed than some people here do not have that spirit: I could have use those hours for development instead of research...
Note3: corrections
So, if you found anything incorrect, would like to supply more informations or want to correct my bad english: just PM me.
To find
- how to dump radio from device
- how to build a custom hero kernel (waiting for HTC sources)
To come
How to prepare your own kitchen and useful scripts (linux)
gecka said:
I am new to android but not to linux.
Click to expand...
Click to collapse
Same here. I do lots of tweeking on my linux machine, so i know quite a lot of linux. If there would be anyone to answer those questions by gecka, I might start tweeking the rom (maybe someday cook one up)
Best regards
Hello,
First post edited, but still some ignorances... Please share if you know anything.
Best regards
unpack and pack boot.img and recovery.img
First you need utilities such as mkbootfs and mkbootimg. maybe you can find them online (i can upload them later compiled for linux x86-64) but i suggest you download android source (http://source.android.com) and do a generic make. In this way you have these and other utilities(tools to pack system.img too, but if you haven't an engineering bootloader you can't flash it directly) in /out/host/... (it's better if you add this in your PATH)
To unpack and pack boot and recovery, read here:
http://forum.xda-developers.com/showthread.php?t=443994
or here:
http://android-dls.com/wiki/index.php?title=HOWTO:_Unpack,_Edit,_and_Re-Pack_Boot_Images
...or...
(I have attached extract-kernel and extract-ramdisk scripts from JF build environment) :
to unpack (boot.img or recovery.img, i'm writing the commands with boot.img):
Code:
extract-kernel boot.img
extract-ramdisk boot.img
at this point you have
boot.img-kernel
boot.img-ramdisk
to repack (boot.img or recovery.img):
For hero you need to specify the base address because it's different (0x19200000). For more information: http://forum.xda-developers.com/showthread.php?t=541522.
Code:
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
Useful resources for android modding are the dream forums (most of the concepts/hacks works for hero too):
http://forum.xda-developers.com/forumdisplay.php?f=448
(informative thread here: http://forum.xda-developers.com/showthread.php?t=519523)
note: mkbootimg with --base support is in donut and master (or find the patch on gerrit and apply it to cupcake)
First of all, the reason you cant unyaffs anything other than system.img is because they aren't YAFFS images. boot/recovery is kernel+initrd like in any normal linux bootimage scenario (see more below).
Tofind
- how to dump radio from device
Click to expand...
Click to collapse
Haven't gotten into that myself yet, but I know modaco posted an update.zip with radio image included on this very forum. Look for it.
- how to extract NAND images other than system.img
Click to expand...
Click to collapse
http://forum.xda-developers.com/showthread.php?t=443994
- rebuild NAND images such as system.img
Click to expand...
Click to collapse
This isn't hard, just loopback mount an image on your linux box and format it with YAFFS.
Building a custom kernel and recovery binary
HTC hasn't yet released the changes they have made to the hero/dream/magic kernels, 32A board, so you can't just compile a kernel from the AOSP. I haven't tried it yet but this patch might work on hero too:
http://forum.xda-developers.com/showthread.php?t=548061
EDIT: HTC Sources for dream and magic at http://developer.htc.com
For building a custom recovery, it's better if you use cyanogen's recovery code, found in his git : github.com/cyanogen, because it already has menus for nandroid and other tools, but you can use the recovery code from AOSP too (cyanogen's one is a patched version with a lot more features, http://forum.xda-developers.com/showthread.php?t=523558). To make a custom recovery you need to change the recovery binary (because the press event of the hero trackball has a different keycode, 191), the kernel and the init scripts. Actually i don't remember what else I've changed to make cm's recovery working with hero (the recovery that we are actually using here), I'm at work now, but i'll check later and post more details, or you can just unpack the recovery and see the changes .
First post updated.
Nandroid only backs up the partitions in the main storage nand, but radio and spl are flashed to the radio's own nand flash. Whether it's possible to dump it or not I don't know, but honestly, I don't see why you'd want to. Radio images are available through RUU's and I don't think editing would be an easy task
jubeh said:
Nandroid only backs up the partitions in the main storage nand, but radio and spl are flashed to the radio's own nand flash. Whether it's possible to dump it or not I don't know, but honestly, I don't see why you'd want to. Radio images are available through RUU's and I don't think editing would be an easy task
Click to expand...
Click to collapse
Sometimes, new radio images appear on new phones. That is why I am looking on a way to extract it.
very useful thread.
Very nice tutorial, thank you!
could you please specify a bit more on how to clone from android's git and then build the mkbootimg and mkbootfs (just make, right)? I tried and I keep getting a "fatal:server dumped connection" error
Are we able to modify an official ROM (also for hero). Which shows up in RUU as INFOsignature checking... failed. Am I able to change the kernel and make it work?
jubeh said:
could you please specify a bit more on how to clone from android's git and then build the mkbootimg and mkbootfs (just make, right)? I tried and I keep getting a "fatal:server dumped connection" error
Click to expand...
Click to collapse
What command do you use?
In fact i won't be able to explain you better than that page: http://source.android.com/download
Following that how to, you'll be able to sync an android branch You can learn more about git, branches and more here (Repo and Git resources)
The sync is long (2.9Go). Then, to build mkbootimg and mkbootfs, you should do a generic build of android going to source folder and issuing the 'make' command.
All that will be part of my upcoming "How to prepare your own kitchen and useful scripts".
awsy44 said:
Are we able to modify an official ROM (also for hero). Which shows up in RUU as INFOsignature checking... failed. Am I able to change the kernel and make it work?
Click to expand...
Click to collapse
Well, to grep the system from a windows RUU exe file you should launch it and then look in your user temporary folder for a rom.zip file in a {uid} subfolder. It contains the system and boot img files.
You then need to make an update.zip package from them. Have a look to someone's hero custom rom and to it's update-script to see how it is achieved. My 'How to' gives you all you need to understand update.zip packages and to extract system.img.
If you are porting a Hero rom, no need to change the kernel.
Regards
Well, to grep the system from a windows RUU exe file you should launch it and then look in your user temporary folder for a rom.zip file in a {uid} subfolder. It contains the system and boot img files.
You then need to make an update.zip package from them. Have a look to someone's hero custom rom and to it's update-script to see how it is achieved. My 'How to' gives you all you need to understand update.zip packages and to extract system.img.
If you are porting a Hero rom, no need to change the kernel.
Regards
Click to expand...
Click to collapse
Thanks so much for this amazing information, however how do i stop getting hit with the infosignature failed error? is that the kernel or the hboot? it says 12 signature verify error.
Oh, I do have the source and I am running my own donut build on my dream with some of my spice, but the problem I was having was cloning that exact project (mkbootimg) from android.git.kernel.org using git, but when I read what you said, I remembered that when you make the build, it also compiles several tools and i overlooked checking the out folder for it, kind of dumb on my part since I had already pulled the fastboot tool from that build and added it to my own bin, i guess mkbootimg and mkbootfs should be there too, right?
i tried running androsign and got this error
Code:
[email protected]:~/android/dev/sdk/tools$ ./androsign META-INF.zip
Exception in thread "main" java.lang.NoClassDefFoundError: testsign
Failed!
[email protected]:~/android/dev/sdk/tools$
if i use a ROM of one device on an other different device, I think I must build a kernel on my own, is that correct?
but what config should I use? a config from my current running ROM? then I think I must make it suitable for new ROM, what options should I care about?
for example, if I want to run a AOSP 2.01 ROM ( system.img) on a Magic 32A device with SPL 1.76, and now I am running a SenseUI ROM which kernel is 2.6.27, I think I should build a 2.6.29 kernel from the git tree, and ensure it will work with camera/bt/wifi/trackball of my device properly first .
how can I make this step successful?
other hand, the dynamic lib files(.so) with the system.img can be incorrect. so, I may need to build them too for pairing with the kernel I built in previous step. I think applications will work properly because they only care about if the interfaces of kernel and lib is correct. for that, also there some config job (like build.prop, etc) to do, is there a list of all of these jobs? and what values can I refer to? the original ROM (Magic 32A SPL 1.76 working ROM here) ?
am I right? what should i do and what are in those steps? are there some doucments I can read from?
Thanks for the good summary. Just one question, where did testsign.jar come from? I'd like to get the source. Thanks!
JackZero said:
Thanks for the good summary. Just one question, where did testsign.jar come from? I'd like to get the source. Thanks!
Click to expand...
Click to collapse
Read this !
http://www.androiddevelopment.org/tag/apk/
;-)

[KERNEL] Any Kernel Updater (Moded for eMMC)

I have just edited the AnyKernel updater script by koush to work with eMMC devices :-D
hope ppl can make use of this
its very simple
1) grab the .tar.gz file
2) extract
3) add the zImage to the /kernel/ directory
4) add .ko modules to /system/lib/modules/ directory
5) **optional** change the boot partition location in the updater-script (not normaly needed)
6) zip up the file
7) its ready to flash in CWM
Credits
Koush for the original boot unpack / repack bin's and scripts
IEF for the stand alone dd binary
what does it do?? sorry
does it make so you can update thru your network?
Thank you! This will be useful to me.
Nice, this is exactly what we needed.
Sent from my HTC Vision
Thanks!! I can finally make an Update.zip for my kernel!
nice work.
Now any kernel devs. can easy make a update.zip
G1_enthusiast said:
what does it do?? sorry
does it make so you can update thru your network?
Click to expand...
Click to collapse
Classic...lol
Why do ppl who have no clue even post stuff like that?
Thanks Apache this will come in handy.
Sent from my HTC Vision using XDA App
any chance to rip bootimg.cfg through the zip file?
since somehow I tried to get the cfg file from the boot.img but seems the boot.img and zImage in some kernel are the same.

[Q] Help with building stock kernel

I would like to learn how to build stuff for my tmobile s2. I figured I should try to build the stock kernel first to get my hands dirty. I have been following this guide here: http://forum.xda-developers.com/showthread.php?t=1442870
Unfortunately it is for the Epic Touch 4G, but I think a lot is similar. I have several questions regarding building a kernel for the T989:
1) How can I extract the initramfs from a stock boot.img?
2) The guide from the link above tars a zimage file. Does this need to be boot.img for the T989?
Thanks.
Below I have posted what I have done so far in trying to compile a kernel for the T989, in case anyone else is also learning like me.
I am using Ubuntu 10.10 32-bit
1) Download T989 source code from here: https://opensource.samsung.com/reception/receptionSub.do?method=search&searchValue=SGH-T989 (download the T989 version for TMobile)
2) unzip SGH-T989_GB_Opensource.zip
3) extract SGH-T989_Kernel.tar.gz
4) next you need to get a version of the initramfs. I got it off of my phone using clockworkmod backup (boot.img file) and following this guide to extract the initramfs: http://www.freeyourandroid.com/guide/extract-edit-repack-boot-img-windows
5) Download arm toolchain here (I use version 2010.09): https://sourcery.mentor.com/sgpp/li...09-51-arm-none-eabi-i686-pc-linux-gnu.tar.bz2
6) extract toolchain
7) Setup cross compile script (run before doing compiles) (change CROSS_PATH for your setup):
cross-compile.sh:
BINVERSION=arm-2010.09
export ARCH=arm
export CROSS_PATH=~/android/toolchains/${BINVERSION}/bin/
export CROSS_NAME=arm-none-eabi-
export CROSS_COMPILE=${CROSS_PATH}${CROSS_NAME}
export CC=${CROSS_NAME}gcc
export CXX=${CROSS_NAME}g++
export LD=${CROSS_NAME}ld
export STRIP=${CROSS_NAME}strip
PATH=${CROSS_PATH}:$PATH
8) Compile script (modify CONFIG_INITRAMFS_SOURCE to point to your initramfs) :
source ../scripts/cross-compile.sh
cd kernel
make clean
make mrproper
make msm8660_celox_usa_tmo_defconfig
make modules
make -j5 CONFIG_INITRAMFS_SOURCE=../initramfs
9) The kernel image is in "arch/arm/boot/zimage"
10) *** Question: How do I make the zimage "odin" compatible
This is still not complete (Steps 10 is unsolved). I need to make the build image odin compatible.
If anyone knows of a kernel building guide that exists for the T989 please post here.
Thanks.
You should pm the devs that posted their kernels in the dev section. Im sure they would love to help. Even exchage google talk or google + with each other to get quicker answers.
sent from the Dark §¡3€
I noticed you hit up the e4gt thread so I came here to see If I can help. If you have Irc I can walk you thru It all the way. I lost all my data today so my machine is down for building. im on freenode #evervolv ...
interloper, thanks for the kind offer. Please let me know when your machine is up and running. Hope to hear from you. Thanks again.
This is the script you want to use to extract the initramfs http://forum.xda-developers.com/wiki/Extract_initramfs_from_zImage
It works for the E4GT without modification so it should work for you guys without modification.
dtm_stretch,
Thanks for the extract script. The script does not work when I try to extract the initramfs from a boot.img I got from doing a backup with clockworkmod. It only manage to extract two empty folders: "dev" and "root"
However, the script does work when I tried it on a zImage I built myself. With the kernel I built I used the initramfs provided at: https://github.com/bubby323/anomaly_kernel_platform_SGH-T989/tree/master/initramfs
I know I can use the initramfs at the github but I really would like to learn how to get it myself so I can apply to other phones later. The knowledge is more important to me.
Thanks.
I was able to extract the initramfs from the boot.img (cwm backup of my phone) using the tools at this site: http://www.freeyourandroid.com/guide/extract-edit-repack-boot-img-windows
Now my only problem is making a odin compatible (flashable) kernel from the compiled zImage. Is it as simple as renaming zImage to boot.img and then put it in a tar to flash with odin? The only reason why I am not certain is my zImage is only about 5megs while the boot.img is 10megs. It seems like the boot.img is a disk copy of the flash partition for the boot on the phone. Do I need to use dd to copy my zImage into boot.img?
I know I make no sense. Hopefully with this last step I have it all down (at least for creating a kernel, rom is next). Please help a noob. Thanks.
datzstr8 said:
I was able to extract the initramfs from the boot.img (cwm backup of my phone) using the tools at this site: http://www.freeyourandroid.com/guide/extract-edit-repack-boot-img-windows
Now my only problem is making a odin compatible (flashable) kernel from the compiled zImage. Is it as simple as renaming zImage to boot.img and then put it in a tar to flash with odin? The only reason why I am not certain is my zImage is only about 5megs while the boot.img is 10megs. It seems like the boot.img is a disk copy of the flash partition for the boot on the phone. Do I need to use dd to copy my zImage into boot.img?
I know I make no sense. Hopefully with this last step I have it all down (at least for creating a kernel, rom is next). Please help a noob. Thanks.
Click to expand...
Click to collapse
Sorry for not replying sooner, but if you want to create a flashable tar in terminal
Code:
# cd /where/your/zimage/is/located
# tar cvf whateveryouwanttocallyourkernel.tar zImage
or you can just use a zip that already flashes a kernel and swap out the zimages.
I was able to successfully build my kernel and flash it to my phone. I needed to use mkbootfs and mkbootimg to combine my zImage and ramdisk to make boot.img. I will post a tutorial up in the development section and will link it here when I am done. Hopefully it will help all the noobs like me get their feet wet. Stay tuned.
update:
here is the link to the guide: http://forum.xda-developers.com/showthread.php?p=22941057#post22941057
ODIN .tar
I advise all of you to learn bash scripting. With bash scripting or pearl you can automate this entire process. Also create a cheat sheet text document with long but common commands, git command reminders and things like that. These commands should create your ODIN .tar file. First cd to the directory the junk is in then:
Code:
tar -H ustar -c factoryfs.rfs cache.rfs modem.bin zImage boot.bin recovery.bin param.lfs sbl.bin > myOdin.tar
That makes the tarball
Then:
Code:
md5sum -t myOdin.tar >> myOdin.tar
That does the MD5 sum
Then:
Code:
mv myOdin.tar myOdin.tar.md5
That sign the tarball with the MD5 sum
You should be able to ODIN that .tar. Now, for the first command you can replace whatever files you want tarred with what I put. If you only want the modem.bin specify that only, etc.
Another word of advice is to find helpful helpful Nautilus scripts to ad to the right click context menu for time saving simple operation. Google it and you find several good resources. Also, if you look, there are Nautilus scripts that can be added to zip and sign .zip and .apk files to make that faster and easier.
Be careful out there and good luck.

[HELP] Can anyone help me recompile this boot.img?

Hi all,
I've been trying to edit a stock boot.img's ramdisk so that I can get proper rw access in USB debugging.
I've successfully
1. unpacked the img.
2. edited the default.prop file to ro.secure=0 and all other variables to 1
3. repacked the ramdisk
But I still can't repack the ramdisk and kernel into the new boot.img!
I've tried using the android kitchen, repack-bootimg.pl and mkbootimg, both in cygwin and a virtual machine running Ubuntu 12.04.
everytime mkbootimg gives an error, either "permission denied" or "no such file or directory"
I'm gonna attach the kernel gz and the edited and compiled ramdisk gz, as well as the boot.img (just in case).
Could someone please repack them into a new boot.img for me?
Many thanks!HelpingEhsan.rar
Hi Ehsan,
Here is a recompiled boot.img. and an analysis of your boot.img. I hope this works for you.
OMG
Wow! I was looking through my old posts and found your epic reply and documented study! I did eventually get it to work back then, but reading this, a year later, after having earned my salt in Android tinkering, have never read something so intriguing as the report you made. I wish I carried the weight of multiple accounts because one "thanks" isn't sufficient to express how grateful I am and how glad this has made me! You are a star!
k02a said:
Hi Ehsan,
Here is a recompiled boot.img. and an analysis of your boot.img. I hope this works for you.
Click to expand...
Click to collapse
Thanks for your encouraging words, I hope it helped you a little bit.

[Q] kernel packaging and boot.img creation

Okay, so I have created and modified my own kernel name BionicSheep and have done couple releases (check my signature for link). My main question is how do I create a flashable zip with a boot.img I have asked a few people and they told me to use the kernel kitchen or google, but this is the only problem I haven't been able to solve after googling daily for the past 4 days. I figured I would ask here.
The reason I would like a boot.img is because I know in order to modify the kernelsplash with my own logo, I need to be able to unpack the bootimage to get the ramdisk and modify an rle file. The problem is I have no idea how to first make this bootimage. I understand to make the bootimage you need a the zImage (kernel binary) and the ramdisk. I have the zImage but I don't know how to make/get a ramdisk.
Currently I have been using this described method of packing my kernel into a flashable zip. I am pretty sure it just packs my modules and zImage into koush's AnyKernel. Thanks for any help, I need it.
Also try my kernel out and leave feedback if you are so inclined! It really is appreciated

Categories

Resources