From f134ddc2f291e478df22070dbe24e93907646121 Mon Sep 17 00:00:00 2001 From: MarianSentiment Date: Thu, 20 Nov 2025 03:17:31 +0200 Subject: [PATCH] New speedrun strat: vivado skip --- .devcontainer/openfpgatoolchain/Dockerfile | 92 +++++++++++++++++++ .../openfpgatoolchain/Dockerfile.alp | 35 +++++++ .devcontainer/openfpgatoolchain/entry.sh | 8 ++ synth_and_flash.sh | 7 ++ 4 files changed, 142 insertions(+) create mode 100644 .devcontainer/openfpgatoolchain/Dockerfile create mode 100644 .devcontainer/openfpgatoolchain/Dockerfile.alp create mode 100644 .devcontainer/openfpgatoolchain/entry.sh create mode 100755 synth_and_flash.sh diff --git a/.devcontainer/openfpgatoolchain/Dockerfile b/.devcontainer/openfpgatoolchain/Dockerfile new file mode 100644 index 00000000..3d9d5626 --- /dev/null +++ b/.devcontainer/openfpgatoolchain/Dockerfile @@ -0,0 +1,92 @@ +# Image used in the pipeline of prjxray +FROM ubuntu:focal + +# Make will not work for prjxray unless this env is set +ENV ALLOW_ROOT=true + +# prjxray dependencies +RUN DEBIAN_FRONTEND=noninteractive apt update -qq + +RUN DEBIAN_FRONTEND=noninteractive apt install -qq -y \ + bash \ + bison \ + build-essential \ + ca-certificates \ + clang-format \ + cmake \ + colordiff \ + coreutils \ + flex \ + git \ + pypy3 \ + iproute2 \ + iputils-ping \ + libtinfo5 \ + netcat-openbsd \ + psmisc \ + python3 \ + python3-dev \ + python3-venv \ + xsltproc \ + sudo \ + bash bison build-essential ca-certificates clang-format cmake psmisc \ + colordiff coreutils git flex python3 python3-dev python3-venv xsltproc libtinfo5 libboost-all-dev libeigen3-dev \ + gzip \ + libftdi1-2 \ + libftdi1-dev \ + libhidapi-hidraw0 \ + libhidapi-dev \ + libudev-dev \ + zlib1g-dev \ + cmake \ + pkg-config \ + make \ + g++ \ + udev + + +# Open synthesys suite +RUN DEBIAN_FRONTEND=noninteractive apt install -qq -y yosys +# Open place-n-route tool (fork for xillinx devices) +RUN git clone https://github.com/gatecat/nextpnr-xilinx /root/nextpnr-xillinx +# Open chipdb generation tool +RUN git clone https://github.com/f4pga/prjxray /root/prjxray +# Open fpga flashing tool +RUN git clone https://github.com/trabucayre/openFPGALoader /root/openFPGALoader + +WORKDIR /root/prjxray +RUN git submodule update --init --recursive +RUN make build -j$(nproc) +RUN sed -i '/# Vivado v2017\.2 (64-bit)/c return' utils/environment.sh +RUN make env +RUN ./download-latest-db.sh + +WORKDIR /root/nextpnr-xillinx +RUN git submodule update --init --recursive + +RUN cmake -DARCH=xilinx . +RUN make -j$(nproc) +RUN cp nextpnr-xilinx /usr/bin/ + +# Build chipdb for xc7a100t-1csg324 +RUN pypy3 xilinx/python/bbaexport.py --device xc7a100tcsg324-1 --bba xilinx/xc7a100t.bba +RUN mkdir /root/chipdb && ./bba/bbasm --l xilinx/xc7a100t.bba /root/chipdb/xc7a100t.bin + + +WORKDIR /root/openFPGALoader +RUN mkdir build +WORKDIR build +RUN cmake .. +RUN cmake --build . + +RUN make install +WORKDIR .. +RUN cp 99-openfpgaloader.rules /etc/udev/rules.d/ +# RUN udevadm control --reload-rules && sudo udevadm trigger +ENV XRAY_DIR=/root/prjxray + + +WORKDIR /work +COPY entry.sh /entry.sh +RUN chmod +x /entry.sh +ENTRYPOINT ["/entry.sh"] \ No newline at end of file diff --git a/.devcontainer/openfpgatoolchain/Dockerfile.alp b/.devcontainer/openfpgatoolchain/Dockerfile.alp new file mode 100644 index 00000000..0e6a0008 --- /dev/null +++ b/.devcontainer/openfpgatoolchain/Dockerfile.alp @@ -0,0 +1,35 @@ +FROM alpine:latest + +RUN apk add --no-cache \ + bash \ + bison \ + build-base \ + ca-certificates \ + clang-extra-tools \ + cmake \ + colordiff \ + coreutils \ + flex \ + git \ + iproute2 \ + iputils \ + ncurses-libs \ + netcat-openbsd \ + psmisc \ + python3 \ + python3-dev \ + libxslt \ + sudo \ + boost-dev \ + eigen-dev + +RUN apk add build-base openssl-dev zlib-dev bzip2-dev readline-dev sqlite-dev \ + libffi-dev ncurses-dev xz-dev +RUN curl https://pyenv.run | sh + +RUN git clone https://github.com/f4pga/prjxray /root/prjxray +WORKDIR /root/prjxray +RUN git submodule update --init --recursive +ENV ALLOW_ROOT=true +RUN make build -j$(nproc) +RUN make env \ No newline at end of file diff --git a/.devcontainer/openfpgatoolchain/entry.sh b/.devcontainer/openfpgatoolchain/entry.sh new file mode 100644 index 00000000..10f2ec2e --- /dev/null +++ b/.devcontainer/openfpgatoolchain/entry.sh @@ -0,0 +1,8 @@ +#!/bin/bash +yosys -p "synth_xilinx -flatten -nowidelut -arch xc7 -top $TOP; write_json $TOP.json" $(echo *.v) +/usr/bin/nextpnr-xilinx --chipdb /root/chipdb/xc7a100t.bin --xdc $TOP.xdc --json $TOP.json --write "${TOP}_routed.json" --fasm $TOP.fasm + +source "${XRAY_DIR}/utils/environment.sh" + +"${XRAY_UTILS_DIR}/fasm2frames.py" --db-root "${XRAY_DATABASE_DIR}/artix7" --part xc7a100tcsg324-1 $TOP.fasm > $TOP.frames +"${XRAY_TOOLS_DIR}/xc7frames2bit" --part_file "${XRAY_DATABASE_DIR}/artix7/xc7a100tcsg324-1/part.yaml" --part_name xc7a100tcsg324-1 --frm_file $TOP.frames --output_file $TOP.bit diff --git a/synth_and_flash.sh b/synth_and_flash.sh new file mode 100755 index 00000000..84eba6e3 --- /dev/null +++ b/synth_and_flash.sh @@ -0,0 +1,7 @@ +#!/bin/bash +filename=$(basename -- "$1") +TOP="${filename%.*}" +CWD=$(dirname -- "$1") +cd $CWD +docker run -it -v .:/work openfpgatoolchain $TOP +openFPGALoader -b arty_a7_100t $TOP.bit \ No newline at end of file