Building a Custom Kernel for Your Device

Mainline kernel, DTS files, building custom kernels
Post Reply
felix
Site Admin
Posts: 15
Joined: Sat Oct 04, 2025 4:48 pm

Building a Custom Kernel for Your Device

Post by felix »

Building a Custom Kernel for Your Device

For advanced users who want to customize their kernel or add hardware support.

Prerequisites
You need a Linux PC (x86_64) for cross-compilation:

Code: Select all

sudo apt install build-essential gcc-aarch64-linux-gnu bc bison flex libssl-dev
sudo apt install device-tree-compiler
Get the Kernel Source
You can use the mainline Linux kernel or the OpenStick fork:

Code: Select all

git clone https://github.com/OpenStick/linux.git
cd linux
Device Tree Files
The device tree describes the hardware layout of your specific board. DTS files for MSM8916 devices are in:

Code: Select all

arch/arm64/boot/dts/qcom/
Each device has its own DTS file. Make sure you select or modify the correct one for your board.

Cross-Compile the Kernel

Code: Select all

export ARCH=arm64
export CROSS_COMPILE=aarch64-linux-gnu-

# Use the OpenStick defconfig
make msm8916_defconfig

# Optional: customize config
make menuconfig

# Build
make -j$(nproc) Image.gz dtbs modules
Key Kernel Configs
Make sure these are enabled:
  • Code: Select all

    CONFIG_ARCH_QCOM=y
    — Qualcomm platform support
  • Code: Select all

    CONFIG_ATH10K=m
    or

    Code: Select all

    CONFIG_WCN36XX=m
    — WiFi driver
  • Code: Select all

    CONFIG_USB_CONFIGFS=y
    — USB gadget support
  • Code: Select all

    CONFIG_FB=y
    — Framebuffer for display support
  • Code: Select all

    CONFIG_QCOM_BAM_DMUX=y
    — Modem data path
Build the Boot Image
The boot image combines the kernel, DTB, and initramfs. Use mkbootimg:

Code: Select all

mkbootimg --kernel arch/arm64/boot/Image.gz \
  --dtb arch/arm64/boot/dts/qcom/msm8916-your-device.dtb \
  --ramdisk initramfs.cpio.gz \
  --base 0x80000000 \
  --pagesize 2048 \
  -o boot.img
Flash and Test

Code: Select all

edl w boot boot.img --memory=emmc
Armbian Alternative
If building your own kernel is too complex, consider Armbian images from the travis90x Armbian guide. These provide pre-built images with good hardware support.
Post Reply