FORUMS
Remove All Ads from XDA

Trying to build the stock kernel from source [SOLVED]

298 posts
Thanks Meter: 77
 
By ksatta, Senior Member on 14th May 2011, 04:18 PM
Post Reply Email Thread
edit: The stock kernel can be built following this thread.

I'm trying to build the stock kernel from source (the one from huaweidevice). I'm running Ubuntu 10.10 64-bit.

I've gotten this far:
- I've extracted config from phone /proc/config.gz and copied it to kernel/.config

- I went through this guide: source.android.com source initializing.html

- I created some symbolic links to get rid of file not found errors when compiling:
kernel-2.6.32-U8800-Froyo/kernel/net/netfilter$ ln -s xt_connmark.c xt_CONNMARK.c
kernel-2.6.32-U8800-Froyo/kernel/net/netfilter$ ln -s xt_HL.c xt_hl.c
kernel-2.6.32-U8800-Froyo/kernel/net/netfilter$ ln -s xt_MARK.c xt_mark.c
kernel-2.6.32-U8800-Froyo/kernel/net/ipv4/netfilter$ ln -s ipt_ECN.c ipt_ecn.c
kernel-2.6.32-U8800-Froyo/kernel/include/linux/netfilter$ ln -s xt_mark.h xt_MARK.h
kernel-2.6.32-U8800-Froyo/kernel/include/linux/netfilter_ipv4$ ln -s ipt_ecn.h ipt_ECN.h
kernel-2.6.32-U8800-Froyo/kernel/include/linux/netfilter$ ln -s xt_DSCP.h xt_dscp.h
kernel-2.6.32-U8800-Froyo/kernel/include/linux/netfilter_ipv4$ ln -s ipt_ttl.h ipt_TTL.h
kernel-2.6.32-U8800-Froyo/kernel/include/linux/netfilter_ipv6$ ln -s ip6t_hl.h ip6t_HL.h


Now for the cross compilation I've tried 3 different toolchains:
- The ones from developer.android.com sdk ndk index.html
- and codesourcery.com sgpp lite arm portal package8734/public/arm-none-eabi/arm-2011.03-42-arm-none-eabi-i686-pc-linux-gnu.tar.bz2

then I've tried compiling with:
make -j8 ARCH=arm CROSS_COMPILE=.../android-ndk-r5b/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/arm-linux-androideabi-

and

make -j8 ARCH=arm CROSS_COMPILE=.../android-ndk-r5b/toolchains/arm-eabi-4.4.0/prebuilt/linux-x86/bin/arm-eabi-

and

make -j8 ARCH=arm CROSS_COMPILE=.../arm-2011.03/bin/arm-none-eabi-

they all give me output similar to this (this is with the 4.4.0 toolchain):
Code:
  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
  CALL    scripts/checksyscalls.sh
  CHK     include/linux/compile.h
  CC      net/netfilter/xt_MARK.o
  CC      net/ipv4/netfilter/ipt_ecn.o
  CC      net/netfilter/xt_NFQUEUE.o
  CC      net/ipv4/netfilter/ipt_NETMAP.o
  CC      net/netfilter/xt_comment.o
  CC      net/netfilter/xt_connlimit.o
net/netfilter/xt_MARK.c: In function 'mark_tg':
net/netfilter/xt_MARK.c:32: error: dereferencing pointer to incomplete type
net/netfilter/xt_MARK.c:32: error: dereferencing pointer to incomplete type
net/netfilter/xt_MARK.c: At top level:
net/netfilter/xt_MARK.c:41: error: invalid application of 'sizeof' to incomplete type 'struct xt_mark_tginfo2' 
make[2]: *** [net/netfilter/xt_MARK.o] Error 1
make[2]: *** Waiting for unfinished jobs....
  CC      net/ipv4/netfilter/ipt_REDIRECT.o
  CC      net/ipv4/netfilter/ipt_REJECT.o
