public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [PATCH v3] Improve handosff prepare on SoCFPGA
@ 2026-04-20  7:46 Brian Sune
  2026-04-20 19:32 ` Simon Glass
  0 siblings, 1 reply; 4+ messages in thread
From: Brian Sune @ 2026-04-20  7:46 UTC (permalink / raw)
  To: u-boot, Tom Rini; +Cc: Brian Sune

There are some cases that the Python scripts
are run and the qts files are not replaced.
Make sure qts folder h files are removed before
handoff script runs.

Signed-off-by: Brian Sune <briansune@gmail.com>
---
 arch/arm/mach-socfpga/config.mk | 29 ++++++++++++++++++++++++++---
 1 file changed, 26 insertions(+), 3 deletions(-)

diff --git a/arch/arm/mach-socfpga/config.mk b/arch/arm/mach-socfpga/config.mk
index 1ca1d33cb16..5a75b773474 100644
--- a/arch/arm/mach-socfpga/config.mk
+++ b/arch/arm/mach-socfpga/config.mk
@@ -8,6 +8,8 @@ else ifeq ($(CONFIG_ARCH_SOCFPGA_ARRIA5),y)
 archprepare: socfpga_g5_handoff_prepare
 endif
 
+HANDOFF_KEEP ?= 0
+
 socfpga_g5_handoff_prepare:
 	@SOCFAMILY="$(SOCFAMILY)"; \
 		if [ -z "$$SOCFAMILY" ]; then \
@@ -43,6 +45,27 @@ socfpga_g5_handoff_prepare:
 			exit 0; \
 		fi; \
 		echo "[INFO] Found hiof file: $$HIOF_FILE"; \
-		echo "[INFO] Running BSP generator..."; \
-		python3 $(srctree)/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."
+		echo "[INFO] Try BSP generator..."; \
+		TEMP_DIR=$$(mktemp -dp "$$BOARD_DIR/"); \
+		if python3 $(srctree)/tools/cv_bsp_generator/cv_bsp_generator.py -i "$$HANDOFF_PATH" -o "$$TEMP_DIR"; then \
+			if [ -n "$$HANDOFF_KEEP" ]; then \
+				echo "[INFO] Preserving old BSP files..."; \
+				TIMESTAMP=$$(date +%Y%m%d_%H%M%S); \
+				for f in "$$BOARD_DIR"/qts/*.h; do \
+					[ -e "$$f" ] || continue; \
+					echo "[INFO] $$f -> $${f%.h}.h.handoff_backup.$$TIMESTAMP"; \
+					mv "$$f" "$${f%.h}.h.handoff_backup.$$TIMESTAMP"; \
+				done; \
+			else \
+				echo "[INFO] Clean old BSP files..."; \
+				if ls "$$BOARD_DIR/qts"/*.h >/dev/null 2>&1; then \
+					rm "$$BOARD_DIR/qts"/*.h; \
+					echo "[INFO] Removed old BSP files..."; \
+				fi; \
+			fi; \
+			mv "$$TEMP_DIR"/*.h "$$BOARD_DIR"/qts; \
+			echo "[INFO] SoCFPGA QTS handoff conversion complete."; \
+		else \
+			echo "[WARN] BSP generator failed!"; \
+		fi; \
+		trap 'rm -rf "$$TEMP_DIR"' EXIT;
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-04-20 23:12 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-20  7:46 [PATCH v3] Improve handosff prepare on SoCFPGA Brian Sune
2026-04-20 19:32 ` Simon Glass
2026-04-20 22:44   ` Sune Brian
2026-04-20 23:12   ` Sune Brian

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox