[PATCH v4] Improve handoff prepare on SoCFPGA
Brian Sune
briansune at gmail.com
Tue Apr 21 02:47:19 CEST 2026
There are some cases that the Python scripts
are run and the qts files are not replaced.
This patch introduces:
1) TMP folder for Python script
2) TMP folder will automatically remove on exit
3) If PY script fails, the replace will not conduct.
4) Only when PY script passed the replace with keep
or without keep will be done via NEW HANDOFF_KEEP=xxx
5) When keep is selected the old files are renamed to
xxx.h.handoff.<timestamp>
As such this ensure qts folder h files are properly
updated.
Signed-off-by: Brian Sune <briansune at gmail.com>
---
arch/arm/mach-socfpga/config.mk | 27 ++++++++++++++++++++++++---
1 file changed, 24 insertions(+), 3 deletions(-)
diff --git a/arch/arm/mach-socfpga/config.mk b/arch/arm/mach-socfpga/config.mk
index 1ca1d33cb16..010ea633f12 100644
--- a/arch/arm/mach-socfpga/config.mk
+++ b/arch/arm/mach-socfpga/config.mk
@@ -43,6 +43,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 [ -n "$${HANDOFF_KEEP+x}" ] && [ "$${HANDOFF_KEEP:-1}" != "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
More information about the U-Boot
mailing list