* [PATCH v6] Add optimized Makefile support for SoCFPGA handoff
@ 2025-11-04 1:00 Brian Sune
2025-11-04 17:51 ` Tom Rini
0 siblings, 1 reply; 10+ messages in thread
From: Brian Sune @ 2025-11-04 1:00 UTC (permalink / raw)
To: Tom Rini, u-boot
Add optimized Makefile support for SoCFPGA handoff
- Introduce socfpga_g5_hanoff_prepare target in U-Boot Makefile
- Detects Altera/Intel SoCFPGA boards from .config
- Combines vendor/board extraction into a single shell call
- Checks for hps_isw_handoff folder and .hiof files
- Uses ls -d instead of find for faster folder detection
- Runs BSP generator script only if files exist
- Non-blocking: continues if handoff folder or files are missing
- HANDOFF_PATH user define allows overriding auto-detected folder
- Minimizes subshells and other slow constructs for faster CI
Signed-off-by: Brian Sune <briansune@gmail.com>
---
Makefile | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++--
1 file changed, 51 insertions(+), 2 deletions(-)
diff --git a/Makefile b/Makefile
index 750f8a84b1f..8431024e186 100644
--- a/Makefile
+++ b/Makefile
@@ -2158,7 +2158,7 @@ scripts: scripts_basic scripts_dtc
# archprepare is used in arch Makefiles and when processed asm symlink,
# version.h and scripts_basic is processed / created.
-PHONY += prepare archprepare prepare1 prepare3
+PHONY += prepare archprepare prepare1 prepare3 socfpga_g5_hanoff_prepare
# prepare3 is used to check if we are building in a separate output directory,
# and if so do:
@@ -2190,8 +2190,57 @@ archprepare: prepare1 scripts
prepare0: archprepare
$(Q)$(MAKE) $(build)=.
+SOCFAMILY :=
+ifeq ($(CONFIG_TARGET_SOCFPGA_CYCLONE5),y)
+SOCFAMILY := cyclone5
+else ifeq ($(CONFIG_TARGET_SOCFPGA_ARRIA5),y)
+SOCFAMILY := arria5
+else ifeq ($(CONFIG_TARGET_SOCFPGA_ARRIA10),y)
+SOCFAMILY := arria10
+endif
+
+# Intel-Altera SoCFPGA GEN5 prepare handoff file conversion
+socfpga_g5_hanoff_prepare:
+ @SOCFAMILY="$(SOCFAMILY)"; \
+ if [ -z "$$SOCFAMILY" ]; then \
+ exit 0; \
+ fi; \
+ echo "[INFO] SOC family detected: $$SOCFAMILY";
+ @set -- $$(awk -F'"' ' \
+ /^CONFIG_SYS_VENDOR=/ {v=$$2} \
+ /^CONFIG_SYS_BOARD=/ {b=$$2} \
+ END {print v, b}' .config); \
+ VENDOR=$$1; \
+ BOARD=$$2; \
+ if [ -z "$$VENDOR" ] || [ -z "$$BOARD" ]; then \
+ exit 0; \
+ fi; \
+ BOARD_DIR=board/$$VENDOR/$$BOARD; \
+ if [ "$$HANDOFF_PATH" ]; then \
+ echo "[INFO] Using manually specified handoff folder: $$HANDOFF_PATH"; \
+ else \
+ HANDOFF_BASE=$$BOARD_DIR/hps_isw_handoff; \
+ if [ ! -d "$$HANDOFF_BASE" ]; then \
+ exit 0; \
+ fi; \
+ HANDOFF_PATH=$$(ls -d "$$HANDOFF_BASE"/*/ 2>/dev/null | head -n1); \
+ if [ -z "$$HANDOFF_PATH" ]; then \
+ exit 0; \
+ fi; \
+ echo "[INFO] Auto-detected handoff folder: $$HANDOFF_PATH"; \
+ fi; \
+ HIOF_FILE=$$HANDOFF_PATH/$$(basename $$HANDOFF_PATH).hiof; \
+ if [ ! -f "$$HIOF_FILE" ]; then \
+ echo "[WARN] No .hiof file found in $$HANDOFF_PATH, skipping BSP generation."; \
+ exit 0; \
+ fi; \
+ echo "[INFO] Found hiof file: $$HIOF_FILE"; \
+ echo "[INFO] Running BSP generator..."; \
+ python3 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."
+
# All the preparing..
-prepare: prepare0 prepare-objtool
+prepare: prepare0 prepare-objtool socfpga_g5_hanoff_prepare
# Support for using generic headers in asm-generic
asm-generic := -f $(srctree)/scripts/Makefile.asm-generic obj
--
2.25.1
^ permalink raw reply related [flat|nested] 10+ messages in thread* Re: [PATCH v6] Add optimized Makefile support for SoCFPGA handoff
2025-11-04 1:00 [PATCH v6] Add optimized Makefile support for SoCFPGA handoff Brian Sune
@ 2025-11-04 17:51 ` Tom Rini
2025-11-04 20:42 ` Sune Brian
2025-11-04 21:11 ` Sune Brian
0 siblings, 2 replies; 10+ messages in thread
From: Tom Rini @ 2025-11-04 17:51 UTC (permalink / raw)
To: Brian Sune; +Cc: u-boot
[-- Attachment #1: Type: text/plain, Size: 1605 bytes --]
On Tue, Nov 04, 2025 at 09:00:03AM +0800, Brian Sune wrote:
> Add optimized Makefile support for SoCFPGA handoff
>
> - Introduce socfpga_g5_hanoff_prepare target in U-Boot Makefile
> - Detects Altera/Intel SoCFPGA boards from .config
> - Combines vendor/board extraction into a single shell call
> - Checks for hps_isw_handoff folder and .hiof files
> - Uses ls -d instead of find for faster folder detection
> - Runs BSP generator script only if files exist
> - Non-blocking: continues if handoff folder or files are missing
> - HANDOFF_PATH user define allows overriding auto-detected folder
> - Minimizes subshells and other slow constructs for faster CI
>
> Signed-off-by: Brian Sune <briansune@gmail.com>
> ---
> Makefile | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++--
> 1 file changed, 51 insertions(+), 2 deletions(-)
This should be able to reside in arch/arm/mach-socfpga/config.mk and so
it should be moved there. It might need to be done under "archprepare".
That would also let us gate even trying it with an ifeq, like we do
currently. I also don't see that you tested this "make O=/tmp/somedir"
(which is not the HANDOFF_PATH thing) and I expect it doesn't work there
as it references ".config" and not "$(objdir)/.config".
Finally, since you mentioned AIs in other emails, we do not yet have a
formal policy for or against their usage in this project (it is
something we need to discuss) but at a minimum the Fedora policy makes
sense to me if using one:
https://docs.fedoraproject.org/en-US/council/policy/ai-contribution-policy/
--
Tom
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v6] Add optimized Makefile support for SoCFPGA handoff
2025-11-04 17:51 ` Tom Rini
@ 2025-11-04 20:42 ` Sune Brian
2025-11-04 21:18 ` Tom Rini
2025-11-04 21:11 ` Sune Brian
1 sibling, 1 reply; 10+ messages in thread
From: Sune Brian @ 2025-11-04 20:42 UTC (permalink / raw)
To: Tom Rini; +Cc: u-boot
> This should be able to reside in arch/arm/mach-socfpga/config.mk and so
> it should be moved there. It might need to be done under "archprepare".
> That would also let us gate even trying it with an ifeq, like we do
> currently. I also don't see that you tested this "make O=/tmp/somedir"
> (which is not the HANDOFF_PATH thing) and I expect it doesn't work there
> as it references ".config" and not "$(objdir)/.config".
I am not too familiar with make O=xxxx i never used it.
I will check what is the issue here.
Meantime, do .mk is same as Makefile or not?
> Finally, since you mentioned AIs in other emails, we do not yet have a
> formal policy for or against their usage in this project (it is
> something we need to discuss) but at a minimum the Fedora policy makes
> sense to me if using one:
> https://docs.fedoraproject.org/en-US/council/policy/ai-contribution-policy/
I don't think asking general on syntax run cost is a kind of issue.
Otherwise it will be a huge trouble to include all people or even
referenced website from the beginning. There are thousand kind
of syntax that can make things run. I will ignore this policy, sorry.
Even google these day uses AI supported engine.
Brian
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v6] Add optimized Makefile support for SoCFPGA handoff
2025-11-04 20:42 ` Sune Brian
@ 2025-11-04 21:18 ` Tom Rini
2025-11-04 21:33 ` Sune Brian
0 siblings, 1 reply; 10+ messages in thread
From: Tom Rini @ 2025-11-04 21:18 UTC (permalink / raw)
To: Sune Brian; +Cc: u-boot
[-- Attachment #1: Type: text/plain, Size: 1495 bytes --]
On Wed, Nov 05, 2025 at 04:42:55AM +0800, Sune Brian wrote:
> > This should be able to reside in arch/arm/mach-socfpga/config.mk and so
> > it should be moved there. It might need to be done under "archprepare".
> > That would also let us gate even trying it with an ifeq, like we do
> > currently. I also don't see that you tested this "make O=/tmp/somedir"
> > (which is not the HANDOFF_PATH thing) and I expect it doesn't work there
> > as it references ".config" and not "$(objdir)/.config".
>
> I am not too familiar with make O=xxxx i never used it.
> I will check what is the issue here.
> Meantime, do .mk is same as Makefile or not?
>
> > Finally, since you mentioned AIs in other emails, we do not yet have a
> > formal policy for or against their usage in this project (it is
> > something we need to discuss) but at a minimum the Fedora policy makes
> > sense to me if using one:
> > https://docs.fedoraproject.org/en-US/council/policy/ai-contribution-policy/
>
> I don't think asking general on syntax run cost is a kind of issue.
> Otherwise it will be a huge trouble to include all people or even
> referenced website from the beginning. There are thousand kind
> of syntax that can make things run. I will ignore this policy, sorry.
> Even google these day uses AI supported engine.
I'm sorry, but I don't think that's an appropriate response to me saying
that if you're using an AI to generate any of this then you should
disclose it.
--
Tom
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v6] Add optimized Makefile support for SoCFPGA handoff
2025-11-04 21:18 ` Tom Rini
@ 2025-11-04 21:33 ` Sune Brian
2025-11-04 22:37 ` Tom Rini
0 siblings, 1 reply; 10+ messages in thread
From: Sune Brian @ 2025-11-04 21:33 UTC (permalink / raw)
To: Tom Rini; +Cc: u-boot
> I'm sorry, but I don't think that's an appropriate response to me saying
> that if you're using an AI to generate any of this then you should
> disclose it.
I didn't generate any of this via AI. I just use AI to analyze the syntax cost
what you pointed out previously on the slow down.
I think there is a very distinct difference. Asking syntax vs telling AI to
generate the code is not the same. Otherwise any copy paste from
google is considered the same act.
However, I should not mention this in the first place because people are
so much trouble with AI tools these days. It is "voldemort" don;t say it's
name!
Back to the original issue.
Indeed $(src) is missing.
HANDOFF_BASE=$(src)/$$BOARD_DIR/hps_isw_handoff;
and
python3 $(src)/tools/cv_bsp_generator/cv_bsp_generator.py
With the above fix it should run smoothly w/o the issue you pointed out.
So you will insist me to move it to arch/arm/mach-socfpga/config.mk?
Brian
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v6] Add optimized Makefile support for SoCFPGA handoff
2025-11-04 21:33 ` Sune Brian
@ 2025-11-04 22:37 ` Tom Rini
2025-11-04 22:48 ` Sune Brian
0 siblings, 1 reply; 10+ messages in thread
From: Tom Rini @ 2025-11-04 22:37 UTC (permalink / raw)
To: Sune Brian; +Cc: u-boot
[-- Attachment #1: Type: text/plain, Size: 1280 bytes --]
On Wed, Nov 05, 2025 at 05:33:15AM +0800, Sune Brian wrote:
> > I'm sorry, but I don't think that's an appropriate response to me saying
> > that if you're using an AI to generate any of this then you should
> > disclose it.
>
> I didn't generate any of this via AI. I just use AI to analyze the syntax cost
> what you pointed out previously on the slow down.
> I think there is a very distinct difference. Asking syntax vs telling AI to
> generate the code is not the same. Otherwise any copy paste from
> google is considered the same act.
>
> However, I should not mention this in the first place because people are
> so much trouble with AI tools these days. It is "voldemort" don;t say it's
> name!
>
> Back to the original issue.
>
> Indeed $(src) is missing.
> HANDOFF_BASE=$(src)/$$BOARD_DIR/hps_isw_handoff;
> and
> python3 $(src)/tools/cv_bsp_generator/cv_bsp_generator.py
>
> With the above fix it should run smoothly w/o the issue you pointed out.
>
> So you will insist me to move it to arch/arm/mach-socfpga/config.mk?
Yes, it really needs to not be in the top level Makefile, the more stuff
we have there the trickier upstream merges get, especially when this can
be hooked to archprepare and work just fine. Thanks.
--
Tom
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v6] Add optimized Makefile support for SoCFPGA handoff
2025-11-04 22:37 ` Tom Rini
@ 2025-11-04 22:48 ` Sune Brian
2025-11-04 23:07 ` Tom Rini
0 siblings, 1 reply; 10+ messages in thread
From: Sune Brian @ 2025-11-04 22:48 UTC (permalink / raw)
To: Tom Rini; +Cc: u-boot
> Yes, it really needs to not be in the top level Makefile, the more stuff
> we have there the trickier upstream merges get, especially when this can
> be hooked to archprepare and work just fine. Thanks.
Done~ see v7
Now back to the documentation you want.
Where and what should be included.
If possible, a good example can help me settle things faster.
Brian
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v6] Add optimized Makefile support for SoCFPGA handoff
2025-11-04 22:48 ` Sune Brian
@ 2025-11-04 23:07 ` Tom Rini
2025-11-04 23:30 ` Sune Brian
0 siblings, 1 reply; 10+ messages in thread
From: Tom Rini @ 2025-11-04 23:07 UTC (permalink / raw)
To: Sune Brian; +Cc: u-boot
[-- Attachment #1: Type: text/plain, Size: 795 bytes --]
On Wed, Nov 05, 2025 at 06:48:19AM +0800, Sune Brian wrote:
> > Yes, it really needs to not be in the top level Makefile, the more stuff
> > we have there the trickier upstream merges get, especially when this can
> > be hooked to archprepare and work just fine. Thanks.
>
> Done~ see v7
>
> Now back to the documentation you want.
> Where and what should be included.
> If possible, a good example can help me settle things faster.
Well, doc/board/ti/, doc/board/nxp/ and doc/board/rockchip are all good
examples of how different SoCs have provided a pretty good level of
documentation, some of which includes various external blobs or tools to
also use. That might be a good starting point for better documenting
socfpga and then also including using this tool.
--
Tom
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v6] Add optimized Makefile support for SoCFPGA handoff
2025-11-04 23:07 ` Tom Rini
@ 2025-11-04 23:30 ` Sune Brian
0 siblings, 0 replies; 10+ messages in thread
From: Sune Brian @ 2025-11-04 23:30 UTC (permalink / raw)
To: Tom Rini; +Cc: u-boot
> Well, doc/board/ti/, doc/board/nxp/ and doc/board/rockchip are all good
> examples of how different SoCs have provided a pretty good level of
> documentation, some of which includes various external blobs or tools to
> also use. That might be a good starting point for better documenting
> socfpga and then also including using this tool.
Sounds like you are having high expectation on this socfpga documentation
revolution.
Just do what I can. HAHA
Brian
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v6] Add optimized Makefile support for SoCFPGA handoff
2025-11-04 17:51 ` Tom Rini
2025-11-04 20:42 ` Sune Brian
@ 2025-11-04 21:11 ` Sune Brian
1 sibling, 0 replies; 10+ messages in thread
From: Sune Brian @ 2025-11-04 21:11 UTC (permalink / raw)
To: Tom Rini; +Cc: u-boot
> currently. I also don't see that you tested this "make O=/tmp/somedir"
> (which is not the HANDOFF_PATH thing) and I expect it doesn't work there
> as it references ".config" and not "$(objdir)/.config".
Do you mean the handoff not generating?
For normal build it is still functioning, and with this config.mk
should also have
this trouble.
```
make prepare O=/tmp/test
HANDOFF_PATH=/media/sf_shared/loader/hps_isw_handoff/ddr3_5128x4_hps_0
make[1]: Entering directory '/tmp/test'
Using /home/intel/u-boot as source for U-Boot
GEN Makefile
UPD include/generated/timestamp_autogenerated.h
[INFO] SOC family detected: cyclone5
[INFO] Using manually specified handoff folder:
/media/sf_shared/loader/hps_isw_handoff/ddr3_5128x4_hps_0
[INFO] Found hiof file:
/media/sf_shared/loader/hps_isw_handoff/ddr3_5128x4_hps_0/ddr3_5128x4_hps_0.hiof
[INFO] Running BSP generator...
python3: can't open file 'tools/cv_bsp_generator/cv_bsp_generator.py':
[Errno 2] No such file or directory
[WARN] BSP generator failed, continuing...
[DONE] SoCFPGA QTS handoff conversion complete.
make[1]: Leaving directory '/tmp/test'
```
Build capture.
```
make clean && make mrproper
CLEAN scripts/basic
CLEAN scripts/kconfig
CLEAN .config
make O=/tmp/test socfpga_cyclone5_defconfig
make[1]: Entering directory '/tmp/test'
GEN Makefile
#
# configuration written to .config
#
make[1]: Leaving directory '/tmp/test'
make O=/tmp/test
make[1]: Entering directory '/tmp/test'
GEN Makefile
scripts/kconfig/conf --syncconfig Kconfig
CFG u-boot.cfg
GEN include/autoconf.mk
GEN include/autoconf.mk.dep
CFG spl/u-boot.cfg
GEN spl/include/autoconf.mk
Using /home/intel/u-boot as source for U-Boot
GEN Makefile
UPD include/generated/version_autogenerated.h
UPD include/generated/timestamp_autogenerated.h
UPD include/generated/dt.h
ENVC include/generated/env.txt
ENVP include/generated/env.in
ENVT include/generated/environment.h
HOSTCC scripts/dtc/dtc.o
HOSTCC scripts/dtc/flattree.o
~/u-boot$ ls /tmp/test/
arch disk examples lib source u-boot
u-boot-dtb.bin u-boot.map u-boot-with-spl.sfp
boot drivers fs Makefile spl u-boot.bin
u-boot-dtb.img u-boot-nodtb.bin
cmd dts generated_defconfig net System.map u-boot.cfg
u-boot.img u-boot.srec
common env include scripts tools u-boot.dtb
u-boot.lds u-boot.sym
```
Brian
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2025-11-04 23:30 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-11-04 1:00 [PATCH v6] Add optimized Makefile support for SoCFPGA handoff Brian Sune
2025-11-04 17:51 ` Tom Rini
2025-11-04 20:42 ` Sune Brian
2025-11-04 21:18 ` Tom Rini
2025-11-04 21:33 ` Sune Brian
2025-11-04 22:37 ` Tom Rini
2025-11-04 22:48 ` Sune Brian
2025-11-04 23:07 ` Tom Rini
2025-11-04 23:30 ` Sune Brian
2025-11-04 21:11 ` Sune Brian
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox