Skip to content

Build Droidian

Kernel (WIP)

Download

git clone -b lineage-18.1 --depth=1 https://github.com/LineageOS/android_kernel_oneplus_sdm845.git kernel/android_kernel_oneplus_sdm845

Build

mkdir -p /work/kernel-build
export KERNEL_SRC=/work/kernel/android_kernel_oneplus_sdm845
export O=/work/kernel-build
export ARCH=arm64
export CROSS_COMPILE=aarch64-linux-gnu-
cd $KERNEL_SRC
make O=$O ARCH=arm64 enchilada_defconfig
make -j$(nproc) O=$O ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- Image dtbs
make -j$(nproc) O=$O ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- modules
make O=$O ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- modules_install INSTALL_MOD_PATH=$O/modules-staging

Ignoring errors

export KERNEL_SRC=/work/kernel/android_kernel_oneplus_sdm845
export O=/work/kernel-build
export ARCH=arm64
export CROSS_COMPILE=aarch64-linux-gnu-

cd $KERNEL_SRC
make O=$O ARCH=$ARCH CROSS_COMPILE=$CROSS_COMPILE WERROR=0 -j$(nproc) Image dtbs

Outputs you should inspect: - Kernel image: $O/arch/arm64/boot/Image (or Image.gz, sometimes Image only) - DTBs: $O/arch/arm64/boot/dts/.../*.dtb (look in qcom subdir) - Modules (if any): $O/modules-staging/lib/modules//... or $O/lib/modules

Fails. I will try with the kernel from ubports. lineage22.2 with clang worked.

Optional in case of errors

If the build errors with missing symbols or compilation errors mentioning clang requirements, try using clang:

Clang/LLVM build (if required by tree):

# install clang/llvm if not present
apt install -y clang llvm

# build with clang:
cd $KERNEL_SRC
make O=$O ARCH=arm64 CC=clang CROSS_COMPILE=aarch64-linux-gnu- LLVM=1 clang_defconfig || true
# or reuse defconfig then:
make -j$(nproc) O=$O ARCH=arm64 CC=clang Image dtbs
If you hit a join error, paste the output and I will diagnose.

Copy files

create dirs

mkdir -p /work/adaptation-bundles/enchilada/kernel
mkdir -p /work/adaptation-bundles/enchilada/kernel/dtb
mkdir -p /work/adaptation-bundles/enchilada/kernel/modules

copy kernel Image

cp $O/arch/arm64/boot/Image /work/adaptation-bundles/enchilada/kernel/

copy dtbs (pick the ones for your device; often under qcom/)

cp $O/arch/arm64/boot/dts/qcom/sdm845-v2.1.dtb /work/adaptation-bundles/enchilada/kernel/dtb/

I did not copy the kernel modules as they did not build

The critical files are: /work/adaptation-bundles/enchilada/kernel/Image one or more DTB files in /work/adaptation-bundles/enchilada/kernel/dtb/ optional modules in kernel/modules/

7) Choosing the correct DTB for OnePlus 6 The OnePlus 6 dtb names vary but are usually found in arch/arm64/boot/dts/qcom/. The kernel will provide a set; the bootloader may expect a particular one. Typical names include sdm845-.dtb or oneplus-.dtb. If uncertain, try the first dtb in the directory when creating boot.img (we can iterate if boot fails).

8) Build tip: reproduce the stock kernel cmdline/base/pagesize if needed When you later create boot.img with mkbootimg, you may need to match --base and --pagesize used by the stock boot. You can extract them from stock boot.img (if you have it) using readelf or unpackbootimg tools. If you don't have them, common defaults for OnePlus 6 are --pagesize 4096 and --base 0x10000000, but verify if boot fails.

9) If the kernel build fails — what to paste here

If make fails, copy/paste the last ~50 lines of the build log (error messages). Useful commands:

# show last 200 lines of build
tail -n 200 $O/build-*.log || tail -n 200 /work/kernel-build/* || true

Common causes: Missing cross toolchain (install gcc-aarch64-linux-gnu). Kernel code expects Android clang toolchain (switch to clang). Missing headers or libssl-dev etc (install dev packages). Defconfig name wrong (I'll pick correct one if you paste ls arch/arm64/configs).

10) Final: test by making a boot.img and flashing (quick command reminder)

After you have Image and ramdisk.img (from Halium) and chosen a DTB, create a boot image:

mkbootimg --kernel /work/adaptation-bundles/enchilada/kernel/Image \ --ramdisk /work/adaptation-bundles/enchilada/halium/ramdisk.img \ --dtb /work/adaptation-bundles/enchilada/kernel/dtb/.dtb \ --cmdline "console=ttyMSM0,115200n8 androidboot.hardware=qcom" \ --base 0x10000000 --pagesize 4096 --output /work/out-images/boot.img

Then flash boot_a/boot_b as shown before. Quick troubleshooting checklist if boot fails Does boot get to any kernel logs (look for screen output / fastboot oem- messages)? If it reboots quickly → likely wrong ramdisk or wrong dtb. Try other dtb files from kernel dtb dir. If kernel panics → retrieve adb logcat (if it gets far enough) or enable serial/dmesg capture. If modules fail (missing .ko) → copy modules into /vendor/lib/modules/ in your system image.


git clone --depth=1 -b halium-9.0 https://gitlab.com/ubports/porting/community-ports/android9/oneplus-6/kernel-oneplus-sdm845.git kernel/ubports-kernel-oneplus-sdm845

mkdir -p /work/kernel-build
export KERNEL_SRC=/work/kernel/ubports-kernel-oneplus-sdm845
export O=/work/kernel-build
export ARCH=arm64
export CROSS_COMPILE=aarch64-linux-gnu-
cd $KERNEL_SRC
ls -la $KERNEL_SRC/arch/arm64/configs/enchilada_defconfig
make O=$O ARCH=arm64 enchilada_defconfig
make -j$(nproc) O=$O ARCH=$ARCH CROSS_COMPILE=$CROSS_COMPILE Image dtbs
make -j$(nproc) O=$O ARCH=$ARCH CROSS_COMPILE=$CROSS_COMPILE WERROR=0 Image dtbs
make -j$(nproc) O=$O ARCH=$ARCH CROSS_COMPILE=$CROSS_COMPILE modules
make O=$O ARCH=$ARCH CROSS_COMPILE=$CROSS_COMPILE modules_install INSTALL_MOD_PATH=$O/modules-staging

rm -rf /work/kernel-build
mkdir -p /work/kernel-build
export O=/work/kernel-build
export ARCH=arm64
export CROSS_COMPILE=aarch64-linux-gnu-
export KERNEL_SRC=/work/kernel/OnePlusOSS-oneplus-sdm845

git clone --depth=1 -b oneplus/SDM845_P_9.0 https://github.com/OnePlusOSS/android_kernel_oneplus_sdm845 $KERNEL_SRC

cd $KERNEL_SRC
ls -la $KERNEL_SRC/arch/arm64/configs/enchilada_defconfig
make O=$O ARCH=arm64 sdm845_defconfig
make -j$(nproc) O=$O ARCH=$ARCH CROSS_COMPILE=$CROSS_COMPILE Image dtbs
make -j$(nproc) O=$O ARCH=$ARCH CROSS_COMPILE=$CROSS_COMPILE WERROR=0 Image dtbs
make -j$(nproc) O=$O ARCH=$ARCH CROSS_COMPILE=$CROSS_COMPILE modules
make O=$O ARCH=$ARCH CROSS_COMPILE=$CROSS_COMPILE modules_install INSTALL_MOD_PATH=$O/modules-staging

needs python2


rm -rf /work/kernel-build
mkdir -p /work/kernel-build
export O=/work/kernel-build
export ARCH=arm64
export CROSS_COMPILE=aarch64-linux-gnu-
export KERNEL_SRC=/work/kernel/SDM845_R_11.0-oneplus-sdm845

git clone --depth=1 -b oneplus/SDM845_R_11.0 https://github.com/OnePlusOSS/android_kernel_oneplus_sdm845 $KERNEL_SRC

cd $KERNEL_SRC
ls -la $KERNEL_SRC/arch/arm64/configs/enchilada_defconfig
make O=$O ARCH=arm64 sdm845_defconfig
make -j$(nproc) O=$O ARCH=$ARCH CROSS_COMPILE=$CROSS_COMPILE WERROR=0 Image dtbs

make O=$O ARCH=arm64 CC=clang CROSS_COMPILE=aarch64-linux-gnu- LLVM=1 sdm845_defconfig
make -j$(nproc) O=$O ARCH=arm64 CC=clang Image dtbs

rm -rf /work/kernel-build
mkdir -p /work/kernel-build
export O=/work/kernel-build
export ARCH=arm64
export CROSS_COMPILE=aarch64-linux-gnu-
export KERNEL_SRC=/work/kernel/lineage-22.2

git clone --depth=1 -b lineage-22.2 https://github.com/LineageOS/android_kernel_oneplus_sdm845 $KERNEL_SRC

cd $KERNEL_SRC
ls -la $KERNEL_SRC/arch/arm64/configs/enchilada_defconfig
make O=$O ARCH=arm64 enchilada_defconfig
make -j$(nproc) O=$O ARCH=$ARCH CROSS_COMPILE=$CROSS_COMPILE WERROR=0 Image dtbs

make O=$O ARCH=arm64 CC=clang CROSS_COMPILE=aarch64-linux-gnu- LLVM=1 enchilada_defconfig
make -j$(nproc) O=$O ARCH=arm64 CC=clang Image dtbs
this last one worked... !!!

now the modules

make -j$(nproc) O=$O ARCH=arm64 CC=clang modules
mkdir $O/modules-staging
make -j$(nproc) O=$O ARCH=arm64 CC=clang modules_install INSTALL_MOD_PATH=$O/modules-staging

Warning: 'make modules_install' requires depmod. Please install it. This is probably in the kmod package. make[1]: Leaving directory '/work/kernel-build'

apt update && apt install -y kmod
make[1]: Entering directory '/work/kernel-build'
  INSTALL drivers/char/rdbg.ko
  INSTALL drivers/media/platform/msm/broadcast/tspp.ko
  INSTALL drivers/media/platform/msm/dvb/demux/mpq-dmx-hw-plugin.ko
  INSTALL drivers/media/platform/msm/dvb/adapter/mpq-adapter.ko
  INSTALL drivers/mmc/card/mmc_test.ko
  INSTALL drivers/net/wireless/ath/wil6210/wil6210.ko
  INSTALL drivers/platform/msm/msm_11ad/msm_11ad_proxy.ko
  INSTALL drivers/soc/qcom/llcc_perfmon.ko
  INSTALL net/bridge/br_netfilter.ko
  DEPMOD  4.9.337-geabce74f5a9c
depmod: WARNING: could not open modules.builtin.modinfo at /work/kernel-build/modules-staging/lib/modules/4.9.337-geabce74f5a9c: No such file or directory
make[1]: Leaving directory '/work/kernel-build'

it gives errors.