Messing about with fastboot on the HTC Hero Orange UK - Hero, G2 Touch Android Development

Hi, since this is my wife's HTC hero from Orange UK, I'm being particularly careful with it. I'm new to xda-developers/HTC platforms (but not new to doing horrible things to embedded platforms) :>
I've been messing about with the phone all evening - downloaded that ROM image from the other thread and pulled it apart to look at the OS files etc - the standard break-a-new-embedded-linux-platform routine.
Anyway, if you hold down BACK when powering on, it enters the bootloader mode with a "FASTBOOT USB" prompt, which sounded interesting. I got a copy of the fastboot binary, and extracted the kernel and the ramdisk images from "boot.img" in the "HEROIMG_Hero_HTC_WWE_1.76.405.1_R3_WWE_release_signed.zip" (using split_bootimg.pl).
Just as a quick test, I tried booting them with:
fastboot boot kernel.img boot.img
since the above just boots a kernel from RAM, and not actually flash it. Anyway, fastboot claims it downloaded and booted it ok, and the phone shows the "HERO" logo. Unfortunately that is as far as it gets. However, if I reset the phone, it boots perfectly fine from the kernel/ramdisk in flash (phew!)
Since it doesn't actually boot into android proper (and doesn't show up as a USB device), I don't know if (a) its showing the HERO logo, but failing the signature check, or (b) actually booting, but crashing 'cos the kernel/ramdisk aren't quite right. I'd guess (a) myself, but I'm new to messing with HTC bootloaders.
Anyway, in case they're useful, the details of the phone from the fastboot mode are:
HERO CVT SHIP S-ON
HBOOT-1.76.0004 (HERO10000)
MICROP-010f
TOUCH PANEL-SYN0104
RADIO-6.35.04.25
Jul 3 2009,15:22:21

That method of entering fastboot is the same as the magic. Check the magic / sapphire wiki and have a read as I suspect the magic is its closest relative and a lot of the magic stuff will work...
daisy xx

Aha, thank you very much, that gives me more information!
Anyway, I just tried booting the boot.img itself instead of splitting it up with:
fastboot boot boot.img
This time, it booted right into the full android! Checking /proc/config.gz:
On the phone booting normally, it says:
# Linux kernel version: 2.6.27
# Fri Jul 3 07:52:06 2009
On the phone booted with boot.img extracted from that zip, it starts:
# Linux kernel version: 2.6.27
# Thu Jun 25 14:16:01 2009
So it seems as though it can boot the boot.img: AFAIK config.gz is hardcoded into the kernel binary. Now: is there a signature in the boot.img file?

Erm, I'm either hallucinating from lack of sleep, or I appear to have a root shell on it now. e.g. I can see the contents of /data from "adb shell":
ps reports: [snip]
root 43 1 3332 164 ffffffff 0000e8f4 S /sbin/adbd
root 619 43 748 340 c005ef5c afe0d08c S /system/bin/sh
# ls /data/app
org.oep.pong.apk
com.google.android.stardroid.apk
se.illusionlabs.labyrinth.lite.apk
com.google.zxing.client.android.apk
com.innovativelanguage.wordpowerlite.jp.apk
com.funambol.android.apk
com.massorbit.sword.apk
com.soundroid2012.piano.apk
jg.entertainment.abook.four.apk
com.maplekeycompany.apps.shake.apk
net.peterd.zombierun.apk
All I did was
1) pull the boot.img apart with split_bootimg
2) gunzip the ramdisk
3) hexedit the ramdisk to set ro.secure=0 (couldn't be bothered faffing about with cpio)
4) gzip the ramdisk
5) rebuild the image with mkbootimg. Oh you need to specify a different base address. Example command line:
/tmp/mkbootimg --kernel boot.img-kernel --ramdisk boot.img-ramdisk.insecure.gz --cmdline 'no_console_suspend=1 console=null' -o test-insecure.img --base 0x19200000
Then I just booted it with "fastboot boot test-insecure.img"

