Skip to content

kernel build attempt

These are just links, notes of my attempt to patch KernelSU-Next into LineageOS kernel.

TLDR: After multiple attempts, I finally decided to compile the entire LineageOS system as opposed to just the kernel.

I think official source: https://source.android.com/docs/setup/build/building-kernels, instructions are for building GKI kernel, while my device (moto g32) has a non-GKI kernel. I need to read up more on this.

1748362796.png

It is because they dropped support for non-GKI kernels that I moved to KernelSU-Next.

I followed the instructions here to the tee to build the kernel: https://gist.github.com/davidgarland/ae6da821016fde4c877973ddd3f8f116

Compiling Kernel with KernelSU-Next and SUSFS

# The basedir
mkdir -p ~/devon/build-kernel
cd ~/devon/build-kernel
git clone 'https://github.com/LineageOS/android_kernel_motorola_sm6225.git'
git clone https://github.com/LineageOS/android_prebuilts_clang_kernel_linux-x86_clang-r416183b -b lineage-22.2
git clone https://github.com/LineageOS/android_prebuilts_gcc_linux-x86_aarch64_aarch64-linux-android-4.9 -b lineage-19.1
git clone https://github.com/LineageOS/android_prebuilts_gcc_linux-x86_arm_arm-linux-androideabi-4.9 -b lineage-19.1
BASEDIR="/home/vector/devon/build-kernel"
GCCDIR=$BASEDIR/android_prebuilts_gcc_linux-x86_aarch64_aarch64-linux-android-4.9
GCCDIR32=$BASEDIR/android_prebuilts_gcc_linux-x86_arm_arm-linux-androideabi-4.9
CLANGDIR=$BASEDIR/android_prebuilts_clang_kernel_linux-x86_clang-r416183b
cd android_kernel_motorola_sm6225
cd arch/arm64/configs
# After connecting to my moto g32 running lineageos.
adb -d shell zcat /proc/config.gz > lineagevec_defconfig
cd ~/devon/build-kernel/android_kernel_motorola_sm6225/

source:

Only use the second link (KernelSU-Next already patched for SUSFS)

1748363253.png

curl -LSs "https://raw.githubusercontent.com/rifsxd/KernelSU-Next/next-susfs/kernel/setup.sh" | bash -s next-susfs

Note that KernelSU-Next is already patched. We only need to patch the cloned kernel itself.

Getting the patch and patch the kernel (skip the instructions specific to kernel-su patch).

# Went with branch 4.19 after determining that to be the kernel version
git clone --branch kernel-4.19 --single-branch --depth 1 https://gitlab.com/simonpunk/susfs4ksu.git
cd susfs4ksu
cp ./kernel_patches/50_add_susfs_in_kernel-4.19.patch ../
cp ./kernel_patches/fs/* ../fs/
cp ./kernel_patches/include/linux/* ../include/linux
patch -p1 < 50_add_susfs_in_kernel-4.19.patch
make O=out ARCH=arm64 KCFLAGS="-Wno-error=return-type" PATH=$CLANGDIR/bin:$GCCDIR/bin:$PATH LD_LIBRARY_PATH=$CLANGDIR/lib LLVM=1 CROSS_COMPILE=$GCCDIR/bin/aarch64-linux-android- CROSS_COMPILE_ARM32=$GCCDIR32/bin/arm-linux-androideabi- CLANG_TRIPLE=aarch64-linux-gnu- -j$(nproc)

Comments