From 1cc903f20fc4917b24bae4dd5c80775e29911c0a Mon Sep 17 00:00:00 2001 From: supersurviveur Date: Wed, 10 Jun 2026 12:29:14 +0200 Subject: [PATCH] fix: Rebuild docker image using newer versions and add a Makefile. --- .gitignore | 1 + Containerfile | 20 ++++++++++--------- Makefile | 49 +++++++++++++++++++++++++++++++++++++++++++++++ example/README.md | 12 ++++++------ 4 files changed, 67 insertions(+), 15 deletions(-) create mode 100644 .gitignore create mode 100644 Makefile diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..1baf833 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +abc.history diff --git a/Containerfile b/Containerfile index 363da31..6654974 100644 --- a/Containerfile +++ b/Containerfile @@ -2,10 +2,10 @@ FROM alpine:edge AS builder # Update databases RUN echo "https://dl-cdn.alpinelinux.org/alpine/edge/testing" >> /etc/apk/repositories && \ - apk update + apk update --no-cache # Download base dependencies -RUN apk add \ +RUN apk add --no-cache \ git \ make \ cmake \ @@ -24,10 +24,11 @@ RUN apk add \ cython \ py3-yaml \ py3-simplejson \ - py3-intervaltree + py3-intervaltree \ + libunwind-dev # Install yosys -RUN apk add yosys +RUN apk add --no-cache yosys WORKDIR /home/root/aur-install @@ -99,8 +100,8 @@ FROM alpine:edge # Install dependencies available in apk RUN echo "https://dl-cdn.alpinelinux.org/alpine/edge/testing" >> /etc/apk/repositories && \ - apk update && \ - apk add abc py3-yaml py3-simplejson py3-intervaltree py3-arpeggio openfpgaloader + apk update --no-cache && \ + apk add --no-cache abc py3-yaml py3-simplejson py3-intervaltree py3-arpeggio openfpgaloader # Get dependencies back COPY --from=builder /dependencies / @@ -112,9 +113,10 @@ COPY --from=builder /home/root/aur-install/nextpnr/build/share /usr/share/nextpn COPY --from=builder /usr/share/xray/database/zynq7 /usr/share/xray/database/zynq7 # These 3 python dependencies were built in the previous image -COPY --from=builder /usr/lib/python3.12/site-packages/prjxray /usr/lib/python3.12/site-packages/prjxray -COPY --from=builder /usr/lib/python3.12/site-packages/fasm /usr/lib/python3.12/site-packages/fasm -COPY --from=builder /usr/lib/python3.12/site-packages/textx /usr/lib/python3.12/site-packages/textx +# COPY --from=builder /usr/lib/python3.14/site-packages/prjxray /usr/lib/python3.14/site-packages/prjxray +# COPY --from=builder /usr/lib/python3.14/site-packages/fasm /usr/lib/python3.14/site-packages/fasm +# COPY --from=builder /usr/lib/python3.14/site-packages/textx /usr/lib/python3.14/site-packages/textx +COPY --from=builder /usr/lib/python3.14/site-packages /usr/lib/python3.14/site-packages/ WORKDIR /root/code diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..b90558b --- /dev/null +++ b/Makefile @@ -0,0 +1,49 @@ +PODMAN_RUN=podman run --mount=type=bind,source=.,target=/root/code +PODMAN_IMAGE=localhost/fmn-toolchain +PODMAN=$(PODMAN_RUN) $(PODMAN_IMAGE) +BUILD=build + +create-image: + podman build -t fmn-toolchain . + +run: + podman run --rm localhost/fmn-toolchain + +CONSTRAINTS=example/adder.xdc +SYSTEM_VERILOG=$(shell find example -name "*.sv") +VERILOG=$(shell find example -name "*.v") +SOURCES=$(patsubst %,$(BUILD)/%,$(VERILOG)) $(patsubst %.sv,$(BUILD)/%.v,$(SYSTEM_VERILOG)) + +$(BUILD): + mkdir -p $(BUILD) + +$(BUILD)/%.v: %.sv + mkdir -p $(dir $@) + $(PODMAN) sv2v $^ -w $@ + +$(BUILD)/%.v: %.v + mkdir -p $(dir $@) + cp $^ $@ + +$(BUILD)/synthesis.json: $(SOURCES) + $(PODMAN) yosys $^ -p "synth_xilinx; write_json $@" + +$(BUILD)/out.fasm: $(BUILD)/synthesis.json + $(PODMAN) nextpnr-himbaechel --json $(filter %.json,$^) -o xdc=$(CONSTRAINTS) -o fasm=$@ --device xc7z010clg400-1 + +$(BUILD)/out.frames: $(BUILD)/out.fasm + $(PODMAN) fasm2frames --part xc7z010clg400-1 --db-root /usr/share/xray/database/zynq7 $^ $@ + +$(BUILD)/out.bin: $(BUILD)/out.frames + $(PODMAN) xc7frames2bit -frm_file $^ -part_file /usr/share/xray/database/zynq7/xc7z010clg400-1/part.yaml --output_file $@ + +bitstream: $(BUILD) $(BUILD)/out.bin + +flash: bitstream + $(eval USB = $(shell lsusb -d 0403:6010 | sed -E "s/Bus ([0-9]{3}) Device ([0-9]{3}).*/\/dev\/bus\/usb\/\1\/\2/g")) + @if [ "$(USB)" = "" ]; then \ + echo "No USB device found !"; \ + else \ + $(PODMAN_RUN) --device=$(USB) \ + $(PODMAN_IMAGE) openFPGALoader -b zybo_z7_10 $(BUILD)/out.bin; \ + fi diff --git a/example/README.md b/example/README.md index ea8d80a..37a80f6 100644 --- a/example/README.md +++ b/example/README.md @@ -7,7 +7,7 @@ This directory shows how to flash a SystemVerilog program (a full-adder) on a Zy Firstly, the SystemVerilog file needs to be converted to verilog to use it with Yosys : ```bash -podman run --mount=type=bind,source=.,target=/root/code fmn_alpine sv2v adder.sv -w adder.v +podman run --mount=type=bind,source=.,target=/root/code localhost/fmn-toolchain sv2v adder.sv -w adder.v ``` The mount parameter is used to provide the current directory to podman. @@ -15,20 +15,20 @@ The mount parameter is used to provide the current directory to podman. Then, Yosys can perform the RTL synthesis of the program : ```bash -podman run --mount=type=bind,source=.,target=/root/code fmn_alpine yosys adder.v -p "synth_xilinx; write_json synthesis.json" +podman run --mount=type=bind,source=.,target=/root/code localhost/fmn-toolchain yosys adder.v -p "synth_xilinx; write_json synthesis.json" ``` Nextpnr can now place and route each component using the XDC constraints file : ```bash -podman run --mount=type=bind,source=.,target=/root/code fmn_alpine nextpnr-himbaechel --json synthesis.json -o xdc=adder.xdc -o fasm=out.fasm --device xc7z010clg400-1 +podman run --mount=type=bind,source=.,target=/root/code localhost/fmn-toolchain nextpnr-himbaechel --json synthesis.json -o xdc=adder.xdc -o fasm=out.fasm --device xc7z010clg400-1 ``` Now the FASM file can be converted to a frames file and then to a bitstream : ```bash -podman run --mount=type=bind,source=.,target=/root/code fmn_alpine fasm2frames --part xc7z010clg400-1 --db-root /usr/share/xray/database/zynq7 out.fasm out.frames -podman run --mount=type=bind,source=.,target=/root/code fmn_alpine xc7frames2bit -frm_file out.frames -part_file /usr/share/xray/database/zynq7/xc7z010clg400-1/part.yaml --output_file out.bin +podman run --mount=type=bind,source=.,target=/root/code localhost/fmn-toolchain fasm2frames --part xc7z010clg400-1 --db-root /usr/share/xray/database/zynq7 out.fasm out.frames +podman run --mount=type=bind,source=.,target=/root/code localhost/fmn-toolchain xc7frames2bit -frm_file out.frames -part_file /usr/share/xray/database/zynq7/xc7z010clg400-1/part.yaml --output_file out.bin ``` ## Flashing the FPGA @@ -44,5 +44,5 @@ Bus 003 Device 005: ID 0403:6010 Future Technology Devices International, Ltd FT Here the usb device path is `/dev/bus/usb/003/005` ```bash -podman run --device=/dev/bus/usb/003/005 --mount=type=bind,source=.,target=/root/code fmn_alpine openFPGALoader -b zybo_z7_10 out.bin +podman run --device=/dev/bus/usb/003/005 --mount=type=bind,source=.,target=/root/code localhost/fmn-toolchain openFPGALoader -b zybo_z7_10 out.bin ```