arm-sdk

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

chromebook-acer.sh (6989B)


      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 Acer Chromebook boards
     19 
     20 ## settings & config
     21 vars+=(device_name arch size parted_type)
     22 vars+=(gitkernel gitbranch)
     23 arrs+=(custmodules)
     24 arrs+=(gpt_root gpt_boot bootfs)
     25 
     26 device_name="chromeacer"
     27 arch="armhf"
     28 size=1730
     29 #inittab=""
     30 
     31 parted_type="gpt"
     32 gpt_boot=(8192 32768)
     33 gpt_root=(40960)
     34 bootfs="none"
     35 
     36 export PATH="$R/gcc/linaro-armhf-unicorns/bin:$PATH"
     37 
     38 extra_packages+=(abootimg cgpt u-boot-tools)
     39 extra_packages+=(vboot-utils vboot-kernel-utils)
     40 extra_packages+=(laptop-mode-tools usbutils)
     41 custmodules=()
     42 
     43 gitkernel="https://chromium.googlesource.com/chromiumos/third_party/kernel"
     44 gitbranch="chromeos-3.10"
     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 
     59 postbuild() {
     60 	fn postbuild
     61 
     62 	notice "executing $device_name postbuild"
     63 
     64 	notice "grabbing some coreboot stuff"
     65 	git clone "https://chromium.googlesource.com/chromiumos/third_party/coreboot" "$R/tmp/chromiumos-coreboot"
     66 	pushd $R/tmp/chromiumos-coreboot
     67 		notice "copying coreboot tegra"
     68 		git checkout 071167b667685c26106641e6899984c7bd91e84b
     69 
     70 		make GCC_PREFIX=${compiler} -C src/soc/nvidia/tegra124/lp0 || zerr
     71 		sudo mkdir -p $strapdir/lib/firmware/tegra12x
     72 		sudo cp -fv src/soc/nvidia/tegra124/lp0/tegra_lp0_resume.fw $strapdir/lib/firmware/tegra/12x/
     73 	popd
     74 
     75 	sudo dd if=$workdir/kernel.bin of=$bootpart || { die "unable to dd to $bootpart"; zerr }
     76 
     77 	postbuild-clean
     78 }
     79 
     80 build_kernel_armhf() {
     81 	fn build_kernel_armhf
     82 	req=(R arch device_name gitkernel gitbranch MAKEOPTS)
     83 	req+=(strapdir)
     84 	req+=(loopdevice)
     85 	ckreq || return 1
     86 
     87 	notice "building $arch kernel"
     88 
     89 	prebuild || zerr
     90 
     91 
     92 	get-kernel-sources
     93 	pushd $R/tmp/kernels/$device_name/${device_name}-linux
     94 		#WIFIVERSION="-3.8" make exynos_defconfig || zerr
     95 		copy-kernel-config
     96 		for i in $R/extra/patches/linux-chromeacer-patches/*.patch ; do
     97 			patch -p1 < $i
     98 		done
     99 		mkdir -p firmware/nvidia/tegra124/
    100 		cp -f $R/extra/chromebook-acer/xusb.bin firmware/nvidia/tegra124/
    101 		make \
    102 			$MAKEOPTS \
    103 			ARCH=arm \
    104 			CROSS_COMPILE=$compiler \
    105 			WIFIVERSION="-3.8" || zerr
    106 		make \
    107 			$MAKEOPTS \
    108 			ARCH=arm \
    109 			CROSS_COMPILE=$compiler \
    110 			WIFIVERSION="-3.8"\
    111 				dtbs || zerr
    112 		sudo -E PATH="$PATH" \
    113 			make \
    114 				$MAKEOPTS \
    115 				ARCH=arm \
    116 				CROSS_COMPILE=$compiler \
    117 				WIFIVERSION="-3.8" \
    118 				INSTALL_MOD_PATH=$strapdir \
    119 					modules_install || zerr
    120 	popd
    121 
    122 	#sudo rm -rf $strapdir/lib/firmware
    123 	#get-kernel-firmware
    124 	#sudo cp $CPVERBOSE -ra $R/tmp/linux-firmware $strapdir/lib/firmware
    125 
    126 	pushd $R/tmp/kernels/$device_name/${device_name}-linux/arch/arm/boot
    127 	## {{{ kernel-nyan.its
    128 	cat << EOF | sudo tee kernel-nyan.its >/dev/null
    129 /dts-v1/;
    130 / {
    131 	description = "Chrome OS kernel image with one or more FDT blobs";
    132 	#address-cells = <1>;
    133 	images {
    134 		kernel@1{
    135 			description = "kernel";
    136 			data = /incbin/("zImage");
    137 			type = "kernel_noload";
    138 			arch = "arm";
    139 			os = "linux";
    140 			compression = "none";
    141 			load = <0>;
    142 			entry = <0>;
    143 		};
    144 		fdt@1{
    145 			description = "tegra124-nyan-big-rev0_2.dtb";
    146 			data = /incbin/("dts/tegra124-nyan-big-rev0_2.dtb");
    147 			type = "flat_dt";
    148 			arch = "arm";
    149 			compression = "none";
    150 			hash@1{
    151 				algo = "sha1";
    152 			};
    153 		};
    154 		fdt@2{
    155 			description = "tegra124-nyan-big-rev3_7.dtb";
    156 			data = /incbin/("dts/tegra124-nyan-big-rev3_7.dtb");
    157 			type = "flat_dt";
    158 			arch = "arm";
    159 			compression = "none";
    160 			hash@1{
    161 				algo = "sha1";
    162 			};
    163 		};
    164 		fdt@3{
    165 			description = "tegra124-nyan-big-rev8_9.dtb";
    166 			data = /incbin/("dts/tegra124-nyan-big-rev8_9.dtb");
    167 			type = "flat_dt";
    168 			arch = "arm";
    169 			compression = "none";
    170 			hash@1{
    171 				algo = "sha1";
    172 			};
    173 		};
    174 		fdt@4{
    175 			description = "tegra124-nyan-blaze.dtb";
    176 			data = /incbin/("dts/tegra124-nyan-blaze.dtb");
    177 			type = "flat_dt";
    178 			arch = "arm";
    179 			compression = "none";
    180 			hash@1{
    181 				algo = "sha1";
    182 			};
    183 		};
    184 		fdt@5{
    185 			description = "tegra124-nyan-rev0.dtb";
    186 			data = /incbin/("dts/tegra124-nyan-rev0.dtb");
    187 			type = "flat_dt";
    188 			arch = "arm";
    189 			compression = "none";
    190 			hash@1{
    191 				algo = "sha1";
    192 			};
    193 		};
    194 		fdt@6{
    195 			description = "tegra124-nyan-rev1.dtb";
    196 			data = /incbin/("dts/tegra124-nyan-rev1.dtb");
    197 			type = "flat_dt";
    198 			arch = "arm";
    199 			compression = "none";
    200 			hash@1{
    201 				algo = "sha1";
    202 			};
    203 		};
    204 		fdt@7{
    205 			description = "tegra124-nyan-kitty-rev0_3.dtb";
    206 			data = /incbin/("dts/tegra124-nyan-kitty-rev0_3.dtb");
    207 			type = "flat_dt";
    208 			arch = "arm";
    209 			compression = "none";
    210 			hash@1{
    211 				algo = "sha1";
    212 			};
    213 		};
    214 		fdt@8{
    215 			description = "tegra124-nyan-kitty-rev8.dtb";
    216 			data = /incbin/("dts/tegra124-nyan-kitty-rev8.dtb");
    217 			type = "flat_dt";
    218 			arch = "arm";
    219 			compression = "none";
    220 			hash@1{
    221 				algo = "sha1";
    222 			};
    223 		};
    224 	};
    225 	configurations {
    226 		default = "conf@1";
    227 		conf@1{
    228 			kernel = "kernel@1";
    229 			fdt = "fdt@1";
    230 		};
    231 		conf@2{
    232 			kernel = "kernel@1";
    233 			fdt = "fdt@2";
    234 		};
    235 		conf@3{
    236 			kernel = "kernel@1";
    237 			fdt = "fdt@3";
    238 		};
    239 		conf@4{
    240 			kernel = "kernel@1";
    241 			fdt = "fdt@4";
    242 		};
    243 		conf@5{
    244 			kernel = "kernel@1";
    245 			fdt = "fdt@5";
    246 		};
    247 		conf@6{
    248 			kernel = "kernel@1";
    249 			fdt = "fdt@6";
    250 		};
    251 		conf@7{
    252 			kernel = "kernel@1";
    253 			fdt = "fdt@7";
    254 		};
    255 		conf@8{
    256 			kernel = "kernel@1";
    257 			fdt = "fdt@8";
    258 		};
    259 	};
    260 };
    261 EOF
    262 	## }}}
    263 	notice "making kernel-nyan image"
    264 	mkimage -f kernel-nyan.its nyan-big-kernel || zerr
    265 
    266 	## BEHOLD THE POWER OF PARTUUID/PARTNROFF
    267 	print "noinitrd console=tty1 quiet root=PARTUUID=%U/PARTNROFF=1 rootwait rw lsm.module_locking=0 net.ifnames=0 rootfstype=ext4" > cmdline
    268 
    269 	sudo dd if=/dev/zero of=bootloader.bin bs=512 count=1 || { die "unable to dd bootloader"; zerr }
    270 
    271 	vbutil_kernel --arch arm --pack $workdir/kernel.bin \
    272 		--keyblock /usr/share/vboot/devkeys/kernel.keyblock \
    273 		--signprivate /usr/share/vboot/devkeys/kernel_data_key.vbprivk \
    274 		--version 1 \
    275 		--config cmdline \
    276 		--bootloader bootloader.bin \
    277 		--vmlinuz nyan-big-kernel || zerr
    278 	popd
    279 
    280 	pushd $R/tmp/kernels/$device_name/${device_name}-linux
    281 		make mrproper
    282 		#WIFIVERSION="-3.8" make exynos_defconfig || zerr
    283 		copy-kernel-config
    284 		sudo -E PATH="$PATH" \
    285 			make \
    286 				$MAKEOPTS \
    287 				ARCH=arm \
    288 				CROSS_COMPILE=$compiler \
    289 				WIFIVERSION="-3.8" \
    290 					modules_prepare || zerr
    291 	popd
    292 
    293 	postbuild || zerr
    294 }