diff mbox series

[v2,1/2] package/zynqmp-firmware: new package

Message ID 20230327170604.22854-1-neal.frager@amd.com
State Changes Requested
Headers show
Series [v2,1/2] package/zynqmp-firmware: new package | expand

Commit Message

Neal Frager March 27, 2023, 5:06 p.m. UTC
This patch adds a new package to buildroot for building the zynqmp pmufw
with the requirement that the user must provide an external microblaze
toolchain.

The below example config options can be used to build the pmufw.elf v2022.2
using the Xilinx toolchain.

BR2_PACKAGE_ZYNQMP_FIRMWARE=y
BR2_PACKAGE_ZYNQMP_FIRMWARE_VERSION="v2022.2"
BR2_PACKAGE_ZYNQMP_FIRMWARE_EXTERNAL_TOOLCHAIN_PATH="/opt/Xilinx/Vitis/2022.2/gnu/microblaze/lin"
BR2_PACKAGE_ZYNQMP_FIRMWARE_EXTERNAL_TOOLCHAIN_PREFIX="microblaze-xilinx-elf-"

Signed-off-by: Neal Frager <neal.frager@amd.com>
---
V1->V2:
  - switched make command to $(MAKE1)
  - removed kria config and replaced it with custom_flags
  - using call github instead of the https path to the sources
  - removed Xilinx/embeddedsw patch that is no longer required
---
 DEVELOPERS                                 |  1 +
 package/Config.in                          |  1 +
 package/zynqmp-firmware/Config.in          | 32 ++++++++++++++++++++++
 package/zynqmp-firmware/zynqmp-firmware.mk | 30 ++++++++++++++++++++
 4 files changed, 64 insertions(+)
 create mode 100644 package/zynqmp-firmware/Config.in
 create mode 100644 package/zynqmp-firmware/zynqmp-firmware.mk

Comments

Luca Ceresoli April 7, 2023, 3:16 p.m. UTC | #1
Hi Neal,

On Mon, 27 Mar 2023 18:06:03 +0100
Neal Frager <neal.frager@amd.com> wrote:

> This patch adds a new package to buildroot for building the zynqmp pmufw
> with the requirement that the user must provide an external microblaze
> toolchain.
> 
> The below example config options can be used to build the pmufw.elf v2022.2
> using the Xilinx toolchain.
> 
> BR2_PACKAGE_ZYNQMP_FIRMWARE=y
> BR2_PACKAGE_ZYNQMP_FIRMWARE_VERSION="v2022.2"
> BR2_PACKAGE_ZYNQMP_FIRMWARE_EXTERNAL_TOOLCHAIN_PATH="/opt/Xilinx/Vitis/2022.2/gnu/microblaze/lin"
> BR2_PACKAGE_ZYNQMP_FIRMWARE_EXTERNAL_TOOLCHAIN_PREFIX="microblaze-xilinx-elf-"
> 
> Signed-off-by: Neal Frager <neal.frager@amd.com>

These two patches look good, and I appreciate a lot your effort, however
I'm not sure it's a good idea to support both an external and a
generated toolchain. It makes things more complicated on the Buildroot
side and I'm not aware of any actual benefits.

Moreover if we take these patches now we would to some extent encourage
users to use an external Microblaze toolchain, possibly reducing usage
of the generated one for initial users. And I guess we would stick to
the external toolchain as a default for the future because it's what
was there initially.

So I would prefer waiting until we have a working
Buildroot-generated toolchain and initially support only that. Support
for an external toolchain can be added easily later, in case the
generated one were not suitable for good reasons.

Do you have any updates on your work to generate a minimal Microblaze
toolchain within Buildroot? Should you be facing any issues, remember
the Buildroot community can be very helpful!

Best regards,
Luca
Thomas Petazzoni Aug. 22, 2023, 10:01 p.m. UTC | #2
On Fri, 7 Apr 2023 17:16:48 +0200
Luca Ceresoli via buildroot <buildroot@buildroot.org> wrote:

> These two patches look good, and I appreciate a lot your effort, however
> I'm not sure it's a good idea to support both an external and a
> generated toolchain. It makes things more complicated on the Buildroot
> side and I'm not aware of any actual benefits.
> 
> Moreover if we take these patches now we would to some extent encourage
> users to use an external Microblaze toolchain, possibly reducing usage
> of the generated one for initial users. And I guess we would stick to
> the external toolchain as a default for the future because it's what
> was there initially.
> 
> So I would prefer waiting until we have a working
> Buildroot-generated toolchain and initially support only that. Support
> for an external toolchain can be added easily later, in case the
> generated one were not suitable for good reasons.
> 
> Do you have any updates on your work to generate a minimal Microblaze
> toolchain within Buildroot? Should you be facing any issues, remember
> the Buildroot community can be very helpful!

I agree with Luca, but I would relax a bit the requirement and say I
would be fine with a pre-built external toolchain to be packaged, like
package/arm-gnu-toolchain/ does for a pre-built ARM32 bare-metal
toolchain.

I looked a bit for such a pre-built Microblaze toolchain, but all what
Xilinx provides is hidden inside multi-GB archives with zillions of
things, and these archives are themselves accessible with a proper
login on the Xilinx site.

So either Xilinx puts online a bare-metal toolchain that we can package
like package/arm-gnu-toolchain/, or we look at adding support for
building a bare-metal toolchain in Buildroot.

Thomas
diff mbox series

Patch

diff --git a/DEVELOPERS b/DEVELOPERS
index b6d288c54f..d3436d40f2 100644
--- a/DEVELOPERS
+++ b/DEVELOPERS
@@ -2151,6 +2151,7 @@  F:	configs/zynqmp_zcu106_defconfig
 F:	configs/zynqmp_kria_kv260_defconfig
 F:	package/bootgen/
 F:	package/versal-firmware/
