URI: 
       tsunxi.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
       ---
       tsunxi.sh (3771B)
       ---
            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="sunxi"
           27 arch="armhf"
           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://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git"
           41 gitbranch="linux-5.11.y"
           42 
           43 prebuild() {
           44         fn prebuild
           45     req=(device_name)
           46     ckreq || return 1
           47 
           48     notice "executing $device_name prebuild"
           49 
           50         copy-root-overlay
           51 
           52         mkdir -p $R/tmp/kernels/$device_name
           53 }
           54 
           55 postbuild() {
           56     fn postbuild
           57         req=(uboot_configs device_name compiler)
           58         ckreq || return 1
           59 
           60     notice "executing $device_name postbuild"
           61 
           62     notice "building u-boot"
           63         mkdir -p $R/dist/u-boot
           64         pushd $R/extra/u-boot
           65                 for board in $uboot_configs; do
           66                         notice "building u-boot for $board"
           67 
           68                         make distclean
           69                         make \
           70                                 $MAKEOPTS \
           71                                 ARCH=arm \
           72                                 CROSS_COMPILE=$compiler \
           73                                         "$board" || { zerr; return 1; }
           74                         make \
           75                                 $MAKEOPTS \
           76                                 ARCH=arm \
           77                                 CROSS_COMPILE=$compiler || { zerr; return 1; }
           78 
           79                         mv -v u-boot-sunxi-with-spl.bin $R/dist/u-boot/${board}.bin
           80                 done
           81     popd
           82 
           83     notice "creating boot.cmd"
           84     cat <<EOF | sudo tee ${strapdir}/boot/boot.cmd
           85 setenv bootargs console=ttyS0,115200 root=/dev/mmcblk0p2 rootwait panic=10 \${extra}
           86 load mmc 0:1 0x43000000 dtbs/\${fdtfile} || load mmc 0:1 0x43000000 boot/dtbs/\${fdtfile}
           87 load mmc 0:1 0x42000000 zImage || load mmc 0:1 0x42000000 boot/zImage
           88 bootz 0x42000000 - 0x43000000
           89 EOF
           90 
           91     notice "creating u-boot script image"
           92     sudo mkimage -A arm -T script -C none \
           93                 -d $strapdir/boot/boot.cmd $strapdir/boot/boot.scr || { zerr; return 1; }
           94 
           95     postbuild-clean
           96 }
           97 
           98 build_kernel_armhf() {
           99     fn build_kernel_armhf
          100     req=(R arch device_name gitkernel gitbranch MAKEOPTS)
          101     req+=(strapdir)
          102     ckreq || return 1
          103 
          104     notice "building $arch kernel"
          105 
          106     prebuild || { zerr; return 1; }
          107 
          108     get-kernel-sources
          109     pushd $R/tmp/kernels/$device_name/${device_name}-linux
          110         #copy-kernel-config
          111                 make $MAKEOPTS \
          112                         ARCH=arm \
          113                         CROSS_COMPILE=$compiler \
          114                                 sunxi_defconfig || { zerr; return 1; }
          115 
          116                 # compile kernel and modules
          117         make \
          118                         $MAKEOPTS \
          119             ARCH=arm \
          120                         CROSS_COMPILE=$compiler \
          121                                 zImage dtbs modules || { zerr; return 1; }
          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; return 1; }
          131 
          132         sudo cp -v arch/arm/boot/zImage $strapdir/boot/ || { zerr; return 1; }
          133                 sudo mkdir -p $strapdir/boot/dtbs
          134                 for board in $board_dtbs; do
          135                         sudo cp -v arch/arm/boot/dts/$board $strapdir/boot/dtbs/ || {
          136                                 zerr; return 1; }
          137                 done
          138     popd
          139 
          140     postbuild || { zerr; return 1; }
          141 }