adq said:
Erm, I'm either hallucinating from lack of sleep, or I appear to have a root shell on it now. e.g. I can see the contents of /data from "adb shell":
ps reports: [snip]
root 43 1 3332 164 ffffffff 0000e8f4 S /sbin/adbd
root 619 43 748 340 c005ef5c afe0d08c S /system/bin/sh
# ls /data/app
org.oep.pong.apk
com.google.android.stardroid.apk
se.illusionlabs.labyrinth.lite.apk
com.google.zxing.client.android.apk
com.innovativelanguage.wordpowerlite.jp.apk
com.funambol.android.apk
com.massorbit.sword.apk
com.soundroid2012.piano.apk
jg.entertainment.abook.four.apk
com.maplekeycompany.apps.shake.apk
net.peterd.zombierun.apk
All I did was
1) pull the boot.img apart with split_bootimg
2) gunzip the ramdisk
3) hexedit the ramdisk to set ro.secure=0 (couldn't be bothered faffing about with cpio)
4) gzip the ramdisk
5) rebuild the image with mkbootimg. Oh you need to specify a different base address. Example command line:
/tmp/mkbootimg --kernel boot.img-kernel --ramdisk boot.img-ramdisk.insecure.gz --cmdline 'no_console_suspend=1 console=null' -o test-insecure.img --base 0x19200000
Then I just booted it with "fastboot boot test-insecure.img"
Click to expand...
Click to collapse
You're ready to build your own rom images ;-)
You could start by preparing your own rooted recovery with nandroid.
For a quick and dirty basic recovery image, just download one from sapphire development forum, replace the boot.img-kernel with a working copy for your hero.
Then rename init.sapphire.rc in init.hero.rc in ramdisk image.
You can simply extract ramdisk image with:
mkdir boot.img-ramdisk
cd boot.img-ramdisk
zcat ../boot.img-ramdisk.gz | cpio -idv
make your changes to ramdisk files
search internet for a script named repack-bootimg.pl
add the new base parameter to mkbootimg line in the script
cd to directory where you unpacked your boot.img
repack-bootimg.pl boot.img-kernel boot.img-ramdisk newboot.img
fastboot your recovery
then you can use nandroid in the recovery image to make a full dump of your rom and use the newer version of boot.img you have in your device to rebuild an up-to-date recovery or any kind of rom (you could start by preparing a copy of your original rom by changing ro.secure=0 in both boot.img and recovery.img).
By the way, I noticed that kernel in HERO uses sapphire fixup. The currently available version on the net is not booting on sapphire (magic) 32A, but it resets after a few minutes.
Maybe the kernel version in your orange hero introduces compatibility with sapphire boards. Well, really I suppose it won't, but if you get a nandrod backup and post your current original boot.img, magic 32A board owners could give it a try while we are waiting for HTC to release updated kernel sources for Magic and Hero.
Bye
daldroid

adq said:
[...]
So it seems as though it can boot the boot.img: AFAIK config.gz is hardcoded into the kernel binary. Now: is there a signature in the boot.img file?
Click to expand...
Click to collapse
No, no signature in standard boot.img, you have to zip it and sign the resulting zip. But no signing keys except for test-keys are available to the public, so I suppose your spl (S-ON) wil not allow you to directly flash rom images from fastboot command line.
However it seems your SPL allows you to fastboot a repacked boot image, so it should not be a problem to use a recovery image to flash whichever rom mod you like.
I suggest you not to flash any SPL you can find on the net, I suppose you have the newest ad no image of your original SPL is available (there is one from a leaked hero image, but yours seems to be newer)
Bye

Yeah, my thoughts exactly, I'd rather not flash the SPL if I can help it: I don't fancy explaining to my wife why I have to rip her phone apart to find the JTAG contacts I'll upload the boot.img later though.
Thats odd about the reset after a few minutes thing: hardware watchdog timer of some sort?

