public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [PATCH v2] Add make feature support for SoCFPGA Handoff
@ 2025-11-01  3:52 Brian Sune
  2025-11-03 15:36 ` Tom Rini
  0 siblings, 1 reply; 9+ messages in thread
From: Brian Sune @ 2025-11-01  3:52 UTC (permalink / raw)
  To: Tom Rini, u-boot

Added new make command to support
Altera GEN5 SoCFPGA handoff conversion.
The new make qts_handoff_gen will use
two parameters QTS_DIR and HANDOFF_DIR.
Checking is done via .config SoCFPGA
family selection and directory existency.

Signed-off-by: Brian Sune <briansune@gmail.com>
---
 Makefile | 42 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 42 insertions(+)

diff --git a/Makefile b/Makefile
index 750f8a84b1f..74474368413 100644
--- a/Makefile
+++ b/Makefile
@@ -484,6 +484,48 @@ CFLAGS_KERNEL	=
 AFLAGS_KERNEL	=
 LDFLAGS_vmlinux =
 
+# Intel-Altera Gen5 SoCFPGA QTS Handoff generator target (detect SoC from .config)
+QTS_HANDOFF_GEN_PY  := $(CURDIR)/tools/cv_bsp_generator/cv_bsp_generator.py
+
+# Detect SOC family from .config
+SOC_FAMILY := $(shell \
+	if grep -q '^CONFIG_TARGET_SOCFPGA_CYCLONE5=y' .config; then \
+		echo cyclone5; \
+	elif grep -q '^CONFIG_TARGET_SOCFPGA_ARRIA5=y' .config; then \
+		echo arria5; \
+	elif grep -q '^CONFIG_TARGET_SOCFPGA_ARRIA10=y' .config; then \
+		echo arria10; \
+	else \
+		echo unknown; \
+	fi)
+
+.PHONY: qts_handoff_gen
+qts_handoff_gen:
+	@if [ ! -f .config ]; then \
+		echo "Error: .config not found. Run 'make <defconfig>' first."; \
+		exit 1; \
+	fi
+	@if [ "$(SOC_FAMILY)" = "unknown" ]; then \
+		echo "Error: Could not detect SoCFPGA family from .config"; \
+		exit 1; \
+	fi
+	@if [ ! -d "$(HANDOFF_DIR)" ]; then \
+		echo "Error: handoff directory '$(HANDOFF_DIR)' does not exist."; \
+		exit 1; \
+	fi
+	@if [ -z "$(QTS_DIR)" ]; then \
+		echo "Error: QTS_DIR is not defined."; \
+		exit 1; \
+	fi
+	@if [ ! -d "$(CURDIR)/board/$(QTS_DIR)/qts" ]; then \
+		echo "Creating QTS output directory: $(CURDIR)/board/$(QTS_DIR)/qts"; \
+		exit 1; \
+	fi
+	@echo "=== Detected SoCFPGA family: $(SOC_FAMILY) ==="
+	@echo "=== Generating BSP to $(CURDIR)/board/$(QTS_DIR)/qts ==="
+	python3 $(QTS_HANDOFF_GEN_PY) -i $(HANDOFF_DIR) -o $(CURDIR)/board/$(QTS_DIR)/qts
+	@echo "=== QTS generation complete ==="
+
 # Use USERINCLUDE when you must reference the UAPI directories only.
 USERINCLUDE    := \
 		-I$(srctree)/arch/$(SRCARCH)/include/uapi \
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH v2] Add make feature support for SoCFPGA Handoff
  2025-11-01  3:52 [PATCH v2] Add make feature support for SoCFPGA Handoff Brian Sune
@ 2025-11-03 15:36 ` Tom Rini
  2025-11-03 18:55   ` Sune Brian
  0 siblings, 1 reply; 9+ messages in thread
From: Tom Rini @ 2025-11-03 15:36 UTC (permalink / raw)
  To: Brian Sune; +Cc: u-boot

[-- Attachment #1: Type: text/plain, Size: 2737 bytes --]

On Sat, Nov 01, 2025 at 11:52:52AM +0800, Brian Sune wrote:

> Added new make command to support
> Altera GEN5 SoCFPGA handoff conversion.
> The new make qts_handoff_gen will use
> two parameters QTS_DIR and HANDOFF_DIR.
> Checking is done via .config SoCFPGA
> family selection and directory existency.
> 
> Signed-off-by: Brian Sune <briansune@gmail.com>
> ---
>  Makefile | 42 ++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 42 insertions(+)
> 
> diff --git a/Makefile b/Makefile
> index 750f8a84b1f..74474368413 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -484,6 +484,48 @@ CFLAGS_KERNEL	=
>  AFLAGS_KERNEL	=
>  LDFLAGS_vmlinux =
>  
> +# Intel-Altera Gen5 SoCFPGA QTS Handoff generator target (detect SoC from .config)
> +QTS_HANDOFF_GEN_PY  := $(CURDIR)/tools/cv_bsp_generator/cv_bsp_generator.py
> +
> +# Detect SOC family from .config
> +SOC_FAMILY := $(shell \
> +	if grep -q '^CONFIG_TARGET_SOCFPGA_CYCLONE5=y' .config; then \
> +		echo cyclone5; \
> +	elif grep -q '^CONFIG_TARGET_SOCFPGA_ARRIA5=y' .config; then \
> +		echo arria5; \
> +	elif grep -q '^CONFIG_TARGET_SOCFPGA_ARRIA10=y' .config; then \
> +		echo arria10; \
> +	else \
> +		echo unknown; \
> +	fi)
> +
> +.PHONY: qts_handoff_gen
> +qts_handoff_gen:
> +	@if [ ! -f .config ]; then \
> +		echo "Error: .config not found. Run 'make <defconfig>' first."; \
> +		exit 1; \
> +	fi
> +	@if [ "$(SOC_FAMILY)" = "unknown" ]; then \
> +		echo "Error: Could not detect SoCFPGA family from .config"; \
> +		exit 1; \
> +	fi
> +	@if [ ! -d "$(HANDOFF_DIR)" ]; then \
> +		echo "Error: handoff directory '$(HANDOFF_DIR)' does not exist."; \
> +		exit 1; \
> +	fi
> +	@if [ -z "$(QTS_DIR)" ]; then \
> +		echo "Error: QTS_DIR is not defined."; \
> +		exit 1; \
> +	fi
> +	@if [ ! -d "$(CURDIR)/board/$(QTS_DIR)/qts" ]; then \
> +		echo "Creating QTS output directory: $(CURDIR)/board/$(QTS_DIR)/qts"; \
> +		exit 1; \
> +	fi
> +	@echo "=== Detected SoCFPGA family: $(SOC_FAMILY) ==="
> +	@echo "=== Generating BSP to $(CURDIR)/board/$(QTS_DIR)/qts ==="
> +	python3 $(QTS_HANDOFF_GEN_PY) -i $(HANDOFF_DIR) -o $(CURDIR)/board/$(QTS_DIR)/qts
> +	@echo "=== QTS generation complete ==="
> +
>  # Use USERINCLUDE when you must reference the UAPI directories only.
>  USERINCLUDE    := \
>  		-I$(srctree)/arch/$(SRCARCH)/include/uapi \

OK. I was hoping that we could just automate as part of the regular
build process seeing for example $(BOARD)/foo.xml and invoking the
script to re-create foo.c and so forth, but that doesn't seem to be the
case. So, no Makefile logic. We should then instead start on some
content for doc/board/socfpga/ and document this tool there. Thanks!

-- 
Tom

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v2] Add make feature support for SoCFPGA Handoff
  2025-11-03 15:36 ` Tom Rini
@ 2025-11-03 18:55   ` Sune Brian
  2025-11-03 20:09     ` Tom Rini
  0 siblings, 1 reply; 9+ messages in thread
From: Sune Brian @ 2025-11-03 18:55 UTC (permalink / raw)
  To: Tom Rini; +Cc: u-boot

> OK. I was hoping that we could just automate as part of the regular
> build process seeing for example $(BOARD)/foo.xml and invoking the
> script to re-create foo.c and so forth, but that doesn't seem to be the
> case. So, no Makefile logic. We should then instead start on some
> content for doc/board/socfpga/ and document this tool there. Thanks!

Ok what you expected on the automation flow.
I can give it a try. But the build flow for Altera project side
is that the compiled handoff is in the form of a folder.
only foo_bar is defined by user other naming on C5
should be fixed.

hps_isw_handoff/foo_bar/

|-- alt_types.h
|-- foo_bar.hiof
|-- emif.xml
|-- hps.xml
|-- id
|-- sdram_io.h
|-- sequencer.c
|-- sequencer.h
|-- sequencer_auto.h
|-- sequencer_auto_ac_init.c
|-- sequencer_auto_inst_init.c
|-- sequencer_defines.h
|-- system.h
|-- tclrpt.c
`-- tclrpt.h

Documentation is not an issue.

Brian

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v2] Add make feature support for SoCFPGA Handoff
  2025-11-03 18:55   ` Sune Brian
@ 2025-11-03 20:09     ` Tom Rini
  2025-11-03 20:16       ` Sune Brian
  0 siblings, 1 reply; 9+ messages in thread
From: Tom Rini @ 2025-11-03 20:09 UTC (permalink / raw)
  To: Sune Brian; +Cc: u-boot

[-- Attachment #1: Type: text/plain, Size: 1186 bytes --]

On Tue, Nov 04, 2025 at 02:55:53AM +0800, Sune Brian wrote:
> > OK. I was hoping that we could just automate as part of the regular
> > build process seeing for example $(BOARD)/foo.xml and invoking the
> > script to re-create foo.c and so forth, but that doesn't seem to be the
> > case. So, no Makefile logic. We should then instead start on some
> > content for doc/board/socfpga/ and document this tool there. Thanks!
> 
> Ok what you expected on the automation flow.
> I can give it a try. But the build flow for Altera project side
> is that the compiled handoff is in the form of a folder.
> only foo_bar is defined by user other naming on C5
> should be fixed.
> 
> hps_isw_handoff/foo_bar/
> 
> |-- alt_types.h
> |-- foo_bar.hiof
> |-- emif.xml
> |-- hps.xml
> |-- id
> |-- sdram_io.h
> |-- sequencer.c
> |-- sequencer.h
> |-- sequencer_auto.h
> |-- sequencer_auto_ac_init.c
> |-- sequencer_auto_inst_init.c
> |-- sequencer_defines.h
> |-- system.h
> |-- tclrpt.c
> `-- tclrpt.h
> 
> Documentation is not an issue.

OK, yes, I think we just document for ourselves too that the tool exists
and how it's expected to be run. Thanks.

-- 
Tom

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v2] Add make feature support for SoCFPGA Handoff
  2025-11-03 20:09     ` Tom Rini
@ 2025-11-03 20:16       ` Sune Brian
  2025-11-03 20:42         ` Tom Rini
  0 siblings, 1 reply; 9+ messages in thread
From: Sune Brian @ 2025-11-03 20:16 UTC (permalink / raw)
  To: Tom Rini; +Cc: u-boot

> On Tue, Nov 04, 2025 at 02:55:53AM +0800, Sune Brian wrote:
> > > OK. I was hoping that we could just automate as part of the regular
> > > build process seeing for example $(BOARD)/foo.xml and invoking the
> > > script to re-create foo.c and so forth, but that doesn't seem to be the
> > > case. So, no Makefile logic. We should then instead start on some

My previous mail would like to know what need to be done for the
Makefile logic automation works as you expected. I can give it a try.
And what is the current difficult?

Should the handoff compiled folder just place in the board/xxx/xxx
And let is auto build or not?

Brian

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v2] Add make feature support for SoCFPGA Handoff
  2025-11-03 20:16       ` Sune Brian
@ 2025-11-03 20:42         ` Tom Rini
  2025-11-03 20:50           ` Sune Brian
  0 siblings, 1 reply; 9+ messages in thread
From: Tom Rini @ 2025-11-03 20:42 UTC (permalink / raw)
  To: Sune Brian; +Cc: u-boot

[-- Attachment #1: Type: text/plain, Size: 1434 bytes --]

On Tue, Nov 04, 2025 at 04:16:28AM +0800, Sune Brian wrote:
> > On Tue, Nov 04, 2025 at 02:55:53AM +0800, Sune Brian wrote:
> > > > OK. I was hoping that we could just automate as part of the regular
> > > > build process seeing for example $(BOARD)/foo.xml and invoking the
> > > > script to re-create foo.c and so forth, but that doesn't seem to be the
> > > > case. So, no Makefile logic. We should then instead start on some
> 
> My previous mail would like to know what need to be done for the
> Makefile logic automation works as you expected. I can give it a try.
> And what is the current difficult?
> 
> Should the handoff compiled folder just place in the board/xxx/xxx
> And let is auto build or not?

I think I'm not explaining things well enough because I don't quite
understand the tooling well enough either. What I would like, but don't
think is possible, is something like:
$ make O=/tmp/myboard myboard_defconfig
... goes along and sees that boards/myvendor/myboard/myboard.xml exists.
... Runs the python script to re-create all of the C files, assuming xml
... is newer than the C files.
... Now compiles the new C files.

But I also don't know how useful that work flow is. Which is why I'm
going back to thinking that just having the tool, and documenting where
it is / how to run it (under docs/boards/... so that it shows up in our
generated docs) is likely good enough.

-- 
Tom

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v2] Add make feature support for SoCFPGA Handoff
  2025-11-03 20:42         ` Tom Rini
@ 2025-11-03 20:50           ` Sune Brian
  2025-11-03 22:17             ` Tom Rini
  0 siblings, 1 reply; 9+ messages in thread
From: Sune Brian @ 2025-11-03 20:50 UTC (permalink / raw)
  To: Tom Rini; +Cc: u-boot

> I think I'm not explaining things well enough because I don't quite
> understand the tooling well enough either. What I would like, but don't
> think is possible, is something like:
> $ make O=/tmp/myboard myboard_defconfig
> ... goes along and sees that boards/myvendor/myboard/myboard.xml exists.
> ... Runs the python script to re-create all of the C files, assuming xml
> ... is newer than the C files.
> ... Now compiles the new C files.
>

No, I think your method is just a bit more complex.
What my last suggestion is just put the handoff folder
next to qts i.e.

board/altera/abc/qts
board/altera/abc/hps_isw_handoff/foo_bar

Then once you run maybe "make prepare"?
It generates the new c sets.

Flow always:
make xxxx_defconfig
make prepare <- this is the place it should be automated.

As the user defines the board then what you need just place
it new to the qts so it even removes the -o -i user parameter.
And maybe leave the foo_bar naming for user to enter as
it could be renamed by the user during the Quartus project build.

Do you think this is good?

Brian

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v2] Add make feature support for SoCFPGA Handoff
  2025-11-03 20:50           ` Sune Brian
@ 2025-11-03 22:17             ` Tom Rini
  2025-11-03 22:32               ` Sune Brian
  0 siblings, 1 reply; 9+ messages in thread
From: Tom Rini @ 2025-11-03 22:17 UTC (permalink / raw)
  To: Sune Brian; +Cc: u-boot

[-- Attachment #1: Type: text/plain, Size: 1420 bytes --]

On Tue, Nov 04, 2025 at 04:50:25AM +0800, Sune Brian wrote:
> > I think I'm not explaining things well enough because I don't quite
> > understand the tooling well enough either. What I would like, but don't
> > think is possible, is something like:
> > $ make O=/tmp/myboard myboard_defconfig
> > ... goes along and sees that boards/myvendor/myboard/myboard.xml exists.
> > ... Runs the python script to re-create all of the C files, assuming xml
> > ... is newer than the C files.
> > ... Now compiles the new C files.
> >
> 
> No, I think your method is just a bit more complex.
> What my last suggestion is just put the handoff folder
> next to qts i.e.
> 
> board/altera/abc/qts
> board/altera/abc/hps_isw_handoff/foo_bar
> 
> Then once you run maybe "make prepare"?
> It generates the new c sets.
> 
> Flow always:
> make xxxx_defconfig
> make prepare <- this is the place it should be automated.
> 
> As the user defines the board then what you need just place
> it new to the qts so it even removes the -o -i user parameter.
> And maybe leave the foo_bar naming for user to enter as
> it could be renamed by the user during the Quartus project build.
> 
> Do you think this is good?

Well, I think so long as you can do "make xxx_defconfig" (and a separate
objdir not source tree), then "make" sees deps and re-runs as needed,
yes, this should be workable. Thanks.

-- 
Tom

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v2] Add make feature support for SoCFPGA Handoff
  2025-11-03 22:17             ` Tom Rini
@ 2025-11-03 22:32               ` Sune Brian
  0 siblings, 0 replies; 9+ messages in thread
From: Sune Brian @ 2025-11-03 22:32 UTC (permalink / raw)
  To: Tom Rini; +Cc: u-boot

> Well, I think so long as you can do "make xxx_defconfig" (and a separate
> objdir not source tree), then "make" sees deps and re-runs as needed,
> yes, this should be workable. Thanks.

Fresh UBOOT

```
make socfpga_cyclone5_defconfig
  HOSTCC  scripts/basic/fixdep
  HOSTCC  scripts/kconfig/conf.o
  YACC    scripts/kconfig/zconf.tab.c
  LEX     scripts/kconfig/zconf.lex.c
  HOSTCC  scripts/kconfig/zconf.tab.o
  HOSTLD  scripts/kconfig/conf
#
# configuration written to .config
#
```

When the board/xxx/ only got qts

```
make prepare
scripts/kconfig/conf  --syncconfig Kconfig
  UPD     include/config.h
  CFG     u-boot.cfg
  GEN     include/autoconf.mk
  GEN     include/autoconf.mk.dep
  CFG     spl/u-boot.cfg
  GEN     spl/include/autoconf.mk
  UPD     include/config/uboot.release
  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
  HOSTCC  scripts/dtc/fstree.o
  HOSTCC  scripts/dtc/data.o
  HOSTCC  scripts/dtc/livetree.o
  HOSTCC  scripts/dtc/treesource.o
  HOSTCC  scripts/dtc/srcpos.o
  HOSTCC  scripts/dtc/checks.o
  HOSTCC  scripts/dtc/util.o
  LEX     scripts/dtc/dtc-lexer.lex.c
  YACC    scripts/dtc/dtc-parser.tab.h
  HOSTCC  scripts/dtc/dtc-lexer.lex.o
  YACC    scripts/dtc/dtc-parser.tab.c
  HOSTCC  scripts/dtc/dtc-parser.tab.o
  HOSTLD  scripts/dtc/dtc
  CC      lib/asm-offsets.s
  UPD     include/generated/generic-asm-offsets.h
  CC      arch/arm/lib/asm-offsets.s
  UPD     include/generated/asm-offsets.h
```

When the board/xxx/handoff is place next to qts

```
make prepare
  UPD     include/generated/timestamp_autogenerated.h
[INFO] Handoff folder found: board/altera/cyclone5-socdk/hps_isw_handoff
[INFO] Handoff subfolder found under board/altera/cyclone5-socdk/hps_isw_handoff
[INFO] Found hiof file:
board/altera/cyclone5-socdk/hps_isw_handoff/ddr3_5128x4_hps_0/ddr3_5128x4_hps_0.hiof
[INFO] Using handoff folder: ddr3_5128x4_hps_0
[INFO] Running BSP generator...
Generating file: board/altera/cyclone5-socdk/qts/sdram_config.h...
Generating file: board/altera/cyclone5-socdk/qts/pinmux_config.h...
Generating file: board/altera/cyclone5-socdk/qts/pll_config.h
Reading file: board/altera/cyclone5-socdk/hps_isw_handoff/ddr3_5128x4_hps_0/ddr3_5128x4_hps_0.hiof...
Generating file: board/altera/cyclone5-socdk/qts/iocsr_config.h...
[DONE] SoCFPGA QTS handoff conversion complete.
```

or simply

```
make -j 8
  UPD     include/generated/timestamp_autogenerated.h
  UPD     include/config/uboot.release
[INFO] Handoff folder found: board/altera/cyclone5-socdk/hps_isw_handoff
[INFO] Handoff subfolder found under board/altera/cyclone5-socdk/hps_isw_handoff
[INFO] Found hiof file:
board/altera/cyclone5-socdk/hps_isw_handoff/ddr3_5128x4_hps_0/ddr3_5128x4_hps_0.hiof
[INFO] Using handoff folder: ddr3_5128x4_hps_0
[INFO] Running BSP generator...
Generating file: board/altera/cyclone5-socdk/qts/sdram_config.h...
Generating file: board/altera/cyclone5-socdk/qts/pinmux_config.h...
Generating file: board/altera/cyclone5-socdk/qts/pll_config.h
  UPD     include/generated/version_autogenerated.h
Reading file: board/altera/cyclone5-socdk/hps_isw_handoff/ddr3_5128x4_hps_0/ddr3_5128x4_hps_0.hiof...
Generating file: board/altera/cyclone5-socdk/qts/iocsr_config.h...
[DONE] SoCFPGA QTS handoff conversion complete.
  LDS     u-boot.lds
  AR      tools/built-in.a
  HOSTCC  tools/gen_eth_addr
  HOSTCC  tools/gen_ethaddr_crc.o
  HOSTCC  tools/img2srec
  WRAP    tools/generated/lib/crc8.c
  HOSTCC  tools/mkenvimage.o
  HOSTCC  tools/os_support.o
  WRAP    tools/generated/lib/crc32.c
  HOSTCC  tools/atmelimage.o
```

Any additional requests?

Brian

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2025-11-03 22:33 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-11-01  3:52 [PATCH v2] Add make feature support for SoCFPGA Handoff Brian Sune
2025-11-03 15:36 ` Tom Rini
2025-11-03 18:55   ` Sune Brian
2025-11-03 20:09     ` Tom Rini
2025-11-03 20:16       ` Sune Brian
2025-11-03 20:42         ` Tom Rini
2025-11-03 20:50           ` Sune Brian
2025-11-03 22:17             ` Tom Rini
2025-11-03 22:32               ` Sune Brian

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox