traspberry-pi4.sh - arm-sdk - os build toolkit for various embedded devices (HTM) git clone https://git.parazyd.org/arm-sdk (DIR) Log (DIR) Files (DIR) Refs (DIR) Submodules (DIR) README (DIR) LICENSE --- traspberry-pi4.sh (2951B) --- 1 #!/usr/bin/env zsh 2 # Copyright (c) 2016-2021 Ivan J. <parazyd@dyne.org> 3 # This file is part of arm-sdk 4 # 5 # This source code is free software: you can redistribute it and/or modify 6 # it under the terms of the GNU General Public License as published by 7 # the Free Software Foundation, either version 3 of the License, or 8 # (at your option) any later version. 9 # 10 # This software is distributed in the hope that it will be useful, 11 # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 # GNU General Public License for more details. 14 # 15 # You should have received a copy of the GNU General Public License 16 # along with this source code. If not, see <http://www.gnu.org/licenses/>. 17 18 ## kernel build script for Raspberry Pi 4 boards 19 20 ## settings & config 21 vars+=(device_name arch size parted_type parted_boot parted_root bootfs inittab) 22 vars+=(gitkernel gitbranch rpifirmware) 23 arrs+=(custmodules) 24 25 device_name="raspi4" 26 arch="arm64" 27 size=1891 28 inittab=("T0:23:respawn:/sbin/agetty -L ttyAMA0 115200 vt100") 29 30 parted_type="dos" 31 bootfs="vfat" 32 rootfs="ext4" 33 dos_boot="fat32 2048s 264191s" 34 dos_root="$rootfs 264192s 100%" 35 36 extra_packages+=() 37 custmodules=(snd_bcm2835) 38 39 gitkernel="https://github.com/raspberrypi/linux" 40 gitbranch="rpi-4.19.y" 41 rpifirmware="https://github.com/raspberrypi/firmware.git" 42 43 44 prebuild() { 45 fn prebuild 46 req=(device_name strapdir) 47 ckreq || return 1 48 49 notice "executing $device_name prebuild" 50 51 mkdir -p $R/tmp/kernels/$device_name 52 } 53 54 postbuild() { 55 fn postbuild 56 57 notice "executing $device_name postbuild" 58 59 copy-root-overlay 60 postbuild-clean 61 } 62 63 build_kernel_arm64() { 64 fn build_kernel_armhf 65 req=(R arch device_name gitkernel gitbranch rpifirmware) 66 req+=(strapdir) 67 ckreq || return 1 68 69 notice "building $arch kernel" 70 71 prebuild || zerr 72 73 get-kernel-sources || zerr 74 pushd $R/tmp/kernels/$device_name/${device_name}-linux 75 # pi4 defconfig 76 make \ 77 $MAKEOPTS \ 78 ARCH=arm64 \ 79 CROSS_COMPILE=$compiler \ 80 bcm2711_defconfig || zerr 81 82 # compile kernel and modules 83 make \ 84 $MAKEOPTS \ 85 ARCH=arm64 \ 86 CROSS_COMPILE=$compiler || zerr 87 88 # install kernel modules 89 sudo -E PATH="$PATH" \ 90 make \ 91 $MAKEOPTS \ 92 ARCH=arm64 \ 93 CROSS_COMPILE=$compiler \ 94 INSTALL_MOD_PATH=$strapdir \ 95 modules_install || zerr 96 popd 97 98 clone-git "$rpifirmware" "$R/tmp/kernels/$device_name/${device_name}-firmware" 99 sudo cp -rf $R/tmp/kernels/$device_name/${device_name}-firmware/boot/* $strapdir/boot/ 100 101 pushd $R/tmp/kernels/$device_name/${device_name}-linux 102 # sudo perl scripts/mkknlimg --dtok arch/arm64/boot/Image.gz $strapdir/boot/kernel8.img 103 sudo cp arch/arm64/boot/Image $strapdir/boot/kernel8.img 104 sudo cp arch/arm64/boot/dts/broadcom/bcm*.dtb $strapdir/boot/ 105 sudo cp arch/arm64/boot/dts/overlays/*.dtbo $strapdir/boot/overlays/ 106 sudo cp arch/arm64/boot/dts/overlays/README $strapdir/boot/overlays/ 107 popd 108 109 postbuild || zerr 110 }