Recently I’ve started a kernel porting project for Xiaomi Mi 6, porting optimisation patches from open source community (e.g. XDA-Developer’s OnePlus 5 forum). Here is a quick note for environment setup and compiling the kernel only without AOSP buildroot.
- Install dependencies:
sudo apt install kernel-package git-core
- Download the source:
git clone https://github.com/huming2207/Popkern-sagit.git
- Toolchain setup: you can either try using Android perbuilt toolchains (may not work on my kernel project due to compiler argument in
CFLAGis not supported with GCC 4.9), or build by your own with crosstool-ng
- Set environment variables:
export CROSS_COMPILE=aarch64-your-toolchain-name- export ARCH=arm64
- Load configuration file
make defconfig sagit_user_defconfig
- Build the kernel
Creating flashable package
- Create a DTB-bundled kernel image. Since Xiaomi’s kernel building script somehow messed up, the
Image.gz-dtbis the same as
Image.gz. So we have to do the merge by our own:
cat arch/arm64/boot/Image.gz arch/arm64/boot/dts/qcom/*.dtb > zImage
- Download my package from here, then unzip it: https://github.com/huming2207/Popkern-sagit/releases
- Replace the
zImagefile which just generated, re-pack it.
- Flash to the device and it should works.