~mmach/netext73/mesa-haswell

« back to all changes in this revision

Viewing changes to .gitlab-ci/bare-metal/fastboot.sh

  • Committer: mmach
  • Date: 2022-09-22 19:56:13 UTC
  • Revision ID: netbit73@gmail.com-20220922195613-wtik9mmy20tmor0i
2022-09-22 21:17:09

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#!/bin/bash
2
 
 
3
 
BM=$CI_PROJECT_DIR/install/bare-metal
4
 
CI_COMMON=$CI_PROJECT_DIR/install/common
5
 
 
6
 
if [ -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
13
 
fi
14
 
 
15
 
if [ -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
20
 
fi
21
 
 
22
 
if [ -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
26
 
fi
27
 
 
28
 
if [ -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
32
 
fi
33
 
 
34
 
if [ -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
37
 
fi
38
 
 
39
 
if [ -z "$BM_DTB" ]; then
40
 
  echo "Must set BM_DTB to your board's DTB file in the job's variables:"
41
 
  exit 1
42
 
fi
43
 
 
44
 
if [ -z "$BM_ROOTFS" ]; then
45
 
  echo "Must set BM_ROOTFS to your board's rootfs directory in the job's variables:"
46
 
  exit 1
47
 
fi
48
 
 
49
 
if echo $BM_CMDLINE | grep -q "root=/dev/nfs"; then
50
 
  BM_FASTBOOT_NFSROOT=1
51
 
fi
52
 
 
53
 
set -ex
54
 
 
55
 
# Clear out any previous run's artifacts.
56
 
rm -rf results/
57
 
mkdir -p results/
58
 
 
59
 
if [ -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
70
 
else
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
92
 
fi
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.
102
 
if 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
110
 
else
111
 
  cat $BM_KERNEL $BM_DTB > Image.gz-dtb
112
 
fi
113
 
 
114
 
mkdir -p artifacts
115
 
abootimg \
116
 
  --create artifacts/fastboot.img \
117
 
  -k Image.gz-dtb \
118
 
  -r rootfs.cpio.gz \
119
 
  -c cmdline="$BM_CMDLINE"
120
 
rm Image.gz-dtb
121
 
 
122
 
export PATH=$BM:$PATH
123
 
 
124
 
# Start background command for talking to serial if we have one.
125
 
if [ -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
131
 
fi
132
 
 
133
 
set +e
134
 
$BM/fastboot_run.py \
135
 
  --dev="$BM_SERIAL" \
136
 
  --fbserial="$BM_FASTBOOT_SERIAL" \
137
 
  --powerup="$BM_POWERUP" \
138
 
  --powerdown="$BM_POWERDOWN"
139
 
ret=$?
140
 
set -e
141
 
 
142
 
if [ -n "$BM_FASTBOOT_NFSROOT" ]; then
143
 
  # Bring artifacts back from the NFS dir to the build dir where gitlab-runner
144
 
  # will look for them.
145
 
  cp -Rp /nfs/results/. results/
146
 
fi
147
 
 
148
 
exit $ret