From: Brian Sune <briansune@gmail.com>
To: u-boot@lists.denx.de, Tom Rini <trini@konsulko.com>,
Marek Vasut <marex@denx.de>,
Chee Tien Fong <tien.fong.chee@altera.com>,
Simon Glass <sjg@chromium.org>
Cc: Brian Sune <briansune@gmail.com>
Subject: [PATCH v6] Improve handoff prepare on SoCFPGA
Date: Thu, 14 May 2026 09:42:42 +0800 [thread overview]
Message-ID: <20260514014242.21676-1-briansune@gmail.com> (raw)
Ensure qts folder header files are properly updated by isolating
the Python execution environment. This prevents partial or failed
script runs from corrupting the target directory.
Signed-off-by: Brian Sune <briansune@gmail.com>
---
Changes for v6:
- Clean HANDOFF_KEEP comments.
Changes for v5:
- Change HANDOFF_KEEP condition to if [ "$${HANDOFF_KEEP:-0}" != "0" ];
- Add HANDOFF_KEEP and HANDOFF_PATH comments in config.mk
Changes for v4:
- Move trap 'rm -rf "$$TEMP_DIR"' EXIT; after temp folder create
- Change HANDOFF_KEEP condition to
if [ -n "$${HANDOFF_KEEP+x}" ] && [ "$${HANDOFF_KEEP:-1}" != "0" ];
HANDOFF_KEEP=0 from rename to discard old header files
Changes for v3:
- Implement a temp folder for Python script execution.
- Clean temp folder automatically despite execution failures.
- Gate the file replacement process on the successful exit of
the Python scripts.
- Execute the replacement (with or without keep) only upon script
success via the NEW HANDOFF_KEEP=xxx variable.
- Rename old files to .h.handoff_backup.<timestamp> when the
keep option is selected.
Changes for v2:
- Add handoff Python script execution check
Changes for v1:
- Implement basic remove and replace header files
Reviewed-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Tien Fong Chee <tien.fong.chee@altera.com>
arch/arm/mach-socfpga/config.mk | 39 ++++++++++++++++++++++++++++++---
1 file changed, 36 insertions(+), 3 deletions(-)
diff --git a/arch/arm/mach-socfpga/config.mk b/arch/arm/mach-socfpga/config.mk
index 1ca1d33cb16..f341aaaea56 100644
--- a/arch/arm/mach-socfpga/config.mk
+++ b/arch/arm/mach-socfpga/config.mk
@@ -1,6 +1,18 @@
# SPDX-License-Identifier: GPL-2.0+
#
# Brian Sune <briansune@gmail.com>
+#
+# HANDOFF_PATH
+# ------------
+# Unset - Board path where qts locates and "hps_isw_handoff" should be placed.
+# Set - Custom path points to "hps_isw_handoff" folder.
+#
+# HANDOFF_KEEP
+# ------------
+# Unset - Clean header files.
+# Set - HANDOFF_KEEP= , Clean header files.
+# HANDOFF_KEEP=0, Clean header files.
+# HANDOFF_KEEP=1, Backup header files and rename to ".h.handoff_backup.<timestamp>".
ifeq ($(CONFIG_ARCH_SOCFPGA_CYCLONE5),y)
archprepare: socfpga_g5_handoff_prepare
@@ -43,6 +55,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/"); \
+ trap 'rm -rf "$$TEMP_DIR"' EXIT; \
+ if python3 $(srctree)/tools/cv_bsp_generator/cv_bsp_generator.py -i "$$HANDOFF_PATH" -o "$$TEMP_DIR"; then \
+ if [ "$${HANDOFF_KEEP:-0}" != "0" ]; 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;
--
2.34.1
next reply other threads:[~2026-05-14 1:42 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-14 1:42 Brian Sune [this message]
-- strict thread matches above, loose matches on Subject: below --
2026-04-23 4:28 [PATCH v6] Improve handoff prepare on SoCFPGA Brian Sune
2026-04-28 14:04 ` Simon Glass
2026-04-28 14:33 ` Sune Brian
2026-04-29 14:21 ` Simon Glass
2026-04-29 14:34 ` Sune Brian
2026-04-29 14:44 ` Simon Glass
2026-04-29 17:14 ` Simon Glass
2026-04-30 4:28 ` Chee, Tien Fong
2026-04-30 4:32 ` Sune Brian
2026-04-30 4:42 ` Sune Brian
2026-04-23 4:25 Brian Sune
2026-04-23 4:04 Brian Sune
2026-04-23 3:48 Brian Sune
2026-04-23 3:35 Brian Sune
2026-04-23 3:30 Brian Sune
2026-04-23 3:11 Brian Sune
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=20260514014242.21676-1-briansune@gmail.com \
--to=briansune@gmail.com \
--cc=marex@denx.de \
--cc=sjg@chromium.org \
--cc=tien.fong.chee@altera.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.