[Huawei P9 Plus Guides, News, & Discussion] newbit:
Update: How to build the kernel for your Huawei P9 Plus

Hello Fellows,

thank you [MENTION=220328]paulobrien[/MENTION] for this nice and handy How To.

It didn't work for me so I've updated your How To a little to compile the P9 Plus kernel for the VIE-L09 Device.

The kernel source and config file comes from the Huawei Opensource Website.

https://consumer.huawei.com/en/opensource/

Filtered for P9 Plus

-> P9 Plus, VIE-AL10, Android 7.0, EMUI 5.0

The source is from the VIE-AL10 but works great with the VIE-L09 as well.

I've put the unmodified kernelsource to github.

The updated How To is also inspired by this [ULTIMATE GUIDE] and the View attachment 5006069 from the Huawei VIE_NG_EMUI5.0_opensource.tar.gz

Thanks and Credits to [MENTION=220328]paulobrien[/MENTION], [MENTION=4544860]osm0sis[/MENTION] and [MENTION=5373435]Eliminator79[/MENTION]

Preconditions:

An unlocked bootloader and rooted P9 Plus

A dump of the phones boot.img for ex. with DD if=/dev/block/mmcblk0p28 of=/...boot.img

A Linux System to compile the source

A working fastboot connection

optional: A working ADB connection (to pull the dumped boot.img)

optional: A working SSH connection (to pull the dumped boot.img)

install ubuntu-14.04.6-desktop-amd64.iso

user and machine name will be displayed in the kernel

update git:

sudo apt-get install git
git --version -> git version 1.9.1
sudo add-apt-repository ppa:git-core/ppa
sudo apt-get update && sudo apt-get install git
git --version -> [B]git version 2.26.2[/B]

menuconfig classic:

sudo apt-get install build-essential libssl-dev libncurses5-dev bison flex

menuconfig modern GUI:

sudo apt-get install libqt4-dev pkg-config

get the ndk r16b toolchain aarch64-linux-android-4.9 from Google:

wget https://dl.google.com/android/repository/android-ndk-r16b-linux-x86_64.zip

extract the aarch64 folder:

unzip android-ndk-r16b-linux-x86_64.zip android-ndk-r16b/toolchains/aarch64-linux-android-4.9/prebuilt/linux-x86_64/*
mv android-ndk-r16b/toolchains/aarch64-linux-android-4.9/prebuilt/linux-x86_64 aarch64-linux-android-4.9 && rm -Rf android-ndk-r16b

export path and cross_compiler: (needs to be done every reboot)

export PATH=$PATH:$(pwd)/aarch64-linux-android-4.9/bin
export CROSS_COMPILE=$(pwd)/aarch64-linux-android-4.9/bin/aarch64-linux-android-

install fastboot

sudo apt-get install android-tools-fastboot
sudo apt-get install android-tools-adb

Clone the actually source or extract the downloaded one in a directory for ex. P9PLUSKERNELSRC

just compile it or make some changes as well.

clone the Huawei P9 Plus Nougat Stock Kernel Source 4.1.18:

git clone https://github.com/newbit1/HUAWEI_P9PLUS_VIENNA_NG_EMUI5.0_STOCK_KERNEL_4.1.18.git P9PLUSKERNELSRC

Update 30.04.2020: OREO repo added

alternative for OREO, clone the P9 Plus Oreo Stock Kernel Source 4.4.23:

The OREO Kernel will not boot the P9Plus with Nougat on it. But It has its config.gz already included.

git clone https://github.com/newbit1/HUAWEI_P9PLUS_VIENNA_OREO_EMUI8.0_STOCK_KERNEL_4.4.23.git P9PLUSKERNELSRC

the stock default kernel config file is in "kernel/arch/arm64/configs/merge_hi3650_defconfig":

cd P9PLUSKERNELSRC/kernel
make ARCH=arm64 distclean
rm ../out -Rf && make clean && make mrproper && mkdir ../out
make ARCH=arm64 O=../out merge_hi3650_defconfig

If you want to make changes, use the menu to config the kernel:

menuconfig classic:

make ARCH=arm64 O=../out menuconfig

menuconfig modern GUI:

make ARCH=arm64 O=../out xconfig

compile the kernel... and have a drink

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

If/when the kernel is compiled, pack it with AIK-Linux in the dumped and unpacked boot.img from your P9-Plus.

An unlocked bootloader and rooted P9 Plus is a precondition!

For example purposes in this How To I use the boot.img from my phone.

It has a init with magisk root 20.3

get the Android Image Kitchen from osm0sis xda:

wget https://xdaforums.com/attachment.php?attachmentid=4825093 -O AIK-Linux-v3.6-ALL.tar.gz
tar -xvzf AIK-Linux-v3.6-ALL.tar.gz
cd AIK-Linux
wget https://github.com/newbit1/HUAWEI_P9PLUS_VIENNA_NG_EMUI5.0_STOCK_KERNEL_4.1.18/raw/master/HUAWEI_P9PLUS_NG_STOCK_BOOT_KERNEL_4.1.18.img -O boot.img
./unpackimg.sh
rm -f split_img/boot.img-zImage

put the just compiled kernel into the AIK and repack it:

mv ~/P9PLUSKERNELSRC/out/arch/arm64/boot/Image.gz ~/AIK-Linux/split_img/boot.img-zImage
./repackimg.sh

the repacked boot image-new.img is ready to be flashed into the P9 Plus
​

checking the ADB connection:

Enable USB Debugging and connect the P9 Plus via USB:

adb devices
List of devices attached
N9xxxxxxxxxxxxxx	device

checking the Fastboot connection:

unplug the usb cable in

switch off the phone

hold the volume down button and keep holding it

plug the usb cable in

phone boots into fastboot mode

release the volume down button

check the fastboot connection with the P9 Plus

sudo fastboot devices
N9xxxxxxxxxxxxxx	fastboot

flash image-new.img with the new kernel

sudo fastboot flash boot image-new.img
target reported max download size of 471859200 bytes
sending 'boot' (16238 KB)...
OKAY [ 0.844s]
writing 'boot'...
OKAY [ 0.121s]
finished. total time: 0.965s

reboot the phone and unplug the cable

sudo fastboot reboot

your phone is booting now...

Enjoy your new kernel

View attachment 5006067