* [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; 6+ 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] 6+ messages in thread
* Re: [PATCH v3] Improve handosff prepare on SoCFPGA 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 0 siblings, 2 replies; 6+ messages in thread From: Simon Glass @ 2026-04-20 19:32 UTC (permalink / raw) To: briansune; +Cc: u-boot, Tom Rini Hi Brian, On 2026-04-20T07:46:01, Brian Sune <briansune@gmail.com> wrote: > Improve handosff prepare on SoCFPGA > > 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(-) Typo in commit message: "handosff" should be "handoff". > diff --git 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) > +HANDOFF_KEEP ?= 0 > diff --git a/arch/arm/mach-socfpga/config.mk b/arch/arm/mach-socfpga/config.mk > @@ -43,6 +45,27 @@ socfpga_g5_handoff_prepare: > + if [ -n "$$HANDOFF_KEEP" ]; then \ HANDOFF_KEEP defaults to "0", so -n "0" is always true. I suspect you want: if [ "$$HANDOFF_KEEP" != "0" ]; then \ Otherwise the 'preserve' path is always taken and the 'clean' path is dead code. You could also have an empty variable meaning don't keep. > diff --git a/arch/arm/mach-socfpga/config.mk b/arch/arm/mach-socfpga/config.mk > @@ -43,6 +45,27 @@ socfpga_g5_handoff_prepare: > + trap 'rm -rf "$$TEMP_DIR"' EXIT; The trap is set after TEMP_DIR has already been used. If the python script or mv fails partway through, the temporary directory won't be cleaned up. You could move the trap to immediately after mktemp Regards, Simon ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v3] Improve handosff prepare on SoCFPGA 2026-04-20 19:32 ` Simon Glass @ 2026-04-20 22:44 ` Sune Brian 2026-04-20 23:12 ` Sune Brian 1 sibling, 0 replies; 6+ messages in thread From: Sune Brian @ 2026-04-20 22:44 UTC (permalink / raw) To: Simon Glass; +Cc: u-boot, Tom Rini On Tue, Apr 21, 2026 at 3:32 AM Simon Glass <sjg@chromium.org> wrote: > > Hi Brian, > > On 2026-04-20T07:46:01, Brian Sune <briansune@gmail.com> wrote: > > Improve handosff prepare on SoCFPGA > > > > 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(-) > > Typo in commit message: "handosff" should be "handoff". Got it. > > > diff --git 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) > > +HANDOFF_KEEP ?= 0 > > > diff --git a/arch/arm/mach-socfpga/config.mk b/arch/arm/mach-socfpga/config.mk > > @@ -43,6 +45,27 @@ socfpga_g5_handoff_prepare: > > + if [ -n "$$HANDOFF_KEEP" ]; then \ > Hi Simon, Thanks for the feedback. Before the patch was pushed I personally tested all these cases and found no issue. make w/o HANDOFF_KEEP=1 will link to clean vice versa. You can use make HANDOFF_KEEP without =1 it will report No rule to make target 'HANDOFF_KEEP' Sorry, cannot see issue on this section. Maybe you can try and test if it is the case. Pure "brain processes code" sometimes is a bit tricky. > HANDOFF_KEEP defaults to "0", so -n "0" is always true. I suspect you want: > > if [ "$$HANDOFF_KEEP" != "0" ]; then \ > > Otherwise the 'preserve' path is always taken and the 'clean' path is dead code. > > You could also have an empty variable meaning don't keep. > > > diff --git a/arch/arm/mach-socfpga/config.mk b/arch/arm/mach-socfpga/config.mk > > @@ -43,6 +45,27 @@ socfpga_g5_handoff_prepare: > > + trap 'rm -rf "$$TEMP_DIR"' EXIT; > > The trap is set after TEMP_DIR has already been used. If the python > script or mv fails partway through, the temporary directory won't be > cleaned up. You could move the trap to immediately after mktemp Sorry, again during the test I did not see any issue what you described. The temp dir cleaned up w/o any issues. Both condition branches keep and clean. mv or python script will not break like exit 1 QUOTE ---> [INFO] Try BSP generator... ./board/altera/cyclone5-socdk/tmp.Z11PmKjAMg Generating file: ./board/altera/cyclone5-socdk/tmp.Z11PmKjAMg/sdram_config.h... Generating file: ./board/altera/cyclone5-socdk/tmp.Z11PmKjAMg/pinmux_config.h... Generating file: ./board/altera/cyclone5-socdk/tmp.Z11PmKjAMg/pll_config.h ***Error: We don't handle more than one .hiof file yet Only the last .hiof file in the list will be converted hiof files found: /media/sf_shared/loader/hps_isw_handoff/pcie_rp_ed_5csxfc6_hps_0/pcie_rp_ed_5csxfc6_hps_0 (copy).hiof /media/sf_shared/loader/hps_isw_handoff/pcie_rp_ed_5csxfc6_hps_0/pcie_rp_ed_5csxfc6_hps_0.hiof Reading file: /media/sf_shared/loader/hps_isw_handoff/pcie_rp_ed_5csxfc6_hps_0/pcie_rp_ed_5csxfc6_hps_0 (copy).hiof... Generating file: ./board/altera/cyclone5-socdk/tmp.Z11PmKjAMg/iocsr_config.h... Traceback (most recent call last): File "/home/intel/u-boot_C5PRJ/./tools/cv_bsp_generator/cv_bsp_generator.py", line 100, in <module> iocsr = iocsr.IOCSRGrokker(hps.getDeviceFamily(), inputDir, outputDir, hiof_file) AttributeError: 'IOCSRGrokker' object has no attribute 'IOCSRGrokker' [WARN] BSP generator failed! ll ./board/altera/cyclone5-socdk/tmp.Z11PmKjAMg ls: cannot access './board/altera/cyclone5-socdk/tmp.Z11PmKjAMg': No such file or directory <--- END QUOTE QUOTE---> UPD include/generated/timestamp_autogenerated.h [INFO] Using manually specified handoff folder: /media/sf_shared/loader/hps_isw_handoff/pcie_rp_ed_5csxfc6_hps_0 [INFO] Found hiof file: /media/sf_shared/loader/hps_isw_handoff/pcie_rp_ed_5csxfc6_hps_0/pcie_rp_ed_5csxfc6_hps_0.hiof [INFO] Try BSP generator... Generating file: ./board/altera/cyclone5-socdk/tmp.TvQv88TcsZ/sdram_config.h... Generating file: ./board/altera/cyclone5-socdk/tmp.TvQv88TcsZ/pinmux_config.h... Generating file: ./board/altera/cyclone5-socdk/tmp.TvQv88TcsZ/pll_config.h Reading file: /media/sf_shared/loader/hps_isw_handoff/pcie_rp_ed_5csxfc6_hps_0/pcie_rp_ed_5csxfc6_hps_0.hiof... Generating file: ./board/altera/cyclone5-socdk/tmp.TvQv88TcsZ/iocsr_config.h... [INFO] Clean old BSP files... mv: target './board/altera/cyclone5-socdk/qts' is not a directory [INFO] SoCFPGA QTS handoff conversion complete. ll ./board/altera/cyclone5-socdk/tmp.TvQv88TcsZ ls: cannot access './board/altera/cyclone5-socdk/tmp.TvQv88TcsZ': No such file or directory <--- END QUOTE Thanks, Brian > > Regards, > Simon ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v3] Improve handosff prepare on SoCFPGA 2026-04-20 19:32 ` Simon Glass 2026-04-20 22:44 ` Sune Brian @ 2026-04-20 23:12 ` Sune Brian 2026-04-21 22:38 ` Simon Glass 1 sibling, 1 reply; 6+ messages in thread From: Sune Brian @ 2026-04-20 23:12 UTC (permalink / raw) To: Simon Glass; +Cc: u-boot, Tom Rini On Tue, Apr 21, 2026 at 3:32 AM Simon Glass <sjg@chromium.org> wrote: > > Hi Brian, > > On 2026-04-20T07:46:01, Brian Sune <briansune@gmail.com> wrote: > > Improve handosff prepare on SoCFPGA > > > > 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(-) > > Typo in commit message: "handosff" should be "handoff". > > > diff --git 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) > > +HANDOFF_KEEP ?= 0 > > > diff --git a/arch/arm/mach-socfpga/config.mk b/arch/arm/mach-socfpga/config.mk > > @@ -43,6 +45,27 @@ socfpga_g5_handoff_prepare: > > + if [ -n "$$HANDOFF_KEEP" ]; then \ > > HANDOFF_KEEP defaults to "0", so -n "0" is always true. I suspect you want: > > if [ "$$HANDOFF_KEEP" != "0" ]; then \ Hi Simon, I think this is a misunderstanding. My original idea is to use the HANDOFF_KEEP=(whatever is mistyped) to run the keep branch. While the absence of HANDOFF_KEEP(anything) will not keep. But simply HANDOFF_KEEP will not work and need HANDOFF_KEEP=xxx. Because the command > "make prepare HANDOFF_KEEP=xxx" is very distinctly long HANDOFF_KEEP=xxx so it must keep my thingy. Even if I mistyped =0 etc. And during the absence of HANDOFF_KEEP=xxxx "make prepare " immediately, see ok clean so it will not keep good. That's my original thought. I think I should changed to: if [ -n "$${HANDOFF_KEEP+x}" ]; then \ Need your comments on this. Thanks, Brian > > Otherwise the 'preserve' path is always taken and the 'clean' path is dead code. > > You could also have an empty variable meaning don't keep. > > > diff --git a/arch/arm/mach-socfpga/config.mk b/arch/arm/mach-socfpga/config.mk > > @@ -43,6 +45,27 @@ socfpga_g5_handoff_prepare: > > + trap 'rm -rf "$$TEMP_DIR"' EXIT; > > The trap is set after TEMP_DIR has already been used. If the python > script or mv fails partway through, the temporary directory won't be > cleaned up. You could move the trap to immediately after mktemp > > Regards, > Simon ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v3] Improve handosff prepare on SoCFPGA 2026-04-20 23:12 ` Sune Brian @ 2026-04-21 22:38 ` Simon Glass 2026-04-21 23:17 ` Sune Brian 0 siblings, 1 reply; 6+ messages in thread From: Simon Glass @ 2026-04-21 22:38 UTC (permalink / raw) To: Sune Brian; +Cc: u-boot, Tom Rini Hi Brian, On Tue, 21 Apr 2026 at 11:12, Sune Brian <briansune@gmail.com> wrote: > > On Tue, Apr 21, 2026 at 3:32 AM Simon Glass <sjg@chromium.org> wrote: > > > > Hi Brian, > > > > On 2026-04-20T07:46:01, Brian Sune <briansune@gmail.com> wrote: > > > Improve handosff prepare on SoCFPGA > > > > > > 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(-) > > > > Typo in commit message: "handosff" should be "handoff". > > > > > diff --git 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) > > > +HANDOFF_KEEP ?= 0 > > > > > diff --git a/arch/arm/mach-socfpga/config.mk b/arch/arm/mach-socfpga/config.mk > > > @@ -43,6 +45,27 @@ socfpga_g5_handoff_prepare: > > > + if [ -n "$$HANDOFF_KEEP" ]; then \ > > > > HANDOFF_KEEP defaults to "0", so -n "0" is always true. I suspect you want: > > > > if [ "$$HANDOFF_KEEP" != "0" ]; then \ > > Hi Simon, > > I think this is a misunderstanding. > My original idea is to use the HANDOFF_KEEP=(whatever is mistyped) > to run the keep branch. > > While the absence of HANDOFF_KEEP(anything) will not keep. > But simply HANDOFF_KEEP will not work and need HANDOFF_KEEP=xxx. I'd suggest either dropping the assignment to '0', since someone reading the Makefile will reasonably expect the shell to see it as 'off'. In any case, how about a comment above to explain what the argument is for and what it does? > > Because the command > > "make prepare HANDOFF_KEEP=xxx" is very distinctly long > HANDOFF_KEEP=xxx so it must keep my thingy. > Even if I mistyped =0 etc. > > And during the absence of HANDOFF_KEEP=xxxx > "make prepare " immediately, see ok clean so it will not keep good. > > That's my original thought. > I think I should changed to: > if [ -n "$${HANDOFF_KEEP+x}" ]; then \ > > > Need your comments on this. > > Thanks, > Brian > > > > > Otherwise the 'preserve' path is always taken and the 'clean' path is dead code. > > > > You could also have an empty variable meaning don't keep. > > > > > diff --git a/arch/arm/mach-socfpga/config.mk b/arch/arm/mach-socfpga/config.mk > > > @@ -43,6 +45,27 @@ socfpga_g5_handoff_prepare: > > > + trap 'rm -rf "$$TEMP_DIR"' EXIT; > > > > The trap is set after TEMP_DIR has already been used. If the python > > script or mv fails partway through, the temporary directory won't be > > cleaned up. You could move the trap to immediately after mktemp OK I had that wrong. If someone presses Ctrl-C while Python is running it would not clean up, but that's a minor issue... Please note that you should add a change log for version 2, 3, etc. - see here for details: https://docs.u-boot.org/en/latest/develop/sending_patches.html Regards, Simon ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v3] Improve handosff prepare on SoCFPGA 2026-04-21 22:38 ` Simon Glass @ 2026-04-21 23:17 ` Sune Brian 0 siblings, 0 replies; 6+ messages in thread From: Sune Brian @ 2026-04-21 23:17 UTC (permalink / raw) To: Simon Glass; +Cc: u-boot, Tom Rini On Wed, Apr 22, 2026 at 6:39 AM Simon Glass <sjg@chromium.org> wrote: > > Hi Brian, > > On Tue, 21 Apr 2026 at 11:12, Sune Brian <briansune@gmail.com> wrote: > > > > On Tue, Apr 21, 2026 at 3:32 AM Simon Glass <sjg@chromium.org> wrote: > > > > > > Hi Brian, > > > > > > On 2026-04-20T07:46:01, Brian Sune <briansune@gmail.com> wrote: > > > > Improve handosff prepare on SoCFPGA > > > > > > > > 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(-) > > > > > > Typo in commit message: "handosff" should be "handoff". > > > > > > > diff --git 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) > > > > +HANDOFF_KEEP ?= 0 > > > > > > > diff --git a/arch/arm/mach-socfpga/config.mk b/arch/arm/mach-socfpga/config.mk > > > > @@ -43,6 +45,27 @@ socfpga_g5_handoff_prepare: > > > > + if [ -n "$$HANDOFF_KEEP" ]; then \ > > > > > > HANDOFF_KEEP defaults to "0", so -n "0" is always true. I suspect you want: > > > > > > if [ "$$HANDOFF_KEEP" != "0" ]; then \ > > > > Hi Simon, > > > > I think this is a misunderstanding. > > My original idea is to use the HANDOFF_KEEP=(whatever is mistyped) > > to run the keep branch. > > > > While the absence of HANDOFF_KEEP(anything) will not keep. > > But simply HANDOFF_KEEP will not work and need HANDOFF_KEEP=xxx. > Hi Simon, > I'd suggest either dropping the assignment to '0', since someone > reading the Makefile will reasonably expect the shell to see it as > 'off'. > Yes indeed so I had pushed patch v4 and fixed what you suggested with my inheritance idea. > In any case, how about a comment above to explain what the argument is > for and what it does? I guess patch v4 has no issue self explaining the check condition has undergone those expected logic cases and exists HANDOFF_KEEP. So v4 simply: HANDOFF_KEEP= <- keep HANDOFF_KEEP=0 <- no keep HANDOFF_KEEP=1 <- keep HANDOFF_KEEP='0' <- no keep HANDOFF_KEEP='1' <- keep etc. Thanks, Brian > > > > > Because the command > > > "make prepare HANDOFF_KEEP=xxx" is very distinctly long > > HANDOFF_KEEP=xxx so it must keep my thingy. > > Even if I mistyped =0 etc. > > > > And during the absence of HANDOFF_KEEP=xxxx > > "make prepare " immediately, see ok clean so it will not keep good. > > > > That's my original thought. > > I think I should changed to: > > if [ -n "$${HANDOFF_KEEP+x}" ]; then \ > > > > > > Need your comments on this. > > > > Thanks, > > Brian > > > > > > > > Otherwise the 'preserve' path is always taken and the 'clean' path is dead code. > > > > > > You could also have an empty variable meaning don't keep. > > > > > > > diff --git a/arch/arm/mach-socfpga/config.mk b/arch/arm/mach-socfpga/config.mk > > > > @@ -43,6 +45,27 @@ socfpga_g5_handoff_prepare: > > > > + trap 'rm -rf "$$TEMP_DIR"' EXIT; > > > > > > The trap is set after TEMP_DIR has already been used. If the python > > > script or mv fails partway through, the temporary directory won't be > > > cleaned up. You could move the trap to immediately after mktemp > > OK I had that wrong. If someone presses Ctrl-C while Python is running > it would not clean up, but that's a minor issue... > > Please note that you should add a change log for version 2, 3, etc. - > see here for details: > > https://docs.u-boot.org/en/latest/develop/sending_patches.html > > Regards, > Simon ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2026-04-21 23:17 UTC | newest] Thread overview: 6+ 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 2026-04-21 22:38 ` Simon Glass 2026-04-21 23:17 ` Sune Brian
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.