FPGA: Added workflow for PM5 fpga build.

This commit is contained in:
dxl committed 2026-10-12 14:27:50 +08:00
1 parent 431cded61e
commit 2802fd1b48
2 files changed
+92 -2

No files matched your search

+87
View File
@@ -0,0 +1,87 @@
name: FPGA PM5 Build
on:
push:
paths:
- 'fpga/**'
- '.github/workflows/fpga-pm5.yml'
pull_request:
paths:
- 'fpga/**'
- '.github/workflows/fpga-pm5.yml'
workflow_dispatch:
env:
# oss-cad-suite is released daily; bump the date to move to a newer one.
OSS_CAD_SUITE_VERSION: '2026-10-11'
permissions:
contents: read
jobs:
pm5:
name: Build PM5 bitstream
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Install oss-cad-suite
run: |
set -euo pipefail
url="https://github.com/YosysHQ/oss-cad-suite-build/releases/download/${OSS_CAD_SUITE_VERSION}/oss-cad-suite-linux-x64-${OSS_CAD_SUITE_VERSION//-/}.tgz"
echo "Fetching $url"
curl -sSL "$url" | tar -xz -C "$RUNNER_TEMP"
# the makefile puts the suite's bin/, lib/ and bundled python3 in
# front of PATH itself, so nothing else needs to be exported
echo "OSS_CAD_SUITE=$RUNNER_TEMP/oss-cad-suite" >> "$GITHUB_ENV"
- name: Show the toolchain
run: |
set -euo pipefail
# the same resolution the build uses, then the versions for the log
make -C fpga -f proxmark5_fpga.mk check-tools
set +u
source "$OSS_CAD_SUITE/environment"
set -u
yosys -V
nextpnr-himbaechel --version
python3 -c "import apycula; print('apycula:', apycula.__file__)"
# Place and route fails the job on a timing violation, so this does not
# only prove the design still elaborates.
- name: Build the PM5 bitstream
run: make -C fpga pm5
- name: Check the bitstream
run: |
set -euo pipefail
bin_size=$(stat -c%s fpga/fpga_pm5.bin)
fs_size=$(stat -c%s fpga/fpga_pm5.fs)
echo "fpga_pm5.bin ${bin_size} bytes"
echo "fpga_pm5.fs ${fs_size} bytes"
# the .bin is the bitstream the ARM JTAG loader shifts out, the .fs is
# its ASCII form: 8 characters plus a newline per byte
test "$bin_size" -gt 100000
test "$fs_size" -gt $((bin_size * 6))
test "$fs_size" -lt $((bin_size * 10))
# A rebuild from scratch has to produce the same bytes; the tools carry no
# timestamp, so a difference means something started leaking one in, and
# a released bitstream could no longer be checked against the sources.
- name: Check the build is reproducible
run: |
set -euo pipefail
md5sum fpga/fpga_pm5.fs fpga/fpga_pm5.bin > "$RUNNER_TEMP/bitstream.md5"
make -C fpga -f proxmark5_fpga.mk clean
make -C fpga pm5
md5sum -c "$RUNNER_TEMP/bitstream.md5"
- name: Upload the bitstream
uses: actions/upload-artifact@v6
with:
name: fpga-pm5-bitstream
path: |
fpga/fpga_pm5.fs
fpga/fpga_pm5.bin
if-no-files-found: error
+5 -2
View File
@@ -43,9 +43,12 @@ PM5_OUT = $(PREFIX)build_$(PM5_NAME)
# The oss-cad-suite launchers need their root, and both bin/ and lib/ on PATH
# (lib/ carries the shared libraries), otherwise they exit without a message.
# The suite bundles its own python, named per platform. With OSS_CAD_SUITE
# unset everything comes from PATH instead, which is what sourcing the suite's
# environment script gives you.
ifneq ($(OSS_CAD_SUITE),)
OC_ENV = YOSYSHQ_ROOT="$(OSS_CAD_SUITE)/" PATH="$(OSS_CAD_SUITE)/bin:$(OSS_CAD_SUITE)/lib:$$PATH" PYTHON_EXECUTABLE="$(OSS_CAD_SUITE)/lib/python3.exe"
OC_PYTHON = $(OSS_CAD_SUITE)/lib/python3.exe
OC_PYTHON = $(firstword $(wildcard $(OSS_CAD_SUITE)/lib/python3.exe $(OSS_CAD_SUITE)/py3bin/python3 $(OSS_CAD_SUITE)/lib/python3 $(OSS_CAD_SUITE)/bin/python3) python3)
OC_ENV = YOSYSHQ_ROOT="$(OSS_CAD_SUITE)/" PATH="$(OSS_CAD_SUITE)/bin:$(OSS_CAD_SUITE)/lib:$$PATH" LD_LIBRARY_PATH="$(OSS_CAD_SUITE)/lib:$$LD_LIBRARY_PATH" PYTHON_EXECUTABLE="$(OC_PYTHON)"
else
OC_ENV =
OC_PYTHON = python3