1#!/bin/bash 2 3BM=$CI_PROJECT_DIR/install/bare-metal 4 5if [ -z "$BM_SERIAL" -a -z "$BM_SERIAL_SCRIPT" ]; then 6 echo "Must set BM_SERIAL OR BM_SERIAL_SCRIPT in your gitlab-runner config.toml [[runners]] environment" 7 echo "BM_SERIAL:" 8 echo " This is the serial device to talk to for waiting for fastboot to be ready and logging from the kernel." 9 echo "BM_SERIAL_SCRIPT:" 10 echo " This is a shell script to talk to for waiting for fastboot to be ready and logging from the kernel." 11 exit 1 12fi 13 14if [ -z "$BM_POWERUP" ]; then 15 echo "Must set BM_POWERUP in your gitlab-runner config.toml [[runners]] environment" 16 echo "This is a shell script that should reset the device and begin its boot sequence" 17 echo "such that it pauses at fastboot." 18 exit 1 19fi 20 21if [ -z "$BM_POWERDOWN" ]; then 22 echo "Must set BM_POWERDOWN in your gitlab-runner config.toml [[runners]] environment" 23 echo "This is a shell script that should power off the device." 24 exit 1 25fi 26 27if [ -z "$BM_FASTBOOT_SERIAL" ]; then 28 echo "Must set BM_FASTBOOT_SERIAL in your gitlab-runner config.toml [[runners]] environment" 29 echo "This must be the a stable-across-resets fastboot serial number." 30 exit 1 31fi 32 33if [ -z "$BM_KERNEL" ]; then 34 echo "Must set BM_KERNEL to your board's kernel vmlinuz or Image.gz in the job's variables:" 35 exit 1 36fi 37 38if [ -z "$BM_DTB" ]; then 39 echo "Must set BM_DTB to your board's DTB file in the job's variables:" 40 exit 1 41fi 42 43if [ -z "$BM_ROOTFS" ]; then 44 echo "Must set BM_ROOTFS to your board's rootfs directory in the job's variables:" 45 exit 1 46fi 47 48if [ -z "$BM_WEBDAV_IP" -o -z "$BM_WEBDAV_PORT" ]; then 49 echo "BM_WEBDAV_IP and/or BM_WEBDAV_PORT is not set - no results will be uploaded from DUT!" 50 WEBDAV_CMDLINE="" 51else 52 WEBDAV_CMDLINE="webdav=http://$BM_WEBDAV_IP:$BM_WEBDAV_PORT" 53fi 54 55set -ex 56 57# Clear out any previous run's artifacts. 58rm -rf results/ 59mkdir -p results 60 61# Create the rootfs in a temp dir 62rsync -a --delete $BM_ROOTFS/ rootfs/ 63. $BM/rootfs-setup.sh rootfs 64 65# Finally, pack it up into a cpio rootfs. Skip the vulkan CTS since none of 66# these devices use it and it would take up space in the initrd. 67pushd rootfs 68find -H | \ 69 egrep -v "external/(openglcts|vulkancts|amber|glslang|spirv-tools)" | 70 egrep -v "traces-db|apitrace|renderdoc|python" | \ 71 cpio -H newc -o | \ 72 xz --check=crc32 -T4 - > $CI_PROJECT_DIR/rootfs.cpio.gz 73popd 74 75# Make the combined kernel image and dtb for passing to fastboot. For normal 76# Mesa development, we build the kernel and store it in the docker container 77# that this script is running in. 78# 79# However, container builds are expensive, so when you're hacking on the 80# kernel, it's nice to be able to skip the half hour container build and plus 81# moving that container to the runner. So, if BM_KERNEL+BM_DTB are URLs, 82# fetch them instead of looking in the container. 83if echo "$BM_KERNEL $BM_DTB" | grep -q http; then 84 apt install -y wget 85 86 wget $BM_KERNEL -O kernel 87 wget $BM_DTB -O dtb 88 89 cat kernel dtb > Image.gz-dtb 90 rm kernel dtb 91else 92 cat $BM_KERNEL $BM_DTB > Image.gz-dtb 93fi 94 95abootimg \ 96 --create artifacts/fastboot.img \ 97 -k Image.gz-dtb \ 98 -r rootfs.cpio.gz \ 99 -c cmdline="$BM_CMDLINE $WEBDAV_CMDLINE" 100rm Image.gz-dtb 101 102# Start nginx to get results from DUT 103if [ -n "$WEBDAV_CMDLINE" ]; then 104 ln -s `pwd`/results /results 105 sed -i s/80/$BM_WEBDAV_PORT/g /etc/nginx/sites-enabled/default 106 sed -i s/www-data/root/g /etc/nginx/nginx.conf 107 nginx 108fi 109 110export PATH=$BM:$PATH 111 112# Start background command for talking to serial if we have one. 113if [ -n "$BM_SERIAL_SCRIPT" ]; then 114 $BM_SERIAL_SCRIPT | tee results/serial-output.txt & 115 116 while [ ! -e results/serial-output.txt ]; do 117 sleep 1 118 done 119fi 120 121$BM/fastboot_run.py \ 122 --dev="$BM_SERIAL" \ 123 --fbserial="$BM_FASTBOOT_SERIAL" \ 124 --powerup="$BM_POWERUP" \ 125 --powerdown="$BM_POWERDOWN" 126