[Nexus 5 Q&A, Help & Troubleshooting] usu4rio:
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

From an adb shell I get the GCC version used to compile the kernel "dmesg | grep -i gcc", which is 4.7

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

Download: git clone https://android.googlesource.com/kernel/msm

Select device: git checkout remotes/origin/android-msm-hammerhead-3.4-kk-r1

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:

[...]

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)

[...]

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? :eek:

Wrong kernel?

Wrong commit?

Wrong toolchain? --> use arm-eabi-4.7