cc1: warnings being treated as errors
net/ipv4/netfilter/ipt_ecn.c:29: error: 'struct ipt_ECN_info' declared inside parameter list
net/ipv4/netfilter/ipt_ecn.c:29: error: its scope is only this definition or declaration, which is probably not what you want
net/ipv4/netfilter/ipt_ecn.c: In function 'set_ect_ip':
net/ipv4/netfilter/ipt_ecn.c:33: error: 'XT_DSCP_MASK' undeclared (first use in this function)
net/ipv4/netfilter/ipt_ecn.c:33: error: (Each undeclared identifier is reported only once
net/ipv4/netfilter/ipt_ecn.c:33: error: for each function it appears in.)
net/ipv4/netfilter/ipt_ecn.c:33: error: dereferencing pointer to incomplete type
net/ipv4/netfilter/ipt_ecn.c:40: error: dereferencing pointer to incomplete type
net/ipv4/netfilter/ipt_ecn.c: At top level:
net/ipv4/netfilter/ipt_ecn.c:48: error: 'struct ipt_ECN_info' declared inside parameter list
net/ipv4/netfilter/ipt_ecn.c: In function 'set_ect_tcp':
net/ipv4/netfilter/ipt_ecn.c:58: error: dereferencing pointer to incomplete type
net/ipv4/netfilter/ipt_ecn.c:58: error: 'IPT_ECN_OP_SET_ECE' undeclared (first use in this function)
net/ipv4/netfilter/ipt_ecn.c:59: error: dereferencing pointer to incomplete type
net/ipv4/netfilter/ipt_ecn.c:60: error: dereferencing pointer to incomplete type
net/ipv4/netfilter/ipt_ecn.c:60: error: 'IPT_ECN_OP_SET_CWR' undeclared (first use in this function)
net/ipv4/netfilter/ipt_ecn.c:61: error: dereferencing pointer to incomplete type
net/ipv4/netfilter/ipt_ecn.c:69: error: dereferencing pointer to incomplete type
net/ipv4/netfilter/ipt_ecn.c:70: error: dereferencing pointer to incomplete type
net/ipv4/netfilter/ipt_ecn.c:71: error: dereferencing pointer to incomplete type
net/ipv4/netfilter/ipt_ecn.c:72: error: dereferencing pointer to incomplete type
net/ipv4/netfilter/ipt_ecn.c: In function 'ecn_tg':
net/ipv4/netfilter/ipt_ecn.c:84: error: dereferencing pointer to incomplete type
net/ipv4/netfilter/ipt_ecn.c:84: error: 'IPT_ECN_OP_SET_IP' undeclared (first use in this function)
net/ipv4/netfilter/ipt_ecn.c:85: error: passing argument 2 of 'set_ect_ip' from incompatible pointer type
net/ipv4/netfilter/ipt_ecn.c:29: note: expected 'const struct ipt_ECN_info *' but argument is of type 'const struct ipt_ECN_info *'
net/ipv4/netfilter/ipt_ecn.c:88: error: dereferencing pointer to incomplete type
net/ipv4/netfilter/ipt_ecn.c:88: error: 'IPT_ECN_OP_SET_ECE' undeclared (first use in this function)
net/ipv4/netfilter/ipt_ecn.c:88: error: 'IPT_ECN_OP_SET_CWR' undeclared (first use in this function)
net/ipv4/netfilter/ipt_ecn.c:90: error: passing argument 2 of 'set_ect_tcp' from incompatible pointer type
net/ipv4/netfilter/ipt_ecn.c:48: note: expected 'const struct ipt_ECN_info *' but argument is of type 'const struct ipt_ECN_info *'
net/ipv4/netfilter/ipt_ecn.c: In function 'ecn_tg_check':
net/ipv4/netfilter/ipt_ecn.c:101: error: dereferencing pointer to incomplete type
net/ipv4/netfilter/ipt_ecn.c:101: error: 'IPT_ECN_OP_MASK' undeclared (first use in this function)
net/ipv4/netfilter/ipt_ecn.c:103: error: dereferencing pointer to incomplete type
net/ipv4/netfilter/ipt_ecn.c:106: error: dereferencing pointer to incomplete type
net/ipv4/netfilter/ipt_ecn.c:106: error: 'XT_DSCP_MASK' undeclared (first use in this function)
net/ipv4/netfilter/ipt_ecn.c:108: error: dereferencing pointer to incomplete type
net/ipv4/netfilter/ipt_ecn.c:111: error: dereferencing pointer to incomplete type
net/ipv4/netfilter/ipt_ecn.c:111: error: 'IPT_ECN_OP_SET_ECE' undeclared (first use in this function)
net/ipv4/netfilter/ipt_ecn.c:111: error: 'IPT_ECN_OP_SET_CWR' undeclared (first use in this function)
net/ipv4/netfilter/ipt_ecn.c: At top level:
net/ipv4/netfilter/ipt_ecn.c:124: error: invalid application of 'sizeof' to incomplete type 'struct ipt_ECN_info' 
make[3]: *** [net/ipv4/netfilter/ipt_ecn.o] Error 1
make[3]: *** Waiting for unfinished jobs....
make[1]: *** [net/netfilter] Error 2
make[1]: *** Waiting for unfinished jobs....
make[2]: *** [net/ipv4/netfilter] Error 2
make[1]: *** [net/ipv4] Error 2
make: *** [net] Error 2
sorry for the messed up links, I'm not allowed to post links (yet).

