Created
July 18, 2023 14:22
-
-
Save kralo/2d243e7112ae7571f824099c27ae2e51 to your computer and use it in GitHub Desktop.
Build kernel for raspberrypi and archive as tar for easy installation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# inspired by the github-actions build-script https://github.com/raspberrypi/linux/blob/rpi-6.1.y/.github/workflows/kernel-build.yml | |
# on the pi, can be installed like so # SKIP_BACKUP=1 SKIP_DOWNLOAD=1 rpi-update http://192.168.178.32:8081/bcm2711_arm64_6.1.32-c2251ce04.tar.gz | |
set -x | |
name=bcm2711_arm64 | |
arch=arm64 | |
defconfig=bcm2711_defconfig | |
matrix_defconfig=$defconfig | |
kernel=kernel8 | |
gh_wspace=/dev/shm/wspace | |
#rm -rf $gh_wspace | |
#mkdir -p $gh_wspace | |
export ARCH=$arch | |
if [[ "$ARCH" == "arm64" ]]; then | |
export CROSS_COMPILE=aarch64-linux-gnu- | |
export DTS_SUBDIR=broadcom | |
export IMAGE=Image.gz | |
else | |
export CROSS_COMPILE=arm-linux-gnueabihf- | |
export DTS_SUBDIR= | |
export IMAGE=zImage | |
fi | |
make O=$gh_wspace/build $matrix_defconfig | |
scripts/config --file $gh_wspace/build/.config --set-val CONFIG_WERROR y | |
scripts/config --file $gh_wspace/build/.config --set-val XFS_FS n | |
scripts/config --file $gh_wspace/build/.config --set-val SOUND n | |
scripts/config --file $gh_wspace/build/.config --set-val MEDIA_DIGITAL_TV_SUPPORT n | |
scripts/config --file $gh_wspace/build/.config --set-val DVB_CORE n | |
scripts/config --file $gh_wspace/build/.config --set-val NETWORK_FILESYSTEMS n | |
scripts/config --file $gh_wspace/build/.config --set-val LOCALVERSION_AUTO y | |
make O=$gh_wspace/build -j $(nproc) $IMAGE modules dtbs | |
rm -rf $gh_wspace/install | |
mkdir -p $gh_wspace/install/boot/overlays | |
make O=$gh_wspace/build INSTALL_MOD_PATH=$gh_wspace/install modules_install | |
cp $gh_wspace/build/arch/${ARCH}/boot/dts/${DTS_SUBDIR}/*.dtb $gh_wspace/install/boot/ | |
cp $gh_wspace/build/arch/${ARCH}/boot/dts/overlays/*.dtb* $gh_wspace/install/boot/overlays/ | |
cp $gh_wspace/arch/${ARCH}/boot/dts/overlays/README $gh_wspace/install/boot/overlays/ | |
cp $gh_wspace/build/arch/${ARCH}/boot/$IMAGE $gh_wspace/install/boot/$kernel.img | |
buildver=$(find $gh_wspace/install/lib/modules/ -maxdepth 1 -mindepth 1 -type d -exec basename {} \;) | |
tar -czvf ${name}_$buildver.tar.gz -C $gh_wspace/install . |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment