* [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
* 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; 4+ 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] 4+ 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; 4+ 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] 4+ 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; 4+ 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] 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