arm-sdk

os build toolkit for various embedded devices
git clone https://git.parazyd.org/arm-sdk
Log | Files | Refs | Submodules | README | LICENSE

pinetab.sh (4010B)


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