Skip to content

Redmi 4 prime (markw/msm8953) stock kernel with proper defconfig and wifi driver.

License

Notifications You must be signed in to change notification settings

some-random-packages/android_kernel_xiaomi_markw

Repository files navigation

Xiaomi Redmi 4 Pro kernel source

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)

How to build

  1. Clone this repo:
git clone --depth 1 https://github.com/RuslanUC/android_kernel_xiaomi_markw
  1. 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
  1. Download and unpack linaro toolchain 4.9-2017.01
  2. Set CROSS_COMPILE environment variable to <unpacked linaro path>/bin/aarch64-linux-gnu-
  3. Set ARCH and SUBARCH environment variables to arm64
  4. Cd to kernel directory
  5. (Optional) Make your changes in defconfig / source code
  6. 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
  1. 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
  1. Unpack it:
abootimg -x boot.img
  1. Replace zImage with one you just built:
rm zImage
cp out/arch/arm64/boot/Image.gz-dtb ./zImage
  1. Repack boot image:
abootimg --create new_boot.img -f bootimg.cfg -k zImage -r initrd.img
  1. Sign wifi kernel module
scripts/sign-file sha512 out/signing_key.priv out/signing_key.x509 out/drivers/staging/prima/wlan.ko
  1. 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
  1. Reboot your device to fastboot
  2. Boot image you just repacked:
fastboot boot new_boot.img
  1. If your device is working properly and new boot image is stable, flash new boot image:
fastboot flash boot new_boot.img
  1. 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