URI: 
       todroid-xu.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
       ---
       todroid-xu.sh (5654B)
       ---
            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 ODROID XU boards
           19 
           20 ## settings & config
           21 vars+=(device_name arch size parted_type parted_boot parted_root bootfs inittab)
           22 vars+=(gitkernel gitbranch hosttuple)
           23 arrs+=(custmodules extra_packages)
           24 
           25 device_name="odroidxu"
           26 arch="armhf"
           27 size=1337
           28 inittab=("T1:12345:respawn:/bin/login -f root ttySAC2 /dev/ttySAC2 2>&1")
           29 
           30 ## this is used for crosscompiling exynos5-hwcomposer.
           31 ## without it there is no framebuffer console.
           32 hosttuple=${compiler:0:-1}
           33 
           34 parted_type="dos"
           35 bootfs="vfat"
           36 rootfs="ext4"
           37 dos_boot="fat32 2048s 264191s"
           38 dos_root="$rootfs 264192s 100%"
           39 
           40 extra_packages+=()
           41 custmodules=()
           42 
           43 gitkernel="https://github.com/hardkernel/linux.git"
           44 gitbranch="odroidxu-3.4.y"
           45 
           46 
           47 prebuild() {
           48         fn prebuild
           49         req=(device_name strapdir)
           50         ckreq || return 1
           51 
           52         notice "executing $device_name prebuild"
           53 
           54         copy-root-overlay
           55 
           56         mkdir -p $R/tmp/kernels/$device_name
           57 
           58         print "M    ttySAC2 c 5 1" | sudo tee -a $strapdir/etc/udev/links.conf
           59         cat <<EOF | sudo tee -a $strapdir/etc/securetty
           60 ttySAC0
           61 ttySAC1
           62 ttySAC2
           63 EOF
           64 }
           65 
           66 postbuild() {
           67         fn postbuild
           68 
           69         notice "executing $device_name postbuild"
           70 
           71         ## {{{ boot txts
           72         notice "Writing bootinfos..."
           73         # 720p
           74         cat << EOF | sudo tee ${strapdir}/boot/boot-hdmi-720.txt
           75 setenv initrd_high "0xffffffff"
           76 setenv fdt_high "0xffffffff"
           77 setenv fb_x_res "1280"
           78 setenv fb_y_res "720"
           79 setenv hdmi_phy_res "720"
           80 setenv bootcmd "fatload mmc 0:1 0x40008000 zImage; fatload mmc 0:1 0x42000000 uInitrd; bootz 0x40008000 0x42000000"
           81 setenv bootargs "console=tty1 console=ttySAC2,115200n8 vmalloc=512M fb_x_res=\${fb_x_res} fb_y_res=\${fb_y_res} hdmi_phy_res=\${hdmi_phy_res} vout=hdmi led_blink=1 fake_fb=true root=/dev/mmcblk0p2 rootwait rootfstype=ext4 rw net.ifnames=0"
           82 boot
           83 EOF
           84         # 1080p
           85         cat << EOF | sudo tee ${strapdir}/boot/boot-hdmi-1080.txt
           86 setenv initrd_high "0xffffffff"
           87 setenv fdt_high "0xffffffff"
           88 setenv fb_x_res "1920"
           89 setenv fb_y_res "1080"
           90 setenv hdmi_phy_res "1080"
           91 setenv bootcmd "fatload mmc 0:1 0x40008000 zImage; fatload mmc 0:1 0x42000000 uInitrd; bootz 0x40008000 0x42000000"
           92 setenv bootargs "console=tty1 console=ttySAC2,115200n8 vmalloc=512M fb_x_res=\${fb_x_res} fb_y_res=\${fb_y_res} hdmi_phy_res=\${hdmi_phy_res} vout=hdmi led_blink=1 fake_fb=true root=/dev/mmcblk0p2 rootwait rw rootfstype=ext4 net.ifnames=0"
           93 boot
           94 EOF
           95         ## }}}
           96 
           97         notice "creating u-boot script images"
           98         sudo mkimage -A arm -T script -C none -d $strapdir/boot/boot-hdmi-720.txt \
           99                 $strapdir/boot/boot-720.scr
          100         sudo mkimage -A arm -T script -C none -d $strapdir/boot/boot-hdmi-1080.txt \
          101                 $strapdir/boot/boot-1080.scr
          102         sudo cp $CPVERBOSE $strapdir/boot/boot-720.scr $strapdir/boot/boot.scr
          103 
          104         notice "doing u-boot magic"
          105         pushd $R/tmp/kernels/$device_name/${device_name}-linux/tools/hardkernel/u-boot-pre-built
          106         sudo sh sd_fusing.sh $loopdevice
          107         act " ^ not this time :)"
          108 
          109         postbuild-clean
          110 }
          111 
          112 build_kernel_armhf() {
          113         fn build_kernel_armhf
          114         req=(R arch device_name gitkernel gitbranch MAKEOPTS)
          115         req+=(strapdir loopdevice)
          116         ckreq || return 1
          117 
          118         notice "building $arch kernel"
          119 
          120         prebuild || zerr
          121 
          122         get-kernel-sources
          123         pushd $R/tmp/kernels/$device_name/${device_name}-linux
          124                 make \
          125                         $MAKEOPTS \
          126                         ARCH=arm \
          127                         CROSS_COMPILE=$compiler \
          128                                 odroidxu_ubuntu_defconfig || zerr
          129                 make \
          130                         $MAKEOPTS \
          131                         ARCH=arm \
          132                         CROSS_COMPILE=$compiler || zerr
          133                 sudo -E PATH="$PATH" \
          134                         make \
          135                                 $MAKEOPTS \
          136                                 ARCH=arm \
          137                                 CROSS_COMPILE=$compiler \
          138                                 INSTALL_MOD_PATH=$strapdir \
          139                                         modules_install || zerr
          140                 sudo cp -v arch/arm/boot/zImage $strapdir/boot/
          141         popd
          142 
          143         notice "building hwcomposer"
          144         pushd $R/tmp/kernels/$device_name/${device_name}-linux/tools/hardkernel/exynos5-hwcomposer
          145         ## it's quite chatty still, so we if 0 the logging, and also add a missing #define
          146         sed -i -e 's/if 1/if 0/g' include/log.h
          147         sed -i -e 's/#define ALOGD/#define ALOGD\r#define ALOGF/g' include/log.h
          148 
          149         ./configure --prefix=/usr --build x86_64-pc-linux-gnu --host $hosttuple || zerr
          150         make \
          151                 $MAKEOPTS \
          152                 ARCH=arm \
          153                 CROSS_COMPILE=$compiler || zerr
          154         sudo -E PATH="$PATH" \
          155                 make \
          156                         $MAKEOPTS \
          157                         ARCH=arm \
          158                         CROSS_COMPILE=$compiler \
          159                         DESTDIR=$strapdir \
          160                                 install || zerr
          161         sudo sed -i -e \
          162                 's:^exit 0:exynos5-hwcomposer > /dev/null 2\&1 \&\nexit 0:' \
          163                 $strapdir/etc/rc.local
          164 
          165         #sudo rm -rf $strapdir/lib/firmware
          166         #get-kernel-firmware
          167         #sudo cp $CPVERBOSE -ra $R/tmp/linux-firmware $strapdir/lib/firmware
          168 
          169         pushd $R/tmp/kernels/$device_name/${device_name}-linux
          170                 sudo -E PATH="$PATH" \
          171                         make \
          172                                 $MAKEOPTS \
          173                                 ARCH=arm \
          174                                 CROSS_COMPILE=$compiler \
          175                                 INSTALL_MOD_PATH=$strapdir \
          176                                         firmware_install || zerr
          177                 make \
          178                         $MAKEOPTS \
          179                         ARCH=arm \
          180                         CROSS_COMPILE=$compiler \
          181                                 mrproper
          182                 #copy-kernel-config
          183                 make \
          184                         $MAKEOPTS \
          185                         ARCH=arm \
          186                         CROSS_COMPILE=$compiler \
          187                                 odroidxu_ubuntu_defconfig || zerr
          188                 sudo -E PATH="$PATH" \
          189                         make \
          190                                 $MAKEOPTS \
          191                                 ARCH=arm \
          192                                 CROSS_COMPILE=$compiler \
          193                                         modules_prepare || zerr
          194         popd
          195 
          196         postbuild || zerr
          197 }