diff mbox series

[v4,1/4] boot/xilinx-source: new boot package

Message ID 20240630134503.3658120-1-neal.frager@amd.com
State New
Headers show
Series [v4,1/4] boot/xilinx-source: new boot package | expand

Commit Message

Neal Frager June 30, 2024, 1:45 p.m. UTC
This patch adds a new boot package for building boot firmware for Xilinx
versal, zynqmp and kria targets.

Signed-off-by: Neal Frager <neal.frager@amd.com>
---
V1->V2:
- add make dependency to be sure bare-metal toolchain is built before trying
  to use the toolchain for building the xilinx-source firmware
V2->V3:
- fix copy paste error that causes build failure
V3->V4:
- remove versal dependency on xilinx-prebuilt package
- simplify build and install variables
---
 DEVELOPERS                            |  1 +
 boot/Config.in                        |  1 +
 boot/xilinx-source/Config.in          | 48 +++++++++++++++++++
 boot/xilinx-source/xilinx-source.hash |  2 +
 boot/xilinx-source/xilinx-source.mk   | 68 +++++++++++++++++++++++++++
 5 files changed, 120 insertions(+)
 create mode 100644 boot/xilinx-source/Config.in
 create mode 100644 boot/xilinx-source/xilinx-source.hash
 create mode 100644 boot/xilinx-source/xilinx-source.mk
diff mbox series

Patch

diff --git a/DEVELOPERS b/DEVELOPERS
index 8a5cceba78..af7f46fc6c 100644
--- a/DEVELOPERS
+++ b/DEVELOPERS
@@ -2342,6 +2342,7 @@  F:	board/xilinx/
 F:	board/zynq/
 F:	board/zynqmp/
 F:	boot/xilinx-prebuilt/
+F:	boot/xilinx-source/
 F:	configs/versal_vck190_defconfig
 F:	configs/zynq_zc702_defconfig
 F:	configs/zynq_zc706_defconfig
diff --git a/boot/Config.in b/boot/Config.in
index 25a50265d2..da22f15e8a 100644
--- a/boot/Config.in
+++ b/boot/Config.in
@@ -22,5 +22,6 @@  source "boot/ti-k3-r5-loader/Config.in"
 source "boot/uboot/Config.in"
 source "boot/vexpress-firmware/Config.in"
 source "boot/xilinx-prebuilt/Config.in"
+source "boot/xilinx-source/Config.in"
 
 endmenu
