Skip to main content

Cross compile kernel deb

安装依赖

sudo apt install build-essential git devscripts libncurses5-dev automake make g++ bison flex libelf-dev libssl-dev bc zstd gcc-aarch64-linux-gnu binutils-aarch64-linux-gnu -y

编译

make-kpkg

make-kpkg是一个已经废弃的kernel deb 包编译工具

export CONCURRENCY_LEVEL=`grep -m1 cpu\ cores /proc/cpuinfo | cut -d : -f 2`
export DEB_HOST_ARCH=arm64
export ARCH=arm64
fakeroot -u make-kpkg --arch arm64 --cross-compile aarch64-linux-gnu- --initrd --append-to-version=-custom1 kernel_image kernel_headers -j24

参考: https://romanrm.net/a10/cross-compile-kernel

make bindeb-pkg

make bindeb-pkg 是当前主流的kernel deb编译方式

提前配置环境变量

export ARCH=arm64
export CROSS_COMPILE=aarch64-linux-gnu-
make bindeb-pkg

make 时指定环境变量

make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- bindeb-pkg