[PATCH v6] Add optimized Makefile support for SoCFPGA handoff

Brian Sune briansune at gmail.com
Tue Nov 4 02:00:03 CET 2025


Add optimized Makefile support for SoCFPGA handoff

- Introduce socfpga_g5_hanoff_prepare target in U-Boot Makefile
- Detects Altera/Intel SoCFPGA boards from .config
- Combines vendor/board extraction into a single shell call
- Checks for hps_isw_handoff folder and .hiof files
- Uses ls -d instead of find for faster folder detection
- Runs BSP generator script only if files exist
- Non-blocking: continues if handoff folder or files are missing
- HANDOFF_PATH user define allows overriding auto-detected folder
- Minimizes subshells and other slow constructs for faster CI

Signed-off-by: Brian Sune <briansune at gmail.com>
---
 Makefile | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 51 insertions(+), 2 deletions(-)

diff --git a/Makefile b/Makefile
index 750f8a84b1f..8431024e186 100644
--- a/Makefile
+++ b/Makefile
@@ -2158,7 +2158,7 @@ scripts: scripts_basic scripts_dtc
 # archprepare is used in arch Makefiles and when processed asm symlink,
 # version.h and scripts_basic is processed / created.
 
-PHONY += prepare archprepare prepare1 prepare3
+PHONY += prepare archprepare prepare1 prepare3 socfpga_g5_hanoff_prepare
 
 # prepare3 is used to check if we are building in a separate output directory,
 # and if so do:
@@ -2190,8 +2190,57 @@ archprepare: prepare1 scripts
 prepare0: archprepare
 	$(Q)$(MAKE) $(build)=.
 
+SOCFAMILY :=
+ifeq ($(CONFIG_TARGET_SOCFPGA_CYCLONE5),y)
+SOCFAMILY := cyclone5
+else ifeq ($(CONFIG_TARGET_SOCFPGA_ARRIA5),y)
+SOCFAMILY := arria5
+else ifeq ($(CONFIG_TARGET_SOCFPGA_ARRIA10),y)
+SOCFAMILY := arria10
+endif
+
+# Intel-Altera SoCFPGA GEN5 prepare handoff file conversion
+socfpga_g5_hanoff_prepare:
+	@SOCFAMILY="$(SOCFAMILY)"; \
+	if [ -z "$$SOCFAMILY" ]; then \
+		exit 0; \
+	fi; \
+	echo "[INFO] SOC family detected: $$SOCFAMILY";
+	@set -- $$(awk -F'"' ' \
+	    /^CONFIG_SYS_VENDOR=/ {v=$$2} \
+	    /^CONFIG_SYS_BOARD=/ {b=$$2} \
+	    END {print v, b}' .config); \
+	VENDOR=$$1; \
+	BOARD=$$2; \
+	if [ -z "$$VENDOR" ] || [ -z "$$BOARD" ]; then \
+		exit 0; \
+	fi; \
+	BOARD_DIR=board/$$VENDOR/$$BOARD; \
+	if [ "$$HANDOFF_PATH" ]; then \
+		echo "[INFO] Using manually specified handoff folder: $$HANDOFF_PATH"; \
+	else \
+		HANDOFF_BASE=$$BOARD_DIR/hps_isw_handoff; \
+		if [ ! -d "$$HANDOFF_BASE" ]; then \
+			exit 0; \
+		fi; \
+		HANDOFF_PATH=$$(ls -d "$$HANDOFF_BASE"/*/ 2>/dev/null | head -n1); \
+		if [ -z "$$HANDOFF_PATH" ]; then \
+			exit 0; \
+		fi; \
+		echo "[INFO] Auto-detected handoff folder: $$HANDOFF_PATH"; \
+	fi; \
+	HIOF_FILE=$$HANDOFF_PATH/$$(basename $$HANDOFF_PATH).hiof; \
+	if [ ! -f "$$HIOF_FILE" ]; then \
+		echo "[WARN] No .hiof file found in $$HANDOFF_PATH, skipping BSP generation."; \
+		exit 0; \
+	fi; \
+	echo "[INFO] Found hiof file: $$HIOF_FILE"; \
+	echo "[INFO] Running BSP generator..."; \
+	python3 tools/cv_bsp_generator/cv_bsp_generator.py -i "$$HANDOFF_PATH" -o "$$BOARD_DIR/qts" || echo "[WARN] BSP generator failed, continuing..."; \
+	echo "[DONE] SoCFPGA QTS handoff conversion complete."
+
 # All the preparing..
-prepare: prepare0 prepare-objtool
+prepare: prepare0 prepare-objtool socfpga_g5_hanoff_prepare
 
 # Support for using generic headers in asm-generic
 asm-generic := -f $(srctree)/scripts/Makefile.asm-generic obj
-- 
2.25.1



More information about the U-Boot mailing list