[Guide] Building from sources [Kernel only for now]

Top Liked Posts

  • There are no posts matching your filters.
  • 11
    Hello everyone.

    This guide will help you in building a kernel from source for your Nexus 10

    Later, when 4.2 hits AOSP, i'll add a guide for building that too :)

    You will need a computer running Linux / OSX to build the kernel, natively, or via a VM.
    This guide assumes you’re running any Linux distro.

    Getting a toolchain:
    You need a toolchain to build the kernel.
    The preferred one is Google’s toolchain, the same they use to build AOSP.

    In a terminal, type:
    Code:
    git clone [url]https://android.googlesource.com/platform/prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.6/[/url]
    export PATH=$PATH:$(pwd)/arm-linux-androideabi-4.6/bin
    export CROSS_COMPILE=arm-linux-androideabi-

    TIp: paste the export statements in your ~/.bashrc to have them exported each login.

    Getting the kernel source:
    The kernel source for Nexus devices is available from Google’s servers.

    Source : https://android.googlesource.com/kernel/exynos
    Github Mirror: https://github.com/chirayudesai/android_kernel_exynos

    Open the terminal, and type the below commands to get the kernel source on your computer.

    Code:
    mkdir -p android/kernel
    cd android/kernel

    For Nexus 10, we get the exynos kernel sources.
    Code:
    git clone [url]https://android.googlesource.com/kernel/exynos[/url]

    Next, we change our directory to the newly fetched source.

    Type
    Code:
    cd exynos

    Figuring out what to build:
    Now, we need to figure out which revision to build.
    You need to be exactly sure about this, otherwise there are chances that the compiled kernel won’t work.

    The commit to build upon can be found by a few ways.
    To get the kernel sources matching the device tree, type the below in the device tree.
    Code:
    git log kernel

    Then type the below in the kernel tree
    Code:
    git checkout <commit>

    The commit of the version running on the current review units is 52f6ab1 (probably), which is same as branch android-exynos-manta-3.4-jb-mr1-fr .

    Compiling:

    Name of defconfig: manta_defconfig

    cd to the directory of the kernel source, then type the below in a terminal.

    Code:
    export ARCH=arm
    export SUBARCH=arm

    Code:
    make <name_of_defconfig>
    make

    The kernel image will be ready at arch/arm/boot/zImage

    To flash it, you need to make it into a boot.img, more on that later. when we have more sources.
    2
    ... To flash it, you need to make it into a boot.img, more on that later. when we have more sources.

    you can extract the contents from the factory image & use getramdisk.py to get the ramdisk.img out of the current boot.img (or use this ramdisk.img)

    then once youve compiled the kernel successfully, use mkbootimg from android_bootimg_tools.tar.gz to repack your boot.img.

    if you want to just test...
    fastboot boot [new-boot.img]

    and flash if satisfied...
    fastboot flash boot [new-boot.img]

    just tested out if anyone wants some verification... screenshot
    1
    so you say that you need to make the zImage into a boot.img (being a noob about this...) on my SGSII, I can flash zImages and boot.img, so I'm confused, lol

    i think it depends on how youre flashing. with the sgsii youre prob using odin/heimdall & it might just overwrite the kernel. flashing with fastboot might require the boot.img cause it contains a ramdisk image after the kernel & is writing a partition. thats just my guess at least, someone else might have a better/more accurate answer for ya
    1
    @cdesai, shouldn't we be using arm-eabi- instead of arm-linux-androideabi- as CROSS_COMPILE

    Code:
    git clone https://android.googlesource.com/platform/prebuilts/gcc/linux-x86/arm/arm-eabi-4.6/
    export PATH=$PATH:$(pwd)/arm-eabi-4.6/bin
    export CROSS_COMPILE=arm-eabi-

    Building with arm-linux-androideabi- causes issues with kernel modules... here's an example of such an issue https://groups.google.com/forum/?fromgroups=#!topic/android-kernel/dzEIOVuxtEo

    And the most updated kernel branch is android-exynos-manta-3.4-jb-mr1 not android-exynos-manta-3.4-jb-mr1-fr