blob: cd97902b70c359a57fd2e86ff002842a2b07c03d [file] [log] [blame]
Austin Schuhf7970ca2022-02-11 22:19:29 -08001#!/bin/bash
2# This script builds the kernel for the raspberry pi.
3#
4# git@github.com:frc971/linux.git
5#
6# We are using the frc971-5.10-pi4-rt branch
7#
8# Point it at the version of that repo you want to build, and it'll generate a
9# .tar.gz of the bits to install.
10
11
12set -ex
13
14echo $#
15if [[ $# -lt 2 ]];
16then
17 echo "Pass in the kernel directory and then the destination .tar.gz"
18 exit 1
19fi
20
21export OUTPUT="$(realpath $(dirname $2))/$(basename ${2})"
22export TMPDIR="${OUTPUT}_tmpdir"
23
24mkdir -p "${TMPDIR}"
25mkdir -p "${TMPDIR}/fat32/overlays"
26mkdir -p "${TMPDIR}/ext4"
27
28pushd "${1}"
29
30export KERNEL=kernel8
31
32make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- Image modules dtbs -j 60
33
34cp arch/arm64/boot/Image "${TMPDIR}/fat32/$KERNEL.img"
35cp arch/arm64/boot/dts/broadcom/*.dtb "${TMPDIR}/fat32/"
36cp arch/arm64/boot/dts/overlays/*.dtb* "${TMPDIR}/fat32/overlays/"
37cp arch/arm64/boot/dts/overlays/README "${TMPDIR}/fat32/overlays/"
38
39make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- INSTALL_MOD_PATH="${TMPDIR}/ext4" modules_install
40
41cd "${TMPDIR}"
42tar cvzf "${OUTPUT}" --owner=0 --group=0 "./"
43
44popd
45
46rm -rf "${TMPDIR}"
47
48echo "Kernel is now available at: ${OUTPUT}"