public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Brian Sune <briansune@gmail.com>
To: Tom Rini <trini@konsulko.com>, u-boot@lists.denx.de
Subject: [PATCH v5] Add make feature support for SoCFPGA Handoff
Date: Tue,  4 Nov 2025 07:48:12 +0800	[thread overview]
Message-ID: <20251103234812.505-1-briansune@gmail.com> (raw)

Introduce socfpga_gen5_handoff_prepare target in U-Boot Makefile
Automatically detects Altera/Intel SoCFPGA boards from .config
Checks for presence of hps_isw_handoff folder and .hiof files
Runs BSP generator script tools/cv_bsp_generator/cv_bsp_generator.py
if files exist
Non-blocking: prepare continues even if handoff folder or files are missing
HANDOFF_PATH user define: override the auto detection in board folder

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

diff --git a/Makefile b/Makefile
index 750f8a84b1f..f5efe679259 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,50 @@ archprepare: prepare1 scripts
 prepare0: archprepare
 	$(Q)$(MAKE) $(build)=.
 
+# Intel-Altera SoCFPGA GEN5 prepare handoff file conversion
+socfpga_g5_hanoff_prepare:
+	@VENDOR=$$(grep -E '^CONFIG_SYS_VENDOR=' .config | cut -d'"' -f2); \
+	BOARD=$$(grep -E '^CONFIG_SYS_BOARD=' .config | cut -d'"' -f2); \
+	if [ -z "$$VENDOR" ] || [ -z "$$BOARD" ]; then \
+		exit 0; \
+	fi; \
+	if grep -q 'CONFIG_TARGET_SOCFPGA_CYCLONE5=y' .config; then \
+		SOCFAMILY=cyclone5; \
+	elif grep -q 'CONFIG_TARGET_SOCFPGA_ARRIA5=y' .config; then \
+		SOCFAMILY=arria5; \
+	elif grep -q 'CONFIG_TARGET_SOCFPGA_ARRIA10=y' .config; then \
+		SOCFAMILY=arria10; \
+	else \
+		exit 0; \
+	fi; \
+	BOARD_DIR=board/$$VENDOR/$$BOARD; \
+	if [ -n "$$HANDOFF_PATH" ]; then \
+		echo "[INFO] Using manually assigned handoff path: $$HANDOFF_PATH"; \
+	else \
+		HANDOFF_BASE=$$BOARD_DIR/hps_isw_handoff; \
+		if [ ! -d $$HANDOFF_BASE ]; then \
+			exit 0; \
+		fi; \
+		echo "[INFO] Handoff folder found: $$HANDOFF_BASE"; \
+		HANDOFF_FOLDER_NAME=$$(basename "$$(find $$HANDOFF_BASE -mindepth 1 -maxdepth 1 -type d | head -n1)"); \
+		if [ -z "$$HANDOFF_FOLDER_NAME" ]; then \
+			exit 0; \
+		fi; \
+		echo "[INFO] Handoff subfolder found under $$HANDOFF_BASE"; \
+		if [ -f $$HANDOFF_BASE/$$HANDOFF_FOLDER_NAME/$$HANDOFF_FOLDER_NAME.hiof ]; then \
+			echo "[INFO] Found hiof file: $$HANDOFF_BASE/$$HANDOFF_FOLDER_NAME/$$HANDOFF_FOLDER_NAME.hiof"; \
+			echo "[INFO] Using handoff folder: $$HANDOFF_FOLDER_NAME"; \
+			echo "[INFO] Running BSP generator..."; \
+		fi; \
+		HANDOFF_PATH=$$BOARD_DIR/hps_isw_handoff/$$HANDOFF_FOLDER_NAME; \
+	fi; \
+	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


                 reply	other threads:[~2025-11-03 23:48 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20251103234812.505-1-briansune@gmail.com \
    --to=briansune@gmail.com \
    --cc=trini@konsulko.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox