Skip to content

A custom kernel for the Redmi 9 (lancelot) based on the Proton kernel, integrating KernelSU Next and SukiSU Ultra for advanced root capabilities. Built for kernel version 4.14 with support for SUSFS and OverlayFS, it uses a custom Clang toolchain and AnyKernel3 for easy flashing.

Notifications You must be signed in to change notification settings

Edhic1/kernel_KSu_Next_Lancelot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Alt text

Kernel KernelSu Next Lancelot

A custom kernel for Redmi 9 (lancelot) with KernelSU and SukiSU Ultra support, based on Proton kernel.

Features

  • KernelSU and SukiSU Ultra for root
  • SUSFS and OverlayFS support
  • Built with custom Clang for performance
  • Automated releases via GitHub Actions

Flashing Instructions

This kernel for the Redmi 9 (lancelot) supports KernelSU and SukiSU Ultra. Flash it using a custom recovery (e.g., TWRP, OrangeFox) or Fastboot. Download the latest release from the Releases page.

Prerequisites

  • Unlocked Bootloader: Ensure your device’s bootloader is unlocked.Tools
  • Custom Recovery: Install TWRP or another custom recovery for recovery flashing (not required for Fastboot).
  • Backup: Back up your data and current kernel/boot partition to avoid issues.
  • Downloads: Get AnyKernel3-KernelSU_10342-lancelot-YYYYMMDDHHMM.zip for recovery or Image.gz-dtb-KernelSU_10342-lancelot-YYYYMMDDHHMM for Fastboot from the latest release.

Method 1: Flash via Custom Recovery (Recommended)

  1. Download the ZIP:
    • Download the AnyKernel3-KernelSU_10342-lancelot-YYYYMMDDHHMM.zip file from the Releases page.
  2. Boot into Recovery:
    • Power off your device.
    • Boot into TWRP or your custom recovery (usually by holding Volume Up + Power).
  3. Flash the ZIP:
    • In TWRP, select Install and navigate to the downloaded AnyKernel3.zip file.
    • Swipe to flash the ZIP.
    • (Optional) Clear cache/dalvik if prompted or required.
  4. Reboot:
    • Select Reboot > System in TWRP.
    • Your device will boot with the new kernel.
  5. Verify:
    • Use a root checker or KernelSU app to confirm the kernel is installed and root is working.

Method 2: Flash via Fastboot

  1. Download the Kernel Image:
    • Download the Image.gz-dtb-KernelSU_10342-lancelot-YYYYMMDDHHMM file from the Releases page.
  2. Set Up Fastboot:
    • Install ADB and Fastboot on your computer (download here).
    • Enable USB debugging on your device and connect it to your computer.
  3. Boot into Fastboot Mode:
    • Power off your device.
    • Boot into Fastboot mode (usually by holding Volume Down + Power).
  4. Flash the Kernel:
    • Open a terminal/command prompt in the folder containing the Image.gz-dtb file.
    • Run the following command:
      fastboot flash boot Image.gz-dtb-KernelSU_10342-lancelot-YYYYMMDDHHMM
      
    • Wait for the flash to complete.
  5. Reboot:
    • Run:
      fastboot reboot
      
    • Your device will boot with the new kernel.
  6. Verify:
    • Use a root checker or KernelSU app to confirm the kernel is installed and root is working.

