Kernel Repacking - Captivate Q&A, Help & Troubleshooting

First I would like to thank boog for all his help to get me to this point, but I'm stuck with an error.
I've been dipping my foot into the kernel unpacking and repacking waters. I'm currently using the attached two scripts boog sent me for unpacking and repacking as well as these toolchains, but this is what my output looks like after unpacking and then attempting to repack the stock I897UCKI2 kernel:
Code:
##### My name is ./repacker.sh #####
##### The source kernel is /media/C70D-E87A/Captivate/Kernels/I897UCKI2/zImage #####
##### The destination zImage file is /media/C70D-E87A/Captivate/Kernels/I897UCKI2/repacked/zImage #####
##### The directory of the initramfs has been selected #####
##### The initramfs is /media/C70D-E87A/Captivate/Kernels/I897UCKI2/initramfs_root (will be gzipped) #####
5970 blocks
##### 01. Extracting kernel from /media/C70D-E87A/Captivate/Kernels/I897UCKI2/zImage (start = 16541) to ./out/Image
321+1 records in
321+1 records out
5310899 bytes (5.3 MB) copied, 0.540424 s, 9.8 MB/s
gzip: stdin: decompression OK, trailing garbage ignored
##### 02. The size of the new initramfs is = 1851649 / original = 3056568
##### 03. The size of the Image is 13428224
##### 04. Making a head.img ( from 0 ~ 143360 )
1+0 records in
1+0 records out
143360 bytes (143 kB) copied, 0.000480648 s, 298 MB/s
##### 05. Making a tail.img ( from 3199928 ~ 13428224 )
3+1 records in
3+1 records out
10228296 bytes (10 MB) copied, 0.0784701 s, 130 MB/s
##### 06. Merging head + initramfs
##### 07. Checking the size of [head+initramfs]
##### 08. Merging [head+initramfs] + padding + tail
1+0 records in
1+0 records out
1204919 bytes (1.2 MB) copied, 0.0129411 s, 93.1 MB/s
#==========================================
##### Now we are rebuilding the zImage #####
#==========================================
##### 09. Image ---> piggy.gz
##### 10. piggy.gz ---> piggy.o
##### 13. head.o + misc.o + piggy.o ---> vmlinux
/opt/toolchains/arm-2009q3/bin/arm-none-linux-gnueabi-ld: arch/arm/boot/compressed/vmlinux: Unknown mandatory EABI object attribute 44
/opt/toolchains/arm-2009q3/bin/arm-none-linux-gnueabi-ld: failed to merge target specific data of file arch/arm/boot/compressed/piggy.o
/opt/toolchains/arm-2009q3/bin/arm-none-linux-gnueabi-ld: arch/arm/boot/compressed/misc.o: Unknown mandatory EABI object attribute 44
/opt/toolchains/arm-2009q3/bin/arm-none-linux-gnueabi-ld: failed to merge target specific data of file arch/arm/boot/compressed/misc.o
##### 14. vmlinux ---> zImage
/opt/toolchains/arm-2009q3/bin/arm-none-linux-gnueabi-objcopy: 'arch/arm/boot/compressed/vmlinux': No such file
##### 15. Getting finished!!
cp: cannot stat `arch/arm/boot/zImage': No such file or directory
rm: cannot remove `arch/arm/boot/compressed/vmlinux': No such file or directory
rm: cannot remove `arch/arm/boot/zImage': No such file or directory
#==========================================
##### DONE!! #####
#==========================================
I ran the script like follows:
./repacker.sh -s /media/C70D-E87A/Captivate/Kernels/I897UCKI2/zImage -d /media/C70D-E87A/Captivate/Kernels/I897UCKI2/repacked/zImage -r /media/C70D-E87A/Captivate/Kernels/I897UCKI2/initramfs_root/ -c gzip
I've attempted to run the repack script normally and with sudo with the same output. Now I'm wanting to pick anyone's brain who will let me in why I'm having this issue.
I was able to compile a new zImage using these toolchains but I would be stuck in a kernel bootloop.
If you need or would like more info just let me know and I'll provide what I can.

Just thought I'd provide a little update and some more OS/hardware information.
I'm working off a laptop with a 1.6Ghz Intel Celeron M 380 and 1G of RAM running Kubuntu 11.04.
I read somewhere that some people have had issues with getting the repacking to work on 11.04 so I'm thinking about downgrading back to 10.04 or whatever is the LTS version is.
I did move the kernel to ~/Kernels/I897UCKI2/ to see if it being on the FATwhatever Flash drive was causing the issue or not with no luck.

Glad to see you put your knowledge to work Patience and u'll get it done, although it would be nice if someone would give u a hand on this. I would gladly do so if I only had the knowledge
gl

fuloplori said:
Glad to see you put your knowledge to work Patience and u'll get it done, although it would be nice if someone would give u a hand on this. I would gladly do so if I only had the knowledge
gl
Click to expand...
Click to collapse
This mostly came from boog's knowledge that he shared with me. I'm still trying out a few things, but so far I'm still stuck. Just burnt me a Ubuntu 11.04 disk that I'm going to try to boot Live from and see if I can't do it from there on my main/gaming PC.
If that doesn't work I'm going to use boog's kernel as a the base for the script mtcarey used to modify boog's kernel with and just replace the initramfs from it with the one I put together. The scripts wouldn't unpack any other kernel but boog's and require more then what the other unpack scripts unpack to repack. Doesn't look like it uses the toolchains though (seeing as I didn't have them installed at the time I used it to unpack boog's kernel).

U'd prolly came across this already, but thought I'd share what I've bumped into http://forum.xda-developers.com/showthread.php?p=15318639

While I didn't see that, I'm pretty sure those are the same (or almost the same) scripts I'm using. Thanks for the tutorial though.

I would like to unpack a kernel so I can change the boot animation of it and then repack it.
Is that hard to do?

whipps said:
I would like to unpack a kernel so I can change the boot animation of it and then repack it.
Is that hard to do?
Click to expand...
Click to collapse
boot animation is not in the kernel....

Pirateghost said:
boot animation is not in the kernel....
Click to expand...
Click to collapse
Sorry. I mean the black screen with the Samsung SGH-i897.
kernel is DarkCore

whipps said:
Sorry. I mean the black screen with the Samsung SGH-i897.
kernel is DarkCore
Click to expand...
Click to collapse
That requires the kernel source. Cannot be changed in the initramfs which is all that is unpacked.
Sent from my SAMSUNG-SGH-I897 using XDA App

Go to ficeto's git hub for the source.
It should still be there,
we use a custom kernel splash for darkcore in mosaic.

studacris said:
Go to ficeto's git hub for the source.
It should still be there,
we use a custom kernel splash for darkcore in mosaic.
Click to expand...
Click to collapse
Thanks for the info.
This is where I went, https://github.com/ficeto, but I'm not sure what I'm looking for.

whipps said:
Thanks for the info.
This is where I went, https://github.com/ficeto, but I'm not sure what I'm looking for.
Click to expand...
Click to collapse
I believe the bottom two from the following url are the ones you want I believe.
https://github.com/DarkyROM/

Kyuta Syuko said:
I believe the bottom two from the following url are the ones you want I believe.
https://github.com/DarkyROM/
Click to expand...
Click to collapse
That looks like what I need, but I hate to say I'm not that advanced to try unpacking a kernel on my phone just to change the boot image.
I guess I will just deal with it.

Related

[HOW TO] compile lge_star_kernel for cm7

this thread is a short how to compile lge_star_kernel for cm7. as i am a noobie, if there is mistake, wrong, etc. please correct me.
there is cm kernel how to at http://wiki.cyanogenmod.com/wiki/Building_Kernel_from_source. i will make a few change from there for p990 (shown in bold)
benee in vorkKernel project posted how to compile vorkKernel at https://github.com/VorkTeam/vorkKernel-Scripts/wiki
git tutorial at http://gitref.org/creating/
lge-kernel-star is at http://github.com/CyanogenMod/lge-kernel-star/
# how to #
0. install required development support package : (see cm kernel how to)
0. assuming that cm rom source in ~/android/system and kernel source in ~/android/kernel for 1A and 1B or ~/android/system/kernel for 1C
1A. download kernel source : (first time only. you can use git for deltas only. see post #4 and follow step 1B instead)
> mkdir -p ~/android/kernel
> cd ~/android/kernel
> git clone git://github.com/CyanogenMod/lge-kernel-star.git
> cd lge-kernel-star
1B. update kernel source by git for new commits
> cd ~/android/kernel/lge-kernel-star
> git pull
1C. alternatively, set up git for cm repo
> cp local_manifest.xml ~/android/system/.repo/local_manifest.xml
> cd ~/android/system
> repo sync -j16 kernel/lge-kernel-star
> cd ~/android/system/kernel/lge-kernel-star
2. set up compiler prefix : we need "ARM EABI Toolchain" from prebuilt/linux-x86/toolchain/arm-eabi-4.4.0/bin/ in CM ROM source tree (4.4.3 also works, and i'm using it)
> export CCOMPILER=${HOME}/android/system/prebuilt/linux-x86/toolchain/arm-eabi-4.4.3/bin/arm-eabi-
3. copy config
> cp arch/arm/configs/star_cyanogenmod_defconfig .config
4. run configuration
> make ARCH=arm CROSS_COMPILE=$CCOMPILER oldconfig
5. build
> make ARCH=arm CROSS_COMPILE=$CCOMPILER -j`grep 'processor' /proc/cpuinfo | wc -l`
6. copy kernel and modules to cm source device folder (zImage is renamed as kernel)
> cp arch/arm/boot/zImage ~/android/system/device/lge/p990/kernel
> cp drivers/net/wireless/bcm4329/wireless.ko ~/android/system/device/lge/p990/prebuilt/wireless.ko
7. build CM ROM using the compiled kernel and modules
p.s. i use a bash script that does 2 to 6 automatically.
kernel source mod
# version : the current versioning that shows up in Settings > About phone > kernel version is a bit hard to follow if everybody compiles his/her own kernel. i customize lge-kernel-star/scripts/mkcompile_h and use date as version
46: DATETODAY=`date +"%Y%m%d"`
47: UTS_VERSION="$DATETODAY#$VERSION"
# compiled by : since i have a different username on linux system that i use, force it to show the name you want on it.
67: echo \#define LINUX_COMPILE_BY \"YOUR_NAME\"
68: echo \#define LINUX_COMPILE_HOST \"YOUR_MACHINE\"
here is my (simplified) shell script to compile kernel
Code:
#!/bin/sh
export CCOMPILER=${HOME}/android/system/prebuilt/linux-x86/toolchain/arm-eabi-4.4.3/bin/arm-eabi-
cd ${HOME}/android/kernel/lge-kernel-star || exit
${CCOMPILER}gcc --verbose || exit # show the cross compiler
\cp arch/arm/configs/star_cyanogenmod_defconfig .config
make ARCH=arm CROSS_COMPILE=$CCOMPILER oldconfig
make ARCH=arm CROSS_COMPILE=$CCOMPILER -j`grep 'processor' /proc/cpuinfo | wc -l`
edit: added a printout of manual checking of compiler in line 4
Following is from myfluxi
myfluxi said:
Hey, it's me again. Regarding the kernel thread, cloning the kernel ressources is not very efficient, instead add the git to your repository and just download deltas. Edit (typically) ~/android/.repo/local_manifest.xml by adding:
Code:
<project path="kernel/lge-kernel-star" name="CyanogenMod/lge-kernel-star.git" remote="github" revision="android-tegra-2.6.32" />
And a late happy birthday...
Cheers
Marc
Click to expand...
Click to collapse
Thanks for sharing. I suppose that's the next fun thing to learn.
Oh btw how do u add/remove kernel or init.rc commits?
Exactly what I looked for the other day. Thanks a lot pastime1971!!
This time I won't fail ;-)
EDIT: but I did... I guess it's the export that made me fail?
Code:
[email protected]:~/android/kernel/lge-kernel-star$ make ARCH=arm CROSS_COMPILE=$CCOMPILER -j`grep 'processor' /proc/cpuinfo | wc -l`
scripts/kconfig/conf -s arch/arm/Kconfig
CHK include/linux/version.h
SYMLINK include/asm -> include/asm-arm
make[1]: `include/asm-arm/mach-types.h' is up to date.
CHK include/linux/utsrelease.h
CC scripts/mod/empty.o
cc1: error: unrecognized command line option "-mlittle-endian"
cc1: error: unrecognized command line option "-mapcs"
cc1: error: unrecognized command line option "-mno-sched-prolog"
cc1: error: unrecognized command line option "-mno-thumb-interwork"
scripts/mod/empty.c:1:0: error: unknown ABI (aapcs-linux) for -mabi= switch
scripts/mod/empty.c:1:0: error: bad value (armv5t) for -march= switch
make[2]: *** [scripts/mod/empty.o] Error 1
make[1]: *** [scripts/mod] Error 2
make: *** [scripts] Error 2
temasek said:
Thanks for sharing. I suppose that's the next fun thing to learn.
Oh btw how do u add/remove kernel or init.rc commits?
Click to expand...
Click to collapse
the way i understand it is that boot.img is built w/ kernel (as prebuilt) and init ram disk when you brunch.
there are several init.rc involved. (see out/target/product/p990/root/)
for example w/ secure clock commit, init.p990.rc is from device/lge/p990/init.p990.rc
so, i build (brunch) cyanogen w/ kernel (zImage goes to device/lge/p990/kernel and modules go to device/lge/p990/prebuilt/) compiled as above and init.rc's changed in cm (you could cherry pick them, i suppose)
for kernel itself, i don't know if you can cherry pick them or not. typically, i just apply diff patches. (if someone know how to cherry pick kernel commits, please let us know.)
pastime1971 said:
the way i understand it is that boot.img is built w/ kernel (as prebuilt) and init ram disk when you brunch.
there are several init.rc involved. (see out/target/product/p990/root/)
for example w/ secure clock commit, init.p990.rc is from device/lge/p990/init.p990.rc
so, i build (brunch) cyanogen w/ kernel (zImage goes to device/lge/p990/kernel and modules go to device/lge/p990/prebuilt/) compiled as above and init.rc's changed in cm (you could cherry pick them, i suppose)
for kernel itself, i don't know if you can cherry pick them or not. typically, i just apply diff patches. (if someone know how to cherry pick kernel commits, please let us know.)
Click to expand...
Click to collapse
Thanks.
I'll have a go and it when I'm free. Good to have u onboard.
sibbor said:
Exactly what I looked for the other day. Thanks a lot pastime1971!!
This time I won't fail ;-)
EDIT: but I did... I guess it's the export that made me fail?
Click to expand...
Click to collapse
can you "echo $CCOMPILER" or "env | grep CCOMPILER" before make to ensure that it is exported correctly ?
it re-defines to use those arm-eabi-gcc and others. see lge-kernel-star/Makefile, line 309 : CC = $(CROSS_COMPILE)gcc
without it, you would be calling gcc which doesn't understand -mlittle-endian or other options in that log
edit: i commented out the line of export from my shell script, and i get the exact same error message. it must be export issue.
edit: you should get the following when you do "${CCOMPILER}gcc --verbose"
> ${CCOMPILER}gcc --verbose
Using built-in specs.
Target: arm-eabi
Configured with: /home/jingyu/projects/gcc/android-toolchainsrc/build/../gcc/gcc-4.4.3/configure --prefix=/usr/local --target=arm-eabi --host=x86_64-linux-gnu --build=x86_64-linux-gnu --with-gnu-as --with-gnu-ld --enable-languages=c,c++ --with-gmp=/home/jingyu/projects/gcc/toolchain_build/gingerbreadobj/temp-install --with-mpfr=/home/jingyu/projects/gcc/toolchain_build/gingerbreadobj/temp-install --disable-libssp --enable-threads --disable-nls --disable-libmudflap --disable-libgomp --disable-libstdc__-v3 --disable-sjlj-exceptions --disable-shared --disable-tls --with-float=soft --with-fpu=vfp --with-arch=armv5te --enable-target-optspace --with-abi=aapcs --with-gcc-version=4.4.3 --with-binutils-version=2.19 --with-gmp-version=4.2.4 --with-mpfr-version=2.4.1 --with-gdb-version=7.1.x --with-arch=armv5te --with-multilib-list=mandroid --with-sysroot=/usr/local/google/home/android/cupcake_rel_root --enable-gold=both/gold --program-transform-name='s&^&arm-eabi-&'
Thread model: single
myfluxi said:
pastime1971 said:
Dear Marc,
Do you know how to set up local copy of git for lge-kernel-star ?
I can add that line to cm/.repo/local_manifest.xml and it works.
But I would like to have a separate one just for kernel.
I can copy .repo from cm and strip it down, and leave just kernel. That works as well.
But I was wondering if there is a better way to do it. I tried to "repo init -u git://github.com/CyanogenMod/lge-kernel-star.git -b android-tegra-2.6.32" but it fails w/ the following message: #error message deleted#
besides, the source goes into .repo/manifests/
maybe I need to use git command directly ?
regards,
pastime
Click to expand...
Click to collapse
Hey,
if you just want to be on top of things of our beloved lge-kernel-star, maybe just:
git clone git://github.com/CyanogenMod/lge-kernel-star.git
and then sync with
cd lge-kernel-star
git [pull | fetch]
What do you think?
Cheers
Marc
Click to expand...
Click to collapse
thanks for your advice. i updated the first post accordingly.
edit: w/ today's commit, i tried "git fetch", and nothing happens. tried "git pull" and it downloads new commits. updated the first post. comment welcome if you know the difference between fetch and pull.
Managed to build the kernel now. Will see if my freshly compiled Kang include it or not. If it's included I think it's magic... because I had to create the folders manually where I copied the zImage. Feels like it should already have been there, no?
Hey, pastime, you've got an error in point #6:
Code:
cp arch/arm/boot/zImage ~/andoid/system/device/lge/p990/kernel
should be
Code:
cp arch/arm/boot/zImage ~/and[B]r[/B]oid/system/device/lge/p990/kernel
sibbor said:
Managed to build the kernel now. Will see if my freshly compiled Kang include it or not. If it's included I think it's magic... because I had to create the folders manually where I copied the zImage. Feels like it should already have been there, no?
Hey, pastime, you've got an error in point #6:
Code:
cp arch/arm/boot/zImage ~/andoid/system/device/lge/p990/kernel
should be
Code:
cp arch/arm/boot/zImage ~/and[B]r[/B]oid/system/device/lge/p990/kernel
Click to expand...
Click to collapse
omg, sorry about the typo.... i manually typed those...
glad it is working for you now
when your kernel is included in your kang, you would see your name and host in "About phone"
edit: typo corrected
edit: i just read your comment on the folder... it should be there already, isn't it ? it is under YOUR_CYANOGEN_ROM_SOURCE_FOLDER/device/lge/p990/
edit: device/lge/p990/kernel is a file, not a folder. "zImage" is renamed to "kernel" in that folder (p990). wireless.ko is the same name in p990/prebuilt/
pastime1971 said:
omg, sorry about the typo.... i manually typed those...
glad it is working for you now
when your kernel is included in your kang, you would see your name and host in "About phone"
edit: typo corrected
edit: i just read your comment on the folder... it should be there already, isn't it ? it is under YOUR_CYANOGEN_ROM_SOURCE_FOLDER/device/lge/p990/
edit: device/lge/p990/kernel is a file, not a folder. "zImage" is renamed to "kernel" in that folder (p990). wireless.ko is the same name in p990/prebuilt/
Click to expand...
Click to collapse
Ah, yeah. Thanks!
Sure, it's working for me. [email protected] Sweet stuff! Thanks for the brilliant guide pastime.
Making my own shell scripts now I learn the whole process a bit better too, from A to Z ;-)
sibbor said:
Ah, yeah. Thanks!
Sure, it's working for me. [email protected] Sweet stuff! Thanks for the brilliant guide pastime.
Making my own shell scripts now I learn the whole process a bit better too, from A to Z ;-)
Click to expand...
Click to collapse
you are welcome.
enlighten us if you find a way to improve it, too.
i moved on to using "git pull", thanks to myfluxi
I did another "pull request" on kernel regarding touch screen.
Not sure if I did it right this time, it seems somehow different from last.
Let say you have a old pull request.
How do I withdraw it, update to the latest, and make a new pull request? (Assuming that is a right procedure.) I had to delete the old one, and started from the scratch. Doesn't feel right.
If you're only interested in the kernel, you can build just the boot image if you like:
make -j4 bootimage
Only takes a few seconds really.
Rusty! said:
If you're only interested in the kernel, you can build just the boot image if you like:
make -j4 bootimage
Only takes a few seconds really.
Click to expand...
Click to collapse
i imagined that something like that would be possible.
never knew how...
thanks, rusty
Rusty! said:
If you're only interested in the kernel, you can build just the boot image if you like:
make -j4 bootimage
Only takes a few seconds really.
Click to expand...
Click to collapse
Could u be a little more specific? I tried that command but it builds generic one... Am I missing something here? I think I am....
Insights pls?
make clean
. build/envsetup.sh
lunch p990-eng
make -j4 bootimage
Rusty! said:
make clean
. build/envsetup.sh
lunch p990-user
make -j4 bootimage
Click to expand...
Click to collapse
Cool.
The boot.img created in a blaze. But this method is only applicable if the kernel is committed? What if it is just committed in the star kernel git but yet to be merged to cm, then we do we have to create a zImage and then compile CM ?
Thanks.....

