[Xiaomi Mi Note 2  Questions & Answers] humjam:
Hi guys,

First time posting on XDA so hope I have the right section etc...

I am trying to compile and boot the kernel for the Xiaomi Mi Note 2 and have had some success, but the image created causes the phone to boot into recover. Can I check my build procedure with your please?

The Xiaomi GitHub wiki page has an guide for another phone, which I have followed as far as possible.

Anyway, here are the steps I have taken. Have I missed anything out in terms of configuration?

Step 1:

Clone the Xiaomi git repo using:

git clone git@github.com:MiCode/Xiaomi_Kernel_OpenSource.git

Step 2:

Checkout the Scorpio branch:

git checkout scorpio-m-oss

Step 3:

Get the release tag for the QualComm suported Android Enablement Project: For the Mi Note 2 it I have used LA.UM.5.5.r1-04600-8x96.0.

Step 4:

Download the QAEP:

repo init -u git://codeaurora.org/platform/manifest.git -b release -m LA.UM.5.5.r1-04600-8x96.0.xml –-repo-url=git://codeaurora.org/tools/repo.git --repo-branch=caf-stable --depth=1

repo sync -j8

Step 7:

Merge Xioami Linux Kernel into QAEP: From the QAEP repo dir...

rm -rf kernel/*

mkdir kernel

cp -rf ~/Mi_Kernel/Xiaomi_Kernel_OpenSource/* kernel/

Step 8:

Build Kernel

source build/envsetup.sh

lunch msm8996-userdebug

make bootimage BOARD_USES_LIBC_WRAPPER=true

I found that I had to specify BOARD_USES_LIBC_WRAPPER=true as otherwise there would be a link error in the build as the symbol __propClientDispatchWrite would not be defined. Searching for this symbol I found that it is defined in ./bionic/libc/codeaurora/PropClientDispatchWrite.cpp:48. Looking at the Makefile ./bionic/libc/Android.mk one can see that this file is only compiled if ifeq ($(BOARD_USES_LIBC_WRAPPER),true), hence the need for the extra define in the command line for make.

Step 9:

Put kernel image into original

Download the original image and unpack:

adb pull /dev/block/sde36 boot_minote2_original.img

./mkboot boot_minote2_original.img boot_minote2_original

Do that same with mkboot for the image I built and unpack that. Then copy the file kernel from the newly build version into boot_minote2_original and repackage:

./mkboot boot_minote2_original boot_minote2_new.img

Step 9:

Attempt to boot new image

adb reboot bootloader

fastboot boot boot_minote2_new.img

And, almost there. The new image boots to a state where I can at least ADB shell into the device. The logcat shows the following significant errors when compared to the logcat of the original xiaomi image:

W SystemServer: ***********************************************

E SystemServer: BOOT FAILURE making display ready

E SystemServer: java.lang.NullPointerException: Attempt to invoke virtual method 'void com.android.server.wm.WindowManagerService.displayReady()' on a null object reference

E SystemServer:	at com.android.server.SystemServer.startOtherServices(SystemServer.java:594)

E SystemServer:	at com.android.server.SystemServer.run(SystemServer.java:281)

E SystemServer:	at com.android.server.SystemServer.main(SystemServer.java:179)

E SystemServer:	at java.lang.reflect.Method.invoke(Native Method)

E SystemServer:	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:738)

E SystemServer:	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:628)

E System : ******************************************

E System : ************ Failure starting system services

E System : java.lang.NullPointerException: Attempt to invoke virtual method 'void com.android.server.wm.WindowManagerService.showBootMessage(java.lang.CharSequence, boolean)' on a null object reference

E System :	at com.android.server.am.ActivityManagerService.showBootMessage(ActivityManagerService.java:6474)

E System :	at com.android.server.SystemServer.startOtherServices(SystemServer.java:627)

E System :	at com.android.server.SystemServer.run(SystemServer.java:281)

E System :	at com.android.server.SystemServer.main(SystemServer.java:179)

E System :	at java.lang.reflect.Method.invoke(Native Method)

E System :	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:738)

E System :	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:628)

D AndroidRuntime: Shutting down VM

E AndroidRuntime: *** FATAL EXCEPTION IN SYSTEM PROCESS: main

E AndroidRuntime: java.lang.NullPointerException: Attempt to invoke virtual method 'void com.android.server.wm.WindowManagerService.showBootMessage(java.lang.CharSequence, boolean)' on a null object reference

E AndroidRuntime:	at com.android.server.am.ActivityManagerService.showBootMessage(ActivityManagerService.java:6474)

E AndroidRuntime:	at com.android.server.SystemServer.startOtherServices(SystemServer.java:627)

E AndroidRuntime:	at com.android.server.SystemServer.run(SystemServer.java:281)

E AndroidRuntime:	at com.android.server.SystemServer.main(SystemServer.java:179)

E AndroidRuntime:	at java.lang.reflect.Method.invoke(Native Method)

E AndroidRuntime:	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:738)

E AndroidRuntime:	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:628)

So, onwards with my investigations but if any one has tips and clues to share, please lemme know :)