gitlab-ci: Replay traces on lava devices
[mesa.git] / .gitlab-ci / container / lava_arm.sh
1 #!/bin/bash
2
3 set -e
4 set -o xtrace
5
6 check_minio()
7 {
8 MINIO_PATH="minio-packet.freedesktop.org/mesa-lava/$1/${DISTRIBUTION_TAG}/${DEBIAN_ARCH}"
9 if wget -q --method=HEAD "https://${MINIO_PATH}/done"; then
10 exit
11 fi
12 }
13
14 # If remote files are up-to-date, skip rebuilding them
15 check_minio "mesa/mesa"
16 check_minio "${CI_PROJECT_PATH}"
17
18 . .gitlab-ci/container/container_pre_build.sh
19
20 if [[ "$DEBIAN_ARCH" = "arm64" ]]; then
21 GCC_ARCH="aarch64-linux-gnu"
22 KERNEL_ARCH="arm64"
23 DEFCONFIG="arch/arm64/configs/defconfig"
24 DEVICE_TREES="arch/arm64/boot/dts/rockchip/rk3399-gru-kevin.dtb arch/arm64/boot/dts/amlogic/meson-gxl-s905x-libretech-cc.dtb arch/arm64/boot/dts/allwinner/sun50i-h6-pine-h64.dtb arch/arm64/boot/dts/amlogic/meson-gxm-khadas-vim2.dtb arch/arm64/boot/dts/qcom/apq8016-sbc.dtb"
25 KERNEL_IMAGE_NAME="Image"
26 else
27 GCC_ARCH="arm-linux-gnueabihf"
28 KERNEL_ARCH="arm"
29 DEFCONFIG="arch/arm/configs/multi_v7_defconfig"
30 DEVICE_TREES="arch/arm/boot/dts/rk3288-veyron-jaq.dtb arch/arm/boot/dts/sun8i-h3-libretech-all-h3-cc.dtb"
31 KERNEL_IMAGE_NAME="zImage"
32 . .gitlab-ci/create-cross-file.sh armhf
33 fi
34
35 # Determine if we're in a cross build.
36 if [[ -e /cross_file-$DEBIAN_ARCH.txt ]]; then
37 EXTRA_MESON_ARGS="--cross-file /cross_file-$DEBIAN_ARCH.txt"
38 EXTRA_CMAKE_ARGS="-DCMAKE_TOOLCHAIN_FILE=/toolchain-$DEBIAN_ARCH.cmake"
39
40 export ARCH=${KERNEL_ARCH}
41 export CROSS_COMPILE="${GCC_ARCH}-"
42 fi
43
44 apt-get update
45 apt-get install -y automake \
46 git \
47 bc \
48 cmake \
49 cpio \
50 wget \
51 debootstrap \
52 libboost-dev \
53 libegl1-mesa-dev \
54 libgbm-dev \
55 libgles2-mesa-dev \
56 libpcre3-dev \
57 libpng-dev \
58 libpython3-dev \
59 libssl-dev \
60 libvulkan-dev \
61 libxcb-keysyms1-dev \
62 python3-dev \
63 python3-distutils \
64 python3-serial \
65 qt5-default \
66 qt5-qmake \
67 qtbase5-dev
68
69
70 if [[ "$DEBIAN_ARCH" = "armhf" ]]; then
71 apt-get install -y libboost-dev:armhf \
72 libegl1-mesa-dev:armhf \
73 libelf-dev:armhf \
74 libgbm-dev:armhf \
75 libgles2-mesa-dev:armhf \
76 libpcre3-dev:armhf \
77 libpng-dev:armhf \
78 libpython3-dev:armhf \
79 libvulkan-dev:armhf \
80 libxcb-keysyms1-dev:armhf \
81 qtbase5-dev:armhf
82 fi
83
84 ############### Build dEQP runner
85 . .gitlab-ci/build-cts-runner.sh
86 mkdir -p /lava-files/rootfs-${DEBIAN_ARCH}/usr/bin
87 mv /usr/local/bin/deqp-runner /lava-files/rootfs-${DEBIAN_ARCH}/usr/bin/.
88
89
90 ############### Build dEQP
91 STRIP_CMD="${GCC_ARCH}-strip"
92 if [ -n "$INCLUDE_VK_CTS" ]; then
93 DEQP_TARGET=surfaceless . .gitlab-ci/build-deqp-vk.sh
94 else
95 . .gitlab-ci/build-deqp-gl.sh
96 fi
97
98 mv /deqp /lava-files/rootfs-${DEBIAN_ARCH}/.
99
100
101 ############### Build apitrace
102 . .gitlab-ci/build-apitrace.sh
103 mkdir -p /lava-files/rootfs-${DEBIAN_ARCH}/apitrace
104 mv /apitrace/build /lava-files/rootfs-${DEBIAN_ARCH}/apitrace
105 rm -rf /apitrace
106
107 mkdir -p /lava-files/rootfs-${DEBIAN_ARCH}/waffle
108 mv /waffle/build /lava-files/rootfs-${DEBIAN_ARCH}/waffle
109 rm -rf /waffle
110
111
112 ############### Build renderdoc
113 EXTRA_CMAKE_ARGS+=" -DENABLE_XCB=false"
114 . .gitlab-ci/build-renderdoc.sh
115 mkdir -p /lava-files/rootfs-${DEBIAN_ARCH}/renderdoc
116 mv /renderdoc/build /lava-files/rootfs-${DEBIAN_ARCH}/renderdoc
117 rm -rf /renderdoc
118
119
120 ############### Cross-build kernel
121 mkdir -p kernel
122 wget -qO- ${KERNEL_URL} | tar -xz --strip-components=1 -C kernel
123 pushd kernel
124 ./scripts/kconfig/merge_config.sh ${DEFCONFIG} ../.gitlab-ci/${KERNEL_ARCH}.config
125 make ${KERNEL_IMAGE_NAME} dtbs
126 for image in ${KERNEL_IMAGE_NAME}; do
127 cp arch/${KERNEL_ARCH}/boot/${image} /lava-files/.
128 done
129 cp ${DEVICE_TREES} /lava-files/.
130
131 if [[ ${DEBIAN_ARCH} = "arm64" ]] && which mkimage > /dev/null; then
132 make Image.lzma
133 mkimage \
134 -f auto \
135 -A arm \
136 -O linux \
137 -d arch/arm64/boot/Image.lzma \
138 -C lzma\
139 -b arch/arm64/boot/dts/qcom/sdm845-cheza-r3.dtb \
140 /lava-files/cheza-kernel
141 fi
142
143 popd
144 rm -rf kernel
145
146 ############### Create rootfs
147 set +e
148 debootstrap \
149 --variant=minbase \
150 --arch=${DEBIAN_ARCH} \
151 --components main,contrib,non-free \
152 buster \
153 /lava-files/rootfs-${DEBIAN_ARCH}/ \
154 http://deb.debian.org/debian
155
156 cat /lava-files/rootfs-${DEBIAN_ARCH}/debootstrap/debootstrap.log
157 set -e
158
159 cp .gitlab-ci/create-rootfs.sh /lava-files/rootfs-${DEBIAN_ARCH}/.
160 chroot /lava-files/rootfs-${DEBIAN_ARCH} sh /create-rootfs.sh
161 rm /lava-files/rootfs-${DEBIAN_ARCH}/create-rootfs.sh
162 pushd /lava-files/rootfs-${DEBIAN_ARCH}
163 find -H | cpio -H newc -o | gzip -c - > /lava-files/lava-rootfs.cpio.gz
164 popd
165
166 if [ ${DEBIAN_ARCH} = arm64 ]; then
167 # Pull down a specific build of qcomlt/release/qcomlt-5.4 8c79b3d12355
168 # ("Merge tag 'v5.4.23' into release/qcomlt-5.4"), where I used the
169 # .config from
170 # http://snapshots.linaro.org/96boards/dragonboard820c/linaro/debian/457/config-5.4.0-qcomlt-arm64
171 # with the following merged in:
172 #
173 # CONFIG_DRM=y
174 # CONFIG_DRM_MSM=y
175 # CONFIG_ATL1C=y
176 #
177 # Reason: 5.5 has a big stack of oopses and warns on db820c. 4.14-5.4
178 # linaro kernel binaries (see above .config link) have these as modules
179 # and distributed the modules only in the debian system, not the initrd,
180 # so they're very hard to extract (involving simg2img and loopback
181 # mounting). 4.11 is missing d72fea538fe6 ("drm/msm: Fix the check for
182 # the command size") so it can't actually run fredreno. qcomlt-4.14 is
183 # unstable at boot (~10% instaboot rate). The 5.4 qcomlt kernel with msm
184 # built in seems like the easiest way to go.
185 wget https://people.freedesktop.org/~anholt/qcomlt-5.4-msm-build/Image.gz -O Image.gz \
186 -O /lava-files/db820c-kernel
187 wget https://people.freedesktop.org/~anholt/qcomlt-5.4-msm-build/apq8096-db820c.dtb \
188 -O /lava-files/db820c.dtb
189
190 # Make a gzipped copy of the Image for db410c.
191 gzip -k /lava-files/Image
192
193 # Add missing a630 firmware, added to debian packge in apr 2020
194 wget https://git.kernel.org/pub/scm/linux/kernel/git/firmware/linux-firmware.git/plain/qcom/a630_gmu.bin \
195 -O /lava-files/rootfs-arm64/lib/firmware/qcom/a630_gmu.bin
196 wget https://git.kernel.org/pub/scm/linux/kernel/git/firmware/linux-firmware.git/plain/qcom/a630_sqe.fw \
197 -O /lava-files/rootfs-arm64/lib/firmware/qcom/a630_sqe.fw
198 fi
199
200 . .gitlab-ci/container/container_post_build.sh
201
202 ############### Upload the files!
203 if [ -n "$UPLOAD_FOR_LAVA" ]; then
204 ci-fairy minio login $CI_JOB_JWT
205 FILES_TO_UPLOAD="lava-rootfs.cpio.gz \
206 $KERNEL_IMAGE_NAME \
207 $(basename -a $DEVICE_TREES)"
208
209 for f in $FILES_TO_UPLOAD; do
210 ci-fairy minio cp /lava-files/$f \
211 minio://${MINIO_PATH}/$f
212 done
213
214 touch /lava-files/done
215 ci-fairy minio cp /lava-files/done minio://${MINIO_PATH}/done
216 fi
217