Skip to contentSkip to conversation

Add make feature support for SoCFPGA Handoff

PATCH Superseded Brian Sune 2 participants 9 messages Nov 1, 2025 – Nov 3, 2025 Kbuild

v2 of 5 Superseded Latest is v5 →

lore
Share & tools
lore

Brian Sune

author
#0 lore raw

PATCH v2 1/1 Add make feature support for SoCFPGA Handoff

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.

---
 Makefile | 42 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 42 insertions(+)
Makefile +42 -0
index 750f8a84b1f..74474368413 100644
@@ -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 \
Signature · 1 line
2.25.1
#1 lore raw
Quoted 55 lines · Brian Sune

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.

---
 Makefile | 42 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 42 insertions(+)
Makefile +35 -0
index 750f8a84b1f..74474368413 100644
@@ -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"; \

Makefile CFLAGS_KERNEL = · line 531

Quoted 10 lines
Makefile +7 -0
+		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!

Signature · 1 line
Tom
author
#2 lore raw
Quoted 5 lines

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

#3 lore raw
Quoted 28 lines · Sune Brian
Quoted 5 lines

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
Quoted 3 lines

`-- 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.

Signature · 1 line
Tom
author
#4 lore raw
Quoted 5 lines · Sune Brian
Quoted 4 lines
Quoted 4 lines

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

#5 lore raw
Quoted 6 lines · Sune Brian
Quoted 5 lines · Sune Brian
Quoted 4 lines
Quoted 4 lines

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

Quoted 6 lines

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.

Signature · 1 line
Tom
author
#6 lore raw
Quoted 9 lines

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

#7 lore raw
Quoted 24 lines · Sune Brian
Quoted 9 lines

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.

Quoted 6 lines

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.

Signature · 1 line
Tom
author
#8 lore raw
Quoted 3 lines

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