Cross compile linux
Clone linux
git clone https://github.com/raspberrypi/linux.git
checkout required branch
Download toolchain
arm-linux-gnueabihf
compile
#!/bin/bash
export KERNEL=kernel7
# it will install modules in INSTALL_MOD_PATH
export INSTALL_MOD_PATH=$(pwd)/../modules
# Toolchain path
export CROSS_COMPILER_PATH=$(pwd)/../gcc-linaro-6.5.0-2018.12-x86_64_arm-linux-gnueabihf/bin
export PATH=$CROSS_COMPILER_PATH:$PATH
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- bcm2709_defconfig
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- zImage modules dtbs
rm -rf output/
mkdir -p output/overlays/
KERNEL=kernel
make ARCH=arm modules INSTALL_MOD_PATH=$(pwd)/../modules
#after this copy the directory rootfs/lib/modules
#cp mnt/fat32/$KERNEL.img mnt/fat32/$KERNEL-backup.img
make ARCH=arm modules_install
cp arch/arm/boot/zImage output/$KERNEL.img
cp arch/arm/boot/dts/*.dtb output/
cp arch/arm/boot/dts/overlays/*.dtb* output/overlays/
cp arch/arm/boot/dts/overlays/README output/overlays/
©2023-2024 rculock.com