Improve handoff prepare on SoCFPGA
Subsystems (3)
PATCH v5 1/1 Improve handoff prepare on SoCFPGA
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.
Changelog v4 -> v5:
- Change HANDOFF_KEEP condition to if [ 2501{HANDOFF_KEEP:-0} != 0 ]
- Add HANDOFF_KEEP and HANDOFF_PATH comments in config.mk
Changes:
- 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.
--- arch/arm/mach-socfpga/config.mk | 38 ++++++++++++++++++++++++++++++--- 1 file changed, 35 insertions(+), 3 deletions(-)
arch/arm/mach-socfpga/config.mk +35 -3
@@ -1,6 +1,17 @@ # SPDX-License-Identifier: GPL-2.0+ # # Brian Sune <[email protected]> +# +# 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 - HANDOFF_KEEP= , Clean header files. +# Set - 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 +54,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;
Signature · 1 line
2.34.1
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 111 lines · Tien Fong
Hi Brian,
Quoted 8 lines · Brian Sune
[CAUTION: This email is from outside your organization. Unless you trust the sender, do not click on links or open attachments as it may be a fraudulent email attempting to steal your information and/or compromise your computer.]
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.
Changelog v4 -> v5:
- ChangeHANDOFF_KEEPcondition to if [ 2501{HANDOFF_KEEP:-0} != 0 ]appears corrupted in the commit message, e.g.:
if [ 2501{HANDOFF_KEEP:-0} != 0 ] Please correct this to the actual test (e.g. reference to "${HANDOFF_KEEP:-0}" and proper quoting) so 'git log' is accurate.Quoted 26 lines
- Add
HANDOFF_KEEPandHANDOFF_PATHcomments in config.mkChanges:
- 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.Signed-off-by Brian Sune <[email protected]>--- arch/arm/mach-socfpga/config.mk | 38 ++++++++++++++++++++++++++++++--- 1 file changed, 35 insertions(+), 3 deletions(-)arch/arm/mach-socfpga/config.mk +1
-0@@ -1,6 +1,17 @@ # SPDX-License-Identifier: GPL-2.0+ # # Brian Sune <[email protected]> +#arch/arm/mach-socfpga/config.mk line 14
Quoted 10 lines
arch/arm/mach-socfpga/config.mk +10
-0+# 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 - HANDOFF_KEEP= , Clean header files. +# Set - HANDOFF_KEEP=0, Clean header files. +# HANDOFF_KEEP=1, Backup header files and rename to ".h.handoff_backup.<timestamp>".Should be tightened to match the real behaviour:
- ForHANDOFF_KEEP, avoid lines that mix "Unset" and "HANDOFF_KEEP= " in a way that is easy to misread. Document:
unset, empty, or =0 => clean old .h in qts, then install new
=1 (or any non-0) => rename old *.h to .h.handoff_backup.<ts>- For
HANDOFF_PATH, a short "unset: autohps_isw_handoff; set: custom handoff path" style note reads clearer than the current phrasing.Quoted 35 lines
arch/arm/mach-socfpga/config.mk +24
-4ifeq ($(CONFIG_ARCH_SOCFPGA_CYCLONE5),y) archprepare: socfpga_g5_handoff_prepare@@ -43,6 +54,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; --Quoted 1 line
2.34.1
You can add Simon and my review tag to a new version.
Quoted 4 lines
I’m fine to proceed with v5 as posted. If you prefer a different implementation,
feel free to propose it in a follow‑up patch and we can review it there.
Hi T.F.,
I committed a new v6 patch just to replace the corrupted " symbol.
The version control placing v5 with v5 is not allowed so v6 is used. While the change log kept v4->v5 because code changes are not done under v6.
So v6 is a git commit text fix only.
Thanks,
Brian
Quoted 6 lines
Best regards,
Tien Fong
Hi Brian,
Quoted 114 lines · Sune Brian
[CAUTION: This email is from outside your organization. Unless you trust the sender, do not click on links or open attachments as it may be a fraudulent email attempting to steal your information and/or compromise your computer.]
Quoted 106 lines · Tien Fong
Hi Brian,
Quoted 8 lines · Brian Sune
[CAUTION: This email is from outside your organization. Unless you trust the sender, do not click on links or open attachments as it may be a fraudulent email attempting to steal your information and/or compromise your computer.]
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.
Changelog v4 -> v5:
- ChangeHANDOFF_KEEPcondition to if [ 2501{HANDOFF_KEEP:-0} != 0 ]appears corrupted in the commit message, e.g.:
if [ 2501{HANDOFF_KEEP:-0} != 0 ] Please correct this to the actual test (e.g. reference to "${HANDOFF_KEEP:-0}" and proper quoting) so 'git log' is accurate.Quoted 26 lines
- Add
HANDOFF_KEEPandHANDOFF_PATHcomments in config.mkChanges:
- 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.Signed-off-by Brian Sune <[email protected]>--- arch/arm/mach-socfpga/config.mk | 38 ++++++++++++++++++++++++++++++--- 1 file changed, 35 insertions(+), 3 deletions(-)arch/arm/mach-socfpga/config.mk +1
-0@@ -1,6 +1,17 @@ # SPDX-License-Identifier: GPL-2.0+ # # Brian Sune <[email protected]> +#arch/arm/mach-socfpga/config.mk line 14
Quoted 10 lines
arch/arm/mach-socfpga/config.mk +10
-0+# 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 - HANDOFF_KEEP= , Clean header files. +# Set - HANDOFF_KEEP=0, Clean header files. +# HANDOFF_KEEP=1, Backup header files and rename to ".h.handoff_backup.<timestamp>".Should be tightened to match the real behaviour:
- ForHANDOFF_KEEP, avoid lines that mix "Unset" and "HANDOFF_KEEP= " in a way that is easy to misread. Document:
unset, empty, or =0 => clean old .h in qts, then install new
=1 (or any non-0) => rename old *.h to .h.handoff_backup.<ts>- For
HANDOFF_PATH, a short "unset: autohps_isw_handoff; set: custom handoff path" style note reads clearer than the current phrasing.Quoted 34 lines
arch/arm/mach-socfpga/config.mk +24
-4ifeq ($(CONFIG_ARCH_SOCFPGA_CYCLONE5),y) archprepare: socfpga_g5_handoff_prepare@@ -43,6 +54,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; --Quoted 1 line
2.34.1
You can add Simon and my review tag to a new version.
Quoted 4 lines
I’m fine to proceed with v5 as posted. If you prefer a different implementation,
feel free to propose it in a follow‑up patch and we can review it there.
Quoted 8 lines
Hi T.F.,
I committed a new v6 patch just to replace the corrupted " symbol.
The version control placing v5 with v5 is not allowed so v6 is used. While the change log kept
v4->v5because code changes are not done under v6.
So v6 is a git commit text fix only.
I’ve received a few v6 patches on my end. Is this the one you’re referring to?
https://patchwork.ozlabs.org/project/uboot/patch/[email protected]/
Thanks.
Best regards,
Tien Fong
Quoted 128 lines · Tien Fong
Hi Brian,
Quoted 114 lines · Sune Brian
[CAUTION: This email is from outside your organization. Unless you trust the sender, do not click on links or open attachments as it may be a fraudulent email attempting to steal your information and/or compromise your computer.]
Quoted 106 lines · Tien Fong
Hi Brian,
Quoted 8 lines · Brian Sune
[CAUTION: This email is from outside your organization. Unless you trust the sender, do not click on links or open attachments as it may be a fraudulent email attempting to steal your information and/or compromise your computer.]
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.
Changelog v4 -> v5:
- ChangeHANDOFF_KEEPcondition to if [ 2501{HANDOFF_KEEP:-0} != 0 ]appears corrupted in the commit message, e.g.:
if [ 2501{HANDOFF_KEEP:-0} != 0 ] Please correct this to the actual test (e.g. reference to "${HANDOFF_KEEP:-0}" and proper quoting) so 'git log' is accurate.Quoted 26 lines
- Add
HANDOFF_KEEPandHANDOFF_PATHcomments in config.mkChanges:
- 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.Signed-off-by Brian Sune <[email protected]>--- arch/arm/mach-socfpga/config.mk | 38 ++++++++++++++++++++++++++++++--- 1 file changed, 35 insertions(+), 3 deletions(-)arch/arm/mach-socfpga/config.mk +1
-0@@ -1,6 +1,17 @@ # SPDX-License-Identifier: GPL-2.0+ # # Brian Sune <[email protected]> +#arch/arm/mach-socfpga/config.mk line 14
Quoted 10 lines
arch/arm/mach-socfpga/config.mk +10
-0+# 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 - HANDOFF_KEEP= , Clean header files. +# Set - HANDOFF_KEEP=0, Clean header files. +# HANDOFF_KEEP=1, Backup header files and rename to ".h.handoff_backup.<timestamp>".Should be tightened to match the real behaviour:
- ForHANDOFF_KEEP, avoid lines that mix "Unset" and "HANDOFF_KEEP= " in a way that is easy to misread. Document:
unset, empty, or =0 => clean old .h in qts, then install new
=1 (or any non-0) => rename old *.h to .h.handoff_backup.<ts>- For
HANDOFF_PATH, a short "unset: autohps_isw_handoff; set: custom handoff path" style note reads clearer than the current phrasing.Quoted 34 lines
arch/arm/mach-socfpga/config.mk +24
-4ifeq ($(CONFIG_ARCH_SOCFPGA_CYCLONE5),y) archprepare: socfpga_g5_handoff_prepare@@ -43,6 +54,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; --Quoted 1 line
2.34.1
You can add Simon and my review tag to a new version.
Quoted 4 lines
I’m fine to proceed with v5 as posted. If you prefer a different implementation,
feel free to propose it in a follow‑up patch and we can review it there.
Quoted 8 lines
Hi T.F.,
I committed a new v6 patch just to replace the corrupted " symbol.
The version control placing v5 with v5 is not allowed so v6 is used. While the change log kept
v4->v5because code changes are not done under v6.
So v6 is a git commit text fix only.
Quoted 6 lines
I’ve received a few v6 patches on my end. Is this the one you’re referring to?
https://patchwork.ozlabs.org/project/uboot/patch/[email protected]/
Thanks.
Please only keep this thank you.
Sorry for the trouble:
Message [email protected]
Thanks,
Brian
Quoted 8 lines
Best regards,
Tien Fong