[DEV TOOLS] - Pack & Repack Boot.img Files - for Windows USERS

Plagiarism will not be tolerated on XDA-Developers:
http://forum.xda-developers.com/showpost.php?p=35640046&postcount=36
Reserved - Possible Updates Using Cygwin
I'm gonna take this one just in case as well
Thx for the app but i have an empty ramdisk folder...and all of the ramdisk files can't created or newer or same age version exists...cydwin won't let me copy the log...im using huawei not SE phone..if it has something to do!! But i can see the contents at boot.img-ramdisk.gz
Thanks but please mirror to other filehoster because mf is buggy on my phone
Sent from my WT19i using xda premium
$ ./extractboot boot.img
./extractboot: ./split_bootimg.pl: /usr/bin/perl: bad interpreter: Permission denied
./extractboot: line 17: cpio: command not found
gzip: ../../boot.img-ramdisk.gz: No such file or directory
what i missed here?
edit: opps. missed the REQUIRED packages. testing again.
$ ./extractboot boot.img
Android Magice not found in ./boot.img/ Giving up.
gzip: ../../boot.img-ramdisk.gz: unexpected end of file
cpio: premature end of archive
Any help with this error? I am trying to split and edit a custom CM9/ICS boot.img
very useful tool, thanks
This isn't working for me on my htc evo 4g lte. I am unpacking the stock boot.img and then repacking it with NO changes and get bootloops.
your image png should not exceed 20KB and your logo.rle should not exceed 60kb Otherwise you will almost always bootloop
stef67000 said:
your image png should not exceed 20KB and your logo.rle should not exceed 60kb Otherwise you will almost always bootloop
Click to expand...
Click to collapse
I didn't change any pngs, logos, or anything. I simply unpacked, repacked, and flashed.
maxdamage2122 said:
I didn't change any pngs, logos, or anything. I simply unpacked, repacked, and flashed.
Click to expand...
Click to collapse
Check on the way your kernel should be build.. Ours use as base 0x20 but yours may change..
Sent from my LT18i using Tapatalk
jimbo77 said:
Check on the way your kernel should be build.. Ours use as base 0x20 but yours may change..
Sent from my LT18i using Tapatalk
Click to expand...
Click to collapse
Is there a way to check without the source? Source for our kernel isn't released yet.
I've tried to unpack the last boot.img from cm9 RC2 to get the new cwm 6.x but I have an issue
Code:
$ ./extractboot boot.img
Page size: 2048 (0x00000800)
Kernel size: 3229308 (0x0031467c)
Ramdisk size: 1789254 (0x001b4d46)
Second size: 0 (0x00000000)
Board name:
Command line:
Writing boot.img-kernel ... complete.
Writing boot.img-ramdisk.gz ... complete.
./extractboot: line 17: cpio: command not found
I use this way http://forum.xda-developers.com/showthread.php?t=1477845
how to change spash screen http://forum.xda-developers.com/showthread.php?t=1140406
You need to download the cpio package through cygic in order to have it fixed..
Sent from my SGS3... Yes I have it!!!!
jimbo77 said:
You need to download the cpio package through cygic in order to have it fixed..
Sent from my SGS3... Yes I have it!!!!
Click to expand...
Click to collapse
thanks
thomas.raines said:
$ ./extractboot boot.img
Android Magice not found in ./boot.img/ Giving up.
gzip: ../../boot.img-ramdisk.gz: unexpected end of file
cpio: premature end of archive
Any help with this error? I am trying to split and edit a custom CM9/ICS boot.img
Click to expand...
Click to collapse
Hello,I'm having the same error with CM9/10 ICS/JellyBean kernel boot.img,there are chances it comes from the kernel itself as it appears to be or should we better look into our configuration?
helo, i repacket doomlord kernel v22 and when im trying to flash it i got this error :
FAILED (remote: Wrong range:0x10008000-0x103202d7. Ok:0x00200000 - 0x03dfff)
It's somethink about size of kernel and "fake size maker" file, but i dont know how to fix it.
So I pulled a working one apart and replaced the kernel with the compiled one.
Code:
[email protected] ~
$ cd /boot
[email protected] /boot
$ ./extractboot boot.img
Page size: 2048 (0x00000800)
Kernel size: 4463500 (0x00441b8c)
Ramdisk size: 372027 (0x0005ad3b)
Second size: 0 (0x00000000)
Board name:
Command line: console=ttyHSL0,115200,n8 androidboot.hardware=qcom loglevel=0
Writing boot.img-kernel ... complete.
Writing boot.img-ramdisk.gz ... complete.
2881 blocks
[email protected] /boot
$ ./packboot
Using base address 0x40200000
Using command line 'console=ttyHSL0,115200,n8 androidboot.hardware=qcom loglevel=0'
No errors
I then put it back together and I'm getting the boot.img is like half the original size (even tho the kernel files were pretty close to almost deadon the same size) and when I try to send to boot I get this
Code:
>fastboot boot boot_new.img
downloading 'boot.img'...
OKAY [ 1.168s]
booting...
FAILED (remote: incomplete bootimage)
finished. total time: 1.168s
This is for a Pantech Burst (p9070) if that helps at all
Original boot.img
New repacked boot.img

