Austin Schuh | f7970ca | 2022-02-11 22:19:29 -0800 | [diff] [blame] | 1 | #!/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 | |
| 12 | set -ex |
| 13 | |
| 14 | echo $# |
| 15 | if [[ $# -lt 2 ]]; |
| 16 | then |
| 17 | echo "Pass in the kernel directory and then the destination .tar.gz" |
| 18 | exit 1 |
| 19 | fi |
| 20 | |
| 21 | export OUTPUT="$(realpath $(dirname $2))/$(basename ${2})" |
| 22 | export TMPDIR="${OUTPUT}_tmpdir" |
| 23 | |
| 24 | mkdir -p "${TMPDIR}" |
| 25 | mkdir -p "${TMPDIR}/fat32/overlays" |
| 26 | mkdir -p "${TMPDIR}/ext4" |
| 27 | |
| 28 | pushd "${1}" |
| 29 | |
| 30 | export KERNEL=kernel8 |
| 31 | |
| 32 | make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- Image modules dtbs -j 60 |
| 33 | |
| 34 | cp arch/arm64/boot/Image "${TMPDIR}/fat32/$KERNEL.img" |
| 35 | cp arch/arm64/boot/dts/broadcom/*.dtb "${TMPDIR}/fat32/" |
| 36 | cp arch/arm64/boot/dts/overlays/*.dtb* "${TMPDIR}/fat32/overlays/" |
| 37 | cp arch/arm64/boot/dts/overlays/README "${TMPDIR}/fat32/overlays/" |
| 38 | |
| 39 | make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- INSTALL_MOD_PATH="${TMPDIR}/ext4" modules_install |
| 40 | |
| 41 | cd "${TMPDIR}" |
| 42 | tar cvzf "${OUTPUT}" --owner=0 --group=0 "./" |
| 43 | |
| 44 | popd |
| 45 | |
| 46 | rm -rf "${TMPDIR}" |
| 47 | |
| 48 | echo "Kernel is now available at: ${OUTPUT}" |