xnux.eu - site map - news

How to build megi's Pineh­pone kernel

If you want to use my kernel branch, you'll need to build it first. By building it yourself, you'll be able to tune the kernel configuration, or add further patches.

My kernel's main integration branch is orange-pi-$VERSION. No other branch is supposed to work alone. My defconfigs are tested and work on the boards I support. Read the README.md for more info.

Only my branches based on the current mainline kernel branch are maintained (those are usually the -rc# kernels!). You can find the current mainline version here https://www.kernel.org/ (mainline: …)

What you'll need

First make sure you have the basic dependencies needed to build the kernel:

Get the source code

First clone my kernel tree:

# create a workspace directory for all the build artifacts
mkdir megi-kernel
cd megi-kernel

# clone my kernel's git repository (shallow clone)
git clone --depth=1 -b orange-pi-5.16 https://github.com/megous/linux

Copy the following code to a build.sh file:

# Original pinephone

# Pinephone Pro



export KBUILD_OUTPUT="$CWD/build"
export ARCH=arm64
export CROSS_COMPILE=aarch64-linux-gnu-

${CROSS_COMPILE}gcc -v 2>/dev/null || {
        echo "Missing cross-compiler ${CROSS_COMPILE}gcc"
        exit 1

set -e

mkdir -p "$KBUILD_OUTPUT" "$CWD/out"

test -f "$KBUILD_OUTPUT/.config" || make -C "$SRC" "$CONFIG"

# Uncomment if you want to customize the configuration
#make -C "$SRC" menuconfig

make -C "$SRC" -j32 Image dtbs modules
make -C "$SRC" modules_install INSTALL_MOD_PATH="$CWD/out/modules"

cp -f "$KBUILD_OUTPUT/arch/arm64/boot/Image" "$CWD/out/Image"
cp -f "$KBUILD_OUTPUT/arch/arm64/boot/dts/$DTB" "$CWD/out/board.dtb"

Build the kernel:

bash build.sh

Firmware files

You may need some firmware files that are available in https://megous.com/…ux-firmware/

git clone https://megous.com/git/linux-firmware/

They are probably already included in your Linux distribution, unless you're building a new one.

If you want to bundle the necessary firmware files into the kernel build, search the defconfig files in linux/arch/arm64/configs for:


Uncomment the lines, fix the CONFIG_EXTRA_FIRMWARE_DIR path, delete the build directory and re-build the kernel.