[v2,6/7] starfive-visionfive2: create u-boot-spl FIT image

Message ID 20230211092152.949442-7-felix.moessbauer@siemens.com
State Superseded, archived
Headers show
Series Add BSP for StarFiveTech VisionFive2 Risc-V board | expand

Commit Message

MOESSBAUER, Felix Feb. 11, 2023, 9:21 a.m. UTC
Signed-off-by: Felix Moessbauer <felix.moessbauer@siemens.com>
---
 .../files/rules.tmpl                          | 12 ++++++
 .../files/visionfive2-u-boot-firmware.install |  1 +
 .../visionfive2-uboot-fit-image.its.tmpl      | 41 +++++++++++++++++++
 .../visionfive2-u-boot-firmware.bb            | 36 ++++++++++++++++
 4 files changed, 90 insertions(+)
 create mode 100644 meta-isar/recipes-bsp/visionfive2-u-boot-firmware/files/rules.tmpl
 create mode 100644 meta-isar/recipes-bsp/visionfive2-u-boot-firmware/files/visionfive2-u-boot-firmware.install
 create mode 100644 meta-isar/recipes-bsp/visionfive2-u-boot-firmware/files/visionfive2-uboot-fit-image.its.tmpl
 create mode 100644 meta-isar/recipes-bsp/visionfive2-u-boot-firmware/visionfive2-u-boot-firmware.bb

Patch

diff --git a/meta-isar/recipes-bsp/visionfive2-u-boot-firmware/files/rules.tmpl b/meta-isar/recipes-bsp/visionfive2-u-boot-firmware/files/rules.tmpl
new file mode 100644
index 00000000..4826f7d6
--- /dev/null
+++ b/meta-isar/recipes-bsp/visionfive2-u-boot-firmware/files/rules.tmpl
@@ -0,0 +1,12 @@ 
+#!/usr/bin/make -f
+
+KERNEL_VERSION=$(shell find /usr/lib/ -maxdepth 1 -type d -name 'linux-image-*' | head -1 | sed 's/.*linux-image-//g')
+
+override_dh_auto_configure:
+	sed -i 's|<KERNEL_VERSION>|$(KERNEL_VERSION)|g' visionfive2-uboot-fit-image.its
+
+override_dh_auto_build:
+	mkimage -A riscv -O u-boot -f ${IMAGE_ITS_FILE} visionfive2_fw_payload.img
+
+%:
+	dh $@
diff --git a/meta-isar/recipes-bsp/visionfive2-u-boot-firmware/files/visionfive2-u-boot-firmware.install b/meta-isar/recipes-bsp/visionfive2-u-boot-firmware/files/visionfive2-u-boot-firmware.install
new file mode 100644
index 00000000..d1bdf6d6
--- /dev/null
+++ b/meta-isar/recipes-bsp/visionfive2-u-boot-firmware/files/visionfive2-u-boot-firmware.install
@@ -0,0 +1 @@ 
+visionfive2_fw_payload.img usr/share/visionfive2-u-boot-firmware
diff --git a/meta-isar/recipes-bsp/visionfive2-u-boot-firmware/files/visionfive2-uboot-fit-image.its.tmpl b/meta-isar/recipes-bsp/visionfive2-u-boot-firmware/files/visionfive2-uboot-fit-image.its.tmpl
new file mode 100644
index 00000000..4cbe9318
--- /dev/null
+++ b/meta-isar/recipes-bsp/visionfive2-u-boot-firmware/files/visionfive2-uboot-fit-image.its.tmpl
@@ -0,0 +1,41 @@ 
+/dts-v1/;
+
+/ {
+	description = "U-boot-spl FIT image for JH7110 VisionFive2";
+	#address-cells = <2>;
+
+	images {
+		firmware {
+			description = "u-boot";
+			data = /incbin/("/usr/lib/opensbi/starfive-visionfive2/fw_payload.bin");
+			type = "firmware";
+			arch = "riscv";
+			os = "u-boot";
+			load = <0x0 0x40000000>;
+			entry = <0x0 0x40000000>;
+			compression = "none";
+		};
+		fdt {
+			description = "DTB";
+			data = /incbin/("/usr/lib/linux-image-<KERNEL_VERSION>/${DTB_FILES}");
+			type = "flat_dt";
+			arch = "riscv";
+			compression = "none";
+			load = <0x46000000>;
+			entry = <0x46000000>;
+			hash {
+				algo = "sha1";
+			};
+		};
+	};
+
+	configurations {
+		default = "config-1";
+
+		config-1 {
+			description = "U-boot-spl FIT config for JH7110 VisionFive2";
+			firmware = "firmware";
+			fdt = "fdt";
+		};
+	};
+};
diff --git a/meta-isar/recipes-bsp/visionfive2-u-boot-firmware/visionfive2-u-boot-firmware.bb b/meta-isar/recipes-bsp/visionfive2-u-boot-firmware/visionfive2-u-boot-firmware.bb
new file mode 100644
index 00000000..b2303968
--- /dev/null
+++ b/meta-isar/recipes-bsp/visionfive2-u-boot-firmware/visionfive2-u-boot-firmware.bb
@@ -0,0 +1,36 @@ 
+#
+# Copyright (c) Siemens AG, 2023
+#
+# SPDX-License-Identifier: MIT
+
+inherit dpkg
+
+DESCRIPTION = "StarFive VisionFive 2 u-boot firmware"
+
+IMAGE_ITS_FILE = "visionfive2-uboot-fit-image.its"
+SRC_URI = " \
+    file://${IMAGE_ITS_FILE}.tmpl \
+    file://rules.tmpl \
+    file://visionfive2-u-boot-firmware.install"
+
+DEPENDS += "opensbi-starfive-visionfive2 linux-image-${KERNEL_NAME}"
+DEBIAN_BUILD_DEPENDS += "opensbi-starfive-visionfive2, u-boot-tools, device-tree-compiler, linux-image-${KERNEL_NAME}"
+
+TEMPLATE_FILES = "${IMAGE_ITS_FILE}.tmpl rules.tmpl"
+TEMPLATE_VARS = "IMAGE_ITS_FILE DTB_FILES"
+
+do_prepare_build[cleandirs] += "${S}/debian"
+do_prepare_build(){
+    cp ${WORKDIR}/${IMAGE_ITS_FILE} ${S}/
+    cp ${WORKDIR}/visionfive2-u-boot-firmware.install ${S}/debian/
+    deb_debianize
+}
+
+do_deploy() {
+    dpkg --fsys-tarfile ${WORKDIR}/visionfive2-u-boot-firmware_${PV}*.deb | \
+        tar xOf - "./usr/share/visionfive2-u-boot-firmware/visionfive2_fw_payload.img" \
+        > "${DEPLOY_DIR_IMAGE}/visionfive2_fw_payload.img"
+}
+
+addtask deploy after do_dpkg_build before do_build
+do_deploy[dirs] = "${DEPLOY_DIR_IMAGE}"