124309e8abe27729e96c95c518008f8d2f70ef70
[mesa.git] / .gitlab-ci / bare-metal / fastboot.sh
1 #!/bin/bash
2
3 BM=$CI_PROJECT_DIR/.gitlab-ci/bare-metal
4
5 if [ -z "$BM_SERIAL" ]; then
6 echo "Must set BM_SERIAL in your gitlab-runner config.toml [[runners]] environment"
7 echo "This is the serial device to talk to for waiting for fastboot to be ready and logging from the kernel."
8 exit 1
9 fi
10
11 if [ -z "$BM_POWERUP" ]; then
12 echo "Must set BM_POWERUP in your gitlab-runner config.toml [[runners]] environment"
13 echo "This is a shell script that should reset the device and begin its boot sequence"
14 echo "such that it pauses at fastboot."
15 exit 1
16 fi
17
18 if [ -z "$BM_POWERDOWN" ]; then
19 echo "Must set BM_POWERDOWN in your gitlab-runner config.toml [[runners]] environment"
20 echo "This is a shell script that should power off the device."
21 exit 1
22 fi
23
24 if [ -z "$BM_FASTBOOT_SERIAL" ]; then
25 echo "Must set BM_FASTBOOT_SERIAL in your gitlab-runner config.toml [[runners]] environment"
26 echo "This must be the a stable-across-resets fastboot serial number."
27 exit 1
28 fi
29
30 if [ -z "$BM_KERNEL" ]; then
31 echo "Must set BM_KERNEL to your board's kernel vmlinuz or Image.gz in the job's variables:"
32 exit 1
33 fi
34
35 if [ -z "$BM_DTB" ]; then
36 echo "Must set BM_DTB to your board's DTB file in the job's variables:"
37 exit 1
38 fi
39
40 if [ -z "$BM_ROOTFS" ]; then
41 echo "Must set BM_ROOTFS to your board's rootfs directory in the job's variables:"
42 exit 1
43 fi
44
45 set -ex
46
47 # Create the rootfs in a temp dir
48 mkdir rootfs
49 . .gitlab-ci/bare-metal/rootfs-setup.sh rootfs
50
51 # Finally, pack it up into a cpio rootfs.
52 pushd rootfs
53 find -H | cpio -H newc -o | xz --check=crc32 -T4 - > $CI_PROJECT_DIR/rootfs.cpio.gz
54 popd
55
56 cat $BM_KERNEL $BM_DTB > Image.gz-dtb
57
58 abootimg \
59 --create artifacts/fastboot.img \
60 -k Image.gz-dtb \
61 -r rootfs.cpio.gz \
62 -c cmdline="$BM_CMDLINE"
63 rm Image.gz-dtb
64
65 # Start watching serial, and power up the device.
66 $BM/serial-buffer.py $BM_SERIAL | tee artifacts/serial-output.txt &
67 while [ ! -e artifacts/serial-output.txt ]; do
68 sleep 1
69 done
70 PATH=$BM:$PATH $BM_POWERUP
71
72 # Once fastboot is ready, boot our image.
73 $BM/expect-output.sh artifacts/serial-output.txt "fastboot: processing commands"
74 fastboot boot -s $BM_FASTBOOT_SERIAL artifacts/fastboot.img
75
76 # Wait for the device to complete the deqp run
77 $BM/expect-output.sh artifacts/serial-output.txt "DEQP RESULT"
78
79 # power down the device
80 PATH=$BM:$PATH $BM_POWERDOWN
81
82 set +e
83 if grep -q "DEQP RESULT: pass" artifacts/serial-output.txt; then
84 exit 0
85 else
86 exit 1
87 fi
88