URI: 
       traspberry-pi1.sh - arm-sdk - os build toolkit for various embedded devices
  HTML git clone https://git.parazyd.org/arm-sdk
   DIR Log
   DIR Files
   DIR Refs
   DIR Submodules
   DIR README
   DIR LICENSE
       ---
       traspberry-pi1.sh (3641B)
       ---
            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 1 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="raspi1"
           26 arch="armel"
           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.git"
           40 gitbranch="rpi-4.14.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 
           61         notice "downloading broadcom firmware for bt/wifi"
           62         sudo mkdir -p $strapdir/lib/firmware/brcm
           63         # https://git.kernel.org/pub/scm/linux/kernel/git/firmware/linux-firmware.git/tree/brcm
           64         sudo wget -q -O "$strapdir/lib/firmware/brcm/brcmfmac43430-sdio.bin" \
           65                 https://git.kernel.org/pub/scm/linux/kernel/git/firmware/linux-firmware.git/plain/brcm/brcmfmac43430-sdio.bin
           66 
           67         postbuild-clean
           68 }
           69 
           70 build_kernel_armel() {
           71         fn build_kernel_armel
           72         req=(R arch device_name gitkernel gitbranch rpifirmware)
           73         req+=(strapdir)
           74         ckreq || return 1
           75 
           76         notice "building $arch kernel"
           77 
           78         prebuild || zerr
           79 
           80         get-kernel-sources || zerr
           81         pushd $R/tmp/kernels/$device_name/${device_name}-linux
           82                 # pi1 defconfig
           83                 make \
           84                         $MAKEOPTS \
           85                         ARCH=arm \
           86                         CROSS_COMPILE=$compiler \
           87                                 bcmrpi_defconfig || zerr
           88 
           89                 # compile kernel and modules
           90                 make \
           91                         $MAKEOPTS \
           92                         ARCH=arm \
           93                         CROSS_COMPILE=$compiler || zerr
           94 
           95                 # install kernel modules
           96                 sudo -E PATH="$PATH" \
           97                         make \
           98                                 $MAKEOPTS \
           99                                 ARCH=arm \
          100                                 CROSS_COMPILE=$compiler \
          101                                 INSTALL_MOD_PATH=$strapdir \
          102                                         modules_install || zerr
          103         popd
          104 
          105         clone-git "$rpifirmware" "$R/tmp/kernels/$device_name/${device_name}-firmware"
          106         sudo cp $R/tmp/kernels/$device_name/${device_name}-firmware/boot/bootcode.bin "$strapdir/boot/"
          107         sudo cp $R/tmp/kernels/$device_name/${device_name}-firmware/boot/fixup* "$strapdir/boot/"
          108         sudo cp $R/tmp/kernels/$device_name/${device_name}-firmware/boot/start* "$strapdir/boot/"
          109         sudo cp $R/tmp/kernels/$device_name/${device_name}-firmware/boot/COPYING.linux "$strapdir/boot/"
          110         sudo cp $R/tmp/kernels/$device_name/${device_name}-firmware/boot/LICENCE.broadcom "$strapdir/boot/"
          111 
          112         pushd $R/tmp/kernels/$device_name/${device_name}-linux
          113                 sudo perl scripts/mkknlimg --dtok arch/arm/boot/zImage $strapdir/boot/kernel.img
          114                 sudo cp arch/arm/boot/dts/bcm*.dtb                 $strapdir/boot/
          115                 sudo cp arch/arm/boot/dts/overlays/*.dtbo          $strapdir/boot/overlays/
          116                 sudo cp arch/arm/boot/dts/overlays/README          $strapdir/boot/overlays/
          117         popd
          118 
          119         postbuild || zerr
          120 }