1*61046927SAndroid Build Coastguard WorkerBare-metal CI 2*61046927SAndroid Build Coastguard Worker============= 3*61046927SAndroid Build Coastguard Worker 4*61046927SAndroid Build Coastguard WorkerThe bare-metal scripts run on a system with gitlab-runner and Docker, 5*61046927SAndroid Build Coastguard Workerconnected to potentially multiple bare-metal boards that run tests of 6*61046927SAndroid Build Coastguard WorkerMesa. Currently "fastboot", "ChromeOS Servo", and POE-powered devices are 7*61046927SAndroid Build Coastguard Workersupported. 8*61046927SAndroid Build Coastguard Worker 9*61046927SAndroid Build Coastguard WorkerIn comparison with LAVA, this doesn't involve maintaining a separate 10*61046927SAndroid Build Coastguard Workerweb service with its own job scheduler and replicating jobs between the 11*61046927SAndroid Build Coastguard Workertwo. It also places more of the board support in Git, instead of 12*61046927SAndroid Build Coastguard Workerweb service configuration. On the other hand, the serial interactions 13*61046927SAndroid Build Coastguard Workerand bootloader support are more primitive. 14*61046927SAndroid Build Coastguard Worker 15*61046927SAndroid Build Coastguard WorkerRequirements (fastboot) 16*61046927SAndroid Build Coastguard Worker----------------------- 17*61046927SAndroid Build Coastguard Worker 18*61046927SAndroid Build Coastguard WorkerThis testing requires power control of the DUTs by the gitlab-runner 19*61046927SAndroid Build Coastguard Workermachine, since this is what we use to reset the system and get back to 20*61046927SAndroid Build Coastguard Workera pristine state at the start of testing. 21*61046927SAndroid Build Coastguard Worker 22*61046927SAndroid Build Coastguard WorkerWe require access to the console output from the gitlab-runner system, 23*61046927SAndroid Build Coastguard Workersince that is how we get the final results back from the tests. You 24*61046927SAndroid Build Coastguard Workershould probably have the console on a serial connection, so that you 25*61046927SAndroid Build Coastguard Workercan see bootloader progress. 26*61046927SAndroid Build Coastguard Worker 27*61046927SAndroid Build Coastguard WorkerThe boards need to be able to have a kernel/initramfs supplied by the 28*61046927SAndroid Build Coastguard Workergitlab-runner system, since Mesa often needs to update the kernel either for new 29*61046927SAndroid Build Coastguard WorkerDRM functionality, or to fix kernel bugs. 30*61046927SAndroid Build Coastguard Worker 31*61046927SAndroid Build Coastguard WorkerThe boards must have networking, so that we can extract the dEQP XML results to 32*61046927SAndroid Build Coastguard Workerartifacts on GitLab, and so that we can download traces (too large for an 33*61046927SAndroid Build Coastguard Workerinitramfs) for trace replay testing. Given that we need networking already, and 34*61046927SAndroid Build Coastguard Workerour dEQP/Piglit/etc. payload is large, we use NFS from the x86 runner system 35*61046927SAndroid Build Coastguard Workerrather than initramfs. 36*61046927SAndroid Build Coastguard Worker 37*61046927SAndroid Build Coastguard WorkerSee ``src/freedreno/ci/gitlab-ci.yml`` for an example of fastboot on DB410c and 38*61046927SAndroid Build Coastguard WorkerDB820c (freedreno-a306 and freedreno-a530). 39*61046927SAndroid Build Coastguard Worker 40*61046927SAndroid Build Coastguard WorkerRequirements (Servo) 41*61046927SAndroid Build Coastguard Worker-------------------- 42*61046927SAndroid Build Coastguard Worker 43*61046927SAndroid Build Coastguard WorkerFor Servo-connected boards, we can use the EC connection for power 44*61046927SAndroid Build Coastguard Workercontrol to reboot the board. However, loading a kernel is not as easy 45*61046927SAndroid Build Coastguard Workeras fastboot, so we assume your bootloader can do TFTP, and that your 46*61046927SAndroid Build Coastguard Workergitlab-runner mounts the runner's tftp directory specific to the board 47*61046927SAndroid Build Coastguard Workerat /tftp in the container. 48*61046927SAndroid Build Coastguard Worker 49*61046927SAndroid Build Coastguard WorkerSince we're going the TFTP route, we also use NFS root. This avoids 50*61046927SAndroid Build Coastguard Workerpacking the rootfs and sending it to the board as a ramdisk, which 51*61046927SAndroid Build Coastguard Workermeans we can support larger rootfses (for Piglit testing), at the cost 52*61046927SAndroid Build Coastguard Workerof needing more storage on the runner. 53*61046927SAndroid Build Coastguard Worker 54*61046927SAndroid Build Coastguard WorkerTelling the board about where its TFTP and NFS should come from is 55*61046927SAndroid Build Coastguard Workerdone using dnsmasq on the runner host. For example, this snippet in 56*61046927SAndroid Build Coastguard Workerthe dnsmasq.conf.d in the Google farm, with the gitlab-runner host we 57*61046927SAndroid Build Coastguard Workercall "servo":: 58*61046927SAndroid Build Coastguard Worker 59*61046927SAndroid Build Coastguard Worker dhcp-host=1c:69:7a:0d:a3:d3,10.42.0.10,set:servo 60*61046927SAndroid Build Coastguard Worker 61*61046927SAndroid Build Coastguard Worker # Fixed dhcp addresses for my sanity, and setting a tag for 62*61046927SAndroid Build Coastguard Worker # specializing other DHCP options 63*61046927SAndroid Build Coastguard Worker dhcp-host=a0:ce:c8:c8:d9:5d,10.42.0.11,set:cheza1 64*61046927SAndroid Build Coastguard Worker dhcp-host=a0:ce:c8:c8:d8:81,10.42.0.12,set:cheza2 65*61046927SAndroid Build Coastguard Worker 66*61046927SAndroid Build Coastguard Worker # Specify the next server, watch out for the double ',,'. The 67*61046927SAndroid Build Coastguard Worker # filename didn't seem to get picked up by the bootloader, so we use 68*61046927SAndroid Build Coastguard Worker # tftp-unique-root and mount directories like 69*61046927SAndroid Build Coastguard Worker # /srv/tftp/10.42.0.11/jwerner/cheza as /tftp in the job containers. 70*61046927SAndroid Build Coastguard Worker tftp-unique-root 71*61046927SAndroid Build Coastguard Worker dhcp-boot=tag:cheza1,cheza1/vmlinuz,,10.42.0.10 72*61046927SAndroid Build Coastguard Worker dhcp-boot=tag:cheza2,cheza2/vmlinuz,,10.42.0.10 73*61046927SAndroid Build Coastguard Worker 74*61046927SAndroid Build Coastguard Worker dhcp-option=tag:cheza1,option:root-path,/srv/nfs/cheza1 75*61046927SAndroid Build Coastguard Worker dhcp-option=tag:cheza2,option:root-path,/srv/nfs/cheza2 76*61046927SAndroid Build Coastguard Worker 77*61046927SAndroid Build Coastguard WorkerSee ``src/freedreno/ci/gitlab-ci.yml`` for an example of Servo on cheza. Note 78*61046927SAndroid Build Coastguard Workerthat other Servo boards in CI are managed using LAVA. 79*61046927SAndroid Build Coastguard Worker 80*61046927SAndroid Build Coastguard WorkerRequirements (POE) 81*61046927SAndroid Build Coastguard Worker------------------ 82*61046927SAndroid Build Coastguard Worker 83*61046927SAndroid Build Coastguard WorkerFor boards with 30W or less power consumption, POE can be used for the power 84*61046927SAndroid Build Coastguard Workercontrol. The parts list ends up looking something like (for example): 85*61046927SAndroid Build Coastguard Worker 86*61046927SAndroid Build Coastguard Worker- x86-64 gitlab-runner machine with a mid-range CPU, and 3+ GB of SSD storage 87*61046927SAndroid Build Coastguard Worker per board. This can host at least 15 boards in our experience. 88*61046927SAndroid Build Coastguard Worker- Cisco 2960S gigabit ethernet switch with POE. (Cisco 3750G, 3560G, or 2960G 89*61046927SAndroid Build Coastguard Worker were also recommended as reasonable-priced HW, but make sure the name ends in 90*61046927SAndroid Build Coastguard Worker G, X, or S) 91*61046927SAndroid Build Coastguard Worker- POE splitters to power the boards (you can find ones that go to micro USB, 92*61046927SAndroid Build Coastguard Worker USBC, and 5V barrel jacks at least) 93*61046927SAndroid Build Coastguard Worker- USB serial cables (Adafruit sells pretty reliable ones) 94*61046927SAndroid Build Coastguard Worker- A large powered USB hub for all the serial cables 95*61046927SAndroid Build Coastguard Worker- A pile of ethernet cables 96*61046927SAndroid Build Coastguard Worker 97*61046927SAndroid Build Coastguard WorkerYou'll talk to the Cisco for configuration using its USB port, which provides a 98*61046927SAndroid Build Coastguard Workerserial terminal at 9600 baud. You need to enable SNMP control, which we'll do 99*61046927SAndroid Build Coastguard Workerusing a "mesaci" community name that the gitlab runner can access as its 100*61046927SAndroid Build Coastguard Workerauthentication (no password) to configure. To talk to the SNMP on the router, 101*61046927SAndroid Build Coastguard Workeryou need to put an IP address on the default VLAN (VLAN 1). 102*61046927SAndroid Build Coastguard Worker 103*61046927SAndroid Build Coastguard WorkerSetting that up looks something like: 104*61046927SAndroid Build Coastguard Worker 105*61046927SAndroid Build Coastguard Worker.. code-block: console 106*61046927SAndroid Build Coastguard Worker 107*61046927SAndroid Build Coastguard Worker Switch> 108*61046927SAndroid Build Coastguard Worker Password: 109*61046927SAndroid Build Coastguard Worker Switch#configure terminal 110*61046927SAndroid Build Coastguard Worker Switch(config)#interface Vlan 1 111*61046927SAndroid Build Coastguard Worker Switch(config-if)#ip address 10.42.0.2 255.255.0.0 112*61046927SAndroid Build Coastguard Worker Switch(config-if)#end 113*61046927SAndroid Build Coastguard Worker Switch(config)#snmp-server community mesaci RW 114*61046927SAndroid Build Coastguard Worker Switch(config)#end 115*61046927SAndroid Build Coastguard Worker Switch#copy running-config startup-config 116*61046927SAndroid Build Coastguard Worker 117*61046927SAndroid Build Coastguard WorkerWith that set up, you should be able to power on/off a port with something like: 118*61046927SAndroid Build Coastguard Worker 119*61046927SAndroid Build Coastguard Worker.. code-block: console 120*61046927SAndroid Build Coastguard Worker 121*61046927SAndroid Build Coastguard Worker % snmpset -v2c -r 3 -t 30 -cmesaci 10.42.0.2 1.3.6.1.4.1.9.9.402.1.2.1.1.1.1 i 1 122*61046927SAndroid Build Coastguard Worker % snmpset -v2c -r 3 -t 30 -cmesaci 10.42.0.2 1.3.6.1.4.1.9.9.402.1.2.1.1.1.1 i 4 123*61046927SAndroid Build Coastguard Worker 124*61046927SAndroid Build Coastguard WorkerNote that the "1.3.6..." SNMP OID changes between switches. The last digit 125*61046927SAndroid Build Coastguard Workerabove is the interface id (port number). You can probably find the right OID by 126*61046927SAndroid Build Coastguard WorkerGoogle, that was easier than figuring it out from finding the switch's MIB 127*61046927SAndroid Build Coastguard Workerdatabase. You can query the POE status from the switch serial using the ``show 128*61046927SAndroid Build Coastguard Workerpower inline`` command. 129*61046927SAndroid Build Coastguard Worker 130*61046927SAndroid Build Coastguard WorkerOther than that, find the dnsmasq/tftp/NFS setup for your boards "servo" above. 131*61046927SAndroid Build Coastguard Worker 132*61046927SAndroid Build Coastguard WorkerSee ``src/broadcom/ci/gitlab-ci.yml`` and ``src/nouveau/ci/gitlab-ci.yml`` for an 133*61046927SAndroid Build Coastguard Workerexamples of POE for Raspberry Pi 3/4, and Jetson Nano. 134*61046927SAndroid Build Coastguard Worker 135*61046927SAndroid Build Coastguard WorkerSetup 136*61046927SAndroid Build Coastguard Worker----- 137*61046927SAndroid Build Coastguard Worker 138*61046927SAndroid Build Coastguard WorkerEach board will be registered in freedesktop.org GitLab. You'll want 139*61046927SAndroid Build Coastguard Workersomething like this to register a fastboot board: 140*61046927SAndroid Build Coastguard Worker 141*61046927SAndroid Build Coastguard Worker.. code-block:: sh 142*61046927SAndroid Build Coastguard Worker 143*61046927SAndroid Build Coastguard Worker sudo gitlab-runner register \ 144*61046927SAndroid Build Coastguard Worker --url https://gitlab.freedesktop.org \ 145*61046927SAndroid Build Coastguard Worker --registration-token $1 \ 146*61046927SAndroid Build Coastguard Worker --name MY_BOARD_NAME \ 147*61046927SAndroid Build Coastguard Worker --tag-list MY_BOARD_TAG \ 148*61046927SAndroid Build Coastguard Worker --executor docker \ 149*61046927SAndroid Build Coastguard Worker --docker-image "alpine:latest" \ 150*61046927SAndroid Build Coastguard Worker --docker-volumes "/dev:/dev" \ 151*61046927SAndroid Build Coastguard Worker --docker-network-mode "host" \ 152*61046927SAndroid Build Coastguard Worker --docker-privileged \ 153*61046927SAndroid Build Coastguard Worker --non-interactive 154*61046927SAndroid Build Coastguard Worker 155*61046927SAndroid Build Coastguard WorkerFor a Servo board, you'll need to also volume mount the board's NFS 156*61046927SAndroid Build Coastguard Workerroot dir at /nfs and TFTP kernel directory at /tftp. 157*61046927SAndroid Build Coastguard Worker 158*61046927SAndroid Build Coastguard WorkerThe registration token has to come from a freedesktop.org GitLab admin 159*61046927SAndroid Build Coastguard Workergoing to https://gitlab.freedesktop.org/admin/runners 160*61046927SAndroid Build Coastguard Worker 161*61046927SAndroid Build Coastguard WorkerThe name scheme for Google's lab is google-freedreno-boardname-n, and 162*61046927SAndroid Build Coastguard Workerour tag is something like google-freedreno-db410c. The tag is what 163*61046927SAndroid Build Coastguard Workeridentifies a board type so that board-specific jobs can be dispatched 164*61046927SAndroid Build Coastguard Workerinto that pool. 165*61046927SAndroid Build Coastguard Worker 166*61046927SAndroid Build Coastguard WorkerWe need privileged mode and the /dev bind mount in order to get at the 167*61046927SAndroid Build Coastguard Workerserial console and fastboot USB devices (--device arguments don't 168*61046927SAndroid Build Coastguard Workerapply to devices that show up after container start, which is the case 169*61046927SAndroid Build Coastguard Workerwith fastboot, and the Servo serial devices are actually links to 170*61046927SAndroid Build Coastguard Worker/dev/pts). We use host network mode so that we can spin up a nginx 171*61046927SAndroid Build Coastguard Workerserver to collect XML results for fastboot. 172*61046927SAndroid Build Coastguard Worker 173*61046927SAndroid Build Coastguard WorkerOnce you've added your boards, you're going to need to add a little 174*61046927SAndroid Build Coastguard Workermore customization in ``/etc/gitlab-runner/config.toml``. First, add 175*61046927SAndroid Build Coastguard Worker``concurrent = <number of boards>`` at the top ("we should have up to 176*61046927SAndroid Build Coastguard Workerthis many jobs running managed by this gitlab-runner"). Then for each 177*61046927SAndroid Build Coastguard Workerboard's runner, set ``limit = 1`` ("only 1 job served by this board at a 178*61046927SAndroid Build Coastguard Workertime"). Finally, add the board-specific environment variables 179*61046927SAndroid Build Coastguard Workerrequired by your bare-metal script, something like:: 180*61046927SAndroid Build Coastguard Worker 181*61046927SAndroid Build Coastguard Worker [[runners]] 182*61046927SAndroid Build Coastguard Worker name = "google-freedreno-db410c-1" 183*61046927SAndroid Build Coastguard Worker environment = ["BM_SERIAL=/dev/ttyDB410c8", "BM_POWERUP=google-power-up.sh 8", "BM_FASTBOOT_SERIAL=15e9e390", "FDO_CI_CONCURRENT=4"] 184*61046927SAndroid Build Coastguard Worker 185*61046927SAndroid Build Coastguard WorkerThe ``FDO_CI_CONCURRENT`` variable should be set to the number of CPU threads on 186*61046927SAndroid Build Coastguard Workerthe board, which is used for auto-tuning of job parallelism. 187*61046927SAndroid Build Coastguard Worker 188*61046927SAndroid Build Coastguard WorkerOnce you've updated your runners' configs, restart with ``sudo service 189*61046927SAndroid Build Coastguard Workergitlab-runner restart`` 190*61046927SAndroid Build Coastguard Worker 191*61046927SAndroid Build Coastguard WorkerCaching downloads 192*61046927SAndroid Build Coastguard Worker----------------- 193*61046927SAndroid Build Coastguard Worker 194*61046927SAndroid Build Coastguard WorkerTo improve the runtime for downloading traces during traces job runs, you will 195*61046927SAndroid Build Coastguard Workerwant a pass-through HTTP cache. On your runner box, install nginx: 196*61046927SAndroid Build Coastguard Worker 197*61046927SAndroid Build Coastguard Worker.. code-block:: sh 198*61046927SAndroid Build Coastguard Worker 199*61046927SAndroid Build Coastguard Worker sudo apt install nginx libnginx-mod-http-lua 200*61046927SAndroid Build Coastguard Worker 201*61046927SAndroid Build Coastguard WorkerAdd the server setup files: 202*61046927SAndroid Build Coastguard Worker 203*61046927SAndroid Build Coastguard Worker.. literalinclude:: fdo-cache 204*61046927SAndroid Build Coastguard Worker :name: /etc/nginx/sites-available/fdo-cache 205*61046927SAndroid Build Coastguard Worker :caption: /etc/nginx/sites-available/fdo-cache 206*61046927SAndroid Build Coastguard Worker 207*61046927SAndroid Build Coastguard Worker.. literalinclude:: uri-caching.conf 208*61046927SAndroid Build Coastguard Worker :name: /etc/nginx/snippets/uri-caching.conf 209*61046927SAndroid Build Coastguard Worker :caption: /etc/nginx/snippets/uri-caching.conf 210*61046927SAndroid Build Coastguard Worker 211*61046927SAndroid Build Coastguard WorkerEdit the listener addresses in fdo-cache to suit the ethernet interface that 212*61046927SAndroid Build Coastguard Workeryour devices are on. 213*61046927SAndroid Build Coastguard Worker 214*61046927SAndroid Build Coastguard WorkerEnable the site and restart nginx: 215*61046927SAndroid Build Coastguard Worker 216*61046927SAndroid Build Coastguard Worker.. code-block:: sh 217*61046927SAndroid Build Coastguard Worker 218*61046927SAndroid Build Coastguard Worker sudo rm /etc/nginx/sites-enabled/default 219*61046927SAndroid Build Coastguard Worker sudo ln -s /etc/nginx/sites-available/fdo-cache /etc/nginx/sites-enabled/fdo-cache 220*61046927SAndroid Build Coastguard Worker sudo systemctl restart nginx 221*61046927SAndroid Build Coastguard Worker 222*61046927SAndroid Build Coastguard Worker # First download will hit the internet 223*61046927SAndroid Build Coastguard Worker wget http://localhost/cache/?uri=https://s3.freedesktop.org/mesa-tracie-public/itoral-gl-terrain-demo/demo-v2.trace 224*61046927SAndroid Build Coastguard Worker # Second download should be cached. 225*61046927SAndroid Build Coastguard Worker wget http://localhost/cache/?uri=https://s3.freedesktop.org/mesa-tracie-public/itoral-gl-terrain-demo/demo-v2.trace 226*61046927SAndroid Build Coastguard Worker 227*61046927SAndroid Build Coastguard WorkerNow, set ``download-url`` in your ``traces-*.yml`` entry to something like 228*61046927SAndroid Build Coastguard Worker``http://caching-proxy/cache/?uri=https://s3.freedesktop.org/mesa-tracie-public`` 229*61046927SAndroid Build Coastguard Workerand you should have cached downloads for traces. Add it to 230*61046927SAndroid Build Coastguard Worker``FDO_HTTP_CACHE_URI=`` in your ``config.toml`` runner environment lines and you 231*61046927SAndroid Build Coastguard Workercan use it for cached artifact downloads instead of going all the way to 232*61046927SAndroid Build Coastguard Workerfreedesktop.org on each job. 233