[Q] Compiling Kernel - Galaxy Tab 2 Q&A, Help & Troubleshooting

Hi All,
I take notes with my Tab2, and sometimes the Default behaviour of the Touchscreen annoys me.
So i decided to recompile the kernel with 3 lines of code added. When done i replaced the zImage in the boot.img of the kkboot stock zip and flashed it trough clockworkmod.
Then i got stuck, my tablet gets stuck inside a boot loop (only the logo comes up, and then reboots after 3 seconds).
The kernel compilation was done by:
- Download Ubuntu, follow the guide on Andriod to setup a build enviorment
- Download Doomlord's toolchain
- Download source from Samsung Open Source
- Adjust code
- Compile using samsungs instructions
How can i resolve this?

http://forum.xda-developers.com/showthread.php?t=1859227 Use Sourcery G++ Lite 2010q1-202 as per Samsung instruction.

ketut.kumajaya said:
http://forum.xda-developers.com/showthread.php?t=1859227 Use Sourcery G++ Lite 2010q1-202 as per Samsung instruction.
Click to expand...
Click to collapse
So, retry compiling with Codesourcery. What parameters do i need to pass to mkbootimg?

Plis man do oc kernel to 1,4 ghz for g tab 7

gieltjev said:
So, retry compiling with Codesourcery. What parameters do i need to pass to mkbootimg?
Click to expand...
Click to collapse
I have my own script base on http://forum.xda-developers.com/showthread.php?t=1241005

ketut.kumajaya said:
I have my own script base on http://forum.xda-developers.com/showthread.php?t=1241005
Click to expand...
Click to collapse
So i downloaded "arm-2010q1-202-arm-none-linux-gnueabi-i686-pc-linux-gnu.tar.bz2" and your toolkit.
First i extracted the boot.img from "kkboot-0.4.2-core-jb-p51xx.zip", extracted the boot.img and made a new one including my zImage. then using zip replaced boot.img with the new boot.img.
This time the booting takes around 6 seconds, but still resetting.
dawidex444 said:
Plis man do oc kernel to 1,4 ghz for g tab 7
Click to expand...
Click to collapse
If the result is positive i will share my adjustments here so that the real cooks can bake a decent kernel

gieltjev said:
So i downloaded "arm-2010q1-202-arm-none-linux-gnueabi-i686-pc-linux-gnu.tar.bz2" and your toolkit.
First i extracted the boot.img from "kkboot-0.4.2-core-jb-p51xx.zip", extracted the boot.img and made a new one including my zImage. then using zip replaced boot.img with the new boot.img.
This time the booting takes around 6 seconds, but still resetting.
If the result is positive i will share my adjustments here so that the real cooks can bake a decent kernel
Click to expand...
Click to collapse
So what "adb shell dmesg" output?
EDIT: Incompatible PVR kernel module, disable MODVERSION and add "-blackhawk" string to LOCALVERSION in your kernel config file or you can extract my config file from "/proc/config.gz" by "insmod /system/lib/modules/configs.ko".

ketut.kumajaya said:
So what "adb shell dmesg" output?
EDIT: Incompatible PVR kernel module, disable MODVERSION and add "-blackhawk" string to LOCALVERSION in your kernel config file or you can extract my config file from "/proc/config.gz" by "insmod /system/lib/modules/configs.ko".
Click to expand...
Click to collapse
Wow, how did you find that out?
So i set, CONF_MODVERSION=n, LOCALVERSION='-blackhawk'
Let's recompile
EDIT: Recompiled, added into the CORE kkboot image. Still resetting. while the logo shows i cannot execute "adb shell dmesg". If executed from CWM it adb shell dmesg works.

Code:
$ cp android_espresso10_omap4430_r02_user_blackhawk_defconfig.txt kernel/arch/arm/configs/android_espresso10_omap4430_r02_user_blackhawk_defconfig
$ cd kernel
$ make mrproper
$ make ARCH=arm android_espresso10_omap4430_r02_user_blackhawk_defconfig
$ make -j4 ARCH=arm

ketut.kumajaya said:
Code:
$ cp android_espresso10_omap4430_r02_user_blackhawk_defconfig.txt kernel/arch/arm/configs/android_espresso10_omap4430_r02_user_blackhawk_defconfig
$ cd kernel
$ make mrproper
$ make ARCH=arm android_espresso10_omap4430_r02_user_blackhawk_defconfig
$ make -j4 ARCH=arm
Click to expand...
Click to collapse
Ok, that works! i've got my own kernel running on the device. Now i will continue getting the fix to work.

gieltjev said:
Ok, that works! i've got my own kernel running on the device. Now i will continue getting the fix to work.
Click to expand...
Click to collapse
Congratulations :good:

gieltjev said:
First i extracted the boot.img from "kkboot-0.4.2-core-jb-p51xx.zip", extracted the boot.img and made a new one including my zImage. then using zip replaced boot.img with the new boot.img.
Click to expand...
Click to collapse
What you've done is exactly what I'm trying to do now.
But I'm stuck in unpacking boot.img in kk-boot.
Which unpack/repack tool did you use? Can you plz share them?

Related

[Guide] - How to compile the CDMA kernel source and Flash it to your phone (Updated)

You should do a nandroid backup and reboot your phone before trying to flash anything to your phone. This how to involves flashing directly to mtd2, if you don't know what you are doing then please use one of the custom roms available in the Sticky Wiki.
#### Update One Fixed scripts
#### Update Two Added instructions to compile and install the wlan.ko module
#### Update Three Fixed get-CDMAHero-source.sh typo
#### Update Four Added Instructions for Jaunty repo's for Ubunut 9.10
First off i would like to give credit to all the people who have made information and scripts available. I used bits and peices of info and tools written by and or made available by these people.
Armin Coralic http://blog.coralic.nl for creating some nice scripts and making them available
chuckhriczko for helping me out in the middle of the night.
LoxDev for creating a wonderfull how to about creating img's and zip's
tkirkton for helping out with enabling legacy jaunty repos to install java 1.5
Second I am writing this How To, so a complete newbie would be able to understand.
REQUIREMENTS....
Ubuntu Desktop 9.04 or better 32bit (cause thats what i used)
Android SDK (Needed to push and pull files as well as shell access to the phone. You will need to set this up by following the instructions found at http://www.android.com)
Legacy repo's enabled in apt to allow java 1.5 to install
Root access. I ran all commands below as root
I created a dir called "heroc" in my /root directory.
Download zip file below and unzip it in the heroc dir that you should have created.
STEPS
.5 Enable Legacy Repo's to allow java 1.5 to install (below is a cut from tkirktons post on page 7)
Code:
in Ubuntu 9.10, the Java 1.5 package doesn't even list. Here's what I had to do to get it to load:
1. Access a repository from the previous build (9.04 Jaunty will work: commands to put into /etc/apt/sources.list -
deb [URL]http://mirrors.us.kernel.org/ubuntu[/URL] jaunty main restricted universe multiverse
deb [URL]http://mirrors.us.kernel.org/ubuntu[/URL] jaunty-backports main restricted universe multiverse
deb [URL]http://mirrors.us.kernel.org/ubuntu[/URL] jaunty-security main restricted universe multiverse
deb [URL]http://mirrors.us.kernel.org/ubuntu[/URL] jaunty-updates main restricted universe multiverse
2. Set the max age higher than the default. This can be accomplished by editing the /etc/apt/apt.conf.d/20archive. Here's what my lines in that file look like:
APT::Archives:MaxAge "2880";
APT::Archives:MinAge "2";
APT::Archives:MaxSize "1000";
Making these two changes should work...although I have the Intrepid, Hardy and Dapper repositories in mine as well (didn't know which one would work, so I overkilled it).
Run the script again after making the changes and let me know if it works.
.
to update just run
Code:
# apt-get update
1. Create your work environment by running createandroidRepo.sh. This will take some time depending on your internet connection. Make sure you are in the heroc dir.
Code:
# unzip Scripts.zip
# chmod a+x *
# ./createAndroidRepo.sh
This will create a dir call my android and setup all the files and programs needed to compile the kernel. This will take some time to complete.
2. You need to download the source using the get-CDMAHero-source.sh
Code:
# ./get-CDMAHero-source.sh
This will download the source, and extract it to its own directory.
3. you will need to have your .config file handy for the next steps. If you don't have it then you will need to get it by doing the following
Code:
# adb pull /proc/config.gz /root/heroc/config.gz
# gunzip config.gz
The first command will pull the gzipped config from your phone and place it into the heroc dir. the second command will extract the file as "config"
4. This is where it gets fun. We now have everything downloaded and are going to start the process of compiling our kernel.
Code:
# cd heroc_ef05d31a
# export ARCH=arm
# export CROSS_COMPILE=arm-eabi-
# export PATH=$PATH:~/heroc/myandroid/prebuilt/linux-x86/toolchain/arm-eabi-4.4.0/bin
# make menuconfig
After you run "make menuconfig" it will bring up a the config menu for our kernel. Go to the bottom and select "Load an alternate configuration file". It will then prompt you to select the config file you want to use. You will need to point it to where you have the config file. So type in "/root/heroc/config"
After you have loaded the config file you can edit what ever you want. however if you don't know what do disable or enable then i wouldn't mess around to much.
Next you will need to save your config file. Choose "Save an alternate configuration file", and save it as "/root/heroc/heroc_ef05d31a/.config"
You can now exit menuconfig
5. Time To Compile the kernel and wlan.ko module
Code:
# make
# export KERNEL_DIR=/root/heroc/heroc_ef05d31a/
# cd myandroid/system/wlan/ti/sta_dk_4_0_4_32/
# make
The kernel will take some time. go grab a drink and have a snack. If all goes well you should end up with a zImage file in "~/heroc//arch/arm/boot/". After the kernel is compiled you need to compile the wlan.ko module by executing the last three commands
6. Next we need to copy the zImage back to the heroc dir
Code:
# cp /root/heroc/heroc_ef05d31a/arch/arm/boot/zImage /root/heroc/zImage
7. Ok so now we need to get the boot image from our phone. We need this cause it has more than just the kernel. I contains the ramdisk image as well. and we need to take the boot image and decompress it and remove the old kernel and add our new compiled kernel, then recompress it to newboot.img
Code:
# adb shell
# cat /dev/mtd/mtd2 > /sdcard/mtd2.img
# exit
# adb pull /sdcard/mtd2.img /root/heroc/mtd2.img
# mv mtd2.img boot.img
The first two commands will open a terminal shell to your phone and copy the boot image to your sdcard. the last two commands will pull the the boot image from your phone, place it in your heroc dir and rename the file to boot.img
8. Now we will split apart the boot.img using some scripts.
Code:
# ./extract-kernel.pl boot.img
# ./extract-ramdisk.pl boot.img
# rm boot.img-kernel
# cp zImage boot.img-kernel
# ./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
The first command extracts the stock kernel from boot.img. The second command extracts the ramdisk from boot.img. The third command will delete the stock kernel. the fourth command renames our zImage to boot.img-kernel. The fifth command takes boot.img-ramdisk folder and zips it up into ramdisk-boot. The sixth comand takes our kernel (renamed to "boot.img-kernel") and ramdisk-boot and combines it back to form a new file called newboot.img.
9. Now we need to flash our "newboot.img" file to our phone. You should reboot your phone before flashing this will insure that you don't get any out of memory errors and will keep your phone from booting into fastboot (Thx Obelisk79).
Code:
# adb push newBoot.img /sdcard/newBoot.img
# adb shell
# cat /dev/zero > /dev/mtd/mtd2 (you may get an error here. don't worry about it)
# flash_image boot /sdcard/newBoot.img
# reboot
The first command will push your boot image to the phone. the second command will bring up shell access to your phone. the third command will zero out mtd2 and get it ready to write your image. the fourth command will flash boot(mtd2) with newboot.img. the last command will reboot your phone
10. After the phone reboots we need to get the wlan.ko file to the phone so that wireless will work
Code:
# adb push /root/myandroid/system/wlan/ti/sta_dk_4_0_4_32/wlan.ko /sdcard/wlan.ko
# adb shell
# mount -o remount,rw -t yaffs2 /dev/block/mtdblock3 /system
# cp /sdcard/wlan.ko /system/lib/modules/wlan.ko
# exit
Now you have a kernel that you compiles with everything work with the exception of power mgmt.
Just as soon as i figure out how to make an update.zip i will post instructions on how to do this
Added it to the CDMA Hero Guides wiki article.
gu1dry said:
Added it to the CDMA Hero Guides wiki article.
Click to expand...
Click to collapse
dang you beat me to it.
Not sure why, but had to run dos2unix on the the first script, not sure if it is all of them, but it was giving me the error
/bin/bash^M: bad interpreter: No such file or directory
Click to expand...
Click to collapse
dos2unix took care of the issue. Also Thanks for the guide, greatly appreciated!!!
make sure you run the script with the "./" , also you may need to chmod +x the files.
Is there a way to get this to run on the Emulator? I tried to specify the zImage after I compiled it but it won't boot when specifying it. Or will that not work for the HTC zImage?
Excellent guide. Can't wait to try it.
blehzz said:
Is there a way to get this to run on the Emulator? I tried to specify the zImage after I compiled it but it won't boot when specifying it. Or will that not work for the HTC zImage?
Click to expand...
Click to collapse
Check out this link
Check out this link
Click to expand...
Click to collapse
Thanks will have a look. Seems to be the Android kernel and not the HTC kernel though, but will read further into it
blehzz said:
Thanks will have a look. Seems to be the Android kernel and not the HTC kernel though, but will read further into it
Click to expand...
Click to collapse
not sure but i think this will work for you
Code:
# emulator -kernel /path/to/your/zImage
First script didn't work for me on ubuntu. Copying and pasting line by line works.
i'll repack the scripts again
not sure but i think this will work for you
Click to expand...
Click to collapse
that's what i tried... emulator never runs when i specify that zImage it built successfully.
Has anybody tried this yet with Ubuntu running under VMware on a PC running Windows? I know that (in theory) VMware's USB compatibility is spectacularly good (it somehow manages to give the guest OS direct ownership and control of the host PC's USB root hub), but up to now I've only tried it to run XP/32 under Vista/64 and Windows 7/64.
FYI, you can download VMware player for free (as in beer) and use it to run Ubuntu 9.04 with their complete blessing. Just make sure you download a guest OS that configures the hardware (memory, cpu, etc) the way you want it to be, because changing the hardware config is one of the few things you genuinely can't do with the free player. If someone here has the full version (and can find somewhere to host it so the bandwidth charges didn't eat him alive), he could even create an Ubuntu distro that's already set up and configured to build Android kernels for others here to download and use.
To use the first script: open up Synaptics, then download "tofromdos". Now, run "fromdos createAndroidRepo.sh", and it should work then
ROM?
Can someone post how to compile a kernel, and make a ROM, and put it all together in a update.zip? Would be really REALLY nice!
Jason(bikcmp)
Thanks for this guide I'm compiling a kernel right now Just a question, how do I change the kernel version name... like you did in that one screenshot?
bikcmp said:
Can someone post how to compile a kernel, and make a ROM, and put it all together in a update.zip? Would be really REALLY nice!
Jason(bikcmp)
Click to expand...
Click to collapse
Its coming
bikcmp said:
Can someone post how to compile a kernel, and make a ROM, and put it all together in a update.zip? Would be really REALLY nice!
Jason(bikcmp)
Click to expand...
Click to collapse
its in general options in menuconfig.

Single Click bootable kernel update maker script for galaxy-y

Hi
I am posting the scripts and tools i am using in my galaxy-y
this tool can produce a kernelUpdate.zip which can be used in recovery mode to flash new kernel in the device from the bare kernel 'zImage' produced from kernel compiling
This will automatically create boot.img and make a 'update.zip' like package from it
Instructions:
*Extract the zip
*place your zImage in the folder
*just run the file file "mkKernelUpdate.sh"
If any error occurs look in to the scriptss.......
I hope this will be help full to you all
-Thanks.....
Wow this is great... Thanks man...
harish2704 said:
this tool can produce a kernelUpdate.zip which can be used in recovery mode to flash new kernel
Click to expand...
Click to collapse
wow ! pretty awesome. you mean those update.zip can be run from stock Android system recov rather than CWM. makes it a bit simpler for some dudes ...
just to clarify this is different from faqbly script right?
this one can be used on stock recovery?
can anyone verify?
Its nice man
zeusseuz said:
just to clarify this is different from faqbly script right?
Click to expand...
Click to collapse
ya different ball game altogether !
Let me clarify....
By the word "recovery mode" I mean the recovery mode we see when pressing 'Vol+' + power +home at boot time FOR A FRESH GALAXY-Y Hand set
I never used other recovery modes
I use this method to flash kernel from my ubuntu linux
Any one knows any othe alternatives to odin????
Not heimdal its not suppoted for our device
No need to say or PRSS thanks.just look my new thread and help me if you can
Click to expand...
Click to collapse
harish2704 said:
Any one knows any othe alternatives to odin????
Click to expand...
Click to collapse
well an alternative to odin is dd, when used after bmlunlock
flashing comes down to dd if= of= when unlocked.
no need for PC & cable ...
CWM is an improved recovery mode with better scripts and stuff. in merruks kernel, when in recov, you have root shell access. does add flexibility ...
also Heimdall recently expanded it's list of supported devices.
it's Windows "zadig" libUSB driver works with SGY too
the amount of work required to get Heimdall working on SGY should be limited.
mai77 said:
also Heimdall recently expanded it's list of supported devices.
it's Windows "zadig" libUSB driver works with SGY too
the amount of work required to get Heimdall working on SGY should be limited.
Click to expand...
Click to collapse
You mean Heimdall now supports SGY?????
Have you tested with linux??
Heimdall does not support SGY yet.
but the libUSB 'zadig' drivers work with the SGY (in Windows)
this reduces the effort it takes to get SGY supported by Heimdall
success report ?
harish2704 said:
this tool can produce a kernelUpdate.zip which can be used in recovery mode to flash new kernel in the device from the bare kernel 'zImage' produced from kernel compiling.
This will automatically create boot.img and make a 'update.zip' like package from it.
Instructions:
* Extract the attached zip
* place your zImage in the folder
* just run the file file "mkKernelUpdate.sh"
Click to expand...
Click to collapse
essentially, make boot image is run
./mkbootimg --kernel ${cwd}/zImage --ramdisk ${cwd}/original_boot.img-ramdisk.gz --base 0x81600000 --kernelMD5 ${kernMd5} -o boot.img
(...)
java -classpath testsign.jar testsign foo.zip KernelUpdate.zip
(...)
mv KernelUpdate.zip KernelUpdate_${tstamp}.zip
so any changes in kernel source or ramdisk init.rc or whatever gives you the ready made boot.img flasher
seemingly the script is fully working on SGY. any reports ?

[GUIDE] How to compile Sidekick 4G Kernel [Ubuntu]

1) download source code from https://opensource.samsung.com/index.jsp. You are looking for source code for SGH-T839.
2) Get initramfs (Need to make a kernel package)
Extract it using extract boot http://www.mediafire.com/?lc12eceeh617b97.
This is why I am looking for a boot.img
extract it
Code:
tar -xvf extractboot.tar.gz
now move into directory with extract boot and copy your boot.img into here and do
Code:
./extractboot boot.img
3) Get mkboot tools
http://www.mediafire.com/?w06d1m6n1dgo4op
untar it by doing
Code:
tar -xvf $FILENAMEHERE
Add the bin directory to your path by moving to the bin directory and copying down the path then
Now you will add this to your path by editing your .bashrc file.
Go to your bashrc file
Code:
gedit ~/.bashrc
and adding this
Code:
PATH=$PATH:/FULLDIRECTORYYOUWROTEDOWN/
export PATH
4) Download the ARM toolchain
https://sourcery.mentor.com/sgpp/lite/arm/portal/package5385/public/arm-none-linux-gnueabi/arm-2009q3-67-arm-none-linux-gnueabi.bin
and
https://sourcery.mentor.com/sgpp/lite/arm/portal/package5355/public/arm-none-eabi/arm-2009q3-68-arm-none-eabi.bin
5) Install the ARM Toolchain
create the directory /opt/toolchains/arm-2009q3/
Code:
sudo mkdir /opt/toolchains/arm-2009q3/
then install the toolchain using /opt/toolchains/arm-2009q3/
as the install directory
Code:
sudo chmod +x arm-2009q3-68-arm-none-eabi.bin
sudo chmod +x arm-2009q3-67-arm-none-linux-gnueabi.bin
sudo ./arm-2009q3-67-arm-none-linux-gnueabi.bin -i console
sudo ./arm-2009q3-68-arm-none-eabi.bin -i console
6) Compile
Extract your source code and go to the directory Kernel and do the following
WARNING: MAKE SURE THERE ARE NO SPACES IN YOUR FILEPATH BECAUSE THE MAKEFILE DOESNT LIKE THEM.
Code:
make clean
make arch=arm sidekick_rev02_defconfig
make ARCH=arm HOSTCFLAGS="-g -O3" -j8 CROSS_COMPILE=/opt/toolchain/bin/arm-none-eabi-
Now copy any of the resulting compiled ko files into the initramfs file you have extracted and you should have what you need to package a kernel.
you forget initramfs
windxixi said:
you forget initramfs
Click to expand...
Click to collapse
yeah I kept it out so that somebody would post a boot.img then could do steps related to that. I am looking for a boot.img to get initramfs from
unpack zImage
Sent from my SGH-T839 using XDA
---------- Post added at 08:46 AM ---------- Previous post was at 07:49 AM ----------
and how to pack a boot.img?
A request to anyone building SK4G kernels.
Please disable the keystroke logging printk statements in the file:
Code:
drivers/input/keyboard/s3c-keypad.c
The lines look like this:
Code:
//printk("\nkey Pressed : key %d map %d\n",i, pdata->keycodes[i]);
and
Code:
//printk("\nkey Released : %d map %d\n",i,pdata->keycodes[i]);
It is possible to recover the actual keystrokes from the numerical codes those statements log, and the messages go into the dmesg buffer. So it's pretty easy to extract them and determine exactly what the user typed.
In the latest Samsung sources I've seen, those lines were already commented out. It makes sense to enable them while debugging a new ROM build, but please do disable them prior to building a kernel intended for general consumption.
Do you guys know if the available source code will produce a kernel that will work with kj2? the kernel version in SGH-T839_Opensource_Update1 looks to match up, but I compilied a zImage and it didn't boot on stock kj2. but I could very well be missing something.
I have done a small amount of kernel work on an HTC device, but I basically just used the Rom Kitchen to pack up my zImages with a boot.img-ramdisk to create a boot.img. I guess I might need a little more instruction for packing up a Samsung kernel. Is it also an option to just tar up the zImage and flash it with Odin/Heindall?
Thanks for this thread, and for any other advice!
Sent from my SGH-T839 using Tapatalk 2
In case it might be useful to someone else working on building a kernel.
The official and Bali_SK4G sources both seem to insist on building with debug symbols enabled for some of the modules. In particular, i was ending up with dhd.ko being 2.4 MB in size, where it should have been less than 400 KB.
The ideal case would be to determine why the debug symbols are being included -- commenting out the labelled debug options in the bcm4329 Makefile didn't accomplish this.
But a workaround is to strip the modules after the build is finished, before assembling the initramfs.
Has anyone been able to build a working zImage for KJ2 using Dr. Honk's Bali sources [1] and sduvick's KJ2 ramdisk files [2]?
I have been able to build a zImage of a reasonable size (6520 KB). But when I flash this to the KERNEL partition using heimdall, the device boot loops to the B&W Sidekick logo. It doesn't get far enough to show any adb log output.
I can then use the same heimdall flashing procedure to flash the Platypus Egg v1 zImage, or other KJ2-compatible zImage files, and the device boots and works properly.
So I'm trying to figure out what I'm doing wrong in building my zImage. If anyone has any advice I would be appreciative.
[1] https://github.com/drhonk/Bali_SK4G
[2] https://github.com/sduvick/SK4g_KJ2_Ramdisk
I got an updated Bali_SK4G kernel booting using the ramdisk from GenericGinger 2.0.
I have worked up some patches to disable the logging of keystrokes and other more trivial debug spew in dmesg. Also included is a Makefile patch that was required for the compile to complete with my toolchain.
https://carbon.flatlan.net/nxd/patches_Bali_SK4G_nxd.tar.bz2
md5sum: 5d14ac32de155cdca0fd82f14bc4ceca
These patches are GPL licensed, in compliance with the license for the Linux kernel itself. I make no guarantees about their suitability for any purpose. I grant permission to use them to anyone who would like to do so, so long as they comply with the GPL.
I'd like to make a compiled kernel available with these changes, but XDA's rules can be interpreted to mean that I must obtain permission from a series of upstream contributors, some of whom may not be reachable. Perhaps a moderator will clarify the parameters of the permission rule.

Boot.img Tools Compiled for Arm^7 -- (un)Pack kernels on your phone !!!

About
These two applets ( mkbootimg + unpackbootimg ) are used to pack and unpack any standard android kernel with 4096 / 2048 page size . Most of tools that pack and unpack boot.img files such as Dsixda kitchen , Kernel kitchen or. ... use these applets .
These applets were compiled only for X86 so we could only (un)pack boot.img in Windows or Ubuntu but I compiled and fixed these applets for Arm7 platform on android devices from Android sources. So you may pack and unpack boot.img on any android device !!
Sources are here ( Lisenced under GPL 2.0 lisence ) : My github
How to use
1- First download applets package
2- Unzip it and push two files in it to /system/bin or /system/xbin
3- Set their pemissions to 777 ( rwxrwxrwx )
For unpacking a kernel
* Assuming that you have boot.img in /sdcard
* Open terminal and type : [ this is just an example , you can change it ]
Code:
su
unpackbootimg -i /sdcard/boot.img -o /sdcard/ -p 4096
*You will have extracted boot.img at /sdcard
* Save ouput information that applets gives you at the end . you need them in future
For packing a kernel
* Copy ramdisk.gz , zimage , cmdline , pagesize , base you got from unpacking boot.img into /sdcard
* Open terminal and type :
Code:
su
mkbootimg --cmdline cmdline --kernel zimage --ramdisk ramdisk.gz --base base --pagesize pagesize -o boot.img
* You will have output ( boot.img ) at /sdcard/boot.img
Download
Download build 1 @ Dev-Host
* Initial build
Credits
* Alireza7991 - for fixing , improving and cross-compiling for arm^7
* Andrew Huang ( [email protected]) - for sources
* Android Open Source Project - for sources
This applet is under GPL 2.0
Using this is free but you have to ask me if you want to use this in your tools or ...
Reserved for OP
very cool, :good::good::good:
Awesome thanks for sharing your work !
I'll be back in a flash
A better link would be really cool can't DL it to my nexus for the life of me :banghead:
Rushing said:
Awesome thanks for sharing your work !
I'll be back in a flash
A better link would be really cool can't DL it to my nexus for the life of me :banghead:
Click to expand...
Click to collapse
What problem do you have with download link ?
segmentation fault
Hey
Trying to unpack a samsung kernel, but I get this error
BUILDER: Alireza7991
BOARD_KERNEL_CMDLINE
BOARD_KERNEL_BASE e19f8000
BOARD_PAGE_SIZE 24061976
Segmentation fault
I guess my boot.img is not supported?
biopsin said:
Hey
Trying to unpack a samsung kernel, but I get this error
BUILDER: Alireza7991
BOARD_KERNEL_CMDLINE
BOARD_KERNEL_BASE e19f8000
BOARD_PAGE_SIZE 24061976
Segmentation fault
I guess my boot.img is not supported?
Click to expand...
Click to collapse
I have unpacked Samsung Galaxy S plus kernel successfuly
Only 2048 & 4096 page sizes are supported !
Edit : I have forgot to say Samsung exynose kernel which uses zImage as in SGS 1/2/3 are not supported
alireza7991 said:
For unpacking a kernel
Click to expand...
Click to collapse
For a good understanding of the structure of boot and recovery images can read such here.
So, now that I unpacked my boot.img, next question is:
How can I modify them through the phone also? Does an application that modifies ramdisk.gz / zImage exist?
I can modify my APKs' xmls and smali files and recompile then on my phone, so I'm wondering if I can modify this also on my phone.... Can it be?
Edit: I tried unpacking boot.img-ramdisk.gz via TermEmu:
Code:
lzma -dc ../boot.img-ramdisk.gz | cpio -i
But, as I expected, it failed and says:
Code:
lzma: out of memory
(Yes I'm new at this thing. Still worth trying )
So, any other workarounds to unpack and modify these babies via our phones?
souler456 said:
So, now that I unpacked my boot.img, next question is:
How can I modify them through the phone also? Does an application that modifies ramdisk.gz / zImage exist?
I can modify my APKs' xmls and smali files and recompile then on my phone, so I'm wondering if I can modify this also on my phone.... Can it be?
Edit: I tried unpacking boot.img-ramdisk.gz via TermEmu:
Code:
lzma -dc ../boot.img-ramdisk.gz | cpio -i
But, as I expected, it failed and says:
Code:
lzma: out of memory
(Yes I'm new at this thing. Still worth trying )
So, any other workarounds to unpack and modify these babies via our phones?
Click to expand...
Click to collapse
I'm amazed , how do you unpack APKs on your phone ? I saw sth for packing APKs but I do'nt know how to decompile APKs
ZImage is a static executable of compiled kernel . but ramdisk is an small file system which includes some essential files for booting your phone such as init.rc , and ... . ramdisk has two compressions , cpio and gz . first you have to gunzip it and then uncpio .
I'm working on a ramdisk unpack tool too .
alireza7991 said:
I'm amazed , how do you unpack APKs on your phone ? I saw sth for packing APKs but I do'nt know how to decompile APKs
ZImage is a static executable of compiled kernel . but ramdisk is an small file system which includes some essential files for booting your phone such as init.rc , and ... . ramdisk has two compressions , cpio and gz . first you have to gunzip it and then uncpio .
I'm working on a ramdisk unpack tool too .
Click to expand...
Click to collapse
I use Apktool, but ported to my phone (yes, an Apktool which is an APK) to get my APKs down and dirty. I'm sure it's on XDA, but I forgot where I did get it though...
For the ramdisk to be unpacked, can I use those commands (gunzip) and execute them via TermEmu? Did you tried it yet?
Also, I don't have a single idea of what a zImage is (except the one you just said, which is also kinda noob-shot my head), what's contained about it, and how to modify it for my tastes... Any tutorials you may shed some?
Will wait patiently for the development of your works related with this. It's really great man
souler456 said:
I use Apktool, but ported to my phone (yes, an Apktool which is an APK) to get my APKs down and dirty. I'm sure it's on XDA, but I forgot where I did get it though...
For the ramdisk to be unpacked, can I use those commands (gunzip) and execute them via TermEmu? Did you tried it yet?
Also, I don't have a single idea of what a zImage is (except the one you just said, which is also kinda noob-shot my head), what's contained about it, and how to modify it for my tastes... Any tutorials you may shed some?
Will wait patiently for the development of your works related with this. It's really great man
Click to expand...
Click to collapse
Since some people here don't know there was an apktool for android then I'll just create a thread for it with instructions for noobs
souler456 said:
I use Apktool, but ported to my phone (yes, an Apktool which is an APK) to get my APKs down and dirty. I'm sure it's on XDA, but I forgot where I did get it though...
For the ramdisk to be unpacked, can I use those commands (gunzip) and execute them via TermEmu? Did you tried it yet?
Also, I don't have a single idea of what a zImage is (except the one you just said, which is also kinda noob-shot my head), what's contained about it, and how to modify it for my tastes... Any tutorials you may shed some?
Will wait patiently for the development of your works related with this. It's really great man
Click to expand...
Click to collapse
I found apk tool on android not on xda , on google code .
Zimage can not be modified because it is compiled , also can not be decompiled . so you can not modify it .
when boot process starts , bootloader reads zimage from pre-defined partition and loads it in ram . then it calls cpu to execute zimage . when zimages executes it sets up initial board configurations ( such as regulators , GPIOs and ... ) , drivers and ... . then it opens ramdisk and unpacks ramdisk . when ramdisk opens , init process starts by kernel . it executes init.rc , init.<target>.rc . init.rc sets up initial kernel configurations and any other thing related to android . init.rc executes some initial android binarys such as bootanimation , surface flinger , adb and finally app process . app process turns on java and dalvik enviroments . finally framework and other java classes runs and android appears
Did you understand what is zimage and ramdisk ??
Juhan Jufri said:
Since some people here don't know there was an apktool for android then I'll just create a thread for it with instructions for noobs
Click to expand...
Click to collapse
You don't have to. There's already a thread for it (found it 35mins after I started the topic ) : http://forum.xda-developers.com/showthread.php?t=2388135
It will only be deleted by Mods, so, yeah...
alireza7991 said:
I found apk tool on android not on xda , on google code .
Zimage can not be modified because it is compiled , also can not be decompiled . so you can not modify it .
when boot process starts , bootloader reads zimage from pre-defined partition and loads it in ram . then it calls cpu to execute zimage . when zimages executes it sets up initial board configurations ( such as regulators , GPIOs and ... ) , drivers and ... . then it opens ramdisk and unpacks ramdisk . when ramdisk opens , init process starts by kernel . it executes init.rc , init.<target>.rc . init.rc sets up initial kernel configurations and any other thing related to android . init.rc executes some initial android binarys such as bootanimation , surface flinger , adb and finally app process . app process turns on java and dalvik enviroments . finally framework and other java classes runs and android appears
Did you understand what is zimage and ramdisk ??
Click to expand...
Click to collapse
Yes. Thanks so much!
So the probability of a modifying process can only be done by the ramdisk only? Well...
souler456 said:
You don't have to. There's already a thread for it (found it 35mins after I started the topic ) : http://forum.xda-developers.com/showthread.php?t=2388135
It will only be deleted by Mods, so, yeah...
Yes. Thanks so much!
So the probability of a modifying process can only be done by the ramdisk only? Well...
Click to expand...
Click to collapse
Oh ****, just created it. But with somewhat better instructions for newbies.
alireza7991 said:
I'm amazed , how do you unpack APKs on your phone ? I saw sth for packing APKs but I do'nt know how to decompile APKs
ZImage is a static executable of compiled kernel . but ramdisk is an small file system which includes some essential files for booting your phone such as init.rc , and ... . ramdisk has two compressions , cpio and gz . first you have to gunzip it and then uncpio .
I'm working on a ramdisk unpack tool too .
Click to expand...
Click to collapse
waiting for this unpack tool...
I only make,decompile,theme and mod apks via my phone...
so slicing up the boot.img via phone is a good additiob too.... XD
great work for this...haven't tried it yet...
but will do whenever the unpack tool is also ready... XD
alireza7991 said:
I'm working on a ramdisk unpack tool too .
Click to expand...
Click to collapse
I'm waiting for this .
Captain_Throwback said:
I'm waiting for this .
Click to expand...
Click to collapse
done
Code:
cpio -i < ramdisk.gz
alireza7991 said:
About
These two applets ( mkbootimg + unpackbootimg ) are used to pack and unpack any standard android kernel with 4096 / 2048 page size . Most of tools that pack and unpack boot.img files such as Dsixda kitchen , Kernel kitchen or. ... use these applets .
These applets were compiled only for X86 so we could only (un)pack boot.img in Windows or Ubuntu but I compiled and fixed these applets for Arm7 platform on android devices from Android sources. So you may pack and unpack boot.img on any android device !!
Sources are here ( Lisenced under GPL 2.0 lisence ) : My github
How to use
1- First download applets package
2- Unzip it and push two files in it to /system/bin or /system/xbin
3- Set their pemissions to 777 ( rwxrwxrwx )
For unpacking a kernel
* Assuming that you have boot.img in /sdcard
* Open terminal and type : [ this is just an example , you can change it ]
Code:
su
unpackbootimg -i /sdcard/boot.img -o /sdcard/ -p 4096
*You will have extracted boot.img at /sdcard
* Save ouput information that applets gives you at the end . you need them in future
For packing a kernel
* Copy ramdisk.gz , zimage , cmdline , pagesize , base you got from unpacking boot.img into /sdcard
* Open terminal and type :
Code:
su
mkbootimg --cmdline cmdline --kernel zimage --ramdisk ramdisk.gz --base base --pagesize pagesize -o boot.img
* You will have output ( boot.img ) at /sdcard/boot.img
Download
Download build 1 @ Uploadboy
* Initial build
Credits
* Alireza7991 - for fixing , improving and cross-compiling for arm^7
* Andrew Huang ( [email protected]) - for sources
* Android Open Source Project - for sources
This applet is under GPL 2.0
Using this is free but you have to ask me if you want to use this in your tools or ...
Click to expand...
Click to collapse
Gonna try this soon
Sent from my H100 using xda app-developers app
alireza7991 said:
done
Code:
cpio -i < ramdisk.gz
Click to expand...
Click to collapse
Hmmm. Was this a recent update? I downloaded the tools this morning. I'm getting the below error:
Code:
cpio: unsupported cpio format, use newc or crc

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
In linux:
http://forum.xda-developers.com/showthread.php?t=1477845
In windows:
http://technopyrate.blogspot.pt/2013/04/how-to-edit-android-bootimg-in-windows.html
zamcum said:
In linux:
http://forum.xda-developers.com/showthread.php?t=1477845
In windows:
http://technopyrate.blogspot.pt/2013/04/how-to-edit-android-bootimg-in-windows.html
Click to expand...
Click to collapse
This is helpful for unpacking modifying and repacking, but I dont have a boot.img to unpack. Like I said, all I have is a zImage, i have no clue how to get a ramdisk. Can I just use one from another kernel or will that cause conflicts? Thanks for the help
aeppacher said:
This is helpful for unpacking modifying and repacking, but I dont have a boot.img to unpack. Like I said, all I have is a zImage, i have no clue how to get a ramdisk. Can I just use one from another kernel or will that cause conflicts? Thanks for the help
Click to expand...
Click to collapse
You can have it, in a stock rom:
Download a stock rom for your phone, open .tar.md5 file with winrar, extract boot.img and unpack it.
Inside you have, ramdisdk and zimage, with another name (boot.img-kernel)
rename your zimage, to boot.img-kernel, edit ramdisk if you want
repalce original boot.img-kernel with yours
and repack
Rename boot-new.img to boot.img
Enjoy
EDIT: To make a flashable Odin file, in Linux:
tar -H ustar -c boot.img > YOURKERNEL.tar
md5sum -t YOURKERNEL.tar >> YOURKERNEL.tar
mv YOURKERNEL.tar YOURKERNEL.tar.md5
That's not necessary. You can make it so that your zImage replaces the zImage inside the boot.img and the initlogo.rle at the same time.
CNexus said:
That's not necessary. You can make it so that your zImage replaces the zImage inside the boot.img and the initlogo.rle at the same time.
Click to expand...
Click to collapse
Which step is not necessary? My biggest problem here was I didn't know i could take any old boot.img to make mine
zamcum said:
You can have it, in a stock rom:
Download a stock rom for your phone, open .tar.md5 file with winrar, extract boot.img and unpack it.
Inside you have, ramdisdk and zimage, with another name (boot.img-kernel)
rename your zimage, to boot.img-kernel, edit ramdisk if you want
repalce original boot.img-kernel with yours
and repack
Rename boot-new.img to boot.img
Enjoy
EDIT: To make a flashable Odin file, in Linux:
tar -H ustar -c boot.img > YOURKERNEL.tar
md5sum -t YOURKERNEL.tar >> YOURKERNEL.tar
mv YOURKERNEL.tar YOURKERNEL.tar.md5
Click to expand...
Click to collapse
hahaha so I think that worked, I have a bootimage with my kernel!! hurrah, now how do I turn it into a flashable zip? Last question I promise
aeppacher said:
hahaha so I think that worked, I have a bootimage with my kernel!! hurrah, now how do I turn it into a flashable zip? Last question I promise
Click to expand...
Click to collapse
the easiest way, is to download a custom kernel for your phone, open the zip with winrar and replace the bott.img by your boot.img
It is important that the exact custom kernel of your phone, so that, there are no incompatibilities in the installation script
zamcum said:
the easiest way, is to download a custom kernel for your phone, open the zip with winrar and replace the bott.img by your boot.img
It is important that the exact custom kernel of your phone, so that, there are no incompatibilities in the installation script
Click to expand...
Click to collapse
Hmmm, I tried this and it didn't boot. :/ then I booted to recovery restarted, and then it booted with my boot splash (yay) went to apps updating and then just got stuck at starting apps. I couldn't get it to fully boot :/
Any ideas whats up
EDIT: I can't thank you since I only get 8 per day, sorry I do appreciate it though
aeppacher said:
Hmmm, I tried this and it didn't boot. :/ then I booted to recovery restarted, and then it booted with my boot splash (yay) went to apps updating and then just got stuck at starting apps. I couldn't get it to fully boot :/
Any ideas whats up
EDIT: I can't thank you since I only get 8 per day, sorry I do appreciate it though
Click to expand...
Click to collapse
If your kernel does not boot, is because it has a problem. It is normal to happen in the first kernel.
The process I use, is what is above. Sorry, II can not help more.
Do not worry about the gratefulness. The important thing is to help
I have a question along the same lines as this thread and I've read all over the place and can't find anything. How do you open a boot.img file to be able to replace the zimage
---------- Post added at 09:21 AM ---------- Previous post was at 08:45 AM ----------
I have a question along the same lines as this thread and I've read all over the place and can't find anything. How do you open a boot.img file to be able to replace the zimage
EDIT: i fixed this
Problem solved, figured I would post a solution:
here are the tools: https://dl.dropboxusercontent.com/u/106865720/bootimg_tools.zip
extract them into any old folder. You also need to have perl installed (just google it)
1. You need to take your built boot.img (from a rom running your kernel successfully) and drag it into the folder.
2. Open up terminal and navigate to the directory with the tools and boot.img
3. First you need to split the boot image into its 2 parts (the ramdisk and the kernel zImage)
Code:
perl split_bootimg.pl boot.img
The "boot.img" part is just the name of your boot.img (I am assuming yours is called boot.img but you can change it as needed)
4. Okay what should have happened is the boot.img should have split into a 'boot.img-ramdisk.gz' and a 'boot.img-kernel' file. The first is a specially compressed ramdisk and the second is the zImage for the kernel
5. Now you need to unpack the ramdisk so that you can modify it. BE CAREFUL AND MODIFY ONLY IF NEEDED Use this code:
Code:
perl unpack_ramdisk boot.img-ramdisk.gz ramdisk
the "boot-img-ramdisk.gz" is the name of the ramdisk, you can change this as needed but it should be named that by default
6.Okay so what should have happened is a folder ramdisk was created (this is the unpacked ramdisk which you need).
7.Okay go back to your directory and delete your boot.img, boot.img-kernel and boot.img-ramdisk.gz files (you no longer need them)
8. Now you need to repack the ramdisk folder you modified so you can rebuild the boot.img use the following:
Code:
perl repack_ramdisk ramdisk boot.img-ramdisk.cpio.gz
9. This will take the 'ramdisk' folder and pack it and name it 'boot.img-ramdisk.cpio.gz'
11. Find your built zImage for your compiled kernel and copy it into this folder with the tools. Rename it as "boot.img-kernel"
10. Sweet now you need to pack the new ramdisk file and your kernel you just stuck in into a new boot.img (this part took me forever to figure out)
11. Here is the code to rebuild
Code:
mkbootimg --kernel boot.img-kernel --ramdisk boot.img-ramdisk.cpio.gz --cmdline 'console=null androidboot.hardware=qcom user_debug=31 zcache' --base 0x80200000 --pagesize 2048 --ramdiskaddr 0x81500000 -o boot.img
12. This should create a file named boot.img in the directory that will have your kernel and modified ramdisk (whoo)
Any further help can be directed to this thread or PMing me!
aeppacher said:
11. Here is the code to rebuild
Code:
mkbootimg --kernel boot.img-kernel --ramdisk boot.img-ramdisk.cpio.gz --cmdline 'console=null androidboot.hardware=qcom user_debug=31 zcache' --base 0x80200000 --pagesize 2048 --ramdiskaddr 0x81500000 -o boot.img
Any further help can be directed to this thread or PMing me!
Click to expand...
Click to collapse
While executing above code I am getting : -bash: mkbootimg: command not found. Whether the mkbootimg file is exist there,
could you please help
mukulsoni said:
While executing above code I am getting : -bash: mkbootimg: command not found. Whether the mkbootimg file is exist there,
could you please help
Click to expand...
Click to collapse
Are you doing this is the same directory as the mkbootimg file? Otherwise you have to path it
aeppacher said:
Are you doing this is the same directory as the mkbootimg file? Otherwise you have to path it
Click to expand...
Click to collapse
Yes I am doing in same path. Its unpacking correctly, but showing error while packing the boot
Hmmm perhaps a bad download?
aeppacher said:
Hmmm perhaps a bad download?
Click to expand...
Click to collapse
but unpacking is fine, My downloaded zip file is in 66.4 Kb size. any way could you please try to compile the attached HP.zip into boot.img in your system. TIA
Edit: sorry downloaded file size is 290kb. please send me the final compiled boot.img file. Thanks so much
mukulsoni said:
but unpacking is fine, My downloaded zip file is in 66.4 Kb size. any way could you please try to compile the attached HP.zip into boot.img in your system. TIA
Edit: sorry downloaded file size is 290kb. please send me the final compiled boot.img file. Thanks so much
Click to expand...
Click to collapse
What version of linux are you running? Ubuntu? what version number, and is it 32-bit or 64-bit
EDIT: try install 32bit packages "sudo apt-get install ia32-libs"
aeppacher said:
What version of linux are you running? Ubuntu? what version number, and is it 32-bit or 64-bit
EDIT: try install 32bit packages "sudo apt-get install ia32-libs"
Click to expand...
Click to collapse
I am running these scripts on window7 using Cygwin64. I guess these script should run on window 7 64 bit too.... please guide
mukulsoni said:
I am running these scripts on window7 using Cygwin64. I guess these script should run on window 7 64 bit too.... please guide
Click to expand...
Click to collapse
I have no clue how to fix that. Mkbootimg is for 32 bit instruction so you need the appropriate libraries. No clue how to do that in windows

Categories

Resources