adq said:
Yeah, my thoughts exactly, I'd rather not flash the SPL if I can help it: I don't fancy explaining to my wife why I have to rip her phone apart to find the JTAG contacts I'll upload the boot.img later though.
Thats odd about the reset after a few minutes thing: hardware watchdog timer of some sort?
Click to expand...
Click to collapse
Well, really it's a little bit mor than a minute or so.
I suppose it's not an hardware watchdog, I don't have access to console debug messages.
Really the reset is a good sign, if you try booting dream or sapphire 32b kernel on 32A boards, it hangs forever.
If you extract piggy.gz from the kernel and hexedit it,you can find hero kerel initializes the hardware using the sapphire fixup.
It could only be that htc reused the same source and fixed hardware details and forgot to change the fixup routine name or that they are prepare to build a kernel able to boot on both hero and magic 32A boards.
32A and hero use the same new base address for kernel and ramdisk loading 0x19200000.
our boards have more memory than dream and 32b boards.
I suspect htc is using a stacked ram configuration and they changed the init code for the number of banks in memory.
In 32A they changed ram location for fb, ram console and maybe gpu1. It was a real mess to guess every change, so I stopped recompiling and rebooting the kernel after a dozen of times ;-) Waiting for htc to release the patched source code ;-)
The radio rom on hero seems to be is newer than 32a's latest available but I don't want to try a flash, you know what I mean ;-)
The available hero SPL shoud work on sapphire (and on blackstone and topaz too) and maybe the newer radio rom requires it, but... I prefer not to brick my Magic.
Have a nice rom rooting time. You could want to give superuser.apk a try.
People on this forum is asking for rooting status on hero, I suppose you'll be able to announce them your succes in a short time.

Wow! That was Fast! Lol..... even thought there is still some work to do.

i feel honoured to have been one of the first to read this i still dont have a hero yet =[ gotta wait till august when i get my ema might start scrounging and saving what i can get so i can get it sooner
Well done to you sir what a fine job uve done, gz =]

I'm waiting for my Hero as well and I'm completely new to android.
But like you I develop for and work with embedded Linux systems so tearing ROMs apart was pretty much on top of my list when my device should arrive .
I don't know what the 'recovery' image does on Android systems, but as I read it like this: You can temporary boot a rom (or at least a kernel and it will get the rest of the system from the rom area) through the fastboot method.
So yes, then you have temporary booted into a rooted ROM. But how to make it permanent? Because if you modify the ROM and flash it back it will probably not work because it detects its modified, right?

Trying to make a "dirty recovery image" to dump full roms using Nandroid Backup
Hello Dalroid,
I read your post and was able to do the following:
1. Using split_bootimg, extract the ramdisk files from the Stock HTC HERO Rom found in the XDA forums.
2. I downloaded the cm-recovery 1.4 image from Sapphire and used split_bootimg on it as well.
3. I copied the extracted kernel from the HTC Hero ROM and replaced the one from the cm-recovery of sapphire.
4. I renamed init.sapphire.rc to init.hero.rc in the extracted recovery image folder.
5. This is where i have trouble. I am using the repack-bootimg.pl, but I am unable to repackage the image.
I did note that you stated that some base parameters needed to be changed in the script for this to work. Could you please shed some light on what I need completed in order to repackage. Thank you in advance.
EDIT: I found one problem so far, I do not have mkbootimg or mkbootfs on my computer. How do I get these on my computer?

JWallstreet said:
Hello Dalroid,
I read your post and was able to do the following:
1. Using split_bootimg, extract the ramdisk files from the Stock HTC HERO Rom found in the XDA forums.
2. I downloaded the cm-recovery 1.4 image from Sapphire and used split_bootimg on it as well.
3. I copied the extracted kernel from the HTC Hero ROM and replaced the one from the cm-recovery of sapphire.
4. I renamed init.sapphire.rc to init.hero.rc in the extracted recovery image folder.
5. This is where i have trouble. I am using the repack-bootimg.pl, but I am unable to repackage the image.
I did note that you stated that some base parameters needed to be changed in the script for this to work. Could you please shed some light on what I need completed in order to repackage. Thank you in advance.
EDIT: I found one problem so far, I do not have mkbootimg or mkbootfs on my computer. How do I get these on my computer?
Click to expand...
Click to collapse
I built my mkbootimg from android source code (android.git.kernel.org), but if you prefer you can find a prebuilt binary from http://rapidshare.com/files/249629878/PortTools.rar. I'm not the author neither I tested it, just searched for mkbootimg in forums and pasted the link for you.
If you use the standard mkbootimg, just add --base 0x19200000 the the mkbootimg line, otherwise the boot.img will be generated with standard load address which won't work for hero (or for my 32A Magic).