Any ideas how to get forward?

The reason I'm doing this is that I want to fix the bug that the internal mic is disabled when a stereo headphone / or a 3.5mm jack - 2xrca cable is plugged in. I think I can fix it from kernel-2.6.32-U8800-Froyo/kernel/arch/arm/mach-msm/rpc_server_handset.c, but first I have to get my build environment working
 
 
14th May 2011, 05:36 PM |#2  
Member
Thanks Meter: 30
 
More
copy missing files instead of link
xt_MARK.c and xt_mark.c are not the same, at least in my source

try copy the missing file from android source
http://android.git.kernel.org/?p=kernel/msm.git;a=tree
14th May 2011, 06:44 PM |#3  
ksatta's Avatar
OP Senior Member
Flag Sieppijärvi
Thanks Meter: 77
 
More
Quote:
Originally Posted by wmi543

xt_MARK.c and xt_mark.c are not the same, at least in my source

try copy the missing file from android source

It worked I copied all the files from the git instead of ln -s.

"Kernel: arch/arm/boot/zImage is ready"

Thanks for the quick reply.

Then I had to remove comment out CONFIG_FB_MSM_MDDI_NT35582_WVGA=y line from .config and answer no to two questions when running make.
I used the 4.4.0 toolchain

Now I have the zImage but don't know how it'll work because the CONFIG_FB_MSM_MDDI_NT35582_WVGA probably has something to do with the display type.

BTW I've taken a backup with genokolar's recovery img. When I try this new kernel and if I can't boot, I should be able to get it to boot again by doing a restore from the earlier backup?

Now I'll start looking into packing the kernel to an .img (android-dls.com wiki/index.php?title=HOWTO:_Unpack,_Edit,_and_Re-Pack_Boot_Images#Structure_of_boot_and_recovery_im ages)..
14th May 2011, 09:13 PM |#4  
ksatta's Avatar
OP Senior Member
Flag Sieppijärvi
Thanks Meter: 77
 
More
OK. I copied the boot.img from the phone in bootloader mode, unpacked it with unpack-bootimg.pl. Then I bsdiffed (binary diff) the resulting boot.img-kernel.gz with the Image file I built, the patch file is only 389K so looks like they are quite similar. The only differences may be because of the display thing I changed in the Makefile.

Might try tomorrow to replace the unpacked kernel with the Image file and see if it works. What is the worst case scenario? I should always be able to restore from the old backup if it doesn't boot?

Maybe I'll also try to get the display thing to build right before trying it on the phone

edit: I read somewhere the .gz extension in the unpacked kernel file is a bug with the unpacking script, so "boot.img-kernel.gz" is actually the unpacked kernel file (so it should be the same as compiled Image) ?
15th May 2011, 08:18 AM |#5  
ksatta's Avatar
OP Senior Member
Flag Sieppijärvi
Thanks Meter: 77
 
