arm-sdk

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

chromebook-veyron.sh (8672B)


      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="chromeveyron"
     27 arch="armhf"
     28 size=1730
     29 #inittab=""
     30 
     31 parted_type="gpt"
     32 bootfs="vfat"
     33 rootfs="ext4"
     34 gpt_boot=(8192 32768)
     35 gpt_root=(40960)
     36 bootfs="none"
     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.14"
     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 	sudo dd if=$workdir/kernel.bin of=$bootpart || { die "unable to dd to $bootpart"; zerr }
     65 
     66 	postbuild-clean
     67 }
     68 
     69 build_kernel_armhf() {
     70 	fn build_kernel_armhf
     71 	req=(R arch device_name gitkernel gitbranch MAKEOPTS)
     72 	req+=(strapdir)
     73 	req+=(loopdevice)
     74 	ckreq || return 1
     75 
     76 	notice "building $arch kernel"
     77 
     78 	prebuild || zerr
     79 
     80 	get-kernel-sources
     81 	pushd $R/tmp/kernels/$device_name/${device_name}-linux
     82 
     83 		notice "patching kernel"
     84 		for i in $R/extra/patches/linux-chromeveyron-patches/*.patch ; do
     85 			patch -p1 < "$i"
     86 		done
     87 
     88 		#WIFIVERSION="-3.8" make multi_v7_defconfig || zerr
     89 		copy-kernel-config
     90 		make \
     91 			$MAKEOPTS \
     92 			ARCH=arm \
     93 			CROSS_COMPILE=$compiler \
     94 			WIFIVERSION="-3.8"
     95 		make \
     96 			$MAKEOPTS \
     97 			ARCH=arm \
     98 			CROSS_COMPILE=$compiler \
     99 			WIFIVERSION="-3.8" \
    100 				dtbs || zerr
    101 		sudo -E PATH="$PATH" \
    102 			make \
    103 				ARCH=arm \
    104 				CROSS_COMPILE=$compiler \
    105 				WIFIVERSION="-3.8" \
    106 				INSTALL_MOD_PATH=$strapdir \
    107 					modules_install || zerr
    108 	popd
    109 
    110 	#sudo rm -rf $strapdir/lib/firmware
    111 	#get-kernel-firmware
    112 	#sudo cp -rav $R/tmp/linux-firmware $strapdir/lib/firmware
    113 
    114 	pushd $R/tmp/kernels/$device_name/${device_name}-linux/arch/arm/boot
    115 # {{{ kernel-veyron.its
    116 	cat << EOF | sudo tee kernel-veyron.its >/dev/null
    117 /dts-v1/;
    118 / {
    119 	description = "Chrome OS kernel image with one or more FDT blobs";
    120 	images {
    121 		kernel@1{
    122 			description = "kernel";
    123 			data = /incbin/("zImage");
    124 			type = "kernel_noload";
    125 			arch = "arm";
    126 			os = "linux";
    127 			compression = "none";
    128 			load = <0>;
    129 			entry = <0>;
    130 		};
    131 		fdt@1{
    132 			description = "rk3288-brain-rev0.dtb";
    133 			data = /incbin/("dts/rk3288-brain-rev0.dtb");
    134 			type = "flat_dt";
    135 			arch = "arm";
    136 			compression = "none";
    137 			hash@1{
    138 				algo = "sha1";
    139 			};
    140 		};
    141 		fdt@2{
    142 			description = "rk3288-jaq-rev1.dtb";
    143 			data = /incbin/("dts/rk3288-jaq-rev1.dtb");
    144 			type = "flat_dt";
    145 			arch = "arm";
    146 			compression = "none";
    147 			hash@1{
    148 				algo = "sha1";
    149 			};
    150 		};
    151 		fdt@3{
    152 			description = "rk3288-nicky-rev0.dtb";
    153 			data = /incbin/("dts/rk3288-nicky-rev0.dtb");
    154 			type = "flat_dt";
    155 			arch = "arm";
    156 			compression = "none";
    157 			hash@1{
    158 				algo = "sha1";
    159 			};
    160 		};
    161 		fdt@4{
    162 			description = "rk3288-danger-rev0.dtb";
    163 			data = /incbin/("dts/rk3288-danger-rev0.dtb");
    164 			type = "flat_dt";
    165 			arch = "arm";
    166 			compression = "none";
    167 			hash@1{
    168 				algo = "sha1";
    169 			};
    170 		};
    171 		fdt@5{
    172 			description = "rk3288-jerry-rev2.dtb";
    173 			data = /incbin/("dts/rk3288-jerry-rev2.dtb");
    174 			type = "flat_dt";
    175 			arch = "arm";
    176 			compression = "none";
    177 			hash@1{
    178 				algo = "sha1";
    179 			};
    180 		};
    181 		fdt@6{
    182 			description = "rk3288-rialto-rev0.dtb";
    183 			data = /incbin/("dts/rk3288-rialto-rev0.dtb");
    184 			type = "flat_dt";
    185 			arch = "arm";
    186 			compression = "none";
    187 			hash@1{
    188 				algo = "sha1";
    189 			};
    190 		};
    191 		fdt@7{
    192 			description = "rk3288-danger-rev1.dtb";
    193 			data = /incbin/("dts/rk3288-danger-rev1.dtb");
    194 			type = "flat_dt";
    195 			arch = "arm";
    196 			compression = "none";
    197 			hash@1{
    198 				algo = "sha1";
    199 			};
    200 		};
    201 		fdt@8{
    202 			description = "rk3288-jerry-rev3.dtb";
    203 			data = /incbin/("dts/rk3288-jerry-rev3.dtb");
    204 			type = "flat_dt";
    205 			arch = "arm";
    206 			compression = "none";
    207 			hash@1{
    208 				algo = "sha1";
    209 			};
    210 		};
    211 		fdt@9{
    212 			description = "rk3288-speedy.dtb";
    213 			data = /incbin/("dts/rk3288-speedy.dtb");
    214 			type = "flat_dt";
    215 			arch = "arm";
    216 			compression = "none";
    217 			hash@1{
    218 				algo = "sha1";
    219 			};
    220 		};
    221 		fdt@10{
    222 			description = "rk3288-evb-act8846.dtb";
    223 			data = /incbin/("dts/rk3288-evb-act8846.dtb");
    224 			type = "flat_dt";
    225 			arch = "arm";
    226 			compression = "none";
    227 			hash@1{
    228 				algo = "sha1";
    229 			};
    230 		};
    231 		fdt@11{
    232 			description = "rk3288-mickey-rev0.dtb";
    233 			data = /incbin/("dts/rk3288-mickey-rev0.dtb");
    234 			type = "flat_dt";
    235 			arch = "arm";
    236 			compression = "none";
    237 			hash@1{
    238 				algo = "sha1";
    239 			};
    240 		};
    241 		fdt@12{
    242 			description = "rk3288-speedy-rev1.dtb";
    243 			data = /incbin/("dts/rk3288-speedy-rev1.dtb");
    244 			type = "flat_dt";
    245 			arch = "arm";
    246 			compression = "none";
    247 			hash@1{
    248 				algo = "sha1";
    249 			};
    250 		};
    251 		fdt@13{
    252 			description = "rk3288-evb-rk808.dtb";
    253 			data = /incbin/("dts/rk3288-evb-rk808.dtb");
    254 			type = "flat_dt";
    255 			arch = "arm";
    256 			compression = "none";
    257 			hash@1{
    258 				algo = "sha1";
    259 			};
    260 		};
    261 		fdt@14{
    262 			description = "rk3288-mighty-rev1.dtb";
    263 			data = /incbin/("dts/rk3288-mighty-rev1.dtb");
    264 			type = "flat_dt";
    265 			arch = "arm";
    266 			compression = "none";
    267 			hash@1{
    268 				algo = "sha1";
    269 			};
    270 		};
    271 		fdt@15{
    272 			description = "rk3288-thea-rev0.dtb";
    273 			data = /incbin/("dts/rk3288-thea-rev0.dtb");
    274 			type = "flat_dt";
    275 			arch = "arm";
    276 			compression = "none";
    277 			hash@1{
    278 				algo = "sha1";
    279 			};
    280 		};
    281 		fdt@16{
    282 			description = "rk3288-gus-rev1.dtb";
    283 			data = /incbin/("dts/rk3288-gus-rev1.dtb");
    284 			type = "flat_dt";
    285 			arch = "arm";
    286 			compression = "none";
    287 			hash@1{
    288 				algo = "sha1";
    289 			};
    290 		};
    291 		fdt@17{
    292 			description = "rk3288-minnie-rev0.dtb";
    293 			data = /incbin/("dts/rk3288-minnie-rev0.dtb");
    294 			type = "flat_dt";
    295 			arch = "arm";
    296 			compression = "none";
    297 			hash@1{
    298 				algo = "sha1";
    299 			};
    300 		};
    301 
    302 	};
    303 	configurations {
    304 		default = "conf@1";
    305 		conf@1{
    306 			kernel = "kernel@1";
    307 			fdt = "fdt@1";
    308 		};
    309 		conf@2{
    310 			kernel = "kernel@1";
    311 			fdt = "fdt@2";
    312 		};
    313 		conf@3{
    314 			kernel = "kernel@1";
    315 			fdt = "fdt@3";
    316 		};
    317 		conf@4{
    318 			kernel = "kernel@1";
    319 			fdt = "fdt@4";
    320 		};
    321 		conf@5{
    322 			kernel = "kernel@1";
    323 			fdt = "fdt@5";
    324 		};
    325 		conf@6{
    326 			kernel = "kernel@1";
    327 			fdt = "fdt@6";
    328 		};
    329 		conf@7{
    330 			kernel = "kernel@1";
    331 			fdt = "fdt@7";
    332 		};
    333 		conf@8{
    334 			kernel = "kernel@1";
    335 			fdt = "fdt@8";
    336 		};
    337 		conf@9{
    338 			kernel = "kernel@1";
    339 			fdt = "fdt@9";
    340 		};
    341 		conf@10{
    342 			kernel = "kernel@1";
    343 			fdt = "fdt@10";
    344 		};
    345 		conf@11{
    346 			kernel = "kernel@1";
    347 			fdt = "fdt@11";
    348 		};
    349 		conf@12{
    350 			kernel = "kernel@1";
    351 			fdt = "fdt@12";
    352 		};
    353 		conf@13{
    354 			kernel = "kernel@1:";
    355 			fdt = "fdt@13";
    356 		};
    357 		conf@14{
    358 			kernel = "kernel@1";
    359 			fdt = "fdt@14";
    360 		};
    361 		conf@15{
    362 			kernel = "kernel@1";
    363 			fdt = "fdt@15";
    364 		};
    365 		conf@16{
    366 			kernel = "kernel@1";
    367 			fdt = "fdt@16";
    368 		};
    369 		conf@17{
    370 			kernel = "kernel@1";
    371 			fdt = "fdt@17";
    372 		};
    373 	};
    374 };
    375 EOF
    376 # }}}
    377 	notice "making veyron-kernel image"
    378 	mkimage -D "-I dts -O dtb -p 2048" -f kernel-veyron.its veyron-kernel || zerr
    379 
    380 	## BEHOLD THE POWER OF PARTUUID/PARTNROFF
    381 	print "noinitrd console=tty1 quiet root=PARTUUID=%U/PARTNROFF=1 rootwait rw lsm.module_locking=0 net.ifnames=0 rootfstype=ext4" > cmdline
    382 
    383 	sudo dd if=/dev/zero of=bootloader.bin bs=512 count=1 || { die "unable to dd bootloader"; zerr }
    384 
    385 	vbutil_kernel \
    386 		--arch arm \
    387 		--pack $workdir/kernel.bin \
    388 		--keyblock /usr/share/vboot/devkeys/kernel.keyblock \
    389 		--signprivate /usr/share/vboot/devkeys/kernel_data_key.vbprivk \
    390 		--version 1 \
    391 		--config cmdline \
    392 		--bootloader bootloader.bin \
    393 		--vmlinuz veyron-kernel || zerr
    394 	popd
    395 
    396 	pushd $R/tmp/kernels/$device_name/${device_name}-linux
    397 		make mrproper
    398 		#WIFIVERSION="-3.8" make multi_v7_defconfig || zerr
    399 		copy-kernel-config
    400 		sudo -E PATH="$PATH" \
    401 			make \
    402 				$MAKEOPTS \
    403 				ARCH=arm \
    404 				CROSS_COMPILE=$compiler \
    405 				WIFIVERSION="-3.8" \
    406 					modules_prepare || zerr
    407 	popd
    408 
    409 	postbuild || zerr
    410 }