Add optimized Makefile support for SoCFPGA handoff
PATCH v6 1/1 Add optimized Makefile support for SoCFPGA handoff
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
--- Makefile | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 51 insertions(+), 2 deletions(-)
Makefile +51 -2
@@ -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
Signature · 1 line
2.25.1
Quoted 12 lines · Brian Sune
Add optimized
Makefilesupport for SoCFPGA handoff- Introduce
socfpga_g5_hanoff_preparetarget in U-BootMakefile
- Detects Altera/Intel SoCFPGA boards from .config
- Combines vendor/board extraction into a single shell call
- Checks forhps_isw_handofffolder 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_PATHuser define allows overriding auto-detected folder
- Minimizes subshells and other slow constructs for faster CI
Quoted 4 lines
Signed-off-by Brian Sune <[email protected]>--- 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/
Signature · 1 line
Tom
Quoted 6 lines
This should be able to reside in
arch/arm/mach-socfpga/config.mkand 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 theHANDOFF_PATHthing) 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?
Quoted 5 lines
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
Quoted 3 lines
currently. I also don't see that you tested this "make O=/tmp/somedir" (which is not the
HANDOFF_PATHthing) 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
Quoted 17 lines · Sune Brian
Quoted 6 lines
This should be able to reside in
arch/arm/mach-socfpga/config.mkand 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 theHANDOFF_PATHthing) 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 asMakefileor not?Quoted 5 lines
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/
Quoted 5 lines
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.
Signature · 1 line
Tom
Quoted 3 lines
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
Quoted 16 lines · Sune Brian
Quoted 3 lines
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.
Quoted 8 lines
Indeed $(src) is missing. HANDOFF_BASE=$(src)/$$BOARD_DIR/hps_isw_handoff; and
python3 $(src)/tools/cv_bsp_generator/cv_bsp_generator.pyWith 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.
Signature · 1 line
Tom
Quoted 3 lines
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
Quoted 9 lines · Sune Brian
Quoted 3 lines
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.
Signature · 1 line
Tom
Quoted 5 lines
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