This script automatically generates the required Redroid kernel patches for Armbian RK3588. By comparing the official Armbian kernel with CNflysky's modified kernel, it extracts key differences that add support for the system-uncached-dma32 DMA heap device and generates a patch file that can be directly applied to the Armbian build process.
- Redroid-rk3588 requires the kernel to provide the
system-uncached-dma32DMA heap device for GPU hardware acceleration - This device was removed from the mainline Linux 6.1 kernel
- Armbian's default kernel (rk-6.1-rkr5.1 branch) does not include this device
- CNflysky added the necessary code in their forked kernel (rk-6.1-rkr4.1 branch)
Manually comparing two kernel branches and extracting differences is time-consuming and error-prone. This script automates the entire process, ensuring:
β Extract only necessary differences (DMA-BUF related code) β Generate standard patch files conforming to Armbian patch format β Repeatable execution for easy updates and maintenance
- Operating System: Ubuntu 22.04 LTS or similar Debian-based distributions
- Memory: At least 8GB RAM
- Storage: At least 15GB free space
- Privileges: Recommended to run as root user (to avoid permission issues)
sudo apt update
sudo apt install -y git diffutils coreutilsThe script needs to be used within a cloned Armbian build directory:
cd ~
git clone --depth=1 https://github.com/armbian/buildcd ~
wget https://github.com/HwlloChen/redroid-rk3588-armbian-kernel-patch/raw/refs/heads/main/generate_redroid_patch.shchmod +x generate_redroid_patch.shConfiguration parameters at the top of the script can be modified as needed:
# Armbian build directory path
ARMBIAN_BUILD_DIR="$HOME/build"
# Armbian target kernel branch (adjust according to your build configuration)
TARGET_KERNEL_BRANCH="rk35xx-vendor-6.1"
# Base kernel branch (Armbian official)
ARMBIAN_KERNEL_BRANCH="rk-6.1-rkr5.1"
# Target kernel branch (CNflysky modified version)
CNFLYSKY_KERNEL_BRANCH="rk-6.1-rkr4.1"Key Parameter Descriptions:
| Parameter | Description | Default Value | When to Modify |
|---|---|---|---|
ARMBIAN_BUILD_DIR |
Armbian build directory path | $HOME/build |
If build directory is in another location |
TARGET_KERNEL_BRANCH |
Your target kernel branch | rk35xx-vendor-6.1 |
Based on actual branch name shown by ./compile.sh |
ARMBIAN_KERNEL_BRANCH |
Armbian base branch | rk-6.1-rkr5.1 |
Usually no need to modify |
CNFLYSKY_KERNEL_BRANCH |
CNflysky kernel branch | rk-6.1-rkr4.1 |
Usually no need to modify |
./generate_redroid_patch.shAfter successful execution, the patch file will be generated at:
~/build/userpatches/kernel/rk35xx-vendor-6.1/0002-dma-uncached-dma32.patch
Verify patch content:
cat ~/build/userpatches/kernel/rk35xx-vendor-6.1/0002-dma-uncached-dma32.patchβββββββββββββββββββββββββββββββββββββββ
β 1. Clone Armbian Official Kernel β
β (Base) rk-6.1-rkr5.1 β
ββββββββββββββββ¬βββββββββββββββββββββββ
β
ββββββββββββββββΌβββββββββββββββββββββββ
β 2. Clone CNflysky Kernel (Target) β
β rk-6.1-rkr4.1 β
ββββββββββββββββ¬βββββββββββββββββββββββ
β
ββββββββββββββββΌβββββββββββββββββββββββ
β 3. Compare Specified Path Diffs β
β - drivers/dma-buf/ β
β - include/linux/dma-buf.h β
β - include/linux/dma-heap.h β
β - include/linux/android_kabi.h β
ββββββββββββββββ¬βββββββββββββββββββββββ
β
ββββββββββββββββΌβββββββββββββββββββββββ
β 4. Generate Unified Format Patch β
β Using diff -Nurb β
ββββββββββββββββ¬βββββββββββββββββββββββ
β
ββββββββββββββββΌβββββββββββββββββββββββ
β 5. Output to Armbian userpatches/ β
β Auto-applied to kernel builds β
βββββββββββββββββββββββββββββββββββββββ
- Precise Diff Extraction: Only compare DMA-BUF related files to avoid unnecessary changes
- Unified Patch Format: Use
diff -Nurbto generate GNU standard patches - Automatic Integration: Output to
userpatches/kernel/directory, automatically applied during Armbian compilation
Cause: Network issues or GitHub access restrictions
Solution:
# Configure Git proxy (if using proxy)
git config --global http.proxy http://127.0.0.1:7890
# Or use GitHub mirror
# Modify repository URLs in the script:
# https://github.com/armbian/linux-rockchip.git
# Change to
# https://mirror.ghproxy.com/https://github.com/armbian/linux-rockchip.gitCause: Kernel branch version mismatch, or file paths don't exist
Solution:
# Manually verify if branches exist in both repositories
git ls-remote https://github.com/armbian/linux-rockchip.git | grep rk-6.1-rkr5.1
git ls-remote https://github.com/CNflysky/linux-rockchip.git | grep rk-6.1-rkr4.1Cause: Target kernel branch name configured incorrectly
Solution:
- Run
./compile.shonce and observe the actual kernel branch name used - Modify the
TARGET_KERNEL_BRANCHparameter in the script - Regenerate the patch
Cause: Additional kernel configuration options may be required
Solution: Ensure the following are enabled in kernel configuration:
CONFIG_ARM64_VA_BITS=39CONFIG_ANDROID_BINDERFS=yCONFIG_PSI=yCONFIG_DMABUF_HEAPS=y
Example of generated patch file format:
From: Redroid Contributor <[email protected]>
Subject: [PATCH 0002] dma-heap: Add system-uncached-dma32 and necessary files for Redroid GPU
---
diff -Nurb armbian-rkr5.1-base/drivers/dma-buf/dma-heap.c cnflysky-rkr4.1-target/drivers/dma-buf/dma-heap.c
--- armbian-rkr5.1-base/drivers/dma-buf/dma-heap.c 2024-01-01 00:00:00.000000000 +0000
+++ cnflysky-rkr4.1-target/drivers/dma-buf/dma-heap.c 2024-01-01 00:00:00.000000000 +0000
@@ -123,6 +123,9 @@
// ... patch content ...- Armbian Build Documentation: https://docs.armbian.com/Developer-Guide_Build-Preparation/
- Redroid-rk3588 Project: https://github.com/CNflysky/redroid-rk3588
- CNflysky Kernel Repository: https://github.com/CNflysky/linux-rockchip
- Armbian Kernel Repository: https://github.com/armbian/linux-rockchip
This script is licensed under MIT License.
Tip: If you encounter issues during usage, please refer to the complete RK3588 Cloud Phone Setup Guide.