Skip to contentSkip to conversation

package/zynqmp-firmware: new package

PATCH Superseded Neal Frager via buildroot 1 participant 5 messages Mar 27, 2023 – Aug 22, 2023 Arm/Zynq architecture

v2 of 12 Superseded Latest is v12 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/2 package/zynqmp-firmware: new package

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-"

---
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
DEVELOPERS +1 -0
index b6d288c54f..d3436d40f2 100644
@@ -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 <[email protected]>
 F:	package/uacme/
package/Config.in +1 -0
index 0f8dab3e71..6c7419490d 100644
@@ -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"
package/zynqmp-firmware/Config.in new file +32 -0
new file mode 100644
index 0000000000..6513c9a995
@@ -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
package/zynqmp-firmware/zynqmp-firmware.mk new file +30 -0
new file mode 100644
index 0000000000..25c8fbf699
@@ -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))
Signature · 6 lines
2.17.1

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#1 lore raw

PATCH v2 2/2 boot/uboot.mk: new zynqmp pmufw build option

The new BR2_TARGET_UBOOT_ZYNQMP_PMUFW_SOURCE option will enable u-boot to use the zynqmp-firmware package for building a pmufw.elf that gets included in the generated boot.bin.

---
V1->V2:
- Improved naming to be clear about choice between building from source or using prebuilt image
- Updated zynqmp_xxx_defconfig files to use new naming convention

---
 boot/uboot/Config.in                | 22 +++++++++++++++++++---
 boot/uboot/uboot.mk                 |  7 ++++++-
 configs/zynqmp_kria_kv260_defconfig |  2 +-
 configs/zynqmp_zcu102_defconfig     |  2 +-
 configs/zynqmp_zcu106_defconfig     |  2 +-
 5 files changed, 28 insertions(+), 7 deletions(-)
boot/uboot/Config.in +19 -3
index f5c20f5168..cf9da88749 100644
@@ -476,11 +476,25 @@ config BR2_TARGET_UBOOT_ZYNQMP
 
 if BR2_TARGET_UBOOT_ZYNQMP
 
-config BR2_TARGET_UBOOT_ZYNQMP_PMUFW
-	string "PMU firmware location"
+choice
+	prompt "zynqmp firmware source or prebuilt"
+	default BR2_TARGET_UBOOT_ZYNQMP_PMUFW_PREBUILT
 	depends on BR2_TARGET_UBOOT_BUILD_SYSTEM_KCONFIG
+
+config BR2_TARGET_UBOOT_ZYNQMP_PMUFW_SOURCE
+	bool "Build zynqmp PMU firmware from source"
+	depends on BR2_PACKAGE_ZYNQMP_FIRMWARE
+	help
+	  This option instructs u-boot to build the zynqmp pmufw using
+	  the zynqmp-firmware package.  u-boot will then include this
+	  pmufw.elf in the generated boot.bin.
+
+	  This feature requires U-Boot >= 2018.07.
+
+config BR2_TARGET_UBOOT_ZYNQMP_PMUFW_PREBUILT
+	string "Pre-built zynqmp PMU firmware location"
 	help
-	  Location of a PMU firmware binary.
+	  Location of a pre-built PMU firmware binary.
 
 	  If not empty, instructs the U-Boot build process to generate
 	  a boot.bin (to be loaded by the ZynqMP boot ROM) containing
@@ -497,6 +511,8 @@ config BR2_TARGET_UBOOT_ZYNQMP_PMUFW
 
 	  This feature requires U-Boot >= 2018.07.
 
+endchoice
+
 config BR2_TARGET_UBOOT_ZYNQMP_PM_CFG
 	string "PMU configuration location"
 	depends on BR2_TARGET_UBOOT_BUILD_SYSTEM_KCONFIG
boot/uboot/uboot.mk +6 -1
index 4eae8e95c3..5493c9fe75 100644
@@ -390,7 +390,12 @@ endef
 
 ifeq ($(BR2_TARGET_UBOOT_ZYNQMP),y)
 