[HOWTO] build nexus 4 kernel

environment: ubuntu 10.04 LTS 64bit
get some package
sudo apt-get install gnupg flex bison gperf build-essential \
zip curl zlib1g-dev libc6-dev lib32ncurses5-dev ia32-libs \
x11proto-core-dev libx11-dev lib32readline5-dev lib32z-dev \
libgl1-mesa-dev g++-multilib mingw32 tofrodos python-markdown \
libxml2-utils xsltproc
install git
first install some packages that git depends on:
sudo apt-get install libcurl4-gnutls-dev libexpat1-dev gettext libz-dev libssl-dev
get the new git source code from http://code.google.com/p/git-core/downloads/list.
download git-1.8.0.tar.gz
tar -xvf git-1.8.0.tar.gz
cd git-1.8.0
./configure
make
sudo make install
this will install git to /usr/local/bin/
get the kernel source code:
mkdir -p ~/android/kernel
cd ~/android/kernel
git clone https://android.googlesource.com/kernel/msm
check which version of kernel to checkout
mkdir ~/work/android/nexus4-kernel
cd ~/work/android/nexus4-kernel
git clone https://android.googlesource.com/device/lge/mako-kernel
cd mako-kernel
git log kernel
get the commit rev, which is e039dcb (nov 25, 2012), this number seems to correspond to the latest commit revision in https://android.googlesource.com/kernel/msm/android-msm-mako-3.4-jb-mr1
check out the kernel
cd ~/android/kernel/kernel_msm
git checkout <commit version>
note: commit version is e039dcb, which is the result of the git log kernel command in the previous step
install google toolchain
mkdir ~/android/toolchain
cd ~/android/toolchain
git clone https://android.googlesource.com/platform/prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.6
add “export PATH=$PATH:~/android/toolchain/arm-linux-androideabi-4.6/bin” to ~/.profile and run source ~/.profile
setup environment variables and build
cd ~/android/kernel/kernel_msm
export ARCH=arm
export SUBARCH=arm
export CROSS_COMPILE=arm-linux-androideabi-
make mako_defconfig
make -j4
done
if you wanna thank me. go to google play and try out my app Wishlist :laugh:
https://play.google.com/store/apps/details?id=com.wish.wishlist
So with this I can make my own kernel for the Nexus 4? Hmm... will be nice to make one and get people to test it out for me lol.
I can edit the CPU, GPU, UV settings, etc? Is this only on Ubuntu or can it be done on Windows?
the kernel source is from google, but you can modify it as you wish. this is only for ubuntu. other linux environment will also work. but not windows.
You could change "make -j4" by "make -j$(grep -c ^processor /proc/cpuinfo)" ...
matt73300 said:
You could change "make -j4" by "make -j$(grep -c ^processor /proc/cpuinfo)" ...
Click to expand...
Click to collapse
that's handy to use.
But should the general rule of N in make -jN be twice the number of cpu core? for example, on my computer, I have two cores, so I use -j4.
yduck said:
that's handy to use.
But should the general rule of N in make -jN be twice the number of cpu core? for example, on my computer, I have two cores, so I use -j4.
Click to expand...
Click to collapse
Not really nice for lambda users. I think it's better when it written as I said (no need to know how many cores you have), or j# (and say replace # by 2xnumber_of_cores).
I have 8 cores on my computer, so I use j16 and it's much faster than j4, some people should know it
for some reason, the kernel I built cannot be booted.
when I did:
fastboot boot zImage
the phone stuck at the google logo.
any idea? I have seen other people in the forum built the kernel and booted it. there must be something wrong with the way I compiled the kernel, or the config is incorrect, or do I need to sign the kernel?
yduck said:
for some reason, the kernel I built cannot be booted.
when I did:
fastboot boot zImage
the phone stuck at the google logo.
any idea? I have seen other people in the forum built the kernel and booted it. there must be something wrong with the way I compiled the kernel, or the config is incorrect, or do I need to sign the kernel?
Click to expand...
Click to collapse
Is the zImage file the one found in "arch/arm/boot/zImage"? If so, then you can't use this directly in fastboot. You need to create a boot.img file.
Edit 2: You could possibly try this: " fastboot flash:raw boot <kernel> <ramdisk> ". I personally have not done, this. I created the boot.img file and flashed it.
Edit 3: Note that Edit 2 does perform a flash instead of boot, so be very wary of this. I recommend you create a boot.img file and use "fastboot boot boot.img" for testing --- it's safer that way.
dsana123 said:
Is the zImage file the one found in "arch/arm/boot/zImage"? If so, then you can't use this directly in fastboot. You need to create a boot.img file.
Edit 2: You could possibly try this: " fastboot flash:raw boot <kernel> <ramdisk> ". I personally have not done, this. I created the boot.img file and flashed it.
Edit 3: Note that Edit 2 does perform a flash instead of boot, so be very wary of this. I recommend you create a boot.img file and use "fastboot boot boot.img" for testing --- it's safer that way.
Click to expand...
Click to collapse
great suggestion. I just figured this out yesterday. as you said, fastboot boot does not work with just the zImage. it needs a boot.img.
so I created a newboot.img by packing my zImage and the ramdisk extracted from google's stock boot.img, and the newboot.img boots!
the command "fastboot flash:raw <kernel> <ramdisk>" seems simple to use. does it have an equivalent "fastboot boot: raw <kernel> <ramdisk"? so I don't need to worry about breaking my phone.
yduck said:
the command "fastboot flash:raw <kernel> <ramdisk>" seems simple to use. does it have an equivalent "fastboot boot: raw <kernel> <ramdisk"? so I don't need to worry about breaking my phone.
Click to expand...
Click to collapse
The fasboot.c source file at
https://android.googlesource.com/pl...8d27c72a03d56c1a36068a57f/fastboot/fastboot.c
indicates that there is no equivalent, although if you want to start modifying the fastboot.c code, it is probably easy enough to do so. Below is the relevant flash:raw code in fastboot.c:
} else if(!strcmp(*argv, "flash:raw")) {
char *pname = argv[1];
char *kname = argv[2];
char *rname = 0;
require(3);
if(argc > 3) {
rname = argv[3];
skip(4);
} else {
skip(3);
}
data = load_bootable_image(page_size, kname, rname, &sz, cmdline);
if (data == 0) die("cannot load bootable image");
fb_queue_flash(pname, data, sz);
Click to expand...
Click to collapse
From your post it sounds like you're using mkbootimg to create the boot image so you have what you need anyway (as long as you call mkbootimg with all the parameters corresponding to the boot header info from the boot image you extracted --- base offset, kernel offset, ramdisk offset, page offset, kernel command line , etc).
I've just added this guide to the Nexus 4 Complete Index
Sent from my GT-I9100 using xda premium
KidCarter93 said:
I've just added this guide to the Nexus 4 Complete Index
Sent from my GT-I9100 using xda premium
Click to expand...
Click to collapse
awesome! my post got into the index. I am so excited.:cyclops:
Thanks- although cdesai already made one
cdesai's thread here
yduck said:
great suggestion. I just figured this out yesterday. as you said, fastboot boot does not work with just the zImage. it needs a boot.img.
so I created a newboot.img by packing my zImage and the ramdisk extracted from google's stock boot.img, and the newboot.img boots!
the command "fastboot flash:raw <kernel> <ramdisk>" seems simple to use. does it have an equivalent "fastboot boot: raw <kernel> <ramdisk"? so I don't need to worry about breaking my phone.
Click to expand...
Click to collapse
I wonder if this is the correct way of making boot.img. I heard kernel image and ramdisk are related, if you modify and recompile the kernel and pack it with an old ramdisk, it may not boot. Is it true? what's the standard way of making boot.img? Is there a method to make our own ramdisk, instead of extracting it from google's stock boot.img?
yduck said:
setup environment variables and build
cd ~/android/kernel/kernel_msm
export ARCH=arm
export SUBARCH=arm
export CROSS_COMPILE=arm-linux-androideabi-
make mako_defconfig
make -j4
Click to expand...
Click to collapse
Based in part on this documentation, I have created a HOWTO on building the system.img and boot.img files (for fastboot) with a single "make" call. Checkout: http://nosemaj.org/howto-build-android-nexus-4 .
Hi, I have two strange problems when trying to compile the mako kernel source. My setup:
Ubuntu 10.04, 64-bit (succesfully compiled a GB kernel for another device with this setup, using Google gcc 4.4.3 and Linaro gcc 4.6.2)
Kernel source from https://android.googlesource.com/kernel/msm, HEAD @ 7ce11cd - this is the android-msm-mako-3.4-jb-mr1.1 branch, wich should be identical to the kernel shipped with 4.2.2
Google gcc 4.6.x from https://android.googlesource.com/platform/prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.6, also jb-mr1.1-release
No changes to the source, yet
There are two problems when compiling. First, there is this error
Code:
error: the frame size of XXXX bytes is larger than 1024 bytes
which is caused by 'CONFIG_FRAME_WARN=1024'. This value is not set in mako_defconfig, but seems to be the default for gcc 4.6 and is written to the .config when running make mako_defconfig. I am able to bypass this by setting 'CONFIG_FRAME_WARN=2048', but question is: Why do I need to? The stock kernel on my device running 4.2.2 has been compiled with 'CONFIG_FRAME_WARN=1024'.
The second problem are warnings of the type
Code:
warning: unwinding may not work because EXIDX input section XX of arch/arm/.../YYY.o is not in EXIDX output section
These can be suppressed by setting '# CONFIG_ARM_UNWIND is not set' and adding 'CONFIG_FRAME_POINTER=y'. But again, the stock kernel is compiled with 'CONFIG_ARM_UNWIND=y' and obviously, the Google guys didn't have this problem. What's wrong with my setup?
add “export PATH=$PATH:~/android/toolchain/arm-linux-androideabi-4.6/bin” to ~/.profile and run source ~/.profile
I can't figure out why but I keep getting a no command 'add' found
Sent From My Paranoid Nexus
atomilluminati said:
add “export PATH=$PATH:~/android/toolchain/arm-linux-androideabi-4.6/bin” to ~/.profile and run source ~/.profile
I can't figure out why but I keep getting a no command 'add' found
Sent From My Paranoid Nexus
Click to expand...
Click to collapse
Thanks for the response. The path to the compiler is defined in my kernel build script. Do I have to change it in my .profile, too?
XDA_Bam said:
Thanks for the response. The path to the compiler is defined in my kernel build script. Do I have to change it in my .profile, too?
Click to expand...
Click to collapse
Actually this was supposed to be a question...my bad... I keep getting to that line in the OP's instructions and can't get past it
Sent From My Paranoid Nexus
atomilluminati said:
Actually this was supposed to be a question...my bad... I keep getting to that line in the OP's instructions and can't get past it
Sent From My Paranoid Nexus
Click to expand...
Click to collapse
Hehe Okay, the answer is that you have to open the ~/.profile and manually add in a text editor the line given in the OP. The file should be in your profile folder (/home/your_user_name/). After this, save, close and run
Code:
source ~/.profile
in the terminal. That should do it, as far as I understood.

[GUIDE] Build CM10 kernel from source + wkpark's RAM hack

For any CM10 ROM, except new bootloader one, hackfest, and CM10.1
This tutorial shows you how to build CM10 kernel from RC and the CM team's source(it is their work), and using wkpark's ramhack patch or other patches
If you are uncomfortable in building the kernel, you use my flashable sample kernel at the end of the post, which uses 56 MB RAM hack.
Pre-requistes:
A Linux system
An internet connectionc
Some time and patience
But the time required for downloading resources, and building once everything is set up, is only a fraction of the time required for a full CM10 ROM
You can follow this guide, with or without having built CM10 following Raum1807's excellent CM10 building guide. At one of the places, the difference occurs whether you had built CM10 before or not, and I have listed it at that place
For a first time build, you need to follow all the steps, but 2nd time onwards, you can skip to the build step or RAM hack setting step
Instructions:
STEP 1: SETTING UP THE ENVIRONMENT
Install any CM10 ROM on the device (old bootloader, non-hackfest, non-CM10.1 one)
If you already have CM10 environment set up, skip to "Create an environment variable..." part
Install development support packages:
Debian based Linux distributions (like Ubuntu)
64bit systems:
Code:
sudo apt-get install git-core gnupg flex bison gperf build-essential \
zip curl libc6-dev libncurses5-dev:i386 x11proto-core-dev \
libx11-dev:i386 libreadline6-dev:i386 libgl1-mesa-glx:i386 \
libgl1-mesa-dev g++-multilib mingw32 openjdk-6-jdk tofrodos \
python-markdown libxml2-utils schedtool pngcrush xsltproc zlib1g-dev:i386
then
Code:
sudo ln -s /usr/lib/i386-linux-gnu/mesa/libGL.so.1 /usr/lib/i386-linux-gnu/libGL.so
Red Hat based Linux distributions
32bit and 64bit systems:
git gnupg java-1.6.0-openjdk-devel flex bison gperf SDL-devel esound-devel wxGTK-devel zip curl ncurses-devel zlib-devel gcc-c++ glibc-devel
64bit only:
glibc-devel.i686 libstdc++.i686 zlib-devel.i686 ncurses-devel.i686
Setting up Java (thanks to Raum for the java setup guide)
You need a Java Development Kit for building CM10. Recommended is the SUN JDK 6. As of writing the most recent version is SUN JDK 6 Update 37.
1. Download the jdk-6u37-linux-i586.bin from the Oracle/Sun Java Download Area. If you are on 64-bit Ubuntu as I am, you should grab jdk-6u37-linux-x64.bin.
2. Make the bin file executable:
Code:
$ chmod +x jdk-6u37-linux-x64.bin
3. Extract the bin file:
Code:
$ ./jdk-6u37-linux-x64.bin
4. Move the extracted folder to this this location:
Code:
$ sudo mv jdk1.6.0_37 /usr/lib/jvm/./jdk-6u37-linux-x64.bin
5. Install the new Java source in system:
Code:
$ sudo update-alternatives --install /usr/bin/javac javac /usr/lib/jvm/jdk-6u37-linux-x64.bin/bin/javac 1
$ sudo update-alternatives --install /usr/bin/java java /usr/lib/jvm/jdk-6u37-linux-x64.bin/bin/java 1
$ sudo update-alternatives --install /usr/bin/javaws javaws /usr/lib/jvm/jdk-6u37-linux-x64.bin/bin/javaws 1
$ sudo update-alternatives --install /usr/bin/javadoc javadoc /usr/lib/jvm/jdk-6u37-linux-x64.bin/bin/javadoc 1
$ sudo update-alternatives --install /usr/bin/javah javah /usr/lib/jvm/jdk-6u37-linux-x64.bin/bin/javah 1
$ sudo update-alternatives --install /usr/bin/javap javap /usr/lib/jvm/jdk-6u37-linux-x64.bin/bin/javap 1
$ sudo update-alternatives --install /usr/bin/jar jar /usr/lib/jvm/jdk-6u37-linux-x64.bin/bin/jar 1
6. Select the default Java version for your system:
Code:
$ sudo update-alternatives --config javac
$ sudo update-alternatives --config java
$ sudo update-alternatives --config javaws
$ sudo update-alternatives --config javadoc
$ sudo update-alternatives --config javah
$ sudo update-alternatives --config javap
$ sudo update-alternatives --config jar
7. Check Java version:
Code:
$ java -version
8. Verify the symlinks. Javac, Java, Javaws, Javadoc, Javah, Javap and Jar should all point to the new Java location and version:
Code:
$ ls -la /etc/alternatives/java* && ls -la /etc/alternatives/jar
Now,
If you have CM10 source fetched already (if you have built cm10)
If the directory name where the cm10 source exists is "cm10" (as in Raum's building guide)
Create an environment variable denoting the location of the android toolchain as follows:
Code:
export CCOMPILER=${HOME}/cm10/prebuilt/linux-x86/toolchain/arm-eabi-4.4.3/bin/arm-eabi-
Or else, replace the path/name if yours is different
(If your arm-eabi version is not 4.4.3, check the folder name and change it accordingly)
If you do not have cm10 source on your pc, then you need to download the ARM EABI Toolchain separately
Download link, ready to extract
If above does not work, download from official site here
Download and extract then, create an environment variable denoting the location of the toolchain as follows:
Code:
export CCOMPILER=[extraction directory]/bin/arm-eabi-
Download Kernel Source Code:
Code:
mkdir -p ~/kernel
cd ~/kernel
Now download RC's CM10 kernel source
In terminal, do
Old bootloader:
Code:
git clone git://github.com/CyanogenMod/lge-kernel-star.git -b jellybean
New bootloader:
Here, pengus77 has made the necessary changes in his repo, so we fetch from that
Code:
git clone git://github.com/pengus77/lge-kernel-star.git
Thus, there should be a folder named "lge-kernel-star" inside /kernel folder
Then in terminal, cd to that directory "lge-kernel-star"
Code:
cd lge-kernel-star
Getting the config file
The next step is to copy the file "/kernel/lge-kernel-star/arch/arm/configs/cyanogenmod_p990_defconfig" to "/kernel/lge-kernel-star and rename it to ".config"
using the command:
Code:
cp arch/arm/configs/cyanogenmod_p990_defconfig .config
(Thanks to tonyp for the tip!)
STEP 2: CONFIGURATION
Configure the build:
Code:
make ARCH=arm CROSS_COMPILE=$CCOMPILER oldconfig
If it happens to ask anything, just accept the defaults at every step by pressing enter.
STEP 3: APPLYING PATCHES
Applying patches like wkpark's RAM hack patch
If you skip this step, the kernel will work, but you'll have a completely stock kernel without RAM hack or other tweaks
Download wkpark's two patches from here and here, and put them in your /kernel directory
Code:
cd ~/kernel
Now to apply the patches, we use the patch command like this:
Code:
patch -Np1 -d lge-kernel-star < patchname.patch
(replace patchname with name of the patch file)
Here, -N is for ignoring patches that seem to be already applied or reversed
p<num> Strip the smallest prefix containing num(here num=1) leading slashes from each file name found in the patch file
In this case, num=1 according to the path names in wkpark's patch, and in a lot of cases, the value of 1 is common
-d is to change to the directory immediately, before doing anything else
You need to apply wkpark's two patches one by one (0001-..., then bootloader-...)
If you get errors while patching, if they are basic errors like file not found etc. then you should manage to fix it yourself.
But if you get errors like "HUNK ... failed",
try
Code:
patch -Np1 --ignore-whitespace -d lge-kernel-star < patchname.patch
A "HUNK ignored" is ok, if patch was attempted previously, since that file might have been successfully patched last time
if a HUNK still fails, then read the troubleshooting guide
Setting RAM hack size (If you skipped the above patching step, dont do this)
wkpark's patch makes it possible for you to set ramhack size in kernel command line parameter.
The cmdline parameter has to have the full boot.img command line parameters, which you can obtain from dmesg. I have done it for you, so you can save time on that
Here's how it looks for the old bootloader: (for the new one, ignore this)
Code:
<5>[70:01:01 00:00:00.000] Kernel command line: loglevel=0 muic_state=1 CRC=10203036179a93 brdrev=1.0 uniqueid=37c7006421f6097 video=tegrafb console=ttyS0,115200n8 usbcore.old_scheme_first=1 tegraboot=sdmmc tegrapart=recovery:35e00:2800:800,linux:34700:1000:800,mbr:400:200:800,system:600:2bc00:800,cache:2c200:8000:800,misc:34200:400:800,userdata:38700:c0000:800 [email protected] vmalloc=128M androidboot.mode=normal androidboot.hardware=star androidboot.serialno=37c7006421f6097
Paste the line starting from loglevel=0 till the end (serialno) into .config file in lge-kernel-star folder in
CONFIG_CMDLINE="<here>"
Insert a carveout size in between vmalloc and androidboot.mode
Determing carveout size: carveout=<152 - RAM hack size>M
For example, if RAM hack size is 56, then carveout is 96M
So in that case, the cmdline is like this:
old bootloader:
Code:
CONFIG_CMDLINE="loglevel=0 muic_state=1 CRC=10203036179a93 brdrev=1.0 uniqueid=37c7006421f6097 video=tegrafb console=ttyS0,115200n8 usbcore.old_scheme_first=1 tegraboot=sdmmc tegrapart=recovery:35e00:2800:800,linux:34700:1000:800,mbr:400:200:800,system:600:2bc00:800,cache:2c200:8000:800,misc:34200:400:800,userdata:38700:c0000:800 [email protected] vmalloc=128M carveout=96M androidboot.mode=normal androidboot.hardware=star androidboot.serialno=37c7006421f6097"
new bootloader:
Code:
CONFIG_CMDLINE="tegraid=20.1.4.0.0 [email protected] carveout=152M android.commchip=0 vmalloc=128M androidboot.serialno=037c7006421f6097 video=tegrafb no_console_suspend=1 console=ttyS0,115200n8 debug_uartport=lsport,-3 androidboot.mode=normal usbcore.old_scheme_first=1 [email protected] [email protected] muic_state=0 tegraboot=sdmmc tegrapart=recovery:35e00:2800:800,boot:34700:1000:800,mbr:400:200:800,persist:600:2bc00:800,cache:2c200:7f00:800,misc:34200:400:800,userdata:38700:c0000:800,bcttable:0:600:800,bootloader:100:300:800,data/ve:f8800:1400:800,system:34c000:40000:800 "
and save the file
Dont set carveout too low, or else some gpu-intensive stuff may not work properly.
STEP 4: BUILDING THE KERNEL
In terminal,
Code:
cd ~/kernel/lge-kernel-star
Code:
make ARCH=arm CROSS_COMPILE=$CCOMPILER -j`grep 'processor' /proc/cpuinfo | wc -l`
This step may take a while, depending on your computer. Took ~5-10 mins for the first build for me, and ~1 min for the second build onwards.
If it asks in the terminal "use default config?" then say "y", if not, then ignore this
If you get some error and the building aborts within a few seconds, try the "Create environment variable part" again, and then return back directly to the build step.
After it is done, you should have a kernel stored in ~/kernel/lge-kernel-star/arch/arm/boot/zImage
Preparing the flashable zip for the kernel
Some compiled modules need to be included so that problems like wifi not switching on dont occur.
They are:
drivers/misc/bthid/bthid.ko
drivers/scsi/scsi_wait_scan.ko
drivers/net/wireless/bcm4329/wireless.ko
They will be used while preparing the flashable zip below.
Thanks to feav's compiled modules and benee's anykernel updater for star, all this is ready-made and you can simply:
Download the sample kernel zip attached below and replace /kernel/zImage and and the above modules in system/lib/modules/hw in that with yours, edit updater-script if you want.
Your flashable zip is now ready
STEP 5: FLASHING AND TESTING THE KERNEL
Put the sample kernel below as a backup in case your kernel does not boot and you need a working phone immediately.
Flash the kernel in recovery, wipe cache, dalvik cache and reboot.
If the phone goes past the LG logo screen(s) and into the bootscreen of the ROM, then it should work
Then you can check "kernel version" in settings->about phone to see your kernel information,
and you can see the new RAM size (which should be 342 MB + RAM hack size) in some app like battery dr saver, or antutu benchmark's system info.
If it doesnt work, make sure you have followed the entire guide properly and then ask queries
If you want to revert to another kernel, flash that kernel in recovery, or for stock kernel, flash your ROM.
Keeping kernel source up to date (for building again later after RC has made changes to the source):
Code:
cd ~/kernel/lge-kernel-star
git pull
This will update your source with the latest commits by RC. Then you can rebuild the kernel by doing the "create environment variable" and then skip directly to the build stage
Standard disclaimer:
I am not responsible if anything goes wrong with your phone or anything else.
Credits:
aremcee/RC and the rest of the CM team for all their work. This is their kernel you are building
wkpark for his valuable contributions, including the ramhack patches and cracking the new bootloader
benee for his Anykernel updater for star, and other tweaks
feav for his compiled wifi modules
pengus77 for the work to make it suitable for the new bootloader
Download links for sample kernels:
SAMPLE 56 MB RAMHACK KERNEL
SAMPLE 32 MB RAMHACK KERNEL
SAMPLE 24 MB RAMHACK KERNEL
Troubleshooting guide:
1. Patch failure
HUNK failed means that a particular file was not patched to some problem. In this case, a .rej file is saved in the same folder as the file to be patched, and it contains the stuff not patched.
Do not neglect "failed" hunk since it means a partially applied patch(some files patched, some files not), and may cause problems. "Ignored hunk" is ok, if the patch had been attempted before on a file and had succeeded on that file last time.
To manually patch the failed hunk, go that file where the hunk failed (has same name as .rej file without .rej extension)
For example, if .rej file is board-star.c.rej, and it contains the following sample lines (look for lines beginning with '+' and remove the + before adding, similar for -) go to board-star.c, and add the lines manually like this:
Code:
#if defined (CONFIG_STAR_REBOOT_MONITOR) || defined (CONFIG_BSSQ_REBOOT_MONITOR)
#define RAM_RESERVED_SIZE 100*1024
/* Force the reserved_buffer to be at its old (Froyo/GB) location
for reboot to work with the older bootloader */
if (strstr(saved_command_line, "brdrev=")) {
extern void *reserved_buffer;
pr_info("The older bootloader detected\n");
if (memblock_end_of_DRAM() > 0x17f80000) {
if (memblock_reserve(0x17f80000, RAM_RESERVED_SIZE)) {
pr_err("Fail to get reserved_buffer for the older bootloader\n");
} else {
pr_info("Change reserved_buffer for the older bootloader\n");
reserved_buffer = phys_to_virt(0x17f80000);
}
} else {
pr_info("Change reserved_buffer\n");
reserved_buffer = ioremap(0x17f80000, RAM_RESERVED_SIZE);
}
}
#endif
This was in the .rej file, and is to be added immediately after
Code:
#if defined(CONFIG_LGE_BROADCAST_TDMB)
star_dmb_init();
#endif /* CONFIG_LGE_BROADCAST */
in board-star.c (and before the next #if defined or closing bracket)
Similarly, the - lines to be deleted and + lines are to be added in that failed hunk file
(do this manual stuff only if hunk fails)
2. If ramhack kernel fails, but normal kernel works:
From your pc, in terminal do
adb shell dmesg > dmesg.txt
or from your phone, in android terminal emulator, do
dmesg > /sdcard/dmesg.txt
Copy it from your dmesg.txt starting from loglevel=0 till the end (serialno)
Look for a line in dmesg.txt which resembles this:
Code:
<5>[70:01:01 00:00:00.000] Kernel command line: loglevel=0 muic_state=1 CRC=10203036179a93 brdrev=1.0 uniqueid=37c7006421f6097 video=tegrafb console=ttyS0,115200n8 usbcore.old_scheme_first=1 tegraboot=sdmmc tegrapart=recovery:35e00:2800:800,linux:34700:1000:800,mbr:400:200:800,system:600:2bc00:800,cache:2c200:8000:800,misc:34200:400:800,userdata:38700:c0000:800 [email protected] vmalloc=128M androidboot.mode=normal androidboot.hardware=star androidboot.serialno=37c7006421f6097
Use your own phone's parameters instead of this and then set carveout size.
3. Problem with config file:
Pulling kernel config from device:
You need to retrieve a working kernel config from the device, and unzip it.
For that, connect your phone to your pc, enable USB debugging if it was disabled, and then in terminal
Code:
adb pull /proc/config.gz ~/kernel/lge-star-kernel-jellybean/config.gz
cat config.gz | gunzip > .config
Alternatively, you can pull the .config from the newest boot.img
Code:
scripts/extract-ikconfig boot.img > .config
Changes and updates:
25/12/12:
Added changes to be made for the new bootloader (in red color)
24/12/12:
Updated the guide, added some fixes and changes
22/12/12:
Slightly modified version of wkpark's 2nd patch (bootloader one) which may possibly fix one of the errors and may remove need for manually adding some lines
Last one
rugglez.....you rock mate....
I am not sure if I will really do something as I am getting old(lolz) and if I understand enough....
but thanks mate, for keeping spirits alive for this device
rugglez,
Did you see these posts: http://forum.xda-developers.com/showpost.php?p=34600723&postcount=189
http://forum.xda-developers.com/showpost.php?p=34601277&postcount=192
Did you experienced any ploblem with USB?
SREEPRAJAY said:
rugglez.....you rock mate....
I am not sure if I will really do something as I am getting old(lolz) and if I understand enough....
but thanks mate, for keeping spirits alive for this device
Click to expand...
Click to collapse
There are always some things worth experiencing once in life, like if you are an Android user, building a ROM and a kernel. You have experienced it with your wonderful AF kernel, thats important
feav said:
rugglez,
Did you see these posts: http://forum.xda-developers.com/showpost.php?p=34600723&postcount=189
http://forum.xda-developers.com/showpost.php?p=34601277&postcount=192
Did you experienced any ploblem with USB?
Click to expand...
Click to collapse
USB works fine, both adb and mass storage
This guide may seem intimidating, but trust me, once you complete it the first time, you'll find it really simple from the next build onwards.
Uploaded a slightly modified version of wkpark's 2nd patch (bootloader one) which may possibly fix one of the errors and may remove need for manually adding some lines. Updated link in OP and attached here too.
I tried the sample kernel and my camera stops functioning and so with other apps such as contacts, they don't start at all. Im on dec 20 nightly. Could it be the ramhack size? Maybe 32mb will suffice. Just saying.
Thanks to this, will probably try this next week..
aldyu said:
I tried the sample kernel and my camera stops functioning and so with other apps such as contacts, they don't start at all. Im on dec 20 nightly. Could it be the ramhack size? Maybe 32mb will suffice. Just saying.
Thanks to this, will probably try this next week..
Click to expand...
Click to collapse
Uploaded 32 MB ram hack kernel for those having problem with camera, try it out.
Download link 32MB RH
Update:
Added 24MB version too. Here you go:
24MB RH kernel
Thanks rugglez, 32 mb rh is ok so far, cm10 is way smoother and can still play nfs most wanted. Btw, can you apply the patch for double lg logo too by wkpark?
Sent from my P990-CM10
After installing the new kernel, if some apps still don't work or there any lag, disable "force gpu rendering" and "disable hardware overlays" in developer settings.
Thank you for your work! Just flashed the 32mb version without any problem. On cm7 the 48mb ramhack was the biggest without breaking 720p recording. Maybe you should give it a try!
Uhm download a kernel zip file?
How about git clone?
Sent from my Nexus 7 using xda app-developers app
tonyp said:
Uhm download a kernel zip file?
How about git clone?
Sent from my Nexus 7 using xda app-developers app
Click to expand...
Click to collapse
Git clone size = ~440mb
Zip size = 120mb which extracts to that same size
Takes more time to download more for people like me with slow Internet, no other reason
Hi rugglez, got the ff. error when installing the required packages, Im on ubuntu 12.10 x64.
Note, selecting 'libsdl1.2-dev' instead of 'libsdl-dev'
Package sun-java6-jdk is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source
E: Package 'sun-java6-jdk' has no installation candidate
E: Unable to locate package libwxgtk2.6-dev
E: Couldn't find any package by regex 'libwxgtk2.6-dev'
How to fix? Thanks.
aldyu said:
Hi rugglez, got the ff. error when installing the required packages, Im on ubuntu 12.10 x64.
Note, selecting 'libsdl1.2-dev' instead of 'libsdl-dev'
Package sun-java6-jdk is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source
E: Package 'sun-java6-jdk' has no installation candidate
E: Unable to locate package libwxgtk2.6-dev
E: Couldn't find any package by regex 'libwxgtk2.6-dev'
How to fix? Thanks.
Click to expand...
Click to collapse
Can you install the dependencies from Raum's CM10 building thread here?
Follow steps 1 and 2 there.
Let me know if that works, ive updated the guide's step 1(setting up environment)
Installing the dependencies from this guide was the only thing i didnt test, since i had the CM10 environment set up already
a step is missing from this guide.
adb pull /proc/config.gz ~/kernel/lge-star-kernel-jellybean/config.gz
cat config.gz | gunzip > .config
Click to expand...
Click to collapse
then
mv config arch/arm/configs/<your_config_name>_defconfig
make ARCH=arm CROSS_COMPILE=$CCOMPILER oldconfig
make <your_config_name>_defconfig
make ARCH=arm CROSS_COMPILE=$CCOMPILER menuconfig
Click to expand...
Click to collapse
then continue...
if you don't make the default config the compiler throws out some errors.
ps: nice guide btw
rugglez said:
Git clone size = ~1.5gb
Zip size = 440mb which extracts to that same size
Takes forever to download more than a gig for people like me with slow Internet, no other reason
Click to expand...
Click to collapse
Hmm.. downloading it now and wondering why it's only 120mb, not 440mb as you said.
rugglez said:
Can you install the dependencies from Raum's CM10 building thread here?
Follow steps 1 and 2 there.
Let me know if that works, ive updated the guide's step 1(setting up environment)
Installing the dependencies from this guide was the only thing i didnt test, since i had the CM10 environment set up already
Click to expand...
Click to collapse
Thanks, ok now using your updated guide.
Btw, did you happen to upload a copy of the kernel zip file? Downloading from github takes forever, only 8 kb/s.
aldyu said:
Thanks, ok now using your updated guide.
Btw, did you happen to upload a copy of the kernel zip file? Downloading from github takes forever, only 8 kb/s.
Click to expand...
Click to collapse
Just use "git clone git://github.com/CyanogenMod/lge-kernel-star.git", it should give you better download speed than for the zipped archive.
I synced the whole CM10 source tree on the remote buildbox in about 5-10 minutes - so github does provide great downspeed
@rugglez: You should add to the OP that you don't have to use adb to get the kernel config, it's already there
arch/arm/configs/cyanogenmod_p990_defconfig
Please refer to the old cm7 kernel how to by pastime: http://forum.xda-developers.com/showthread.php?t=1227241
I really like the fact that more and more building guides get posted here - and that more and more people are building their own ROMs and kernels these days.
After building (which already is a great start) many people even want to learn more about android development in general. That's the true xda spirit!
Kudos!

[HOWTO] Build insecure (or permissive) kernels for Nexus 6 Marshmallow

Hi all,
I am trying to get an insecure kernel for Nexus 6, marshmallow 6.0, and I stuck at a bootloop.
The AOSP tag android-6.0.0_r1 builds without any errors. Then I flash the produced insecure boot image on a nexus 6, which had the latest 6.0 factory images.
Has anyone managed to do this procedure?
Btw, I am compiling the AOSP sources, and not the kernel sources.
In AOSP, I think, the kernel/zImage is precompiled, and the aosp build system bundles it into a boot image.
So, if someone has managed to build a working insecure boot.img from any marshmallow branch please let me know.
Or has done the same thing from kernels sources, also let me know.
EDIT:
How to compile an insecure kernel:
0. This will use the precompiled kernel found in aosp sources.
So we are not actually compiling. But this title might help some folks googling the topic.
2. modify device/<maker>/<codename>/fstab.<codename>/, and remove verify tag from system
3. make -jN bootimage
Alternatively, you can follow the procedure by ziddey, and removing the verify tag from fstab.shamu, allows the kernel to be booted!
NOTE: insecure kernel is not permissive.
How to compile a permissive kernel:
0. Now we will actually compile the kernel.
1. Download the kernel sources, and checkout the branch you want. Do these modifications.
Finally compile the kernel. (There are many tutorials for kernel compilation online)
2. copy the kernel (arch/arm/boot/zImage-dtb) to your aosp_dir/device/<maker>/<codename>-kernel/
3. Disable verification (as w/ insecure kernel)
4. make -j8 bootimage
How to compile an insecure and permissive kernel:
Not sure about this. I 'd play with configurations in aosp_dir/device/<maker>/<codename>,
or maybe try an eng build. If anyone knows just post it!
I have tried these with the kernel branch "android-msm-shamu-3.10-marshmallow-mr1",
and the aosp tag "android-6.0.1_r21".
I have also tried to unpack and repack the boot.img using unpackbootimg and mkbootimg from https://github.com/osm0sis/mkbootimg.
I have extracted ramdisk, edited the default prob, repacked ramdisk, and packed using:
Code:
mkbootimg --kernel su_boot.img-zImage --ramdisk su_boot.img-ramdisk.gz --cmdline 'console=ttyHSL0,115200,n8 androidboot.console=ttyHSL0 androidboot.hardware=shamu msm_rtb.filter=0x37 ehci-hcd.park=3 utags.blkdev=/dev/block/platform/msm_sdcc.1/by-name/utags utags.backup=/dev/block/platform/msm_sdcc.1/by-name/utagsBackup coherent_pool=8M' --base 00000000 --pagesize 2048 --kernel_offset 00008000 --ramdisk_offset 02000000 --tags_offset 01e00000 --board "" -o ins_su_boot.img
Have I missed anything?
*EDIT* also tried w/ 'abootimg'. Still no luck.
Screwing around with random files found on the internet is not going to solve your problem. Use the program from *AOSP*. And make sure your parameters match (I'm not going to verify them for you). Bootloops are always cute, what did you change? Typically running make bootimg should make you a good bootimg from AOSP sources.
Well, turns out that in this case, that assumption is not correct.
The first issue is that the verity keys are not present in a custom built boot.img. At least not ones without also involving an entire system build (not that they would match the system partition that you already have).
So to solve that, edit the fstab file in the shamu device tree to remove the verify parameter from the system partition. Once that is done, it should no longer randomly reboot.
UNFORTUNATELY, that may not be enough to make the whole thing work properly still, since there appears to be some other differences between the AOSP userdebug's boot.img and the google user build. You will be able to adb in, but the android subsystem won't run.
These utilities I have used were the ones that have been successfully used to pack/unpack boot images by others. I have also done this successfully in the past, for another device running earlier versions.
Yeap. That's the problem. A kernel build from AOSP sources does not work out of the box with the rest of the system, if it is a production build. This used to work for Lollipop, but I guess they tighten security up.
Building zImage from kernel sources is still not a solution for me, as I can't properly pack/unpack a Marshmallow boot.img
The problem might be something very stupid, OS specific, and I don't want to waste any more time on this.
For now I will live with SuperSu and adbd insecure.
Maybe at some point I might try to remove the verification to see whether the rest of the stuff play nicely.
Thanks for your time!
[edit]
Answer is root. http://forum.xda-developers.com/showpost.php?p=64110288&postcount=1283
[/edit]
I spent a while tonight trying to figure this out as well. Simply dumping boot.img and recreating it works fine. But something goes wrong when unpacking/repacking the ramdisk. Stripping bootsize from bootimg.cfg so abootimg recalculates it doesn't help.
1. I did find that mkboot "works": https://github.com/ModdingMyMind/mkbootimg_tools
Simply run `mkboot boot.img boot` to dump to dir boot. Make changes to ramdisk, and then run `mkboot boot newboot.img` to create a new image. However, for whatever reason, this causes at least one issue for me. The sbin dir, despite being 755 in the ramdisk is 750 again in Android. Not sure what's going on here since I can redump newboot.img and confirm that sbin is 755.
2. I looked at seSuperuser/super-bootimg and found https://github.com/seSuperuser/super-bootimg/blob/master/scripts/bootimg.sh
The relevant part is in doneBootImgEdit(). Looking at the comments, Husson found that appending the changes to the inflated ramdisk cpio and then deflating it works. I just tested this and indeed it does work.
Husson only appends new/changed files; as a test, I tried appending the entire new ramdisk onto the old one, and sure enough, it bugs out again. Will have to investigate why this happening later, but for now, this is good enough.
As well, abootimg also comes with the tools abootimg-pack-initrd and aboot-unpack-initrd, which takes care of gzip/cpio. Of course, since the packing part doesn't work, we can't use it.
So, here's an example. Say you want to change fstab.shamu (to remove /system verification and/or /data forced encryption):
Code:
# extract boot.img
abootimg -x boot.img
# unpack the extracted initrd.img to ramdisk dir
abootimg-unpack-initrd
cd ramdisk
# make your changes to ramdisk/fstab.shamu here....
echo fstab.shamu | cpio -o -H newc > ../initrd2
cd ..
# inflate initrd.img
cp initrd.img initrd.gz
gunzip initrd.gz
# append and create new initrd.img
cat initrd initrd2 |gzip -9 -c > newinitrd.img
# strip bootsize from bootimg.cfg
sed 1d bootimg.cfg > newbootimg.cfg
# create new boot.img
abootimg --create newboot.img -f newbootimg.cfg -k zImage -r newinitrd.img
newboot.img should be a working boot image. If modifying multiple files, it may be easiest to create a different dir with those files and use find . |cpio -o -H newc > ../initrd2
Hope this helps. And if anyone can explain why this is necessary / how to recreate initrd from scratch, I can continue being lazy.
Thanks @phhusson
[edit]
Damn. I tried applying a different init file and it ate ****.
[/edit]
ziddey said:
I spent a while tonight trying to figure this out as well. Simply dumping boot.img and recreating it works fine. But something goes wrong when unpacking/repacking the ramdisk. Stripping bootsize from bootimg.cfg so abootimg recalculates it doesn't help.
1. I did find that mkboot "works": https://github.com/ModdingMyMind/mkbootimg_tools
Simply run `mkboot boot.img boot` to dump to dir boot. Make changes to ramdisk, and then run `mkboot boot newboot.img` to create a new image. However, for whatever reason, this causes at least one issue for me. The sbin dir, despite being 755 in the ramdisk is 750 again in Android. Not sure what's going on here since I can redump newboot.img and confirm that sbin is 755.
2. I looked at seSuperuser/super-bootimg and found https://github.com/seSuperuser/super-bootimg/blob/master/scripts/bootimg.sh
The relevant part is in doneBootImgEdit(). Looking at the comments, Husson found that appending the changes to the inflated ramdisk cpio and then deflating it works. I just tested this and indeed it does work.
Husson only appends new/changed files; as a test, I tried appending the entire new ramdisk onto the old one, and sure enough, it bugs out again. Will have to investigate why this happening later, but for now, this is good enough.
As well, abootimg also comes with the tools abootimg-pack-initrd and aboot-unpack-initrd, which takes care of gzip/cpio. Of course, since the packing part doesn't work, we can't use it.
So, here's an example. Say you want to change fstab.shamu (to remove /system verification and/or /data forced encryption):
Code:
# extract boot.img
abootimg -x boot.img
# unpack the extracted initrd.img to ramdisk dir
abootimg-unpack-initrd
cd ramdisk
# make your changes to ramdisk/fstab.shamu here....
echo fstab.shamu | cpio -o -H newc > ../initrd2
cd ..
# inflate initrd.img
cp initrd.img initrd.gz
gunzip initrd.gz
# append and create new initrd.img
cat initrd initrd2 |gzip -9 -c > newinitrd.img
# strip bootsize from bootimg.cfg
sed 1d bootimg.cfg > newbootimg.cfg
# create new boot.img
abootimg --create newboot.img -f newbootimg.cfg -k zImage -r newinitrd.img
newboot.img should be a working boot image. If modifying multiple files, it may be easiest to create a different dir with those files and use find . |cpio -o -H newc > ../initrd2
Hope this helps. And if anyone can explain why this is necessary / how to recreate initrd from scratch, I can continue being lazy.
Thanks @phhusson
[edit]
Damn. I tried applying a different init file and it ate ****.
[/edit]
Click to expand...
Click to collapse
My guess, and the reason why I tried appending without further thinking, is that the new initramfs files contains SELinux labels, which standard GNU/Linux cpio tool doesn't support.
One would have to investigate the changes in mkbootfs done recently.
Also, I guess mkboot is using Android's mkbootfs, which forces the permissions by itself I think.
Though the fact that extracting back give the result you expected is weird.
In super-bootimg I chose to change init.rc to chmod /sbin
Wow. http://forum.xda-developers.com/showpost.php?p=64110288&postcount=1283
Just tested and sure enough, everything is working.
Thanks @shoey63
Hopefully a final update:
The difference is in ownership. Unpacking (cpio -i) as a regular user will not preserve the ownership. However, repacking (cpio -o) does.
To repack, add -R 0.0 to cpio (i.e. --owner root.root).
e.g.
Code:
find . |cpio -o -H newc -R 0.0 | gzip -9 > ../newinitrd.img
I just tested and this works just fine without being root.
ziddey said:
Hopefully a final update:
The difference is in ownership. Unpacking (cpio -i) as a regular user will not preserve the ownership. However, repacking (cpio -o) does.
To repack, add -R 0.0 to cpio (i.e. --owner root.root).
e.g.
Code:
find . |cpio -o -H newc -R 0.0 | gzip -9 > ../newinitrd.img
I just tested and this works just fine without being root.
Click to expand...
Click to collapse
Erf that's weird, I'm pretty sure I always ran the script as root...
Anyway, thanks for the info! I'll probably update my scripts with it
I just wanted to post that using root to extract the cpio file fixed the boot failure for me on my Nexus 9 with 6.0.1. You also need to use root to find the files and create the cpio file because some files are only accessible by root of course. I guess that should have been obvious (usually needed for /dev nodes) as @phhusson said, but this time I didn't do that until reading here.
To unpack the boot.img file I used: https://github.com/osm0sis/mkbootimg.git
To pack the boot.img file I used: https://android.googlesource.com/platform/system/core/+/master/mkbootimg
I'm not sure you need the official google packer, but I just happened to use when it worked.
EDIT: I needed to update boot.img and I tried it using the osm0sis packer and it worked.
Hey guys. Thanks for the replies!
I needed a permissive kernel this time, and I have played around with the sources and your recommendations and got it working. :good:
The post by ziddey might be the easiest way to make any kernel bootable, by disabling the verification from fstab.
(and uses just one packing/unpacking tool)
You can do the same thing from sources, again by modifying the fstab on aosp.
You can build an insecure kernel by using the pre-built kernel (is aosp),
or compile and then pack a permissive one.
This procedure wasn't working for me back then when I tried it (hence this thread). I am not sure if it was my fault or the initial marshmallow release had differences from the sources. More info on the first post.

Categories

Resources