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