arm-sdk

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

beaglebone-black.sh (5282B)


      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 BeagleBone Black boards
     19 
     20 ## settings & config
     21 vars+=(device_name arch size inittab)
     22 vars+=(parted_type parted_boot parted_root bootable_part bootfs)
     23 vars+=(gitkernel gitbranch)
     24 arrs+=(custmodules)
     25 
     26 device_name="beagleboneblack"
     27 arch="armhf"
     28 size=1666
     29 inittab=("T0:12345:respawn:/sbin/getty -L ttyS0 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 bootable_part="1"
     37 
     38 extra_packages+=()
     39 custmodules=()
     40 
     41 gitkernel="https://github.com/beagleboard/linux"
     42 gitbranch="4.9"
     43 
     44 
     45 prebuild() {
     46 	fn prebuild
     47 	req=(device_name strapdir)
     48 	ckreq || return 1
     49 
     50 	notice "executing $device_name prebuild"
     51 
     52 	copy-root-overlay
     53 
     54 	mkdir -p $R/tmp/kernels/$device_name
     55 }
     56 
     57 postbuild() {
     58 	fn postbuild
     59 
     60 	notice "executing $device_name postbuild"
     61 
     62 	notice "building u-boot"
     63 
     64 	pushd $R/extra/u-boot
     65 
     66 	git checkout -b build "v2017.05"
     67 	wget "https://rcn-ee.com/repos/git/u-boot-patches/v2017.05/0001-am335x_evm-uEnv.txt-bootz-n-fixes.patch"
     68 	patch -p1 < "0001-am335x_evm-uEnv.txt-bootz-n-fixes.patch"
     69 
     70 	make distclean
     71 	make $MAKEOPTS ARCH=arm CROSS_COMPILE=$compiler am335x_evm_defconfig
     72 	make $MAKEOPTS ARCH=arm CROSS_COMPILE=$compiler || zerr
     73 
     74 	sudo cp -v MLO u-boot.img "$strapdir"/boot/
     75 
     76 	git reset --hard
     77 	git checkout -
     78 	git branch -D build
     79 
     80 	popd
     81 
     82 	## {{{ uEnv.txt
     83 	notice "creating uEnv.txt file"
     84 	cat <<EOF | sudo tee ${strapdir}/boot/uEnv.txt
     85 #u-boot eMMC specific overrides; Angstrom Distribution (BeagleBone Black) 2013-06-20
     86 kernel_file=zImage
     87 initrd_file=uInitrd
     88 
     89 loadaddr=0x82000000
     90 fdtaddr=0x88000000
     91 initrd_addr=0x88080000
     92 
     93 loadzimage=load mmc \${mmcdev}:\${mmcpart} \${loadaddr} \${kernel_file}
     94 loadinitrd=load mmc \${mmcdev}:\${mmcpart} \${initrd_addr} \${initrd_file}; setenv initrd_size \${filesize}
     95 loadfdt=load mmc \${mmcdev}:\${mmcpart} \${fdtaddr} /dtbs/\${fdtfile}
     96 #
     97 
     98 console=ttyO0,115200n8
     99 mmcroot=/dev/mmcblk0p2 rw net.ifnames=0
    100 mmcrootfstype=ext4 rootwait fixrtc
    101 
    102 ##To disable HDMI/eMMC...
    103 #optargs=capemgr.disable_partno=BB-BONELT-HDMI,BB-BONELT-HDMIN,BB-BONE-EMMC-2G
    104 
    105 ##3.1MP Camera Cape
    106 #optargs=capemgr.disable_partno=BB-BONE-EMMC-2G
    107 
    108 mmcargs=setenv bootargs console=\${console} root=\${mmcroot} rootfstype=\${mmcrootfstype} \${optargs}
    109 
    110 #zImage:
    111 uenvcmd=run loadzimage; run loadfdt; run mmcargs; bootz \${loadaddr} - \${fdtaddr}
    112 
    113 #zImage + uInitrd: where uInitrd has to be generated on the running system
    114 #boot_fdt=run loadzimage; run loadinitrd; run loadfdt
    115 #uenvcmd=run boot_fdt; run mmcargs; bootz \${loadaddr} \${initrd_addr}:\${initrd_size} \${fdtaddr}
    116 EOF
    117 	## }}}
    118 	## {{{ xorg.conf
    119 	notice "writing xorg.conf for future use"
    120 	cat <<EOF | sudo tee ${strapdir}/root/xorg.conf
    121 # For using Xorg, move this file to /etc/X11/xorg.conf
    122 Section "Monitor"
    123 	Identifier    "Builtin Default Monitor"
    124 EndSection
    125 
    126 Section "Device"
    127 	Identifier    "Builtin Default fbdev Device 0"
    128 	Driver        "fbdev"
    129 	Option        "SWCursor" "true"
    130 EndSection
    131 
    132 Section "Screen"
    133 	Identifier    "Builtin Default fbdev Screen 0"
    134 	Device        "Builtin Default fbdev Device 0"
    135 	Monitor       "Builtin Default Monitor"
    136 	DefaultDepth  16
    137 	# Comment out the above and uncomment the below if using a
    138 	# bbb-view or bbb-exp
    139 	#DefaultDepth  24
    140 EndSection
    141 
    142 Section "ServerLayout"
    143 	Identifier    "Builtin Default Layout"
    144 	Screen        "Builtin Default fbdev Screen 0"
    145 EndSection
    146 EOF
    147 	## }}}
    148 
    149 	notice "grabbing script for using usb as ethernet device"
    150 	sudo wget -c \
    151 		https://raw.github.com/RobertCNelson/tools/master/scripts/beaglebone-black-g-ether-load.sh \
    152 		-O $strapdir/root/bbb-ether-load.sh
    153 
    154 	postbuild-clean
    155 }
    156 
    157 build_kernel_armhf() {
    158 	fn build_kernel_armhf
    159 	req=(R arch device_name gitkernel gitbranch MAKEOPTS)
    160 	req+=(strapdir)
    161 	req+=(loopdevice)
    162 	ckreq || return 1
    163 
    164 	notice "building $arch kernel"
    165 
    166 	prebuild || zerr
    167 
    168 	get-kernel-sources
    169 	pushd $R/tmp/kernels/$device_name/${device_name}-linux
    170 		make \
    171 			ARCH=arm \
    172 			CROSS_COMPILE=$compiler \
    173 				bb.org_defconfig || zerr
    174 
    175 		make \
    176 			$MAKEOPTS \
    177 			ARCH=arm \
    178 			CROSS_COMPILE=$compiler || zerr
    179 
    180 		sudo cp -v arch/arm/boot/zImage $strapdir/boot/zImage
    181 		sudo mkdir -p $strapdir/boot/dtbs
    182 		sudo cp -v arch/arm/boot/dts/*.dtb $strapdir/boot/dtbs/
    183 
    184 		sudo -E PATH="$PATH" \
    185 			make \
    186 				$MAKEOPTS \
    187 				ARCH=arm \
    188 				CROSS_COMPILE=$compiler \
    189 				INSTALL_MOD_PATH=$strapdir \
    190 					modules_install || zerr
    191 
    192 		sudo -E PATH="$PATH" \
    193 			make \
    194 				$MAKEOPTS \
    195 				ARCH=arm \
    196 				CROSS_COMPILE=$compiler \
    197 				INSTALL_MOD_PATH=$strapdir \
    198 					firmware_install || zerr
    199 	popd
    200 
    201 	postbuild || zerr
    202 }