This is pretty exciting stuff
I really want to remove the SIM lock from the Hero - is this something you can do now you've got su access?
Is it going to be possible to have a 'how to' guide for the Hero to tell us what to do to get the phone unlocked?
I want to see someone install the Magic image on the Hero - it should fly with the extra RAM

Just out of curiosity, what would happen if I booted the original cm-recovery-1.4.img on the Hero?
My phone will hopefully arrive tomorrow, and the first thing I'd like to do is create a backup with the nandroid script.

wossName said:
Just out of curiosity, what would happen if I booted the original cm-recovery-1.4.img on the Hero?
My phone will hopefully arrive tomorrow, and the first thing I'd like to do is create a backup with the nandroid script.
Click to expand...
Click to collapse
It wont boot. You can instead use the modified(only trackball press event and kernel) cyanogen's recovery here: http://forum.xda-developers.com/showthread.php?t=541807&page=2

enlightener said:
It wont boot. You can instead use the modified cyanogen's recovery here: http://forum.xda-developers.com/showthread.php?t=541807&page=2
Click to expand...
Click to collapse
I'm new to all this, so I'd be grateful for some more information: is the Dream and Hero hardware too different to boot the same image? Or would it be possible to create multi-platform images?
I already downloaded the modified image from that thread and have extracted the same kernel, so I should be all set.

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/
;-)

How to make and flash a kernel from Official Htc Froyo Kernel sources?

