Wiktor Olszewski 2fe165351a Enhanced kernel builder with comprehensive SUSFS integration and build fixes
Major improvements:
- Added proper GKI defconfig base with garnet fragment support
- Created comprehensive SUSFS headers (susfs.h, susfs_def.h) with full API
- Fixed KPM copy_to_user compilation issues using put_user()
- Added extensive SUSFS configuration flags for full integration
- Enhanced error handling and dependency checking for Arch Linux
- Added clean build function that preserves source integrations
- Comprehensive warning suppression for problematic drivers
- Advanced compiler flags to handle hardened copy checking

Features implemented:
- Multi-distro dependency checking (Arch/Debian/Ubuntu)
- SUSFS path/mount hiding, kstat spoofing, uname modification
- KPM (Kernel Patch Module) support with compilation fixes
- Enhanced security configurations while maintaining compatibility
- Proper SUSFS constant definitions and working modes
- Clean build artifacts function with source preservation

Build system improvements:
- GKI 2.0 base configuration with device-specific fragments
- Parallel compilation with all CPU cores
- Comprehensive build logging and error tracking
- Advanced warning suppression for complex driver builds
- Proper cross-compilation toolchain detection and setup
2025-07-02 01:05:50 +02:00

Garnet Kernel Builder

Automated kernel build script for Redmi Note 13 Pro 5G (garnet) with integrated Sukisu Ultra (KernelSU fork) and SUSFS root hiding capabilities.

Features

  • 🔧 Automated Build Process - Complete kernel compilation with one command
  • Sukisu Ultra Integration - Enhanced KernelSU fork with advanced features
  • 🛡️ SUSFS Root Hiding - Filesystem-level root detection bypass
  • 📦 AnyKernel3 Packaging - Ready-to-flash ZIP files
  • 🎯 Multiple Build Options - Stock, KernelSU-only, SUSFS-only configurations

Device Compatibility

  • Device: Redmi Note 13 Pro 5G
  • Codename: garnet
  • SoC: SM7435 (Snapdragon 7s Gen 2)
  • Android: 13, 14, 15
  • Architecture: ARM64

Quick Start

Prerequisites

Arch Linux:

sudo pacman -S base-devel git bc bison flex openssl elfutils zip aarch64-linux-gnu-gcc

Ubuntu/Debian:

sudo apt install git make bc bison flex libssl-dev libelf-dev zip gcc-aarch64-linux-gnu

Clone and Build

# Clone the repository
git clone https://github.com/overspend1/garnet-kernel-builder.git
cd garnet-kernel-builder

# Make executable
chmod +x build_garnet_kernel.sh

# Build with all features (recommended)
./build_garnet_kernel.sh

Build Options

# Full build with Sukisu Ultra + SUSFS (default)
./build_garnet_kernel.sh

# Stock kernel without root features
./build_garnet_kernel.sh --stock

# KernelSU only (no SUSFS)
./build_garnet_kernel.sh --sukisu-only

# SUSFS only (no KernelSU)
./build_garnet_kernel.sh --susfs-only

# Skip AnyKernel3 ZIP creation
./build_garnet_kernel.sh --no-anykernel3

# Show help
./build_garnet_kernel.sh --help

Android NDK Support (Optional)

For optimal Android kernel compilation, use Android NDK:

# Set NDK path
export ANDROID_NDK_HOME=/path/to/android-ndk

# Build with NDK toolchain
./build_garnet_kernel.sh

Output

Build artifacts are created in garnet_kernel_build/output/:

  • Image.gz-dtb - Kernel with device tree (for fastboot)
  • *.dtb - Individual device tree files
  • Garnet-Kernel-SukiSU-SUSFS-YYYYMMDD-HHMM.zip - Flashable ZIP

Installation

  1. Boot into TWRP/custom recovery
  2. Flash the generated ZIP file
  3. Reboot system

Method 2: Fastboot

fastboot flash boot Image.gz-dtb
fastboot reboot

Post-Installation

  1. Install Sukisu Ultra Manager APK
  2. Install SUSFS4KSU Module for root hiding
  3. Configure root hiding through the manager app

Build Process Details

The script automatically:

  1. Dependency Verification - Checks for required build tools
  2. Toolchain Setup - Configures ARM64 cross-compilation
  3. Repository Management - Clones/updates kernel sources
  4. Feature Integration - Applies Sukisu Ultra and SUSFS patches
  5. Kernel Configuration - Enables required features
  6. Compilation - Parallel build using all CPU cores
  7. Package Creation - Generates flashable ZIP files

Advanced Configuration

Kernel Features Enabled

  • KPM Support - Kernel Patch Module for Sukisu Ultra
  • KALLSYMS - Symbol resolution for KernelSU
  • Security Framework - SELinux, LSM, audit support
  • Overlay Filesystem - Required for SUSFS
  • Namespace Support - Container isolation
  • Memory Protection - Hardened security features

Repositories Used

  • Kernel: garnet-random/android_kernel_xiaomi_sm7435
  • Device Trees: garnet-random/android_kernel_xiaomi_sm7435-devicetrees
  • Modules: garnet-random/android_kernel_xiaomi_sm7435-modules
  • Sukisu Ultra: SukiSU-Ultra/SukiSU-Ultra
  • SUSFS: sidex15/susfs4ksu-module

Troubleshooting

Common Issues

Build Failures:

  • Check build.log in kernel directory
  • Verify all dependencies are installed
  • Ensure sufficient disk space (>10GB)

Missing Cross-Compiler:

# Arch Linux
sudo pacman -S aarch64-linux-gnu-gcc

# Ubuntu/Debian
sudo apt install gcc-aarch64-linux-gnu

Integration Failures:

  • Check setup_sukisu.log for Sukisu Ultra errors
  • Verify internet connectivity for repository access
  • Try manual integration fallback

Build Time

  • First Build: 20-40 minutes (downloads repositories)
  • Subsequent Builds: 10-20 minutes (incremental)
  • Clean Build: 15-30 minutes

Security Notice

This script integrates defensive security tools:

  • KernelSU: Provides root access management
  • SUSFS: Enables root hiding from detection
  • Hardened Configuration: Security-focused kernel options

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Test thoroughly
  5. Submit a pull request

License

This project is for educational and defensive security purposes only. Ensure compliance with local laws and device warranties.

Support

  • Issues: GitHub Issues
  • Device: Redmi Note 13 Pro 5G (garnet) only
  • Android: Versions 13, 14, 15

⚠️ Warning: Flashing custom kernels can void warranties and potentially brick devices. Proceed at your own risk with proper backups.

Description
Automated kernel build script for Redmi Note 13 Pro 5G (garnet) with Sukisu Ultra and SUSFS integration
Readme MIT 51 KiB
Languages
Shell 100%