fix(efinity): fail early when toolchain is missing

This commit is contained in:
onur cayan
2026-08-13 01:47:09 +03:00
parent 1dbd1b5151
commit 584a69302a
5 changed files with 104 additions and 31 deletions
+70 -19
View File
@@ -1,6 +1,7 @@
SHELL := /bin/bash
.SHELLFLAGS := -euo pipefail -c
.ONESHELL:
.NOTPARALLEL: detect interface map bitstream program-fpga program-flash-loader
FPGA_DIR := $(abspath $(dir $(lastword $(MAKEFILE_LIST))))
REPO_DIR := $(abspath $(FPGA_DIR)/../../..)
@@ -85,7 +86,8 @@ OPENOCD_CFG ?= $(DEBUG_DIR)/openocd_ti375c529_bscan.cfg
GDB_LOAD_SCRIPT ?= $(DEBUG_DIR)/gdb_load_and_run.gdb
GDB_ATTACH_SCRIPT ?= $(DEBUG_DIR)/gdb_attach.gdb
.PHONY: help all fpga-config detect software chisel rtl soc interface map bitstream \
.PHONY: help all fpga-config efinity-build-check efinity-program-check \
detect software chisel rtl soc interface map bitstream \
program-fpga debug-openocd debug-load debug-gdb uart-listen \
flash-image flash-regions program-flash program-flash-elf \
program-flash-bitstream program-flash-regions program-flash-all \
@@ -116,12 +118,34 @@ help:
all: bitstream
efinity-build-check:
@if [[ -z "$(strip $(EFINITY_HOME))" ]]; then
echo "Efinity installation not found." >&2
echo "Install Efinity 2025.2, then set EFINITY_HOME=/path/to/efinity/2025.2." >&2
echo "Searched /tools/efinix/efinity, /opt, \$$HOME, and tools/local/efinity." >&2
exit 1
fi
for required in "$(EFINITY_SETUP)" "$(EFX_RUN)"; do
if [[ ! -r "$$required" ]]; then
echo "Incomplete Efinity installation: missing $$required" >&2
echo "Set EFINITY_HOME to the directory containing bin/setup.sh." >&2
exit 1
fi
done
efinity-program-check: efinity-build-check
@if [[ ! -x "$(EFX_PGM)" ]]; then
echo "Incomplete Efinity installation: missing $(EFX_PGM)" >&2
exit 1
fi
fpga-config:
@printf '%s\n' \
'Ti375C529 FPGA config:' \
' EFINITY_HOME=$(EFINITY_HOME)' \
' EFX_RUN=$(EFX_RUN)' \
' EFX_PGM=$(EFX_PGM)' \
' EFINITY_HOME=$(if $(strip $(EFINITY_HOME)),$(EFINITY_HOME),NOT FOUND)' \
' EFINITY_SETUP=$(if $(strip $(EFINITY_SETUP)),$(EFINITY_SETUP),NOT FOUND)' \
' EFX_RUN=$(if $(strip $(EFX_RUN)),$(EFX_RUN),NOT FOUND)' \
' EFX_PGM=$(if $(strip $(EFX_PGM)),$(EFX_PGM),NOT FOUND)' \
' OPENOCD=$(OPENOCD)' \
' GDB=$(GDB)' \
' DEVICE=$(DEVICE)' \
@@ -146,9 +170,12 @@ fpga-config:
' UART_PORT=$(UART_PORT)' \
' UART_BAUD=$(UART_BAUD)'
detect:
detect: efinity-program-check
@set +u
source "$(EFINITY_SETUP)" >/dev/null 2>&1
if ! source "$(EFINITY_SETUP)" >/dev/null; then
echo "Failed to initialize Efinity from $(EFINITY_SETUP)" >&2
exit 1
fi
set -u
"$(EFX_PGM)" --scan_usb
@@ -258,31 +285,40 @@ soc: rtl
$(INTERFACE_SCRIPT): $(INTERFACE_SOURCE)
cp "$<" "$@"
interface: $(INTERFACE_SCRIPT)
interface: efinity-build-check $(INTERFACE_SCRIPT)
@mkdir -p "$(LOG_DIR)"
cd "$(FLOW_DIR)"
# Efinity prefers a matching generated .peri.xml over the source .isf.
# Remove it so pin/PLL changes in the checked-in interface script are applied.
rm -f "$(FLOW_DIR)/ti375c529_rocket.peri.xml"
set +u
source "$(EFINITY_SETUP)" >/dev/null 2>&1
if ! source "$(EFINITY_SETUP)" >/dev/null; then
echo "Failed to initialize Efinity from $(EFINITY_SETUP)" >&2
exit 1
fi
set -u
python3 "$(EFX_RUN)" "$(PROJECT_XML)" --flow interface --un_flow \
--pt_opts "peri_scripts=$(INTERFACE_SCRIPT)" 2>&1 | tee "$(LOG_DIR)/interface.log"
map: rtl interface
map: efinity-build-check rtl interface
@mkdir -p "$(LOG_DIR)"
cd "$(FLOW_DIR)"
set +u
source "$(EFINITY_SETUP)" >/dev/null 2>&1
if ! source "$(EFINITY_SETUP)" >/dev/null; then
echo "Failed to initialize Efinity from $(EFINITY_SETUP)" >&2
exit 1
fi
set -u
python3 "$(EFX_RUN)" "$(PROJECT_XML)" --flow map 2>&1 | tee "$(LOG_DIR)/map.log"
bitstream: rtl interface
bitstream: efinity-build-check rtl interface
@mkdir -p "$(LOG_DIR)" "$(dir $(BIT_FILE))"
cd "$(FLOW_DIR)"
set +u
source "$(EFINITY_SETUP)" >/dev/null 2>&1
if ! source "$(EFINITY_SETUP)" >/dev/null; then
echo "Failed to initialize Efinity from $(EFINITY_SETUP)" >&2
exit 1
fi
set -u
: > "$(LOG_DIR)/full.log"
python3 "$(EFX_RUN)" "$(PROJECT_XML)" --flow map 2>&1 | tee -a "$(LOG_DIR)/full.log"
@@ -306,14 +342,17 @@ bitstream: rtl interface
fi
printf 'Bitstream: %s\nConfiguration HEX: %s\n' "$(BIT_FILE)" "$(CONFIG_HEX)"
program-fpga:
program-fpga: efinity-program-check
@if [[ ! -f "$(BIT_FILE)" ]]; then
echo "Missing bitstream: $(BIT_FILE)" >&2
echo "Run: make -C $(FPGA_DIR) bitstream" >&2
exit 1
fi
set +u
source "$(EFINITY_SETUP)" >/dev/null 2>&1
if ! source "$(EFINITY_SETUP)" >/dev/null; then
echo "Failed to initialize Efinity from $(EFINITY_SETUP)" >&2
exit 1
fi
set -u
ftdi_args=()
if [[ -n "$(FTDI_URL)" ]]; then
@@ -365,13 +404,16 @@ flash-regions: software
--app-hex "$(APP_HEX)" \
--manifest "$(FLASH_MANIFEST)"
program-flash-loader:
program-flash-loader: efinity-program-check
@if [[ ! -f "$(FLASH_LOADER)" ]]; then
echo "Missing Ti375 JTAG-to-SPI loader: $(FLASH_LOADER)" >&2
exit 1
fi
set +u
source "$(EFINITY_SETUP)" >/dev/null 2>&1
if ! source "$(EFINITY_SETUP)" >/dev/null; then
echo "Failed to initialize Efinity from $(EFINITY_SETUP)" >&2
exit 1
fi
set -u
ftdi_args=()
if [[ -n "$(FTDI_URL)" ]]; then
@@ -382,7 +424,10 @@ program-flash-loader:
program-flash program-flash-elf program-app: flash-regions
@$(MAKE) -C "$(FPGA_DIR)" program-flash-loader
set +u
source "$(EFINITY_SETUP)" >/dev/null 2>&1
if ! source "$(EFINITY_SETUP)" >/dev/null; then
echo "Failed to initialize Efinity from $(EFINITY_SETUP)" >&2
exit 1
fi
set -u
ftdi_args=()
if [[ -n "$(FTDI_URL)" ]]; then
@@ -400,7 +445,10 @@ program-flash-bitstream program-bitstream:
fi
$(MAKE) -C "$(FPGA_DIR)" program-flash-loader
set +u
source "$(EFINITY_SETUP)" >/dev/null 2>&1
if ! source "$(EFINITY_SETUP)" >/dev/null; then
echo "Failed to initialize Efinity from $(EFINITY_SETUP)" >&2
exit 1
fi
set -u
ftdi_args=()
if [[ -n "$(FTDI_URL)" ]]; then
@@ -413,7 +461,10 @@ program-flash-bitstream program-bitstream:
program-flash-regions program-flash-all program-flash-combined: flash-image
@$(MAKE) -C "$(FPGA_DIR)" program-flash-loader
set +u
source "$(EFINITY_SETUP)" >/dev/null 2>&1
if ! source "$(EFINITY_SETUP)" >/dev/null; then
echo "Failed to initialize Efinity from $(EFINITY_SETUP)" >&2
exit 1
fi
set -u
ftdi_args=()
if [[ -n "$(FTDI_URL)" ]]; then