This is version of source that builds and works just like stock kernel (if anyone need to rebuild stock kernel, but has some problems like wifi not working)
- Clone this repo:
git clone --depth 1 https://github.com/RuslanUC/android_kernel_xiaomi_markw
- Install build dependencies (this command is for ubuntu):
apt install -y adb android-sdk-platform-tools git-core ark tar make gnupg flex bc bison gperf build-essential zip curl zlib1g-dev gcc-multilib g++-multilib libc6-dev-i386 lib32ncurses5-dev x11proto-core-dev libx11-dev lib32z-dev libgl1-mesa-dev libxml2-utils xsltproc unzip python2 wget abootimg liblzo2-dev python3-pip
- Download and unpack linaro toolchain 4.9-2017.01
- Set CROSS_COMPILE environment variable to
<unpacked linaro path>/bin/aarch64-linux-gnu-
- Set ARCH and SUBARCH environment variables to
arm64
- Cd to kernel directory
- (Optional) Make your changes in defconfig / source code
- Build kernel:
make clean O=out
make mrproper O=out
make markw_defconfig O=out
make -j8 O=out # Replace 8 with number of your cpu cores
- Pull your current kernel from device:
adb shell dd if=/dev/block/mmcblk0p21 of=/sdcard/boot-stock.img
adb pull /sdcard/boot-stock.img ./boot.img
- Unpack it:
abootimg -x boot.img
- Replace zImage with one you just built:
rm zImage
cp out/arch/arm64/boot/Image.gz-dtb ./zImage
- Repack boot image:
abootimg --create new_boot.img -f bootimg.cfg -k zImage -r initrd.img
- Sign wifi kernel module
scripts/sign-file sha512 out/signing_key.priv out/signing_key.x509 out/drivers/staging/prima/wlan.ko
- Push wifi kernel module to your device:
adb shell mv /system/lib/modules/pronto/pronto_wlan.ko /system/lib/modules/pronto/pronto_wlan.ko.bak # IMPORTANT! Backup your current wifi module because if you flash back stock kernel, wifi will not work!
adb push out/drivers/staging/prima/wlan.ko /system/lib/modules/pronto/pronto_wlan.ko
adb shell chmod 0644 /system/lib/modules/pronto/pronto_wlan.ko
- Reboot your device to fastboot
- Boot image you just repacked:
fastboot boot new_boot.img
- If your device is working properly and new boot image is stable, flash new boot image:
fastboot flash boot new_boot.img
- To revert wifi kernel module to the stock one (use only with stock boot image):
adb shell rm /system/lib/modules/pronto/pronto_wlan.ko
adb shell mv /system/lib/modules/pronto/pronto_wlan.ko.bak /system/lib/modules/pronto/pronto_wlan.ko
adb reboot