More
Looks like the unpack-bootimg.pl and repack-bootimg.pl are not working right for the U8800 boot.img. I just tried to unpack the original boot.img and repack it, I got a blue screen when trying to boot. I could restore the original just by going to bootloader mode and copying back the original.

Any ideas how to unpack and repack the boot.img of the U8800?
15th May 2011, 09:05 AM |#6  
Retired Recognized Developer
Flag Brisbane
Thanks Meter: 597
 
Donate to Me
More
You can repack the boot/recovery images with the following:

Code:
./mkbootfs RAMDISK DIRECTORY | ./minigzip > ramdisk-boot.img

./mkbootimg --kernel KERNEL --ramdisk ramdisk-boot.img --base 0x00200000 --pagesize 4096 --cmdline 'console=ttyDCC0 androidboot.hardware=huawei' -o boot.img
I just modified the repack perl script accordingly and added lines so that it will mount cust_backup and transfer the image across for me. Saves heaps of time.
15th May 2011, 10:02 AM |#7  
ksatta's Avatar
OP Senior Member
Flag Sieppijärvi
Thanks Meter: 77
 
More
Quote:
Originally Posted by stockwell

You can repack the boot/recovery images with the following:

Code:
./mkbootfs RAMDISK DIRECTORY | ./minigzip > ramdisk-boot.img

./mkbootimg --kernel KERNEL --ramdisk ramdisk-boot.img --base 0x00200000 --pagesize 4096 --cmdline 'console=ttyDCC0 androidboot.hardware=huawei' -o boot.img
I just modified the repack perl script accordingly and added lines so that it will mount cust_backup and transfer the image across for me. Saves heaps of time.

I used the unpack script from http://forum.xda-developers.com/showthread.php?t=891333 then modified the line "#$bootimg = substr($bootimg,2048);" to "$bootimg = substr($bootimg,4096);". There's still a difference of 215 bytes with the repacked img, but it works.

Now I can test the kernel I built myself. Thank you for the help.

edit: Looks like the built kernel doesn't work, now I can start tackling that
15th May 2011, 10:30 AM |#8  
Member
Thanks Meter: 30
 
More
CONFIG_FB_MSM_MDDI_NT35582_WVGA=y
if you see only blue screen when you boot your own kernel, refer to my experience, edit .config, change 2 lines as below instead of comment out CONFIG_FB_MSM_MDDI_NT35582_WVGA=y should fix it

CONFIG_FB_MSM_MDDI_AUTO_DETECT=y
CONFIG_FB_MSM_TRY_MDDI_CATCH_LCDC_PRISM=y


BTW, there is a tool "abootimg" which is quite handy for packing the kernel
http://gitorious.org/ac100/abootimg
15th May 2011, 10:45 AM |#9  
ksatta's Avatar
OP Senior Member
Flag Sieppijärvi
Thanks Meter: 77
 
More
Quote:
Originally Posted by wmi543

if you see only blue screen when you boot your own kernel, refer to my experience, edit .config, change 2 lines as below instead of comment out CONFIG_FB_MSM_MDDI_NT35582_WVGA=y should fix it

CONFIG_FB_MSM_MDDI_AUTO_DETECT=y
CONFIG_FB_MSM_TRY_MDDI_CATCH_LCDC_PRISM=y


BTW, there is a tool "abootimg" which is quite handy for packing the kernel
http://gitorious.org/ac100/abootimg

Works! great! Thanks for the help. Hopefully soon I can release my fixed kernel
23rd May 2011, 02:57 AM |#10  
Senior Member
Thanks Meter: 56
 
More
Sorry, I'm new to Android. What advantages are there if you get the stock kernel or whatever?
23rd May 2011, 08:51 AM |#11  
ksatta's Avatar
OP Senior Member
Flag Sieppijärvi
Thanks Meter: 77
 
More
"Stock" means the kernel that comes with the phone when you buy it. I just wanted to build it so I could modify it. I created a modified kernel that allows you to use the internal mic with headphones or for example when you connect the phone to your car stereo. The modified kernel is in the other thread.

Sent from my u8800 using XDA App
Post Reply Subscribe to Thread

Guest Quick Reply (no urls or BBcode)
Message:
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes