Automated script for building Android kernels with optional support for KernelSU and KernelSU-Next. Designed to simplify the build process, dependency management, and final kernel packaging.
- Automated Build: Compiles Android kernels with simplified configuration
- KernelSU Support: Optional integration with KernelSU or KernelSU-Next
- Dependency Management: Automatic Clang cloning if not present
- Smart Cleanup: Automatically removes previous builds and old KernelSU directories
- AnyKernel3 Packaging: Generates flashable ZIP ready for installation
- Input Validation: Checks user responses and aborts build on invalid input
- Error Logging: Saves compilation errors to
error.log - Build Timer: Calculates and displays total compilation time
- Pre-cleanup: Removes old KernelSU/KernelSU-Next directories
- Build Type Selection:
- Stock build (without KernelSU)
- Build with KernelSU
- Build with KernelSU-Next
- Automatic Setup: Downloads and configures chosen KernelSU version
- Compiler Check: Automatic Clang cloning if needed
- Compilation: Kernel build with LLVM/Clang
- Packaging: Creates flashable ZIP via AnyKernel3
- Final Cleanup: Removes temporary files
- Linux system
- Git installed
- Android kernel build dependencies
AnyKernel3/directory configured at the same level as the script
chmod +x build.sh
./build.sh1. Include KernelSU?
Do you want to include KernelSU? (y / n)
y= Proceed with KernelSUn= Stock build without root
2. KernelSU Version (if selected)
KernelSU or KernelSU Next??
1 to KernelSU
2 to KernelSU Next
1= Official KernelSU (stable)2= KernelSU-Next (development)
Locate and edit these variables in the script according to your device:
DEVICE_CODENAME="stone" # Device codename
DEVICE_NAME="POCO X5 5G/Redmi Note 12 5G/Note 12R Pro" # Market name
KERNEL_NAME="Eclipse" # Kernel name
BUILD_STATUS="STABLE" # Status: STABLE/TESTING
COMPILER_PATH="$HOME/clang-r547379/bin" # Compiler pathproject/
βββ build.sh # This script
βββ AnyKernel3/ # AnyKernel3 template
βββ arch/arm64/configs/ # Kernel defconfigs
βββ error.log # Generated on error
The script automatically generates a ZIP with nomenclature:
- Stock:
Eclipse-Kernel-stone-YYYYMMDD.zip - KernelSU:
Eclipse-Kernel-KSU-stone-YYYYMMDD.zip - KernelSU-Next:
Eclipse-Kernel-KSU-Next-stone-YYYYMMDD.zip
Image- Compiled kerneldtb- Device Tree Blobdtbo.img- Device Tree Overlay- AnyKernel3 scripts for installation
After automatic setup, you need to:
Option 1: Add to defconfig
# In arch/arm64/configs/stone_defconfig
CONFIG_KPROBES=y
CONFIG_HAVE_KPROBES=y
CONFIG_KPROBE_EVENTS=y
CONFIG_MODULES=y
CONFIG_MODULE_UNLOAD=y
Option 2: Add to Makefile
# Before 'all:' target in root Makefile
-include $(srctree)/KernelSU/kernel/Makefile.ext
# or
-include $(srctree)/KernelSU-Next/kernel/Makefile.extThe script enables these configurations automatically via scripts/config, but manual configuration ensures persistence between builds.
- Auto-download: Automatic cloning if not found
- Source: crDroid Android Prebuilts
- Branch: 15.0
- Configuration: LLVM=1, LLVM_IAS=1
To use another compiler, edit:
COMPILER_PATH="/path/to/your/compiler/bin"- Check
error.logfor details - Confirm all dependencies are installed
- Verify defconfig is correct
- Verify configurations were added to defconfig
- Confirm
KernelSU/kernelorKernelSU-Next/kernelexists - Reinstall by running the script again
- Check if
AnyKernel3/exists in correct directory - Confirm
Image,dtbo.imganddtb.imgwere compiled - Verify write permissions in directory
This script is a modified and improved version with the following changes:
- β Automatic Pre-cleanup: Removes old KernelSU directories before selection
- β Input Validation: Checks y/n and 1/2 responses, aborts on invalid input
- β KernelSU-Next Support: Additional option besides official KernelSU
- β
Automatic Configuration: Enables required configs via
scripts/config - β Intelligent Naming: ZIP named according to chosen build type
- β Final Pause: Waits for ENTER before closing terminal
- β Clean Code: Removed duplicate code and fixed if/elif/else structure
- β Improved Messages: Emojis and formatting for better UX
The copyright was changed to Julival Bittencourt due to the following substantial modifications:
- Complete Refactoring: Restructuring of flow logic and validations
- New Functionalities: KernelSU-Next support, pre-cleanup, validations
- Critical Fixes: Bug fixes in if/elif/else logic
- UX Improvements: Enhanced interactive interface
- Original Code: Maintains GPL v2 license respecting original license terms
The original script was used as a base, but the modifications represent significant derivative work, justifying the copyright update under GPL terms.
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License v2 as published by the Free Software Foundation.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
- Author: Julival Bittencourt
- License: GNU GPL v2
- Year: 2025
Script based on original work by:
- Amrita Das - bhabanidas431@gmail.com
Special thanks to the communities:
- KernelSU - Kernel-level root framework
- KernelSU-Next - KernelSU development fork
- AnyKernel3 - Universal kernel installation template
- crDroid Android - Clang toolchain
To report issues or suggest improvements, open an issue in the project repository.