Skip to content

Commit

Permalink
use docker compose to build
Browse files Browse the repository at this point in the history
Signed-off-by: Daniel Estévez <[email protected]>
  • Loading branch information
daniestevez committed Nov 30, 2024
1 parent 6ab363c commit 5034567
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 30 deletions.
30 changes: 1 addition & 29 deletions .github/workflows/build-firmware.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,47 +6,20 @@ on:
tags:
- maia-sdr-*

# TODO: refactor this as a workflow_call action

jobs:
build-firmware:
strategy:
matrix:
target: [pluto, plutoplus]
name: Build firmware
runs-on: [self-hosted, vivado]
container:
image: ghcr.io/maia-sdr/maia-sdr-devel:latest
volumes:
- vivado2023_2:/opt/Xilinx
options: --user root
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Build firmware
# xsct, which is run by the make process, uses Xvfb, which usually needs a
# connection to an X server (even though it is a CLI application). We run
# Xvfb in the container to create a "fake" X session that makes xsct
# happy.
#
# We cannot '.' the main settings.sh file for Vivado, because it uses
# 'source' to run the sub-files, and we are not using bash. Instead, we
# '.' each individual sub-file.
run: |
. /opt/Xilinx/Vitis/2023.2/.settings64-Vitis.sh
. /opt/Xilinx/Vivado/2023.2/.settings64-Vivado.sh
. /opt/Xilinx/Vitis_HLS/2023.2/.settings64-Vitis_HLS.sh
. /opt/rust/env
export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin/:/usr/bin:/sbin:/bin:$PATH:/opt/oss-cad-suite/bin
export PYTHONPATH=/usr/local/lib/python3.10/dist-packages
apt-get update
DEBIAN_FRONTEND=noninteractive apt-get install -y xvfb
Xvfb :10 &
export DISPLAY=:10
export ADI_IGNORE_VERSION_CHECK=1
export TARGET=${{matrix.target}}
make
DOCKER_USER="$(id -u):$(id -g)" TARGET=${{matrix.target}} docker compose run --rm build
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
Expand All @@ -55,7 +28,6 @@ jobs:
build/*-fw-*.zip
build/*-jtag-bootstrap-*.zip
build/system_top.xsa
if-no-files-found: error
# The working directory in the self-hosted runner needs be cleaned before
# building. We use if: ${{ always() }} to clean even if the build fails.
- name: Clean up runner working dir
Expand Down
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,19 @@ for any topics which are not issues (general questions, comments, etc.).

Using the `ghcr.io/maia-sdr/maia-sdr-devel` Docker image from
[maia-sdr-docker](https://github.com/maia-sdr/maia-sdr-docker) is recommended to build
the firmware. To build the FPGA bitstream, Vivado 2022.2 is required.
the firmware. To build the FPGA bitstream, Vivado 2023.2 is required.

Once the environment variables and `PATH` have been set as indicated in the
[Docker container README](https://github.com/maia-sdr/maia-sdr-docker#readme),
the firmware can be built using
```
make
```

It is also possible to build using `docker compose` by running
```
DOCKER_USER="$(id -u):$(id -g)" TARGET=pluto docker compose run --rm build
```

## Pluto+

Expand Down
19 changes: 19 additions & 0 deletions build-docker.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/bash

set -euox pipefail

source /opt/Xilinx/Vitis/2023.2/.settings64-Vitis.sh
source /opt/Xilinx/Vivado/2023.2/.settings64-Vivado.sh
source /opt/Xilinx/Vitis_HLS/2023.2/.settings64-Vitis_HLS.sh
source /opt/rust/env
export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin/:/usr/bin:/sbin:/bin:$PATH:/opt/oss-cad-suite/bin
export PYTHONPATH=/usr/local/lib/python3.10/dist-packages

# xsct, which is run by the make process, uses Xvfb, which usually needs a
# connection to an X server (even though it is a CLI application). We run
# Xvfb in the container to create a "fake" X session that makes xsct
# happy.
Xvfb :10 &
export DISPLAY=:10

make -C /w
22 changes: 22 additions & 0 deletions compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
services:
build:
image: ghcr.io/maia-sdr/maia-sdr-devel:latest
pull_policy: always
volumes:
- vivado2023_2:/opt/Xilinx
- type: bind
source: $PWD
target: /w
environment:
- TARGET
entrypoint: /w/build-docker.sh
user: $DOCKER_USER
# https://github.com/moby/moby/issues/45436#issuecomment-1528752777
ulimits:
nofile:
soft: 1024
hard: 1048576

volumes:
vivado2023_2:
external: true

0 comments on commit 5034567

Please sign in to comment.