• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/bin/bash
2# shellcheck disable=SC1091 # The relative paths in this file only become valid at runtime.
3# shellcheck disable=SC2034
4# shellcheck disable=SC2086 # we want word splitting
5
6. "$SCRIPTS_DIR"/setup-test-env.sh
7
8BM=$CI_PROJECT_DIR/install/bare-metal
9CI_COMMON=$CI_PROJECT_DIR/install/common
10
11if [ -z "$BM_SERIAL" ] && [ -z "$BM_SERIAL_SCRIPT" ]; then
12  echo "Must set BM_SERIAL OR BM_SERIAL_SCRIPT in your gitlab-runner config.toml [[runners]] environment"
13  echo "BM_SERIAL:"
14  echo "  This is the serial device to talk to for waiting for fastboot to be ready and logging from the kernel."
15  echo "BM_SERIAL_SCRIPT:"
16  echo "  This is a shell script to talk to for waiting for fastboot to be ready and logging from the kernel."
17  exit 1
18fi
19
20if [ -z "$BM_POWERUP" ]; then
21  echo "Must set BM_POWERUP in your gitlab-runner config.toml [[runners]] environment"
22  echo "This is a shell script that should reset the device and begin its boot sequence"
23  echo "such that it pauses at fastboot."
24  exit 1
25fi
26
27if [ -z "$BM_POWERDOWN" ]; then
28  echo "Must set BM_POWERDOWN in your gitlab-runner config.toml [[runners]] environment"
29  echo "This is a shell script that should power off the device."
30  exit 1
31fi
32
33if [ -z "$BM_FASTBOOT_SERIAL" ]; then
34  echo "Must set BM_FASTBOOT_SERIAL in your gitlab-runner config.toml [[runners]] environment"
35  echo "This must be the a stable-across-resets fastboot serial number."
36  exit 1
37fi
38
39if [ -z "$BM_KERNEL" ]; then
40  echo "Must set BM_KERNEL to your board's kernel vmlinuz or Image.gz in the job's variables:"
41  exit 1
42fi
43
44if [ -z "$BM_DTB" ]; then
45  echo "Must set BM_DTB to your board's DTB file in the job's variables:"
46  exit 1
47fi
48
49if [ -z "$BM_ROOTFS" ]; then
50  echo "Must set BM_ROOTFS to your board's rootfs directory in the job's variables:"
51  exit 1
52fi
53
54if echo $BM_CMDLINE | grep -q "root=/dev/nfs"; then
55  BM_FASTBOOT_NFSROOT=1
56fi
57
58set -ex
59
60# Clear out any previous run's artifacts.
61rm -rf results/
62mkdir -p results/
63
64if [ -n "$BM_FASTBOOT_NFSROOT" ]; then
65  # Create the rootfs in the NFS directory.  rm to make sure it's in a pristine
66  # state, since it's volume-mounted on the host.
67  rsync -a --delete $BM_ROOTFS/ /nfs/
68  mkdir -p /nfs/results
69  . $BM/rootfs-setup.sh /nfs
70
71  # Root on NFS, no need for an inintramfs.
72  rm -f rootfs.cpio.gz
73  touch rootfs.cpio
74  gzip rootfs.cpio
75else
76  # Create the rootfs in a temp dir
77  rsync -a --delete $BM_ROOTFS/ rootfs/
78  . $BM/rootfs-setup.sh rootfs
79
80  # Finally, pack it up into a cpio rootfs.  Skip the vulkan CTS since none of
81  # these devices use it and it would take up space in the initrd.
82
83  if [ -n "$PIGLIT_PROFILES" ]; then
84    EXCLUDE_FILTER="deqp|arb_gpu_shader5|arb_gpu_shader_fp64|arb_gpu_shader_int64|glsl-4.[0123456]0|arb_tessellation_shader"
85  else
86    EXCLUDE_FILTER="piglit|python"
87  fi
88
89  pushd rootfs
90  find -H . | \
91    grep -E -v "external/(openglcts|vulkancts|amber|glslang|spirv-tools)" |
92    grep -E -v "traces-db|apitrace|renderdoc" | \
93    grep -E -v $EXCLUDE_FILTER | \
94    cpio -H newc -o | \
95    xz --check=crc32 -T4 - > $CI_PROJECT_DIR/rootfs.cpio.gz
96  popd
97fi
98
99if echo "$BM_KERNEL $BM_DTB" | grep -q http; then
100  curl -L --retry 4 -f --retry-all-errors --retry-delay 60 \
101      "$BM_KERNEL" -o kernel
102  # FIXME: modules should be supplied too
103  curl -L --retry 4 -f --retry-all-errors --retry-delay 60 \
104      "$BM_DTB" -o dtb
105
106  cat kernel dtb > Image.gz-dtb
107
108elif [ -n "${FORCE_KERNEL_TAG}" ]; then
109  curl -L --retry 4 -f --retry-all-errors --retry-delay 60 \
110      "${FDO_HTTP_CACHE_URI:-}${KERNEL_IMAGE_BASE}/${DEBIAN_ARCH}/${BM_KERNEL}" -o kernel
111  curl -L --retry 4 -f --retry-all-errors --retry-delay 60 \
112      "${FDO_HTTP_CACHE_URI:-}${KERNEL_IMAGE_BASE}/${DEBIAN_ARCH}/modules.tar.zst" -o modules.tar.zst
113
114  if [ -n "$BM_DTB" ]; then
115    curl -L --retry 4 -f --retry-all-errors --retry-delay 60 \
116	"${FDO_HTTP_CACHE_URI:-}${KERNEL_IMAGE_BASE}/${DEBIAN_ARCH}/${BM_DTB}.dtb" -o dtb
117  fi
118
119  cat kernel dtb > Image.gz-dtb || echo "No DTB available, using pure kernel."
120  rm kernel
121  tar --keep-directory-symlink --zstd -xf modules.tar.zst -C "$BM_ROOTFS/"
122  rm modules.tar.zst &
123else
124  cat /baremetal-files/"$BM_KERNEL" /baremetal-files/"$BM_DTB".dtb > Image.gz-dtb
125  cp /baremetal-files/"$BM_DTB".dtb dtb
126fi
127
128export PATH=$BM:$PATH
129
130mkdir -p artifacts
131mkbootimg.py \
132  --kernel Image.gz-dtb \
133  --ramdisk rootfs.cpio.gz \
134  --dtb dtb \
135  --cmdline "$BM_CMDLINE" \
136  $BM_MKBOOT_PARAMS \
137  --header_version 2 \
138  -o artifacts/fastboot.img
139
140rm Image.gz-dtb dtb
141
142# Start background command for talking to serial if we have one.
143if [ -n "$BM_SERIAL_SCRIPT" ]; then
144  $BM_SERIAL_SCRIPT > results/serial-output.txt &
145
146  while [ ! -e results/serial-output.txt ]; do
147    sleep 1
148  done
149fi
150
151set +e
152$BM/fastboot_run.py \
153  --dev="$BM_SERIAL" \
154  --test-timeout ${TEST_PHASE_TIMEOUT:-20} \
155  --fbserial="$BM_FASTBOOT_SERIAL" \
156  --powerup="$BM_POWERUP" \
157  --powerdown="$BM_POWERDOWN"
158ret=$?
159set -e
160
161if [ -n "$BM_FASTBOOT_NFSROOT" ]; then
162  # Bring artifacts back from the NFS dir to the build dir where gitlab-runner
163  # will look for them.
164  cp -Rp /nfs/results/. results/
165fi
166
167exit $ret
168