Hi,
I have a branded Desire which have been first unbranded (goldcard), OTA updated to latest Htc froyo update, and then Unrevoked 3.21+S-off 1.5 by alpharev.
Now, i want to make my own kernel from htc sources.
I know linux (using Gentoo for years), but process to flash a new kernel on an android device is not clear for me.
Is this link ok for Desire?
http://htcevohacks.com/htc-evo-hacks/how-to-build-your-own-htc-evo-4g-android-kernel/
Regards.
Sent from my HTC Desire using XDA App
I followed Cyanogen wiki for building the HTC Kernel as I found the toolchain from Codesourcery threw errors when trying to compile.
Obviously with the CyanogenMod guide, I don't clone the kernel from their git, instead I untar the HTC source.
I would be interested in hearing your findings, if you do try and compile with that toolchain.
As for flashing the Kernel, I just use koush's AnyKernel - drop the zImage into the kernel folder and then compress and sign, to make a flashable zip.
Mekrel said:
I followed Cyanogen wiki for building the HTC Kernel as I found the toolchain from Codesourcery threw errors when trying to compile.
Obviously with the CyanogenMod guide, I don't clone the kernel from their git, instead I untar the HTC source.
I would be interested in hearing your findings, if you do try and compile with that toolchain.
As for flashing the Kernel, I just use koush's AnyKernel - drop the zImage into the kernel folder and then compress and sign, to make a flashable zip.
Click to expand...
Click to collapse
Yeah, basically this. It's pretty straightforward, it can just be a bit finicky sometimes.
Hi,
Thanks for answers.
Mekrel:
For the Sourcery compiler, I have same results as yours: errors and does not compile.
I believe HTC are working with the "google" toolchain, so their sources are not veryfied to work with another compiler.
Using the Cyanogen compile way ( with "google" toolchain), it does compile fine.
I'm happy to see this option in the kernel (Change Cpu Policy While Screen is ON/OFF), but I wonder why it is not activated by default... :
http://img833.imageshack.us/img833/3668/desiredefault.jpg
With changes made:
http://img145.imageshack.us/img145/3707/desiremodified.jpg
It would certainly be better than using SetCpu for me ( I'm using it just to force cpu at 245MHz when screen is off), and not need to hack HTC performance lock feature since I don't want to underclock or overclock my Cpu.
Now I just have to test it...but I do have few questions before doing that:
I can use koush's AnyKernel tool to flash my new zImage, but in case all goes wrong? How to revert back?
-->Can I save my actual boot.img in sdcard, and in case flash process goes wrong revert back to my actual boot.img?
Please help if possible with detailed process (or a web link but I have not being able to find a detailed process for Desire).
Regards.
Edit: Seems for me that Kouch's tool will not reuse my ramdisk, but another one?
-->I just want being able to modify my kernel, so I prefer to reuse ramdisk which is actually in my boot.img if possible.
-->I have tried this way: http://android-dls.com/wiki/index.php?title=HOWTO:_Unpack%2C_Edit%2C_and_Re-Pack_Boot_Images, but script provided on this link gave me error because my boot.img has a "Second Stage".
Judge584 said:
Hi,
Thanks for answers.
Mekrel:
For the Sourcery compiler, I have same results as yours: errors and does not compile.
I believe HTC are working with the "google" toolchain, so their sources are not veryfied to work with another compiler.
Using the Cyanogen compile way ( with "google" toolchain), it does compile fine.
I'm happy to see this option in the kernel (Change Cpu Policy While Screen is ON/OFF), but I wonder why it is not activated by default... :
http://img833.imageshack.us/img833/3668/desiredefault.jpg
With changes made:
http://img145.imageshack.us/img145/3707/desiremodified.jpg
It would certainly be better than using SetCpu for me ( I'm using it just to force cpu at 245MHz when screen is off), and not need to hack HTC performance lock feature since I don't want to underclock or overclock my Cpu.
Now I just have to test it...but I do have few questions before doing that:
I can use koush's AnyKernel tool to flash my new zImage, but in case all goes wrong? How to revert back?
-->Can I save my actual boot.img in sdcard, and in case flash process goes wrong revert back to my actual boot.img?
Please help if possible with detailed process (or a web link but I have not being able to find a detailed process for Desire).
Regards.
Edit: Seems for me that Kouch's tool will not reuse my ramdisk, but another one?
-->I just want being able to modify my kernel, so I prefer to reuse ramdisk which is actually in my boot.img if possible.
-->I have tried this way: http://android-dls.com/wiki/index.php?title=HOWTO:_Unpack%2C_Edit%2C_and_Re-Pack_Boot_Images, but script provided on this link gave me error because my boot.img has a "Second Stage".
Click to expand...
Click to collapse
You can backup via:
Code:
cat /dev/mtd/mtd2 > /sdcard/mtd2.img
Then you can use fastboot to flash boot:
Code:
fastboot flash boot mtd2.img
The guide you linked to doesn't recommend trying to split the boot.img from your phone (in this example, mtd2.img) due to possible corruption issues, which is why I went for Koush' AnyKernel.
So what you're saying is you can't get the ramdisk from your boot.img via:
Code:
% mkdir ramdisk
cd ramdisk
gzip -dc ../boot.img-ramdisk.gz | cpio -i
as this is the part that throws the error?
no, errors came from the perl scripts posted on the link http://android-dls.com/wiki/index.php?title=HOWTO:_Unpack,_Edit,_and_Re-Pack_Boot_Images
So to resume:
Code:
cat /dev/mtd/mtd2 > /sdcard/mtd2.img
will backup my boot.img but it may be corrupted
Code:
fastboot flash boot mtd2.img
will restore it but if it's corrupted then it's useless.
Why can it be corrupted?
Why not possible to flash this way, without the hassle of dealing with boot.img?:
Code:
fastboot flash zimage zImage
Edit:
OK, I have done some search: please confirm this procedure to be safe to flash a modified kernel:
1°)Make an Nandroid Backup
2°)Since my Desire is rooted and S-OFFed it does not need any-more signed files, so for me I just have to put my new wifi kernel module (bcm4329.ko) to /system/lib/modules/bcm4329.ko (via adb push)
3°And then flash the new kernel zImage in fastboot using this command:
Code:
fastboot flash zimage zImage
4°)Once done: I will have to power off my Desire.
5°)Then, Power it on again in bootloader mode, wait for 3 seconds and then go to fastboot: the zImage should now start flashing automaticaly.
6°)Once done: reboot to test my new kernel.
7°)In case something goes wrong, all I will have to do is to restore boot via my Nandroid backup and all will be fine.
If someone can confirm this procedure to be right and safe, thank you.
Best Regards.
Ok, my new kernel is ready.
Does someone can confirm that step 1 to 7 in previous post are corrects?
Sent from my HTC Desire using XDA App
The 7 steps you posted look about right - I'm not entirely sure about #3, I don't have much experience in fastboot flashing. You might be better off using AnyKernel and flashing that in recovery.
It works good!
Thanks a lot.
Sent from my HTC Desire using XDA App