diff --git a/boot/xilinx-source/Config.in b/boot/xilinx-source/Config.in
new file mode 100644
index 0000000000..68b329d07c
--- /dev/null
+++ b/boot/xilinx-source/Config.in
@@ -0,0 +1,48 @@ 
+config BR2_TARGET_XILINX_SOURCE
+	bool "xilinx-source"
+	depends on BR2_aarch64
+	depends on BR2_TOOLCHAIN_BARE_METAL_BUILDROOT_ARCH = "microblazeel-xilinx-elf"
+	depends on !BR2_TARGET_XILINX_PREBUILT
+	help
+	  Build microblaze boot firmware from source for Xilinx boards.
+	  Users should choose either xilinx-source or xilinx-prebuilt.
+
+	  https://github.com/Xilinx/embeddedsw
+
+comment "xilinx-source needs a bare metal toolchain for tuple microblazeel-xilinx-elf"
+	depends on BR2_TOOLCHAIN_BARE_METAL_BUILDROOT_ARCH != "microblazeel-xilinx-elf"
+
+if BR2_TARGET_XILINX_SOURCE
+
+config BR2_TARGET_XILINX_SOURCE_VERSION
+	string "source version"
+	default "xilinx_v2024.1"
+	help
+	  Release version of Xilinx firmware.
+	  Must be xilinx_v2023.1 or newer.
+
+choice
+	bool "family variant"
+	default BR2_TARGET_XILINX_SOURCE_ZYNQMP
+
+config BR2_TARGET_XILINX_SOURCE_ZYNQMP
+	bool "zynqmp"
+
+config BR2_TARGET_XILINX_SOURCE_KRIA
+	bool "kria"
+
+config BR2_TARGET_XILINX_SOURCE_VERSAL
+	bool "versal"
+	help
+	  If building versal firmware from source, only the plm.elf and
+	  psmfw.elf images will be built by this package.  Users will need
+	  to include a Vivado generated PDI file for their target hardware.
+
+endchoice
+
+config BR2_TARGET_XILINX_SOURCE_USER_CFLAGS
+	string "optional user cflags"
+	help
+	  Add optional config flags when building xilinx boot firmware.
+
+endif # BR2_TARGET_XILINX_SOURCE
diff --git a/boot/xilinx-source/xilinx-source.hash b/boot/xilinx-source/xilinx-source.hash
new file mode 100644
index 0000000000..ed6a165574
--- /dev/null
+++ b/boot/xilinx-source/xilinx-source.hash
@@ -0,0 +1,2 @@ 
+# Locally calculated
+sha256  733fdb09b2525c1fa322242b97f015122aaf9e32530a824dec71d6328be83850  xilinx-source-xilinx_v2024.1.tar.gz
diff --git a/boot/xilinx-source/xilinx-source.mk b/boot/xilinx-source/xilinx-source.mk
new file mode 100644
index 0000000000..c555667de4
--- /dev/null
+++ b/boot/xilinx-source/xilinx-source.mk
@@ -0,0 +1,68 @@ 
+################################################################################
+#
+# xilinx-source
+#
+################################################################################
+
+XILINX_SOURCE_VERSION = $(call qstrip,$(BR2_TARGET_XILINX_SOURCE_VERSION))
+XILINX_SOURCE_SITE = $(call github,Xilinx,embeddedsw,$(XILINX_SOURCE_VERSION))
+XILINX_SOURCE_LICENSE = MIT
+XILINX_SOURCE_LICENSE_FILES = LICENSE
+XILINX_SOURCE_INSTALL_TARGET = NO
+XILINX_SOURCE_INSTALL_IMAGES = YES
+XILINX_SOURCE_DEPENDENCIES = toolchain-bare-metal-buildroot
+
+XILINX_SOURCE_USER_CFLAGS = $(call qstrip,$(BR2_TARGET_XILINX_SOURCE_USER_CFLAGS))
+ifeq ($(BR2_TARGET_XILINX_SOURCE_KRIA),y)
+XILINX_SOURCE_CFLAGS = "-Os -flto -ffat-lto-objects -DK26_SOM $(XILINX_SOURCE_USER_CFLAGS)"
+else
+XILINX_SOURCE_CFLAGS = "-Os -flto -ffat-lto-objects $(XILINX_SOURCE_USER_CFLAGS)"
+endif
+
+ifeq ($(BR2_TARGET_XILINX_SOURCE_VERSAL),y)
+define XILINX_SOURCE_BUILD
+	$(MAKE) -C $(@D)/lib/sw_apps/versal_plm/src/versal \
+		COMPILER=$(HOST_DIR)/bin/microblazeel-xilinx-elf-gcc \
+		ARCHIVER=$(HOST_DIR)/bin/microblazeel-xilinx-elf-gcc-ar \
+		CC=$(HOST_DIR)/bin/microblazeel-xilinx-elf-gcc \
+		CFLAGS=$(XILINX_SOURCE_CFLAGS)
+		
+	$(MAKE) -C $(@D)/lib/sw_apps/versal_psmfw/src/versal \
+		COMPILER=$(HOST_DIR)/bin/microblazeel-xilinx-elf-gcc \
+		ARCHIVER=$(HOST_DIR)/bin/microblazeel-xilinx-elf-gcc-ar \
+		CC=$(HOST_DIR)/bin/microblazeel-xilinx-elf-gcc \
+		CFLAGS=$(XILINX_SOURCE_CFLAGS)
+endef
+else # BR2_TARGET_XILINX_SOURCE_VERSAL
+define XILINX_SOURCE_BUILD
+	$(MAKE) -C $(@D)/lib/sw_apps/zynqmp_pmufw/src \
+		COMPILER=$(HOST_DIR)/bin/microblazeel-xilinx-elf-gcc \
+		ARCHIVER=$(HOST_DIR)/bin/microblazeel-xilinx-elf-gcc-ar \
+		CC=$(HOST_DIR)/bin/microblazeel-xilinx-elf-gcc \
+		CFLAGS=$(XILINX_SOURCE_CFLAGS)
+endef
+endif # BR2_TARGET_XILINX_SOURCE_VERSAL
+
+define XILINX_SOURCE_BUILD_CMDS
+	$(XILINX_SOURCE_BUILD)
+endef
+
+ifeq ($(BR2_TARGET_XILINX_SOURCE_VERSAL),y)
+define XILINX_SOURCE_INSTALL
+	$(INSTALL) -D -m 0755 $(@D)/lib/sw_apps/versal_plm/src/versal/plm.elf \
+		$(BINARIES_DIR)/plm.elf
+	$(INSTALL) -D -m 0755 $(@D)/lib/sw_apps/versal_psmfw/src/versal/psmfw.elf \
+		$(BINARIES_DIR)/psmfw.elf
+endef
+else # BR2_TARGET_XILINX_SOURCE_VERSAL
+define XILINX_SOURCE_INSTALL
+	$(INSTALL) -D -m 0755 $(@D)/lib/sw_apps/zynqmp_pmufw/src/executable.elf \
+		$(BINARIES_DIR)/pmufw.elf
+endef
+endif # BR2_TARGET_XILINX_SOURCE_VERSAL
+
+define XILINX_SOURCE_INSTALL_IMAGES_CMDS
+	$(XILINX_SOURCE_INSTALL)
+endef
+
+$(eval $(generic-package))