ci: add U-Boot specific fetch strings
[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" -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 set -ex
49
50 # Create the rootfs in a temp dir
51 mkdir rootfs
52 . .gitlab-ci/bare-metal/rootfs-setup.sh rootfs
53
54 # Finally, pack it up into a cpio rootfs.
55 pushd rootfs
56 find -H | cpio -H newc -o | xz --check=crc32 -T4 - > $CI_PROJECT_DIR/rootfs.cpio.gz
57 popd
58
59 cat $BM_KERNEL $BM_DTB > Image.gz-dtb
60
61 abootimg \
62 --create artifacts/fastboot.img \
63 -k Image.gz-dtb \
64 -r rootfs.cpio.gz \
65 -c cmdline="$BM_CMDLINE"
66 rm Image.gz-dtb
67
68 # Start watching serial, and power up the device.
69 if [ -n "$BM_SERIAL" ]; then
70 $BM/serial-buffer.py $BM_SERIAL | tee artifacts/serial-output.txt &
71 else
72 PATH=$BM:$PATH $BM_SERIAL_SCRIPT | tee artifacts/serial-output.txt &
73 fi
74
75 while [ ! -e artifacts/serial-output.txt ]; do
76 sleep 1
77 done
78 PATH=$BM:$PATH $BM_POWERUP
79
80 # Once fastboot is ready, boot our image.
81 $BM/expect-output.sh artifacts/serial-output.txt \
82 -f "fastboot: processing commands" \
83 -f "Listening for fastboot command on" \
84 -e "data abort"
85
86 fastboot boot -s $BM_FASTBOOT_SERIAL artifacts/fastboot.img
87
88 # Wait for the device to complete the deqp run
89 $BM/expect-output.sh artifacts/serial-output.txt -f "DEQP RESULT"
90
91 # power down the device
92 PATH=$BM:$PATH $BM_POWERDOWN
93
94 set +e
95 if grep -q "DEQP RESULT: pass" artifacts/serial-output.txt; then
96 exit 0
97 else
98 exit 1
99 fi
100