vendredi 3 juin 2016

How to build the kernel for your Huawei P9 Plus

Huawei have helpfully released the kernel source for the Huawei P9 Plus on their download site. Impressively, the version posted there (3.10.90) actually matches the current release build. However, the download itself is only part of the puzzle - it's important to then know how to compile it and use it. Hence this guide. :)

Some points to note first of all...
  • This guide refers to building on Linux. You can probably build on OSX or whatever too but seriously, it's less pain in the long run to spin up an Ubuntu VM.
  • In the download linked above, as well as the kernel, there are some other bits and pieces (some of which are quite bizarre). I've mirrored the kernel to Bitbucket, so you don't need to grab the whole download.
Got that? OK, so here's a step by step on how to build the kernel! I strongly recommend building stock first and testing that works for you, then you can start adding your tweaks in. I'm interested to hear what you add / change!
  • Open a terminal window on your Linux machine / in your Linux VM. No GUIs here. :) Change to the directory where you want the kernel / toolchain to live.
  • First of all, we're going to clone the toolchain from AOSP.
    Code:

    git clone http://ift.tt/1OX4C3c
  • Next we're going to clone the kernel source itself from my git repo on bitbucket.
    Code:

    git clone http://ift.tt/22D0jzW kernel
  • We need to add the toolchain location to the path.
    Code:

    export PATH=$(pwd)/aarch64-linux-android-4.9/bin:$PATH
  • We need to specify that we are cross compiling for arm64.
    Code:

    export CROSS_COMPILE=$(pwd)/aarch64-linux-android-4.9/bin/aarch64-linux-android-
  • Let's create a directory for our output to go in to.
    Code:

    mkdir out
  • We've got the kernel downloaded, so let's change to that directory so we're ready to go.
    Code:

    cd kernel
  • A bit of cleaning up before we get started...
    Code:

    make ARCH=arm64 O=../out mrproper
  • Specify that we're building for the P9 (hisi3650 chipset)...
    Code:

    make ARCH=arm64 O=../out p9plus_extracted_defconfig
  • And build it!
    Code:

    make ARCH=arm64 O=../out -j8

When this process completes, we can check the '../out' directory and you should find the file arch/arm64/boot/Image. This is the kernel that you've just built! You can't flash it as is though, you need to put it into a boot image first.

Here's how you do it...
  • Change out of the kernel directory back to its parent.
    Code:

    cd ..
  • Download tools for manipulating the boot image.
    Code:

    git clone http://ift.tt/1T2Mggc
  • Download the stock boot image (actually we're using the root ready version for convenience).
    Code:

    wget -O boot.img http://ift.tt/22D02Nj
  • Extract the boot image.
    Code:

    mkbootimg_tools/mkboot boot.img boot.extracted
  • Copy the new kernel into the extracted boot folder.
    Code:

    cp out/arch/arm64/boot/Image.gz boot.extracted/kernel
  • Build a new boot image.
    Code:

    mkbootimg_tools/mkboot boot.extracted boot.newkernel.img
You now have a new boot image (boot.newkernel.img). All that's left is to flash it to your device! Reboot to bootloader (either using 'adb reboot bootloader' or by powering on with volume down held), flash using 'fastboot flash boot boot.newkernel.img' and then reboot using 'fastboot reboot'. Job done! In the About screen of settings you should see the date of the new kernel and details of your build machine.


from xda-developers http://ift.tt/1t6GepD
via IFTTT

Aucun commentaire:

Enregistrer un commentaire