No introductions or pleasantries this time, this is a guide so lets cut to the chase

KernelSU guide for A14

Note:

This guide was made specifically with the SM-A145R, a device that I own, in mind, however that does not mean you cannot take these instructions for yourself and run with them, just be prepared for trial and error mkay? I’ll be generalising stuff that the official KernelSU non-GKI integrate guide covers, let me make one thing clear, I expect you to read it and read it fully, this is NOT a replacement more than it is a side

What we have to do to install KernelSU

The list goes as follows

  • Download and extract the kernel from Samsung Opensource
  • Search your model number and download the file available for it, it will contain README files and Kernel.tar.gz and Platform.tar.gz, we only want the Kernel.tar.gz file (and maybe the README_Kernel file, that’s nice to have too)
  • Don’t even try to use WSL, use proper linux or get fucked and go home, dualbooting is easy
  • If there is no file available for your device, email them asking for it, they’ll upload it on request because they legally have to, I got them to upload it with a fucking @doinyour.mom email ok you can do it from your gmail
  • Set up KernelSU in your kernel’s folder, since 0.9.5 is the last version to support GKIs as of time of writing we will run curl -LSs "https://raw.githubusercontent.com/tiann/KernelSU/main/kernel/setup.sh" | bash -s v0.9.5
  • This should be pretty straightforward and easy, just look out for errors
  • Modify your defconfig files to enable kprobes fully
  • No need to test it, kprobes 100% work in the A145R’s kernel
  • Defconfig files are stored in arch/arm64/configs, in the case of the A145R the files we need are a14m_defconfig and a14m_00_defconfig
  • Make sure to check the state of each kprobe config line KernelSU’s guide provides, in the A145R’s config one is enabled already but we need all of them
  • (optional I guess but that’s no fun) Backport path_umount to enable umount functionality, this section of KernelSU’s guide contains a patch that you need to merge into fs/namespace.c either with some kind of patch merger or just manually like I did it
  • If kernel compilation fails, this is the first thing you need to look for errors in
  • This is pretty difficult, if you can live without umount functionality you can get away with not backporting it but I like it so I included it
  • Get a toolchain (AKA the hardest step for me personally lol), the A145R’s kernel needs clang-r383902, which you can get prebuilt in android’s repositories
  • Modify build_kernel.sh to point to your toolchain, I left my (very scuffed) config below
  • It might complain if you used a clang prebuilt like I did, the build still goes fine to my knowledge
  • You can also modify it to not copy out/arch/arm64/boot/Image (the built kernel) to $(pwd)/arch/arm64/boot/Image but honestly there’s no point idk why I did that
export PATH=$(pwd)/../linux-x86/clang-r383902/bin:$PATH
export CROSS_COMPILE=$(pwd)/../linux-x86/clang-r383902/bin/aarch64-linux-gnu-
export CC=$(pwd)/../linux-x86/clang-r383902/bin/clang
export CLANG_TRIPLE=aarch64-linux-gnu-
export ARCH=arm64
export PLATFORM_VERSION=12
  • Run build_kernel.sh
  • Good luck!
  • If it fails you should be able to use the error message it generates to determine where it went wrong and fix it
  • The most common things to mess up are the toolchain and the path_umount backport
  • Copy out/arch/arm64/boot/Image to another folder
  • Just to avoid clutter
  • Obtain a stock boot.img file, if you need to acquire firmware for Samsung devices you can use Bifrost and use any old archive tool with the ability to read .tar files to extract it from the AP file
  • Install magiskboot, either from the AUR or some other way of getting the official x86_64 linux version, or just use magiskboot_build if you’re patching on Windows or macOS for some reason
  • You can also deviate from here and patch your boot.img your own way but you do that at your own risk
  • With the magiskboot binary somewhere on the PATH and boot.img in the same directory as Image, run magiskboot unpack boot.img to unpack your boot image
  • You can also have magiskboot in the same directory or somewhere not on the path, if you can run it I don’t care. Become ungovernable.
  • Run rm -f kernel, then mv Image kernel to replace the kernel from the boot.img with the one we just compiled
  • You can use any other command or non command method to do this, the commands are just a means to an end
  • Run magiskboot repack boot.img to pack our kernel into a boot.img file in the same configuration as the original boot.img
  • Flash our new-boot.img through whatever means you have available
  • The A145R supports fastboot! Though the drivers are really weird on Windows specifically, run adb reboot bootloader to enter fastboot, if you’re on Windows and fastboot can’t find a device then you need to go into device manager, find the device that is in fastboot, then update it’s driver to a “SAMSUNG Bootloader USB device” (name may or may not be different, that’s just the general gist)
  • ODIN is also a good method of flashing, just rename new-boot.img to boot.img, add it to a .tar file, then flash it in the AP slot and boom!
  • Boot your device
  • If you encounter a bootloop then something went wrong in either the kernel build or the boot.img repacking processes
  • Open the KernelSU manager app
  • If it still shows “Not supported” then chances are you flashed the wrong boot.img
  • Done! Enjoy your KernelSU!

Closing thoughts

I love KernelSU, and I love how I managed to install it on something it was never designed for. The KernelSU telegram group is also cool, to get in you have to complete a mini test in a fake terminal where you flash a device with a KernelSU GKI boot.img to see if you’ve read the docs or not, and that’s really cool in my opinion!

See you next time!

-george2781