81d94766cdcb84db026fd2ffde998e1e656b312e
[mesa.git] / .gitlab-ci / bare-metal / fastboot.sh
1 #!/bin/bash
2
3 BM=$CI_PROJECT_DIR/install/bare-metal
4
5 if [ -z "$BM_SERIAL" -a -z "$BM_SERIAL_SCRIPT" ]; then
6 echo "Must set BM_SERIAL OR BM_SERIAL_SCRIPT in your gitlab-runner config.toml [[runners]] environment"
7 echo "BM_SERIAL:"
8 echo " This is the serial device to talk to for waiting for fastboot to be ready and logging from the kernel."
9 echo "BM_SERIAL_SCRIPT:"
10 echo " This is a shell script to talk to for waiting for fastboot to be ready and logging from the kernel."
11 exit 1
12 fi
13
14 if [ -z "$BM_POWERUP" ]; then
15 echo "Must set BM_POWERUP in your gitlab-runner config.toml [[runners]] environment"
16 echo "This is a shell script that should reset the device and begin its boot sequence"
17 echo "such that it pauses at fastboot."
18 exit 1
19 fi
20
21 if [ -z "$BM_POWERDOWN" ]; then
22 echo "Must set BM_POWERDOWN in your gitlab-runner config.toml [[runners]] environment"
23 echo "This is a shell script that should power off the device."
24 exit 1
25 fi
26
27 if [ -z "$BM_FASTBOOT_SERIAL" ]; then
28 echo "Must set BM_FASTBOOT_SERIAL in your gitlab-runner config.toml [[runners]] environment"
29 echo "This must be the a stable-across-resets fastboot serial number."
30 exit 1
31 fi
32
33 if [ -z "$BM_KERNEL" ]; then
34 echo "Must set BM_KERNEL to your board's kernel vmlinuz or Image.gz in the job's variables:"
35 exit 1
36 fi
37
38 if [ -z "$BM_DTB" ]; then
39 echo "Must set BM_DTB to your board's DTB file in the job's variables:"
40 exit 1
41 fi
42
43 if [ -z "$BM_ROOTFS" ]; then
44 echo "Must set BM_ROOTFS to your board's rootfs directory in the job's variables:"
45 exit 1
46 fi
47
48 if [ -z "$BM_WEBDAV_IP" -o -z "$BM_WEBDAV_PORT" ]; then
49 echo "BM_WEBDAV_IP and/or BM_WEBDAV_PORT is not set - no results will be uploaded from DUT!"
50 WEBDAV_CMDLINE=""
51 else
52 WEBDAV_CMDLINE="webdav=http://$BM_WEBDAV_IP:$BM_WEBDAV_PORT"
53 fi
54
55 set -ex
56
57 # Clear out any previous run's artifacts.
58 rm -rf results/
59 mkdir -p results
60 find artifacts/ -name serial\*.txt | xargs rm -f
61
62 # Create the rootfs in a temp dir
63 rsync -a --delete $BM_ROOTFS/ rootfs/
64 . $BM/rootfs-setup.sh rootfs
65
66 # Finally, pack it up into a cpio rootfs. Skip the vulkan CTS since none of
67 # these devices use it and it would take up space in the initrd.
68 pushd rootfs
69 find -H | \
70 egrep -v "external/(openglcts|vulkancts|amber|glslang|spirv-tools)" |
71 egrep -v "traces-db|apitrace|renderdoc|python" | \
72 cpio -H newc -o | \
73 xz --check=crc32 -T4 - > $CI_PROJECT_DIR/rootfs.cpio.gz
74 popd
75
76 cat $BM_KERNEL $BM_DTB > Image.gz-dtb
77
78 abootimg \
79 --create artifacts/fastboot.img \
80 -k Image.gz-dtb \
81 -r rootfs.cpio.gz \
82 -c cmdline="$BM_CMDLINE $WEBDAV_CMDLINE"
83 rm Image.gz-dtb
84
85 # Start nginx to get results from DUT
86 if [ -n "$WEBDAV_CMDLINE" ]; then
87 ln -s `pwd`/results /results
88 sed -i s/80/$BM_WEBDAV_PORT/g /etc/nginx/sites-enabled/default
89 sed -i s/www-data/root/g /etc/nginx/nginx.conf
90 nginx
91 fi
92
93 # Start watching serial, and power up the device.
94 if [ -n "$BM_SERIAL" ]; then
95 python3 $BM/serial_buffer.py \
96 --dev $BM_SERIAL \
97 --file artifacts/serial-output.txt \
98 --prefix "SERIAL> " &
99 else
100 PATH=$BM:$PATH $BM_SERIAL_SCRIPT | tee artifacts/serial-output.txt &
101 fi
102
103 while [ ! -e artifacts/serial-output.txt ]; do
104 sleep 1
105 done
106 PATH=$BM:$PATH $BM_POWERUP
107
108 # Once fastboot is ready, boot our image.
109 $BM/expect-output.sh artifacts/serial-output.txt \
110 -f "fastboot: processing commands" \
111 -f "Listening for fastboot command on" \
112 -e "data abort"
113
114 fastboot boot -s $BM_FASTBOOT_SERIAL artifacts/fastboot.img
115
116 # Wait for the device to complete the deqp run
117 $BM/expect-output.sh artifacts/serial-output.txt \
118 -f "bare-metal result" \
119 -e "---. end Kernel panic"
120
121 # power down the device
122 PATH=$BM:$PATH $BM_POWERDOWN
123
124 set +e
125 if grep -q "bare-metal result: pass" artifacts/serial-output.txt; then
126 exit 0
127 else
128 exit 1
129 fi
130