Notes

  • Custom Recovery: Flashing via TWRP is easier and supports AnyKernel3’s automatic kernel installation. Use this method unless you lack a custom recovery.
  • Fastboot: Flashing via Fastboot directly replaces the boot image. Ensure the Image.gz-dtb is compatible with your ROM.
  • Issues: If the device fails to boot, restore your backup or reflash the stock boot image. Join our Telegram group/community for support (https://t.me/Jbub5_Discussion).
  • Root: After flashing, install the KernelSU app to manage root access.

Explanation

  • Custom Recovery Method: Uses AnyKernel3.zip, which is designed for recovery flashing. AnyKernel3 automatically extracts and installs the kernel (Image.gz-dtb) into the boot partition, making it user-friendly.
  • Fastboot Method: Uses the raw Image.gz-dtb file to directly flash the boot partition. This is useful if no custom recovery is installed but requires a computer and Fastboot setup.
  • Artifacts: The instructions reference the artifact names generated by your workflow (e.g., AnyKernel3-KernelSU_10342-lancelot-YYYYMMDDHHMM.zip), based on your environment variables (UPLOADNAME, DEVICE, BUILD_TIME).
  • Safety: Emphasizes backups and verification to prevent bootloops or data loss.
  • Support: https://t.me/Jbub5_Discussion.

Step-by-step guide to build using action

Click to open

1.

01

2.

02 Note: Unselect Copy the kernel-tree_lancelot branch only if you are building for merlin.

3.

03

4.

04

5.

05

6.

06

7.

07

8.

08

9.

09

10.

10

11.

11 Note: Reload this page if the yellow circle does not appear.

12.

12

13.

13

14.

14


Options Guide

Click to open

All options are located in config.env

KERNEL_SOURCE

Change this to your kernel repository link.

For example: https://github.com/Jbub5/android_kernel_xiaomi_mt6768

KERNEL_SOURCE_BRANCH

Change this to your kernel branch.

For example: kernel-tree

KERNEL_CONFIG

Change this to your kernel defconfig name.

For example: lancelot_defconfig

KERNEL_IMAGE_NAME

Change this to the kernel binary that needs to be flashed, generally consistent with BOARD_KERNEL_IMAGE_NAME in your AOSP device tree.

For example: Image.gz-dtb

Common names include Image, Image.gz.

KERNEL_ARCH

For example: arm64

ENABLE_KERNELSU

Enable KernelSU support.

KERNELSU_TAG

KernelSU 1.0 no longer supports non-GKI kernels. The last supported version is v0.9.5, please make sure to use the correct branch.

Select the branch or tag of KernelSU:

  • main branch (development version): KERNELSU_TAG=main
  • Latest TAG (stable version): KERNELSU_TAG=v0.9.5
  • Specify the TAG (such as v0.5.2): KERNELSU_TAG=v0.5.2

KSU_EXPECTED_SIZE and KSU_EXPECTED_HASH

Customize the size and hash values of the KernelSU manager signature, if you don't need to customize the manager then please leave them empty or fill in the official default values:

KSU_EXPECTED_SIZE=0x033b

KSU_EXPECTED_HASH=c371061b19d8c7d7d6133c6a9bafe198fa944e50c1b31c9d8daa8d7f1fc2d2d6

You can type ksud debug get-sign <apk_path> to get the size and hash of the apk signature.

KSU_REVERT

This will revert the commit that removed non-GKI support, making it possible to continue using official KernelSU up to version 1.0.1. Using versions newer than 1.0.1 is not possible due to the removal of non-GKI support from the manager.

ADD_KPROBES_CONFIG

This is used in the installation of KernelSU via kprobe. If kprobe is broken in your kernel or you don't know what it is then don't touch this config.

See details: https://kernelsu.org/guide/how-to-integrate-for-non-gki.html#integrate-with-kprobe

KSU_HOOKS_PATCH

If kprobe does not work in your kernel, then try enabling this option, this will automatically patch kernel source code to support KernelSU.

See details: https://kernelsu.org/guide/how-to-integrate-for-non-gki.html#manually-modify-the-kernel-source

ADD_OVERLAYFS_CONFIG

If enabled will automatically put the configs needed for OverlayFS into your defconfig.

ADD_APATCH_SUPPORT

If enabled will automatically put the configs needed for APatch into your defconfig.

FIX_APATCH_OPENELA

This option provides fix for bmax121/APatch#400.

OLD_ANDROID_SUPPORT

There is no official support for older Android and MIUI, and bug reports will not be accepted on them.

This option provides support for MIUI 12.5 and custom ROMs based on Android 11 through 12, but breaks support for Android 13 and above.

USE_CUSTOM_CLANG

You can use a non-official clang such as proton-clang.

CUSTOM_CLANG_SOURCE

Fill in a link that includes .git if it is a git repository.

Git repository or direct chain of compressed zip files is supported.

CUSTOM_CLANG_BRANCH

For example: main

CLANG_BRANCH

Due to #23, we provide an option to customize the Google main branch. The main ones include:

Clang Branch
master
master-kernel-build-2021
master-kernel-build-2022

Or other branches, please search for them according to your own needs at https://android.googlesource.com/platform/prebuilts/clang/host/linux-x86.

CLANG_VERSION

Enter the Clang version to use.

Clang Version Corresponding Android Version AOSP-Clang Version
12.0.5 Android S r416183b
14.0.6 Android T r450784d
14.0.7 r450784e
15.0.1 r458507
17.0.1 r487747b
17.0.2 Android U r487747c

Generally, Clang12 can compile most of the 4.14 and above kernels. My MI 6X 4.19 uses r450784d.

ENABLE_GCC_AOSP

Enables usage of standart GCC toolchain.

ENABLE_GCC_ARM64

Enable GCC 64C cross-compiler.

ENABLE_GCC_ARM32

Enable GCC 32C cross-compiler.

EXTRA_CMDS

Some kernels require additional compilation commands to compile correctly. Generally, no other commands are needed, so please search for information about your kernel. Please separate the command and the command with a space.

For example: LLVM=1 LLVM_IAS=1

USE_CUSTOM_ANYKERNEL3

Can use custom AnyKernel3.

CUSTOM_ANYKERNEL3_SOURCE

If it is a git repository, please fill in the link containing .git

Supports direct links to git repositories or zip compressed packages.

CUSTOM_ANYKERNEL3_BRANCH

Customize the warehouse branch of AnyKernel3.

NEED_DTBO

Upload DTBO. Some devices require it.

BUILD_BOOT_IMG

Added from previous workflows, view historical commits

Build boot.img, and you need to provide a Source boot image.

SOURCE_BOOT_IMAGE

As the name suggests, it provides a boot image source system that can boot normally and requires a direct chain, preferably from the same kernel source and AOSP device tree as your current system. Ramdisk contains the partition table and init, without which the compiled image will not boot up properly.

For example: https://raw.githubusercontent.com/xiaoleGun/KernelSU_action/main/boot/boot-wayne-from-Miku-UI-latest.img

DISABLE_LTO

LTO is used to optimize the kernel but sometimes causes errors.

DISABLE_CC_WERROR

Sometimes even a harmless warning breaks the build.

FIX_WIFI_SPEED

Switching to other drivers fixed spontaneous reboots when turning on Wi-Fi on some devices, but resulted in decreased network speeds. This option will revert to the previous drivers and thus fix the network speed.

REMOVE_UNUSED_PACKAGES

To clean unnecessary packages and free up more disk space. If you need these packages, please disable this option.

ENABLE_CCACHE

Enable the cache to make the second kernel compile faster (or slower).


Credits

Thanks

About

A custom kernel for the Redmi 9 (lancelot) based on the Proton kernel, integrating KernelSU Next and SukiSU Ultra for advanced root capabilities. Built for kernel version 4.14 with support for SUSFS and OverlayFS, it uses a custom Clang toolchain and AnyKernel3 for easy flashing.

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

Contributors 16