tpinephone-dontbeevil.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
---
tpinephone-dontbeevil.sh (4018B)
---
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 ## generic kernel build script for sunxi allwinner boards
19 ## http://linux-sunxi.org
20
21 ## settings & config
22 vars+=(device_name arch size parted_type parted_boot parted_root bootfs inittab)
23 vars+=(gitkernel gitbranch)
24 arrs+=(custmodules)
25
26 device_name="pinephone-dontbeevil"
27 arch="arm64"
28 size=1891
29 inittab=("T1:12345:respawn:/sbin/agetty -L ttyS0 115200 vt100")
30
31 parted_type="dos"
32 bootfs="ext2"
33 rootfs="ext4"
34 dos_boot="$bootfs 2048s 264191s"
35 dos_root="$rootfs 264192s 100%"
36
37 extra_packages+=()
38 custmodules=()
39
40 gitkernel="https://gitlab.com/pine64-org/linux.git"
41 gitbranch="pinephone-dontbeevil-5.1-rc7"
42
43 atfgit="https://github.com/ARM-software/arm-trusted-firmware.git"
44 ubootgit="https://gitlab.com/pine64-org/u-boot.git"
45
46 prebuild() {
47 fn prebuild
48 req=(device_name)
49 ckreq || return 1
50
51 notice "executing $device_name prebuild"
52
53 mkdir -p $R/tmp/kernels/$device_name
54 }
55
56 postbuild() {
57 fn postbuild
58 req=(device_name compiler loopdevice)
59 ckreq || return 1
60
61 notice "executing $device_name postbuild"
62
63 copy-root-overlay
64
65 notice "building arm-trusted-firmware"
66 git clone --depth 1 "$atfgit" "$R/tmp/kernels/arm-trusted-firmware" || zerr
67 pushd "$R/tmp/kernels/arm-trusted-firmware"
68 make CROSS_COMPILE=$compiler PLAT=sun50i_a64 DEBUG=1 bl31 || zerr
69 popd
70
71 notice "building u-boot"
72 git clone --depth 1 "$ubootgit" "$R/tmp/kernels/u-boot-pinephone" || zerr
73 pushd "$R/tmp/kernels/u-boot-pinephone"
74 make $MAKEOPTS sopine_baseboard_defconfig
75 cp "$R/tmp/kernels/arm-trusted-firmware/build/sun50i_a64/debug/bl31.bin" .
76 make $MAKEOPTS ARCH=arm CROSS_COMPILE=$compiler || zerr
77 mkdir -p "$R/dist"
78 cat spl/sunxi-spl.bin u-boot.itb > "$R/dist/u-boot-sunxi-with-spl-sopine.bin"
79 popd
80
81 cat <<EOF | sudo tee "${strapdir}/boot/boot.txt"
82 setenv bootargs console=tty0 console=\${console} root=/dev/mmcblk0p2 rw rootwait rootfstype=ext4 fbcon=rotate:1
83 setenv kernel_addr_z 0x44080000
84
85 if load \${devtype} \${devnum}:\${distro_bootpart} \${kernel_addr_z} Image.gz; then
86 unzip \${kernel_addr_z} \${kernel_addr_r}
87 if load \${devtype} \${devnum}:\${distro_bootpart} \${fdt_addr_r} sun50i-a64-dontbeevil.dtb; then
88 booti \${kernel_addr_r} - \${fdt_addr_r};
89 fi;
90 fi
91 EOF
92 pushd "${strapdir}/boot"
93 sudo mkimage -C none -A arm -T script -d boot.txt boot.scr
94 popd
95
96 sudo dd if="$R/dist/u-boot-sunxi-with-spl-sopine.bin" of="${loopdevice}" seek=8 \
97 bs=1024 conv=notrunc,nocreat
98
99 postbuild-clean
100 }
101
102 build_kernel_arm64() {
103 fn build_kernel_arm64
104 req=(R arch device_name gitkernel gitbranch MAKEOPTS)
105 req+=(strapdir)
106 ckreq || return 1
107
108 notice "building $arch kernel"
109
110 prebuild || zerr
111
112 get-kernel-sources
113 pushd $R/tmp/kernels/$device_name/${device_name}-linux
114 copy-kernel-config
115
116 # compile kernel and modules
117 make \
118 $MAKEOPTS \
119 ARCH=arm64 \
120 CROSS_COMPILE=$compiler \
121 Image modules allwinner/sun50i-a64-dontbeevil.dtb || zerr
122
123 # install kernel modules
124 sudo -E PATH="$PATH" \
125 make \
126 $MAKEOPTS \
127 ARCH=arm \
128 CROSS_COMPILE=$compiler \
129 INSTALL_MOD_PATH=$strapdir \
130 modules_install || zerr
131
132 sudo cp -v arch/arm64/boot/Image $strapdir/boot/ || zerr
133 pushd "$strapdir/boot"
134 sudo gzip Image
135 popd
136 sudo cp -v arch/arm64/boot/dts/allwinner/sun50i-a64-dontbeevil.dtb \
137 "$strapdir/boot/" || zerr
138 popd
139
140 postbuild || zerr
141 }