Problem flashing custom kernel

We have the Ava-Froyo 2.2 ROM with stock kernel (I think).
We got the source for the new kernel and re-compiled it with a flag we need.
We are trying to flash the kernel using "fastboot zimage c:\zImage" and "fastboot kernel c:\zImage" but neither work. We keep getting sending 'zimage'... OKAY then writing 'zimage'... FAILED (remote: not allowed)
We can't figure it out.
I ran unrevoked3 latest and set S-OFF and bootloader confirms it is S-OFF.
Why can't I write to flash/kernel??
How else can I flash a custom kernel?
I have ClockWork Mod 2.5.0.1 installed.
I only found one thing which said something about unrevoked's method makes you lose some of the advanced fastboot functions????
You can flash kernels from the clockwork recovery just like you would flash a rom. Just do it after you flash the rom of choice.
Sent from my PC36100 using XDA App
OK, but it looks like I can't just drop zImage on the SD and get CWM to flash it. It looks like I have to put it in an update.zip or something. Any ideas how to make one for my new zImage file?
Any other thoughts on how I could fastboot flash zimage w/out it complaining of out of memory or whatever?
Thanks in advance!!
why in the world are you doing it this way? simply create a flashable zip and flash it like you would a ROM
t3project said:
why in the world are you doing it this way? simply create a flashable zip and flash it like you would a ROM
Click to expand...
Click to collapse
+1 I agree with this guy. just create a flashable zip and voila.
Is this how you guys do that?
Step 7 - http://forum.androidcentral.com/htc...how-build-your-own-kernel-package-source.html
1. You probably don't have the eng bootloader that allows you to use fastboot.
2. Get any custom kernel in zip package, open it, delete everything you don't need and insert your zimage where the custom kernels zimage is. Keep the "kernel" and "META" directory and just replace your zimage in the kernel directory in the zip.
At the risk of sounding like an I ass I have to ask, how do you not know how to use fastboot or make an update.zip yet you managed to recompile the kernel? That one just goes over my head.
Well I didn't recompile the kernel, BUT I have re/compiled kernels for ~16 years so I know that part pretty well.
I just expected fastboot to work. I think my comment about unrEVOked borking fastboot is accurate then if you agree about the Eng loader.
I will grab a kernel zip and put that in. I saw these kernel scripts in one of them so I was thinking it is a lot of work to make that put, but what should my kernel script look like or do I really need one (this is in the .zip I update)..
IPvFletch said:
Well I didn't recompile the kernel, BUT I have re/compiled kernels for ~16 years so I know that part pretty well.
I just expected fastboot to work. I think my comment about about unrEVOked borking fastboot is accurate then if you agree and the eng loader.
I will grab a kernel zip and put that in. I saw these kernel scripts in one of them so I was thinking it is a lot of work to make that put, but what should my kernel script look like or do I really need one (this is in the .zip I update)..
Click to expand...
Click to collapse
I said it was at the risk of sounding like an ass and at least you came through and said you have re/compiled kernels before.
ENG bootloader would be my best guess as to why your fastboot is not working. I rooted with unrevo.forever and my fastboot works AFTER I replaced the bootloader.
If you use a zip package from a custom kernel like netarchy or kingklick the script is already there along with the scripts needed to install the kernel. You just have to place your zimage where that kernels zimage is and the scripts handle everything.
EDIT: I didn't make the zip but it should help you in the "write" direction (pun intended).
Examine the contents and the updater-script file.
How did you replace the bootloader after?
Ok so I got the HTC stock kernel 3.26 zip and I pulled out boot.img and replaced it with my zImage file renamed to boot.img. The update-script looks like it has no other major dependencies, the module is in the zip still, that stock one is Ok for me.
Code:
assert compatible_with("0.2") == "true"
show_progress 0.1 0
format BOOT:
copy_dir PACKAGE:system SYSTEM:
set_perm_recursive 0 0 0755 0755 SYSTEM:lib/modules
write_raw_image PACKAGE:boot.img BOOT:
show_progress 0.1 0
So.... here goes (via CWM Recovery)...
Crap what did I do wrong. It won't boot now, it goes into bootloader all the time.
Here's the zip I just tried...
IPvFletch said:
Crap what did I do wrong. It won't boot now, it goes into bootloader all the time.
Here's the zip I just tried...
Click to expand...
Click to collapse
Check my last post before this. You're problem is you tried to install it as a boot.img file and the boot.img file holds the system image as well as the kernel.
To install a kernel alone it has to be a zimage file and installed differently.
I pushed the original htc-froyo-stock-kernel-signed.zip kernel update just now and it is booting again.
Gonna guess something to do with the signed zip yet unsigned kernel boot.img?
How can I fix my zip with my new zImage?
lovethyEVO said:
Check my last post before this. You're problem is you tried to install it as a boot.img file and the boot.img file holds the system image as well as the kernel.
To install a kernel alone it has to be a zimage file and installed differently.
Click to expand...
Click to collapse
OK I kind of thought that but didn't know. I know boot.img is the whole boot partition not just the kernel image. doh. :]
Ok back to YOUR/koush kernel installer .zip...
The update-script has no mention of zImage though, so do I need to do more than just dump my zImage into this zip? EDIT: Guess so got error 6 it aborted.
IPvFletch said:
OK I kind of thought that but didn't know. I know boot.img is the whole boot partition not just the kernel image. doh. :]
Ok back to YOUR/koush kernel installer .zip...
The update-script has no mention of zImage though, so do I need to do more than just dump my zImage into this zip? EDIT: Guess so got error 6 it aborted.
Click to expand...
Click to collapse
Check the updater-script. You will see what happens in the process.
If anything, send me your files and I can test install them onto my system.
OK so it dumps system and kernel into temp folders. For kernel it goes through the entire folder and sets perms 4 of the 5 files (excluding zImage) and then runs dump_image. This I guess is smart enough to pick up zImage and dumps it all into a new boot.img. Then eventually it runs mkbootimg which takes zImage and the new boot image ramdisk and creates a new shell. Then it runs that shell.
I don't see why it fails though. I didn't put any modules in there but it looks like it doesn't need me to. I already have the latest versions of those kernel module files anyways.
lovethyEVO: Post 11, thanks!
So if I understand correctly, in post 11 you renamed the zimage to boot.img?
Just making sure so I know how to test it.
LOL oh yes that is that zip HAHA sorry.
No go through zip. Gave me status error 6 and because I use fastboot mostly I'm not sure how to correct it.
Flashed it through fastboot:
fastboot flash boot zImage.img = FAILED <remote: image error! <BootMagic check fail>
fastboot flash system zImage.img = OK but stuck at splash screen which I expected.
But now you have a general idea of what's going. It's possibly your kernel and maybe not just the zip file.
Can someone just put this zImage in a kernel flash zip for me? I will try later as well but clearly I'm not good at this.. :]
The zImage is in a .zip file attached. Thanks!

