1#!/bin/bash 2 3# Boot script for Chrome OS devices attached to a servo debug connector, using 4# NFS and TFTP to boot. 5 6# We're run from the root of the repo, make a helper var for our paths 7BM=$CI_PROJECT_DIR/install/bare-metal 8 9# Runner config checks 10if [ -z "$BM_SERIAL" ]; then 11 echo "Must set BM_SERIAL in your gitlab-runner config.toml [[runners]] environment" 12 echo "This is the CPU serial device." 13 exit 1 14fi 15 16if [ -z "$BM_SERIAL_EC" ]; then 17 echo "Must set BM_SERIAL in your gitlab-runner config.toml [[runners]] environment" 18 echo "This is the EC serial device for controlling board power" 19 exit 1 20fi 21 22if [ ! -d /nfs ]; then 23 echo "NFS rootfs directory needs to be mounted at /nfs by the gitlab runner" 24 exit 1 25fi 26 27if [ ! -d /tftp ]; then 28 echo "TFTP directory for this board needs to be mounted at /tftp by the gitlab runner" 29 exit 1 30fi 31 32# job config checks 33if [ -z "$BM_KERNEL" ]; then 34 echo "Must set BM_KERNEL to your board's kernel FIT image" 35 exit 1 36fi 37 38if [ -z "$BM_ROOTFS" ]; then 39 echo "Must set BM_ROOTFS to your board's rootfs directory in the job's variables" 40 exit 1 41fi 42 43if [ -z "$BM_CMDLINE" ]; then 44 echo "Must set BM_CMDLINE to your board's kernel command line arguments" 45 exit 1 46fi 47 48set -ex 49 50# Clear out any previous run's artifacts. 51rm -rf results/ 52mkdir -p results 53 54# Create the rootfs in the NFS directory. rm to make sure it's in a pristine 55# state, since it's volume-mounted on the host. 56rsync -a --delete $BM_ROOTFS/ /nfs/ 57mkdir -p /nfs/results 58. $BM/rootfs-setup.sh /nfs 59 60# Put the kernel/dtb image and the boot command line in the tftp directory for 61# the board to find. For normal Mesa development, we build the kernel and 62# store it in the docker container that this script is running in. 63# 64# However, container builds are expensive, so when you're hacking on the 65# kernel, it's nice to be able to skip the half hour container build and plus 66# moving that container to the runner. So, if BM_KERNEL is a URL, fetch it 67# instead of looking in the container. Note that the kernel build should be 68# the output of: 69# 70# make Image.lzma 71# 72# mkimage \ 73# -A arm64 \ 74# -f auto \ 75# -C lzma \ 76# -d arch/arm64/boot/Image.lzma \ 77# -b arch/arm64/boot/dts/qcom/sdm845-cheza-r3.dtb \ 78# cheza-image.img 79 80rm -rf /tftp/* 81if echo "$BM_KERNEL" | grep -q http; then 82 apt install -y wget 83 wget $BM_KERNEL -O /tftp/vmlinuz 84else 85 cp $BM_KERNEL /tftp/vmlinuz 86fi 87echo "$BM_CMDLINE" > /tftp/cmdline 88 89set +e 90python3 $BM/cros_servo_run.py \ 91 --cpu $BM_SERIAL \ 92 --ec $BM_SERIAL_EC 93ret=$? 94set -e 95 96# Bring artifacts back from the NFS dir to the build dir where gitlab-runner 97# will look for them. 98cp -Rp /nfs/results/. results/ 99 100exit $ret 101