Introducing XDA:DevCon – A Conference For Developers By Developers
XDA Developers Android and Mobile Development Forum
Forgot your password?
 
Post Reply+
Tip us?
 
Lox_Dev
Old
(Last edited by Lox_Dev; 6th November 2009 at 12:41 AM.)
#1  
Lox_Dev's Avatar
Senior Member - OP
Thanks Meter 24
Posts: 323
Join Date: Oct 2007
Location: Kanaky-New-Caledonia

 
DONATE TO ME
Default [How to] Rom cooking

Original post:

Quote:
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
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)
Attached Files
File Type: zip testsign.zip - [Click for QR Code] (12.9 KB, 1857 views)
File Type: zip unyaffs.zip - [Click for QR Code] (4.5 KB, 1284 views)
File Type: zip androsign.zip - [Click for QR Code] (432 Bytes, 1659 views)
File Type: zip extract-*.zip - [Click for QR Code] (1.2 KB, 1752 views)
File Type: zip mkboot*-linux.zip - [Click for QR Code] (21.3 KB, 1167 views)
The Following 3 Users Say Thank You to Lox_Dev For This Useful Post: [ Click to Expand ]
 
oblika
Old
#2  
Senior Member
Thanks Meter 0
Posts: 61
Join Date: Jun 2008
Quote:
Originally Posted by gecka View Post
I am new to android but not to linux.
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
 
Lox_Dev
Old
#3  
Lox_Dev's Avatar
Senior Member - OP
Thanks Meter 24
Posts: 323
Join Date: Oct 2007
Location: Kanaky-New-Caledonia

 
DONATE TO ME
Hello,

First post edited, but still some ignorances... Please share if you know anything.

Best regards
 
enlightener
Old
(Last edited by enlightener; 15th September 2009 at 10:55 PM.)
#4  
Senior Member
Thanks Meter 0
Posts: 134
Join Date: Aug 2008
Location: Rome
Wink 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.ph...ck_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)

Attached Files
File Type: zip tools.zip - [Click for QR Code] (1.2 KB, 425 views)
It's all about choices
 
packetlss
Old
#5  
packetlss's Avatar
Senior Member
Thanks Meter 5
Posts: 220
Join Date: Aug 2009
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).

Quote:
Tofind
- how to dump radio from device
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.

Quote:
- how to extract NAND images other than system.img
http://forum.xda-developers.com/showthread.php?t=443994
Quote:
- rebuild NAND images such as system.img
This isn't hard, just loopback mount an image on your linux box and format it with YAFFS.
 
enlightener
Old
(Last edited by enlightener; 27th August 2009 at 09:42 PM.) Reason: htc sources released
#6  
Senior Member
Thanks Meter 0
Posts: 134
Join Date: Aug 2008
Location: Rome
Default 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 :P.
It's all about choices
 
Lox_Dev
Old
#7  
Lox_Dev's Avatar
Senior Member - OP
Thanks Meter 24
Posts: 323
Join Date: Oct 2007
Location: Kanaky-New-Caledonia

 
DONATE TO ME
First post updated.
Lox
Nexus4 - Galaxy Nexus - Nexus 7 - Asus Transformer Prime Infinity
Ubuntu 64bit

 
jubeh
Old
#8  
jubeh's Avatar
Senior Member
Thanks Meter 15
Posts: 1,259
Join Date: Mar 2009
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
Best reference thread ever: Learn to compile your own AOSP build (for sapphire, but applies to dream too)
 
Lox_Dev
Old
#9  
Lox_Dev's Avatar
Senior Member - OP
Thanks Meter 24
Posts: 323
Join Date: Oct 2007
Location: Kanaky-New-Caledonia

 
DONATE TO ME
Quote:
Originally Posted by jubeh View Post
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
Sometimes, new radio images appear on new phones. That is why I am looking on a way to extract it.
Lox
Nexus4 - Galaxy Nexus - Nexus 7 - Asus Transformer Prime Infinity
Ubuntu 64bit

 
hdubli
Old
#10  
Senior Member
Thanks Meter 6
Posts: 1,134
Join Date: Dec 2004
very useful thread.
Just too many devices, can"t list them here now
twitter : http://twitter.com/hdubli

 
Post Reply+
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

report this ad
Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Go to top of page...

XDA PORTAL POSTS

What Happened at Google I/O 2013 – XDA Developer TV

Unless you just emerged from a deep, dark, dank cavern under the Earth, you know … more

Forums Added for the LG Optimus G Pro and Sony Xperia Tablet Z

Not too long ago, we talked about how Sony was continuing its AOSP efforts on … more

Permanent Screen Off for the Visually Impaired

Most of us take the simple act of waking up our devices and having a quick glance at the … more

App Analytics, or the Death of the Independent App Developer

This is entry number one in a series of articles about tools for app developers, … more