arm-sdk

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

odroid-xu4.sh (3592B)


      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 XU4 boards
     19 ## https://lastlog.de/blog/posts/odroid_xu4_with_nixos.html
     20 
     21 ## settings & config
     22 vars+=(device_name arch size parted_type parted_boot parted_root bootfs inittab)
     23 vars+=(gitkernel gitbranch hosttuple)
     24 arrs+=(custmodules extra_packages)
     25 
     26 device_name="odroidxu4"
     27 arch="armhf"
     28 size=1891
     29 inittab=("T1:12345:respawn:/sbin/agetty -L ttySAC2 115200 vt100")
     30 
     31 parted_type="dos"
     32 bootfs="vfat"
     33 rootfs="ext4"
     34 dos_boot="fat32 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-4.14.y"
     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 	copy-root-overlay
     52 
     53 	mkdir -p $R/tmp/kernels/$device_name
     54 }
     55 
     56 postbuild() {
     57 	fn postbuild
     58 	req=(loopdevice)
     59 	ckreq || return 1
     60 
     61 	notice "executing $device_name postbuild"
     62 
     63 	notice "building u-boot"
     64 	pushd $R/extra/u-boot
     65 		make distclean
     66 		make \
     67 			$MAKEOPTS \
     68 			ARCH=arm \
     69 			CROSS_COMPILE=$compiler \
     70 				odroid-xu3_config
     71 
     72 		make \
     73 			$MAKEOPTS \
     74 			ARCH=arm \
     75 			CROSS_COMPILE=$compiler || {
     76 				zerr
     77 				return 1
     78 			}
     79 		mkdir -p "$R/tmp/xu4-uboot"
     80 		cp -v u-boot-dtb.bin "$R/tmp/xu4-uboot"
     81 	popd
     82 	pushd $R/extra/u-boot-hardkernel/sd_fuse
     83 		git checkout odroidxu4-v2017.05
     84 		cp -v * "$R/tmp/xu4-uboot"
     85 	popd
     86 	pushd $R/tmp/xu4-uboot
     87 		chmod +x sd_fusing.sh
     88 		sudo ./sd_fusing.sh $loopdevice
     89 	popd
     90 	rm -rf $R/tmp/xu4-uboot
     91 
     92 	notice "creating boot.cmd"
     93 	cat <<EOF | sudo tee ${strapdir}/boot/boot.cmd
     94 setenv bootargs console=tty0 console=ttySAC2,115200n8 verbose earlyprintk debug root=/dev/mmcblk1p2 init=/sbin/init ro \${extra}
     95 load mmc 0 0x43000000 \${fdtfile}
     96 load mmc 0 0x41000000 zImage
     97 #load mmc 0 0x50000000 uInitrd
     98 #setenv initrd_high 0xffffffff
     99 #bootz 0x41000000 0x50000000 0x43000000
    100 bootz 0x41000000 - 0x43000000
    101 EOF
    102 	notice "creating u-boot script image"
    103 	sudo mkimage -A arm -T script -C none \
    104 		-d $strapdir/boot/boot.cmd $strapdir/boot/boot.scr || zerr
    105 
    106 	postbuild-clean
    107 }
    108 
    109 build_kernel_armhf() {
    110 	fn build_kernel_armhf
    111 	req=(R arch device_name gitkernel gitbranch MAKEOPTS)
    112 	req+=(strapdir loopdevice)
    113 	ckreq || return 1
    114 
    115 	notice "building $arch kernel"
    116 
    117 	prebuild || zerr
    118 
    119 	get-kernel-sources
    120 	pushd $R/tmp/kernels/$device_name/${device_name}-linux
    121 		copy-kernel-config
    122 
    123 		# compile kernel and modules
    124 		make \
    125 			$MAKEOPTS \
    126 			ARCH=arm \
    127 			CROSS_COMPILE=$compiler \
    128 				zImage dtbs modules || zerr
    129 
    130 		# install kernel modules
    131 		sudo -E PATH="$PATH" \
    132 			make \
    133 				$MAKEOPTS \
    134 				ARCH=arm \
    135 				CROSS_COMPILE=$compiler \
    136 				INSTALL_MOD_PATH=$strapdir \
    137 					modules_install || zerr
    138 
    139 		sudo cp -v arch/arm/boot/zImage $strapdir/boot/ || zerr
    140 		sudo cp -v arch/arm/boot/dts/exynos5422-odroidxu4.dtb $strapdir/boot/ || zerr
    141 	popd
    142 
    143 	postbuild || zerr
    144 }