-UBOOT_ZYNQMP_PMUFW = $(call qstrip,$(BR2_TARGET_UBOOT_ZYNQMP_PMUFW))
+ifeq ($(BR2_TARGET_UBOOT_ZYNQMP_PMUFW_SOURCE),y)
+UBOOT_DEPENDENCIES += zynqmp-firmware
+UBOOT_ZYNQMP_PMUFW = $(BINARIES_DIR)/pmufw.elf
+else
+UBOOT_ZYNQMP_PMUFW = $(call qstrip,$(BR2_TARGET_UBOOT_ZYNQMP_PMUFW_PREBUILT))
+endif
 
 ifneq ($(findstring ://,$(UBOOT_ZYNQMP_PMUFW)),)
 UBOOT_EXTRA_DOWNLOADS += $(UBOOT_ZYNQMP_PMUFW)
configs/zynqmp_kria_kv260_defconfig +1 -1
index e180d5e7e7..36cac86282 100644
@@ -31,7 +31,7 @@ BR2_TARGET_UBOOT_NEEDS_OPENSSL=y
 BR2_TARGET_UBOOT_SPL=y
 BR2_TARGET_UBOOT_SPL_NAME="spl/boot.bin"
 BR2_TARGET_UBOOT_ZYNQMP=y
-BR2_TARGET_UBOOT_ZYNQMP_PMUFW="https://github.com/Xilinx/ubuntu-firmware/raw/2022.2_br_1/kv260/kv260_pmufw.elf"
+BR2_TARGET_UBOOT_ZYNQMP_PMUFW_PREBUILT="https://github.com/Xilinx/ubuntu-firmware/raw/2022.2_br_1/kv260/kv260_pmufw.elf"
 BR2_TARGET_UBOOT_ZYNQMP_PM_CFG="board/zynqmp/kria/kv260/pm_cfg_obj.c"
 BR2_TARGET_UBOOT_FORMAT_ITB=y
 BR2_TARGET_UBOOT_NEEDS_ATF_BL31=y
configs/zynqmp_zcu102_defconfig +1 -1
index 00b33261b6..0b76f76c70 100644
@@ -29,7 +29,7 @@ BR2_TARGET_UBOOT_NEEDS_OPENSSL=y
 BR2_TARGET_UBOOT_SPL=y
 BR2_TARGET_UBOOT_SPL_NAME="spl/boot.bin"
 BR2_TARGET_UBOOT_ZYNQMP=y
-BR2_TARGET_UBOOT_ZYNQMP_PMUFW="https://github.com/Xilinx/ubuntu-firmware/raw/2022.2_br_1/zcu102/zcu102_pmufw.elf"
+BR2_TARGET_UBOOT_ZYNQMP_PMUFW_PREBUILT="https://github.com/Xilinx/ubuntu-firmware/raw/2022.2_br_1/zcu102/zcu102_pmufw.elf"
 BR2_TARGET_UBOOT_ZYNQMP_PM_CFG="board/zynqmp/zcu102/pm_cfg_obj.c"
 BR2_TARGET_UBOOT_FORMAT_ITB=y
 BR2_TARGET_UBOOT_NEEDS_ATF_BL31=y
configs/zynqmp_zcu106_defconfig +1 -1
index 88295571af..04beeba0fe 100644
@@ -29,7 +29,7 @@ BR2_TARGET_UBOOT_NEEDS_OPENSSL=y
 BR2_TARGET_UBOOT_SPL=y
 BR2_TARGET_UBOOT_SPL_NAME="spl/boot.bin"
 BR2_TARGET_UBOOT_ZYNQMP=y
-BR2_TARGET_UBOOT_ZYNQMP_PMUFW="https://github.com/Xilinx/ubuntu-firmware/raw/2022.2_br_1/zcu106/zcu106_pmufw.elf"
+BR2_TARGET_UBOOT_ZYNQMP_PMUFW_PREBUILT="https://github.com/Xilinx/ubuntu-firmware/raw/2022.2_br_1/zcu106/zcu106_pmufw.elf"
 BR2_TARGET_UBOOT_ZYNQMP_PM_CFG="board/zynqmp/zcu106/pm_cfg_obj.c"
 BR2_TARGET_UBOOT_FORMAT_ITB=y
 BR2_TARGET_UBOOT_NEEDS_ATF_BL31=y
Signature · 6 lines
2.17.1

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#2 lore raw

Re: [Buildroot] [PATCH v2 2/2] boot/uboot.mk: new zynqmp pmufw build option

boot/uboot/Config.in config BR2_TARGET_UBOOT_ZYNQMP · line 480

Quoted 2 lines · On Mon, 27 Mar 2023 18:06:04 +0100 Neal Frager via buildroot…
boot/uboot/Config.in +0 -2
-config BR2_TARGET_UBOOT_ZYNQMP_PMUFW
-	string "PMU firmware location"

The removal of this option will require Config.in.legacy handling.

Quoted 7 lines
boot/uboot/Config.in +6 -0
+choice
+	prompt "zynqmp firmware source or prebuilt"
+	default BR2_TARGET_UBOOT_ZYNQMP_PMUFW_PREBUILT
 	depends on BR2_TARGET_UBOOT_BUILD_SYSTEM_KCONFIG
+
+config BR2_TARGET_UBOOT_ZYNQMP_PMUFW_SOURCE
+	bool "Build zynqmp PMU firmware from source"

boot/uboot/Config.in config BR2_TARGET_UBOOT_ZYNQMP · line 495

Quoted 10 lines
boot/uboot/Config.in +10 -0
+	depends on BR2_PACKAGE_ZYNQMP_FIRMWARE
+	help
+	  This option instructs u-boot to build the zynqmp pmufw using
+	  the zynqmp-firmware package.  u-boot will then include this
+	  pmufw.elf in the generated boot.bin.
+
+	  This feature requires U-Boot >= 2018.07.
+
+config BR2_TARGET_UBOOT_ZYNQMP_PMUFW_PREBUILT
+	string "Pre-built zynqmp PMU firmware location"

We can have choice between a boolean option and a string option? Does that work?

Thomas

Signature · 7 lines
Thomas Petazzoni, co-owner and CEO, Bootlin
Embedded Linux and Kernel engineering and training
https://bootlin.com
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#3 lore raw
In reply to Neal Frager via buildroot

Hi Neal,

Quoted 7 lines · On Mon, 27 Mar 2023 18:06:03 +0100 Neal Frager <[email protected]> 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.

Quoted 6 lines

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-"

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

Signature · 7 lines
Luca Ceresoli, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#4 lore raw
Quoted 11 lines · On Fri, 7 Apr 2023 17:16:48 +0200 Luca Ceresoli via buildroot…

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.

Quoted 8 lines

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

Signature · 7 lines
Thomas Petazzoni, co-owner and CEO, Bootlin
Embedded Linux and Kernel engineering and training
https://bootlin.com
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot