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
+6 -3
View File
@@ -560,9 +560,12 @@ interface: SPIx4
### Ti375C529 Efinity build ve flash ### Ti375C529 Efinity build ve flash
Efinity varsayilan olarak `/tools/efinix/efinity` altinda aranir. Farkli bir Efinity `/tools/efinix/efinity`, `/opt`, kullanici dizini ve
kurulum `EFINITY_HOME=/path/to/efinity` ile secilebilir. Build, SRAM'e gecici `tools/local/efinity` altinda aranir. Farkli bir kurulum
programlama ve kart tespiti kokten su sekilde yapilir: `EFINITY_HOME=/path/to/efinity/2025.2` ile secilebilir. `fpga-bitstream`, uzun
RTL elaborasyonundan once kurulumdaki `bin/setup.sh` ve `scripts/efx_run.py`
dosyalarini kontrol eder. Build, SRAM'e gecici programlama ve kart tespiti
kokten su sekilde yapilir:
```sh ```sh
make FPGA_BOARD=ti375c529 fpga-config make FPGA_BOARD=ti375c529 fpga-config
+70 -19
View File
@@ -1,6 +1,7 @@
SHELL := /bin/bash SHELL := /bin/bash
.SHELLFLAGS := -euo pipefail -c .SHELLFLAGS := -euo pipefail -c
.ONESHELL: .ONESHELL:
.NOTPARALLEL: detect interface map bitstream program-fpga program-flash-loader
FPGA_DIR := $(abspath $(dir $(lastword $(MAKEFILE_LIST)))) FPGA_DIR := $(abspath $(dir $(lastword $(MAKEFILE_LIST))))
REPO_DIR := $(abspath $(FPGA_DIR)/../../..) 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_LOAD_SCRIPT ?= $(DEBUG_DIR)/gdb_load_and_run.gdb
GDB_ATTACH_SCRIPT ?= $(DEBUG_DIR)/gdb_attach.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 \ program-fpga debug-openocd debug-load debug-gdb uart-listen \
flash-image flash-regions program-flash program-flash-elf \ flash-image flash-regions program-flash program-flash-elf \
program-flash-bitstream program-flash-regions program-flash-all \ program-flash-bitstream program-flash-regions program-flash-all \
@@ -116,12 +118,34 @@ help:
all: bitstream 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: fpga-config:
@printf '%s\n' \ @printf '%s\n' \
'Ti375C529 FPGA config:' \ 'Ti375C529 FPGA config:' \
' EFINITY_HOME=$(EFINITY_HOME)' \ ' EFINITY_HOME=$(if $(strip $(EFINITY_HOME)),$(EFINITY_HOME),NOT FOUND)' \
' EFX_RUN=$(EFX_RUN)' \ ' EFINITY_SETUP=$(if $(strip $(EFINITY_SETUP)),$(EFINITY_SETUP),NOT FOUND)' \
' EFX_PGM=$(EFX_PGM)' \ ' EFX_RUN=$(if $(strip $(EFX_RUN)),$(EFX_RUN),NOT FOUND)' \
' EFX_PGM=$(if $(strip $(EFX_PGM)),$(EFX_PGM),NOT FOUND)' \
' OPENOCD=$(OPENOCD)' \ ' OPENOCD=$(OPENOCD)' \
' GDB=$(GDB)' \ ' GDB=$(GDB)' \
' DEVICE=$(DEVICE)' \ ' DEVICE=$(DEVICE)' \
@@ -146,9 +170,12 @@ fpga-config:
' UART_PORT=$(UART_PORT)' \ ' UART_PORT=$(UART_PORT)' \
' UART_BAUD=$(UART_BAUD)' ' UART_BAUD=$(UART_BAUD)'
detect: detect: efinity-program-check
@set +u @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 set -u
"$(EFX_PGM)" --scan_usb "$(EFX_PGM)" --scan_usb
@@ -258,31 +285,40 @@ soc: rtl
$(INTERFACE_SCRIPT): $(INTERFACE_SOURCE) $(INTERFACE_SCRIPT): $(INTERFACE_SOURCE)
cp "$<" "$@" cp "$<" "$@"
interface: $(INTERFACE_SCRIPT) interface: efinity-build-check $(INTERFACE_SCRIPT)
@mkdir -p "$(LOG_DIR)" @mkdir -p "$(LOG_DIR)"
cd "$(FLOW_DIR)" cd "$(FLOW_DIR)"
# Efinity prefers a matching generated .peri.xml over the source .isf. # 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. # Remove it so pin/PLL changes in the checked-in interface script are applied.
rm -f "$(FLOW_DIR)/ti375c529_rocket.peri.xml" rm -f "$(FLOW_DIR)/ti375c529_rocket.peri.xml"
set +u 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 set -u
python3 "$(EFX_RUN)" "$(PROJECT_XML)" --flow interface --un_flow \ python3 "$(EFX_RUN)" "$(PROJECT_XML)" --flow interface --un_flow \
--pt_opts "peri_scripts=$(INTERFACE_SCRIPT)" 2>&1 | tee "$(LOG_DIR)/interface.log" --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)" @mkdir -p "$(LOG_DIR)"
cd "$(FLOW_DIR)" cd "$(FLOW_DIR)"
set +u 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 set -u
python3 "$(EFX_RUN)" "$(PROJECT_XML)" --flow map 2>&1 | tee "$(LOG_DIR)/map.log" 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))" @mkdir -p "$(LOG_DIR)" "$(dir $(BIT_FILE))"
cd "$(FLOW_DIR)" cd "$(FLOW_DIR)"
set +u 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 set -u
: > "$(LOG_DIR)/full.log" : > "$(LOG_DIR)/full.log"
python3 "$(EFX_RUN)" "$(PROJECT_XML)" --flow map 2>&1 | tee -a "$(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 fi
printf 'Bitstream: %s\nConfiguration HEX: %s\n' "$(BIT_FILE)" "$(CONFIG_HEX)" printf 'Bitstream: %s\nConfiguration HEX: %s\n' "$(BIT_FILE)" "$(CONFIG_HEX)"
program-fpga: program-fpga: efinity-program-check
@if [[ ! -f "$(BIT_FILE)" ]]; then @if [[ ! -f "$(BIT_FILE)" ]]; then
echo "Missing bitstream: $(BIT_FILE)" >&2 echo "Missing bitstream: $(BIT_FILE)" >&2
echo "Run: make -C $(FPGA_DIR) bitstream" >&2 echo "Run: make -C $(FPGA_DIR) bitstream" >&2
exit 1 exit 1
fi fi
set +u 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 set -u
ftdi_args=() ftdi_args=()
if [[ -n "$(FTDI_URL)" ]]; then if [[ -n "$(FTDI_URL)" ]]; then
@@ -365,13 +404,16 @@ flash-regions: software
--app-hex "$(APP_HEX)" \ --app-hex "$(APP_HEX)" \
--manifest "$(FLASH_MANIFEST)" --manifest "$(FLASH_MANIFEST)"
program-flash-loader: program-flash-loader: efinity-program-check
@if [[ ! -f "$(FLASH_LOADER)" ]]; then @if [[ ! -f "$(FLASH_LOADER)" ]]; then
echo "Missing Ti375 JTAG-to-SPI loader: $(FLASH_LOADER)" >&2 echo "Missing Ti375 JTAG-to-SPI loader: $(FLASH_LOADER)" >&2
exit 1 exit 1
fi fi
set +u 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 set -u
ftdi_args=() ftdi_args=()
if [[ -n "$(FTDI_URL)" ]]; then if [[ -n "$(FTDI_URL)" ]]; then
@@ -382,7 +424,10 @@ program-flash-loader:
program-flash program-flash-elf program-app: flash-regions program-flash program-flash-elf program-app: flash-regions
@$(MAKE) -C "$(FPGA_DIR)" program-flash-loader @$(MAKE) -C "$(FPGA_DIR)" program-flash-loader
set +u 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 set -u
ftdi_args=() ftdi_args=()
if [[ -n "$(FTDI_URL)" ]]; then if [[ -n "$(FTDI_URL)" ]]; then
@@ -400,7 +445,10 @@ program-flash-bitstream program-bitstream:
fi fi
$(MAKE) -C "$(FPGA_DIR)" program-flash-loader $(MAKE) -C "$(FPGA_DIR)" program-flash-loader
set +u 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 set -u
ftdi_args=() ftdi_args=()
if [[ -n "$(FTDI_URL)" ]]; then 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 program-flash-regions program-flash-all program-flash-combined: flash-image
@$(MAKE) -C "$(FPGA_DIR)" program-flash-loader @$(MAKE) -C "$(FPGA_DIR)" program-flash-loader
set +u 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 set -u
ftdi_args=() ftdi_args=()
if [[ -n "$(FTDI_URL)" ]]; then if [[ -n "$(FTDI_URL)" ]]; then
+13 -2
View File
@@ -16,8 +16,19 @@ make FPGA_BOARD=ti375c529 fpga-bitstream
make FPGA_BOARD=ti375c529 fpga-program make FPGA_BOARD=ti375c529 fpga-program
``` ```
The Makefile auto-discovers Efinity under `/tools/efinix/efinity`. Override The Makefile auto-discovers versioned Efinity installations under
`EFINITY_HOME` when another installation is required. `/tools/efinix/efinity`, `/opt`, the current user's home directory, and
`tools/local/efinity`. Override discovery when required:
```bash
make FPGA_BOARD=ti375c529 fpga-bitstream \
EFINITY_HOME=/path/to/efinity/2025.2
```
`fpga-rtl` does not require Efinity. The `interface`, `bitstream`, and
programming targets require a complete Efinity installation containing
`bin/setup.sh` and `scripts/efx_run.py`; they now stop before hardware
elaboration with a direct diagnostic when it is absent.
Programming auto-selects the connected Ti375 development kit. If more than Programming auto-selects the connected Ti375 development kit. If more than
one compatible FTDI device is attached, run `make FPGA_BOARD=ti375c529 one compatible FTDI device is attached, run `make FPGA_BOARD=ti375c529
@@ -9,8 +9,8 @@ Ti375 device is not used.
## What was added ## What was added
- Added `ti375c529` to the root FPGA board selection and build targets. - Added `ti375c529` to the root FPGA board selection and build targets.
- Added Efinity 2025.2 discovery through `EFINITY_HOME`; the current installation - Added Efinity 2025.2 discovery through `EFINITY_HOME`. Common `/tools`,
is `/tools/efinix/efinity/2025.2`. `/opt`, user-local, and repository-local installation paths are searched.
- Added a generated Ti375 wrapper around `VCU118RocketSystem` so the existing - Added a generated Ti375 wrapper around `VCU118RocketSystem` so the existing
Rocket, DTIM, UART, GPS acquisition, tracking, PPS, and SPI logic is reused. Rocket, DTIM, UART, GPS acquisition, tracking, PPS, and SPI logic is reused.
- Added the Efinity XML project, interface script, SDC constraints, PLLs, pin - Added the Efinity XML project, interface script, SDC constraints, PLLs, pin
@@ -280,7 +280,7 @@ make FPGA_BOARD=ti375c529 fpga-flash-mcs APP=hello_uart
``` ```
The Makefile first loads Efinity's device-matched bridge The Makefile first loads Efinity's device-matched bridge
`/tools/efinix/efinity/2025.2/pgm/fli/titanium/u006A0A79.bit`, then uses `$(EFINITY_HOME)/pgm/fli/titanium/u006A0A79.bit`, then uses
`jtag_bridge` programming with on-chip verification. A fixed Efinity install `jtag_bridge` programming with on-chip verification. A fixed Efinity install
path is not required; `FLASH_LOADER` is derived from `EFINITY_HOME` and can be path is not required; `FLASH_LOADER` is derived from `EFINITY_HOME` and can be
overridden. overridden.
+12 -4
View File
@@ -16,10 +16,18 @@ FIRTOOL ?= $(firstword $(wildcard $(SOC_TOOLS_ROOT)/circt-current/bin/firtool) $
Z3_LIB_DIR ?= $(firstword $(wildcard $(SOC_TOOLS_ROOT)/z3-current/bin) $(wildcard $(PROJECT_TOOLS_DIR)/z3/*/bin)) Z3_LIB_DIR ?= $(firstword $(wildcard $(SOC_TOOLS_ROOT)/z3-current/bin) $(wildcard $(PROJECT_TOOLS_DIR)/z3/*/bin))
CIRCT_LIB_DIR ?= $(patsubst %/bin/firtool,%/lib,$(FIRTOOL)) CIRCT_LIB_DIR ?= $(patsubst %/bin/firtool,%/lib,$(FIRTOOL))
VIVADO ?= $(lastword $(sort $(wildcard /tools/Xilinx/*/Vivado/bin/vivado) $(shell command -v vivado 2>/dev/null))) VIVADO ?= $(lastword $(sort $(wildcard /tools/Xilinx/*/Vivado/bin/vivado) $(shell command -v vivado 2>/dev/null)))
EFINITY_HOME ?= $(lastword $(sort $(wildcard /tools/efinix/efinity/*))) _EFINITY_SETUP_CANDIDATES := $(sort \
EFINITY_SETUP ?= $(EFINITY_HOME)/bin/setup.sh $(wildcard /tools/efinix/efinity/*/bin/setup.sh) \
EFX_RUN ?= $(EFINITY_HOME)/scripts/efx_run.py $(wildcard /opt/efinix/efinity/*/bin/setup.sh) \
EFX_PGM ?= $(EFINITY_HOME)/pgm/bin/ftdi_pgm.sh $(wildcard /opt/efinity/bin/setup.sh) \
$(wildcard /opt/efinity/*/bin/setup.sh) \
$(wildcard $(HOME)/efinix/efinity/*/bin/setup.sh) \
$(wildcard $(HOME)/Efinity/*/bin/setup.sh) \
$(wildcard $(PROJECT_TOOLS_DIR)/efinity/*/bin/setup.sh))
EFINITY_HOME ?= $(patsubst %/bin/setup.sh,%,$(lastword $(_EFINITY_SETUP_CANDIDATES)))
EFINITY_SETUP ?= $(if $(strip $(EFINITY_HOME)),$(EFINITY_HOME)/bin/setup.sh)
EFX_RUN ?= $(if $(strip $(EFINITY_HOME)),$(EFINITY_HOME)/scripts/efx_run.py)
EFX_PGM ?= $(if $(strip $(EFINITY_HOME)),$(EFINITY_HOME)/pgm/bin/ftdi_pgm.sh)
# RISCV_TOOLCHAIN may point either to the toolchain root or its bin directory. # RISCV_TOOLCHAIN may point either to the toolchain root or its bin directory.
# TOOLCHAIN keeps compatibility with the existing software Makefiles. # TOOLCHAIN keeps compatibility with the existing software Makefiles.