FORUMS
Remove All Ads from XDA

[Q] [SOLVED] Stock Kernel Build Problems

19 posts
Thanks Meter: 17
 
By usu4rio, Junior Member on 18th November 2013, 10:59 AM
Post Reply Email Thread
Hello,

Just for the fun (and to learn something) I'm trying to rebuild the stock nexus5 kernel. However I'm miserably failing.

I've found some guides for nexus4 but none for the nexus5, so far.
  • Host(s): Ubuntu 12.04 x86_64, Ubuntu 13.10 x86_64, Ubuntu 13.10 x86
  • Kernel source: https://android.googlesource.com/kernel/msm
  • Toolchain: Android NDK legacy version GCC 4.7

The process I'm following is:

NDK toolchain
  1. From an adb shell I get the GCC version used to compile the kernel "dmesg | grep -i gcc", which is 4.7
  2. Download the legacy NDK which has GCC 4.7 (for x86_64 in my case): https://dl.google.com/android/ndk/android-ndk-r9b-linux-x86_64-legacy-toolchains.tar.bz2

Kernel source
  1. Download: git clone https://android.googlesource.com/kernel/msm
  2. Select device: git checkout remotes/origin/android-msm-hammerhead-3.4-kk-r1
  3. Select commit: git checkout 9eb14ba

Building kernel
  • export PATH=$PATH:<NDK_PATH>/toolchains/arm-linux-androideabi-4.7/prebuilt/linux-x86_64/bin/
  • export ARCH=arm
  • export SUBARCH=arm
  • export CROSS_COMPILE=arm-linux-androideabi-
  • make hammerhead_defconfig
  • make -j2

However the build process fails with:
Code:
[...]

  LD      vmlinux.o
  MODPOST vmlinux.o
ERROR: modpost: Found 2 section mismatch(es).
To see full details build your kernel with:
'make CONFIG_DEBUG_SECTION_MISMATCH=y'
To build the kernel despite the mismatches, build with:
'make CONFIG_NO_ERROR_ON_MISMATCH=y'
(NOTE: This is not recommended)
make[1]: *** [vmlinux.o] Error 1
make: *** [vmlinux.o] Error 2
I've also tried to build with CONFIG_DEBUG_SECTION_MISMATCH=y, but as expected fails (although with more information)
Code:
[...]

CC      kernel/kallsyms.o
WARNING: arch/arm/mach-msm/built-in.o(.data+0x679c): Section mismatch in reference from the variable msm_mpm_debug_mask to the funct
ion .init.text:mpm_irq_domain_linear_size()
The variable msm_mpm_debug_mask references
the function __init mpm_irq_domain_linear_size()
If the reference is valid then annotate the
variable with __init* or __refdata (see linux/init.h) or name the variable:
*_template, *_timer, *_sht, *_ops, *_probe, *_probe_one, *_console

WARNING: arch/arm/mach-msm/built-in.o(.data+0x67b4): Section mismatch in reference from the variable msm_mpm_debug_mask to the funct
ion .init.text:mpm_irq_domain_legacy_size()
The variable msm_mpm_debug_mask references
the function __init mpm_irq_domain_legacy_size()
If the reference is valid then annotate the
variable with __init* or __refdata (see linux/init.h) or name the variable:
*_template, *_timer, *_sht, *_ops, *_probe, *_probe_one, *_console

[...]

  LD      vmlinux.o
  MODPOST vmlinux.o
WARNING: vmlinux.o(.data+0x74d4): Section mismatch in reference from the variable msm_mpm_debug_mask to the function .init.text:mpm_irq_domain_linear_size()
The variable msm_mpm_debug_mask references
the function __init mpm_irq_domain_linear_size()
If the reference is valid then annotate the
variable with __init* or __refdata (see linux/init.h) or name the variable:
*_template, *_timer, *_sht, *_ops, *_probe, *_probe_one, *_console

WARNING: vmlinux.o(.data+0x74ec): Section mismatch in reference from the variable msm_mpm_debug_mask to the function .init.text:mpm_irq_domain_legacy_size()
The variable msm_mpm_debug_mask references
the function __init mpm_irq_domain_legacy_size()
If the reference is valid then annotate the
variable with __init* or __refdata (see linux/init.h) or name the variable:
*_template, *_timer, *_sht, *_ops, *_probe, *_probe_one, *_console

To build the kernel despite the mismatches, build with:
'make CONFIG_NO_ERROR_ON_MISMATCH=y'
(NOTE: This is not recommended)
make[1]: *** [vmlinux.o] Error 1
make: *** [vmlinux.o] Error 2
Although it also states that building with CONFIG_NO_ERROR_ON_MISMATCH=y is not recommend I've also tried with this flag. It generated the zImage but I'm not confident with the result.


So the question is what am I doing wrong and how do I compile the android nexus5 kernel?
  • Wrong kernel?
  • Wrong commit?
  • Wrong toolchain? --> use arm-eabi-4.7
The Following 2 Users Say Thank You to usu4rio For This Useful Post: [ View ] Gift usu4rio Ad-Free
 
 
22nd November 2013, 06:55 AM |#2  
Senior Member
Flag Seattle
Thanks Meter: 1,115
 
Donate to Me
More
Yeah I was having the same error. Using the arm-eabi-4.7 toolchain seems to work fine.
The Following User Says Thank You to mohit1234 For This Useful Post: [ View ] Gift mohit1234 Ad-Free
22nd November 2013, 09:40 AM |#3  
OP Junior Member
Thanks Meter: 17
 
More
Quote:
Originally Posted by mohit1234

Yeah I was having the same error. Using the arm-eabi-4.7 toolchain seems to work fine.

Thanks. That did the trick
28th November 2013, 09:34 PM |#4  
Junior Member
Thanks Meter: 0
 
More
Re: [Q] Stock Kernel Build Problems
Interestingly enough I had to do:

make zImage-dtb

to create the zImage that I then encapsulate in the boot.img for Nexus5, using the tools provided in AOSP 4.4_r1.

out/host/linux-x86/bin/mkbootimg --kernel out/target/product/hammerhead/kernel --ramdisk out/target/product/hammerhead/ramdisk.img --cmdline "console=ttyHSL0,115200,n8 androidboot.hardware=hammerhead user_debug=31 maxcpus=2 msm_watchdog_v2.enable=1" --base 0x00000000 --pagesize 2048 --ramdisk_offset 0x02900000 --tags_offset 0x02700000 --output out/target/product/hammerhead/boot.img
out/target/product/hammerhead/boot.img maxsize=23519232 blocksize=135168 total=8826880 reserve=270336
2nd December 2013, 08:35 AM |#5  
Junior Member
Thanks Meter: 17
 
More
Makefile Changes for Easy Kernel Builds
Quote:
Originally Posted by boy3dfx

Interestingly enough I had to do:

make zImage-dtb

to create the zImage that I then encapsulate in the boot.img for Nexus5, using the tools provided in AOSP 4.4_r1.

out/host/linux-x86/bin/mkbootimg --kernel out/target/product/hammerhead/kernel --ramdisk out/target/product/hammerhead/ramdisk.img --cmdline "console=ttyHSL0,115200,n8 androidboot.hardware=hammerhead user_debug=31 maxcpus=2 msm_watchdog_v2.enable=1" --base 0x00000000 --pagesize 2048 --ramdisk_offset 0x02900000 --tags_offset 0x02700000 --output out/target/product/hammerhead/boot.img
out/target/product/hammerhead/boot.img maxsize=23519232 blocksize=135168 total=8826880 reserve=270336

Hey thanks for the zip @boy3dfx . Using this I was able to adapt the build system a little bit so you can just "make updatepackage" or "make bootimage". It requires changes to kernel/AndroidKernel.mk and device/lge/hammerhead . Hopefully though it saves a bit of time in the long run and is less error prone that typing out the whole mkbootimg line each time.

Changes are detailed here: http://nosemaj.org/howto-build-android-kitkat-nexus-5 under "Including the Kernel Sources."

Best,
Jameson
The Following User Says Thank You to jhwilliams For This Useful Post: [ View ] Gift jhwilliams Ad-Free
2nd December 2013, 08:53 PM |#6  
OP Junior Member
Thanks Meter: 17
 
More
Quote:
Originally Posted by jhwilliams

Changes are detailed here: http://nosemaj.org/howto-build-android-kitkat-nexus-5 under "Including the Kernel Sources."

Excelent guide, thanks!!
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