+F:	package/zynqmp-firmware/
 
 N:	Nicola Di Lieto <nicola.dilieto@gmail.com>
 F:	package/uacme/
diff --git a/package/Config.in b/package/Config.in
index 0f8dab3e71..6c7419490d 100644
--- a/package/Config.in
+++ b/package/Config.in
@@ -450,6 +450,7 @@  menu "Firmware"
 	source "package/wilc-firmware/Config.in"
 	source "package/wilink-bt-firmware/Config.in"
 	source "package/zd1211-firmware/Config.in"
+	source "package/zynqmp-firmware/Config.in"
 endmenu
 	source "package/18xx-ti-utils/Config.in"
 	source "package/a10disp/Config.in"
diff --git a/package/zynqmp-firmware/Config.in b/package/zynqmp-firmware/Config.in
new file mode 100644
index 0000000000..6513c9a995
--- /dev/null
+++ b/package/zynqmp-firmware/Config.in
@@ -0,0 +1,32 @@ 
+config BR2_PACKAGE_ZYNQMP_FIRMWARE
+	bool "zynqmp-firmware"
+	help
+	  This package builds the PMU Firmware application required to run
+	  U-Boot and Linux in the Zynq MPSoC devices.
+
+if BR2_PACKAGE_ZYNQMP_FIRMWARE
+
+config BR2_PACKAGE_ZYNQMP_FIRMWARE_VERSION
+	string "firmware version"
+	default "xilinx_v2022.2"
+	help
+	  Release version of zynqmp firmware.
+
+config BR2_PACKAGE_ZYNQMP_FIRMWARE_EXTERNAL_TOOLCHAIN_PATH
+	string "external toolchain path"
+	default "/opt/Xilinx/Vitis/2022.2/gnu/microblaze/lin"
+	help
+	  Path to pre-installed external microblaze toolchain.
+
+config BR2_PACKAGE_ZYNQMP_FIRMWARE_EXTERNAL_TOOLCHAIN_PREFIX
+	string "external toolchain prefix"
+	default "microblaze-xilinx-elf-"
+	help
+	  Pre-installed external microblaze toolchain prefix.
+
+config BR2_PACKAGE_ZYNQMP_FIRMWARE_CUSTOM_CFLAGS
+	string "custom cflags"
+	help
+	  Adds additional CFLAGS for building zynqmp firmware.
+
+endif # BR2_PACKAGE_ZYNQMP_FIRMWARE
diff --git a/package/zynqmp-firmware/zynqmp-firmware.mk b/package/zynqmp-firmware/zynqmp-firmware.mk
new file mode 100644
index 0000000000..25c8fbf699
--- /dev/null
+++ b/package/zynqmp-firmware/zynqmp-firmware.mk
@@ -0,0 +1,30 @@ 
+################################################################################
+#
+# zynqmp-firmware
+#
+################################################################################
+
+ZYNQMP_FIRMWARE_VERSION = $(call qstrip,$(BR2_PACKAGE_ZYNQMP_FIRMWARE_VERSION))
+ZYNQMP_FIRMWARE_SITE = $(call github,Xilinx,embeddedsw,$(ZYNQMP_FIRMWARE_VERSION))
+ZYNQMP_FIRMWARE_LICENSE = MIT
+ZYNQMP_FIRMWARE_LICENSE_FILES = license.txt
+ZYNQMP_FIRMWARE_INSTALL_IMAGES = YES
+ZYNQMP_FIRMWARE_INSTALL_TARGET = NO
+
+ZYNQMP_FIRMWARE_EXTERNAL_TOOLCHAIN_PATH = $(call qstrip,$(BR2_PACKAGE_ZYNQMP_FIRMWARE_EXTERNAL_TOOLCHAIN_PATH))
+ZYNQMP_FIRMWARE_EXTERNAL_TOOLCHAIN_PREFIX = $(call qstrip,$(BR2_PACKAGE_ZYNQMP_FIRMWARE_EXTERNAL_TOOLCHAIN_PREFIX))
+ZYNQMP_CFLAGS = "-Os -flto -ffat-lto-objects $(call qstrip,$(BR2_PACKAGE_ZYNQMP_FIRMWARE_CUSTOM_CFLAGS))"
+
+define ZYNQMP_FIRMWARE_BUILD_CMDS
+	$(MAKE1) -C $(@D)/lib/sw_apps/zynqmp_pmufw/src \
+		COMPILER=$(ZYNQMP_FIRMWARE_EXTERNAL_TOOLCHAIN_PATH)/$(ZYNQMP_FIRMWARE_EXTERNAL_TOOLCHAIN_PREFIX)gcc \
+		ARCHIVER=$(ZYNQMP_FIRMWARE_EXTERNAL_TOOLCHAIN_PATH)/$(ZYNQMP_FIRMWARE_EXTERNAL_TOOLCHAIN_PREFIX)gcc-ar \
+		CC=$(ZYNQMP_FIRMWARE_EXTERNAL_TOOLCHAIN_PATH)/$(ZYNQMP_FIRMWARE_EXTERNAL_TOOLCHAIN_PREFIX)gcc \
+		CFLAGS=$(ZYNQMP_CFLAGS)
+endef
+
+define ZYNQMP_FIRMWARE_INSTALL_IMAGES_CMDS
+	$(INSTALL) -D -m 0755 $(@D)/lib/sw_apps/zynqmp_pmufw/src/executable.elf $(BINARIES_DIR)/pmufw.elf
+endef
+
+$(eval $(generic-package))