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