How to integrate BakaSU
On this page
BakaSU can be integrated into non-GKI kernels and was backported to 3.4 and earlier versions.
Due to the fragmentation of non-GKI kernels, we don't have a universal way to build them; therefore, we cannot provide a non-GKI boot.img. However, you can build the kernel with BakaSU integrated on your own.
First, you should be able to build a bootable kernel from kernel source code. If the kernel isn't open source, then it is difficult to run BakaSU for your device.
If you're able to build a bootable kernel, you can add BakaSU into your kernel by following this guide.
Building Kernel
Sync the kernel source code
repo init -u https://android.googlesource.com/kernel/manifest
mv <kernel_manifest.xml> .repo/manifests
repo init -m manifest.xml
repo sync
The <kernel_manifest.xml> file is a manifest that uniquely identifies a build, allowing you to make it reproducible. To do this, you should download the manifest file from GKI release builds.
Build
Please check the Building kernels first.
For example, to build an aarch64 kernel image:
LTO=thin BUILD_CONFIG=common/build.config.gki.aarch64 build/build.sh
Don't forget to add the LTO=thin flag; otherwise, the build may fail if your computer has less than 24 GB of memory.
Starting from Android 13, the kernel is built by bazel:
tools/bazel build --config=fast //common:kernel_aarch64_dist
Build kernel with BakaSU
First, add BakaSU to your kernel source tree:
curl -LSs "https://raw.githubusercontent.com/Baka-SU/BakaSU/main/kernel/setup.sh" | bash
Then,choose one of the following methods to integrate BakaSU into your kernel:
Manual hooks
Then,add BakaSU's hooks into your kernel, and build your kernel again, and BakaSU should work correctly.
SUSFS
Then, in the SUSFS repository, choose the branch that matches your kernel version and apply the kernel-side patches as instructed; after making the changes, rebuild the kernel.