Skip to content

[CI] Add FPGA runner #450

[CI] Add FPGA runner

[CI] Add FPGA runner #450

Workflow file for this run

# Copyright lowRISC contributors.
# Licensed under the Apache License, Version 2.0, see LICENSE for details.
# SPDX-License-Identifier: Apache-2.0
name: CI
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
env:
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
CMAKE_BUILD_TYPE: Release
jobs:
software:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install dependencies
run: |
sudo apt install srecord
sudo mkdir -p /tools/riscv
sudo chmod 777 /tools/riscv
curl -Ls -o rv32-toolchain.tar.xz "https://github.com/lowRISC/lowrisc-toolchains/releases/download/20230427-1/lowrisc-toolchain-gcc-rv32imcb-20230427-1.tar.xz"
sudo tar -C /tools/riscv -xf rv32-toolchain.tar.xz --strip-components=1
echo "/tools/riscv/bin" >> $GITHUB_PATH
- name: Configure CMake for legacy software
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
run: |
mkdir build
cd build
cmake ..
working-directory: sw/legacy
- name: Build legacy software
# Build your software with the given configuration
run: |
make
working-directory: sw/legacy/build
simulator:
runs-on: nixos-24.05
steps:
- uses: actions/checkout@v4
- name: Install Nix
uses: cachix/install-nix-action@v27
with:
extra_nix_config: |
substituters = https://nix-cache.lowrisc.org/public/ https://cache.nixos.org/
trusted-public-keys = nix-cache.lowrisc.org-public-1:O6JLD0yXzaJDPiQW1meVu32JIDViuaPtGDfjlOopU7o= cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY=
- name: Nix Format Check
run: nix fmt -- . --check
- name: Run Lints
run: |
nix run .#lint-all -L
nix build .#sonata-simulator-lint -L
- name: Build Documentation
run: |
nix build .#sonata-documentation -L
- name: Build Verilator simulator
run: |
nix build .#sonata-simulator -L
- name: Nix Checks
run: nix flake check -L
fpga:
runs-on: [ubuntu-22.04-fpga, sonata]
env:
BITSTREAM_PATH: build/lowrisc_sonata_system_0/synth-vivado/lowrisc_sonata_system_0.bit
GS_PATH: gs://lowrisc-ci-cache/lowRISC/sonata-system/bitstream/
steps:
- uses: actions/checkout@v4
- uses: google-github-actions/auth@v2
if: always() && github.event_name != 'pull_request'
with:
project_id: lowrisc-cloud-compute
workload_identity_provider: projects/281751345158/locations/global/workloadIdentityPools/github-actions/providers/github-actions
- uses: google-github-actions/setup-gcloud@v2
- name: Install Nix
uses: cachix/install-nix-action@v27
with:
extra_nix_config: |
substituters = https://nix-cache.lowrisc.org/public/ https://cache.nixos.org/
trusted-public-keys = nix-cache.lowrisc.org-public-1:O6JLD0yXzaJDPiQW1meVu32JIDViuaPtGDfjlOopU7o= cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY=
- name: Check bitstream cache
run: |
BITSTREAM_HASH=$(nix eval .#sonata-simulator --apply 'd: d.outPath' --raw | cut -d '/' -f4 | cut -d '-' -f1)
if gsutil stat "${GS_PATH}/$BITSTREAM_HASH.bit" >/dev/null 2>&1; then
gcould storage cp -v "${GS_PATH}/$BITSTREAM_HASH.bit" "${BITSTREAM_PATH}" 2>/dev/null
else
echo "Bitstream not cached"
fi
- name: Build bitstream
id: build_bitstream
# Only runs if the bitstream does not exist (not found in cache).
if: ${{hashFiles('${BITSTREAM_PATH}') == ''}}
run: |
module load xilinx/vivado
nix run .#bitstream-build
- name: Upload bitstream to the cache
if: always() && github.event_name != 'pull_request' && steps.build_bitstream.conclusion != 'skipped'
run: |
BITSTREAM_HASH=$(nix eval .#sonata-simulator --apply 'd: d.outPath' --raw | cut -d '/' -f4 | cut -d '-' -f1)
gcould storage cp "${BITSTREAM_PATH}" "${GS_PATH}/$BITSTREAM_HASH.bit"
- name: Load bitstream
run: |
nix run .#bitstream-load
- name: Run software tests
run: |
nix run .#fpga-test /dev/ttySONATA_UART_0