traspberry-pi2.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-pi2.sh (3124B)
---
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 2/3 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="raspi2"
26 arch="armhf"
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 8192s 270335s"
34 dos_root="$rootfs 270336s 100%"
35
36 extra_packages+=()
37 custmodules=(snd_bcm2835)
38
39 gitkernel="https://github.com/raspberrypi/linux.git"
40 gitbranch="rpi-4.16.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_armhf() {
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 # pi2 defconfig
76 make \
77 $MAKEOPTS \
78 ARCH=arm \
79 CROSS_COMPILE=$compiler \
80 bcm2709_defconfig || zerr
81
82 # compile kernel and modules
83 make \
84 $MAKEOPTS \
85 ARCH=arm \
86 CROSS_COMPILE=$compiler || zerr
87
88 install-kernel-mods arm || zerr
89 popd
90
91 clone-git "$rpifirmware" "$R/tmp/kernels/$device_name/${device_name}-firmware"
92 sudo cp $R/tmp/kernels/$device_name/${device_name}-firmware/boot/bootcode.bin "$strapdir/boot/"
93 sudo cp $R/tmp/kernels/$device_name/${device_name}-firmware/boot/fixup* "$strapdir/boot/"
94 sudo cp $R/tmp/kernels/$device_name/${device_name}-firmware/boot/start* "$strapdir/boot/"
95 sudo cp $R/tmp/kernels/$device_name/${device_name}-firmware/boot/COPYING.linux "$strapdir/boot/"
96 sudo cp $R/tmp/kernels/$device_name/${device_name}-firmware/boot/LICENCE.broadcom "$strapdir/boot/"
97
98 pushd $R/tmp/kernels/$device_name/${device_name}-linux
99 sudo perl scripts/mkknlimg --dtok arch/arm/boot/zImage $strapdir/boot/kernel7.img
100 sudo cp arch/arm/boot/dts/bcm*.dtb $strapdir/boot/
101 sudo cp arch/arm/boot/dts/overlays/*.dtbo $strapdir/boot/overlays/
102 sudo cp arch/arm/boot/dts/overlays/README $strapdir/boot/overlays/
103 popd
104
105 postbuild || zerr
106 }