[Q] editing boot.img

i extracted the boot.img from my desire and run this script on it.
but it returns:
Code:
./unpack-bootimg.pl boot.img
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.
i've been searching the internet for two days now and i cant find any other script that does that, only a tutorial for manually doing it with a hex editor, but that still doesn't cover that last file the script is complaining about.
any ideas?
p.s.: i need to modify boot.img because i'm trying to set up dual boot - android + android - for testing purposes, will post if successful
update:
i managed to extract kernel and ramdisk
first i tried booting kernel from fastboot, worked like a charm
then i tried booting kernel+ramdisk from fastboot - hangs on htc logo
i also tried compiling kernel+ramdisk into boot.img instuctions - again hangs on htc bootscreen
adb says no devices, fastboot detects it, but shows no ID, just ??????????
so apparently the last file in boot.img is important
any ideas?
i'm using cyangenmod7 btw

Unable to build kernel from source, what i'm missing?

Hello to all!
I'm an heavy oneplus user, currently with Nord, but i'm try to use my old but Gold Oneplus 3 to run Klipper+Moonraker+Fluidd.
Klipper side everything is perfect, still remains one big issue: there is no kernel compiled for OP3 which has USB_SERIAL_CH341 driver enabled.
I'm trying to build but without success. Here is what i've done under Linux Mint latest version.
First of all i've installed a lot of packages, i cant remember all because i used various guides since initially i was not able neither of finish compilation.
Then i've downloaded:
kernel source: https://github.com/lin16-microg/android_kernel_oneplus_msm8996/tree/lin-16.0-mse2
from this ROM thread, which is the rom im still using: https://forum.xda-developers.com/t/...ened-lineageos-16-0-for-oneplus-3-3t.4034869/
initially i've tried to use EVAgcc toolchain, but it was impossible to finish to build. Then i switched to AOSP toolchains:
32bit: https://android.googlesource.com/pl...inux-androideabi-4.9/+/refs/heads/pie-release
64bit: https://android.googlesource.com/pl...64-linux-android-4.9/+/refs/heads/pie-release
With Them i was able to compile from source, but before doing i modified the file called "lineageos_oneplus3_defconfig" by adding "USB_SERIAL_CH341=y" just under the "USB_SERIAL=y" in order to have the serial driver compiled and loader (if i have understood right?).
to build i've used from inside kernel source cloned directory:
>make clean
>make mrproper
>ARCH=arm64 SUBARCH=arm64 CROSS_COMPILE=googletoolpath/bin/aarch64-stuffs- CROSS_COMPILE_ARM32=googletoolpath/bin/arm-stuffs- make O=out lineageos_oneplus3_defconfig
>ARCH=arm64 SUBARCH=arm64 CROSS_COMPILE=googletoolpath/bin/aarch64-stuffs- CROSS_COMPILE_ARM32=googletoolpath/bin/arm-stuffs- make O=out Image -j2
in this way i've obtained an Image (not a zimage since with zimage returned error).
Then i unpacked the stock boot.img with Android Image Kitchen, substituted boot.img-kernel file (which is an archive..?) with the compiled image renamed.
Finally i repacked everything.
Tried to flash the repacked boot img but no boot, the phone returns to fastboot screen.
I've noticed that my newboot.img is around 25mb insted of around 12mb like the stock one present in the Rom.zip
Probably the error resides in how i've managed to unpack and repack the kernel image..
Do someone see some heavy error which can cause the problem? What can i try?
From a side, as automation engineer, i want to learn and try to do it by myself, but on the other side, if someone is able to compile it for me with serial CH341 driver enabled a beer is assured.
Thanks all to have read up to now and for any advice
not sure that's important but you forgot to gzip kernel before repacking. I recommend to compile with configuration of running kernel from device /proc/config.gz first.
alecxs said:
not sure that's important but you forgot to gzip kernel before repacking. I recommend to compile with configuration of running kernel from device /proc/config.gz first.
Click to expand...
Click to collapse
I've to try because it is not gzipped by default, the problem is that I don't found all in one scripts or config file as the one mentioned by you. I would never thought that rebuild a kernel were so tricky.

Categories

Resources