Files
gowin-toolchain/Makefile
2026-07-09 22:48:08 +02:00

55 lines
1.6 KiB
Makefile
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

DCK=podman
IMAGE_NAME=gowin
WORKDIR=.
DCK_VOLUMES=-v $(WORKDIR):/work
DCK_RUN=$(DCK) run $(DCK_VOLUMES) $(IMAGE_NAME)
DCK_RUN_IT=$(DCK) run $(DCK_VOLUMES) -it $(IMAGE_NAME)
RTL_DIR=RTL/
RTL_V=$(shell find $(RTL_DIR) -name *.v)
RTL_SV=$(shell find $(RTL_DIR) -name "*.sv")
RTL_SVV = $(patsubst %.sv,%.v,$(RTL_SV))
RTL_SOURCE=$(RTL_SVV) $(shell find $(RTL_DIR) -name "*.v")
DEVICE_PATH=$(shell lsusb | grep "0403:6010" | sed -E "s/Bus ([0-9]{3}) Device ([0-9]{3}).*/\/dev\/bus\/usb\/\1\/\2/g")
DCK_DEVICES=--device $(DEVICE_PATH)
.PHONY: build_image bash clean
## Build the container
build_image:
$(DCK) build -t $(IMAGE_NAME) .
## Get a bash shell inside the container
bash:
$(DCK_RUN_IT) /bin/bash
gw_sh:
$(DCK_RUN_IT) gw_sh
impl/pnr/build.fs: $(RTL_SVV) $(RTL_V) build.tcl
$(DCK_RUN) "RTL_FILES=\"$(shell find $(RTL_DIR) -name *.v)\" gw_sh build.tcl"
flash: impl/pnr/build.fs
if [ -z "$(DEVICE_PATH)" ]; then \
echo "Device not found."; \
else \
$(DCK) run --privileged --device /dev/bus/usb:/dev/bus/usb $(DCK_VOLUMES) gowin "openFPGALoader --freq 2500000 --board tangmega138k impl/pnr/build.fs"; \
fi
flash2:
$(DCK) run --privileged --device /dev/ttyUSB1:/dev/ttyUSB1 --device /dev/ttyUSB0:/dev/ttyUSB0 $(DCK_VOLUMES) gowin "openFPGALoader --cable ft2232 --freq 2500000 --board tangmega138k impl/pnr/build.fs"; \
help_o:
$(DCK) run --privileged --device /dev/ttyUSB1:/dev/ttyUSB1 --device /dev/ttyUSB0:/dev/ttyUSB0 $(DCK_VOLUMES) gowin "openFPGALoader --help"; \
%.v: %.sv
$(DCK_RUN) "sv2v --write=adjacent $<"
clean:
rm -rf $(RTL_SVV)
rm -rf impl