[PATCH xenomai-images v3 3/4] riscv: Add StarFive VisionFive2 board support

Tobias Schaffner <[email protected]>
Newsgroups dev.linux.lists.xenomai
Message-ID <[email protected]>
Add machine config, U-Boot, OpenSBI, and WIC layout for StarFive
VisionFive2 RISC-V board.

Use the latest openSBI version 1.8.1 but stick to u-boot 2025.07 which
is unfortunately the last version that supports booting from SD-Card.

Signed-off-by: Tobias Schaffner <[email protected]>
---
 conf/machine/starfive-visionfive2.conf        | 21 +++++++++++++
 kas/board/starfive-visionfive2.yaml           | 15 ++++++++++
 .../opensbi-starfive-visionfive2_1.8.1.bb     | 18 +++++++++++
 .../u-boot-starfive-visionfive2_2025.07.bb    | 30 +++++++++++++++++++
 wic/starfive-visionfive2.wks                  | 23 ++++++++++++++
 5 files changed, 107 insertions(+)
 create mode 100644 conf/machine/starfive-visionfive2.conf
 create mode 100644 kas/board/starfive-visionfive2.yaml
 create mode 100644 recipes-bsp/opensbi/opensbi-starfive-visionfive2_1.8.1.bb
 create mode 100644 recipes-bsp/u-boot/u-boot-starfive-visionfive2_2025.07.bb
 create mode 100644 wic/starfive-visionfive2.wks

diff --git a/conf/machine/starfive-visionfive2.conf b/conf/machine/starfive-visionfive2.conf
new file mode 100644
index 0000000..9f8b67d
--- /dev/null
+++ b/conf/machine/starfive-visionfive2.conf
@@ -0,0 +1,21 @@
+#
+# Copyright (c) Siemens AG, 2023-2026
+#
+# SPDX-License-Identifier: MIT
+#
+
+DISTRO_ARCH = "riscv64"
+
+DTB_FILES = " \
+    starfive/jh7110-starfive-visionfive-2-v1.2a.dtb \
+    starfive/jh7110-starfive-visionfive-2-v1.3b.dtb"
+
+IMAGE_FSTYPES ?= "wic"
+WKS_FILE ?= "starfive-visionfive2.wks"
+IMAGER_INSTALL:wic += " \
+    u-boot-starfive-visionfive2 \
+    ${SYSTEMD_BOOTLOADER_INSTALL}"
+IMAGER_BUILD_DEPS += "u-boot-starfive-visionfive2"
+
+PREFERRED_PROVIDER_u-boot-${MACHINE} = "u-boot-starfive-visionfive2"
+
diff --git a/kas/board/starfive-visionfive2.yaml b/kas/board/starfive-visionfive2.yaml
new file mode 100644
index 0000000..406ed07
--- /dev/null
+++ b/kas/board/starfive-visionfive2.yaml
@@ -0,0 +1,15 @@
+#
+# Xenomai Real-Time System
+#
+# Copyright (c) Siemens AG, 2026
+#
+# Authors:
+#  Tobias Schaffner <[email protected]>
+#
+# SPDX-License-Identifier: MIT
+#
+
+header:
+  version: 14
+
+machine: starfive-visionfive2
diff --git a/recipes-bsp/opensbi/opensbi-starfive-visionfive2_1.8.1.bb b/recipes-bsp/opensbi/opensbi-starfive-visionfive2_1.8.1.bb
new file mode 100644
index 0000000..bef5b04
--- /dev/null
+++ b/recipes-bsp/opensbi/opensbi-starfive-visionfive2_1.8.1.bb
@@ -0,0 +1,18 @@
+#
+# Copyright (c) Siemens AG, 2023-2026
+#
+# SPDX-License-Identifier: MIT
+
+inherit opensbi
+
+DESCRIPTION = "OpenSBI firmware for StarFive VisionFive 2"
+
+SRC_URI += "https://github.com/riscv-software-src/opensbi/archive/refs/tags/v${PV}.tar.gz;downloadfilename=opensbi-${PV}.tar.gz"
+SRC_URI[sha256sum] = "fb1ae61a85e966322101acb1c982f84d9eaafc4de7dd474a7d7546d9bb321c6f"
+
+S = "${WORKDIR}/opensbi-${PV}"
+
+OPENSBI_EXTRA_BUILDARGS = "FW_TEXT_START=0x40000000 FW_OPTIONS=0"
+OPENSBI_BIN = "fw_dynamic.bin"
+
+COMPATIBLE_MACHINE = "^(starfive-visionfive2)$"
diff --git a/recipes-bsp/u-boot/u-boot-starfive-visionfive2_2025.07.bb b/recipes-bsp/u-boot/u-boot-starfive-visionfive2_2025.07.bb
new file mode 100644
index 0000000..d5c8d92
--- /dev/null
+++ b/recipes-bsp/u-boot/u-boot-starfive-visionfive2_2025.07.bb
@@ -0,0 +1,30 @@
+#
+# Copyright (c) Siemens AG, 2023-2026
+#
+# SPDX-License-Identifier: MIT
+
+inherit u-boot
+
+DESCRIPTION = "U-Boot for StarFive VisionFive 2"
+
+COMPATIBLE_MACHINE = "^(starfive-visionfive2)$"
+
+SRC_URI += "https://ftp.denx.de/pub/u-boot/u-boot-${PV}.tar.bz2"
+SRC_URI[sha256sum] = "0f933f6c5a426895bf306e93e6ac53c60870e4b54cda56d95211bec99e63bec7"
+
+S = "${WORKDIR}/u-boot-${PV}"
+
+DEPENDS += "opensbi-starfive-visionfive2"
+DEBIAN_BUILD_DEPENDS .= ", opensbi-starfive-visionfive2, \
+    python3-dev:native, python3-setuptools, swig, \
+    libssl-dev:${DISTRO_ARCH}, libssl-dev:native, \
+    libgnutls28-dev:${DISTRO_ARCH}, libgnutls28-dev:native"
+
+U_BOOT_CONFIG = "starfive_visionfive2_defconfig"
+U_BOOT_BIN = "all"
+U_BOOT_EXTRA_BUILDARGS = "OPENSBI=/usr/lib/opensbi/starfive-visionfive2/fw_dynamic.bin"
+
+do_prepare_build:append() {
+    echo "u-boot.itb spl/u-boot-spl.bin.normal.out /usr/lib/u-boot/${MACHINE}" > \
+        ${S}/debian/u-boot-${MACHINE}.install
+}
diff --git a/wic/starfive-visionfive2.wks b/wic/starfive-visionfive2.wks
new file mode 100644
index 0000000..4b0fd69
--- /dev/null
+++ b/wic/starfive-visionfive2.wks
@@ -0,0 +1,23 @@
+#
+# Copyright (c) Siemens AG, 2023-2026
+#
+# SPDX-License-Identifier: MIT
+
+# The partition layout is based on the VisionFive2 example image:
+# https://github.com/starfive-tech/VisionFive2/blob/JH7110_VisionFive2_devel/Makefile#L394
+# However, instead of booting via ubootenv + fit, we boot fit + efi
+#
+# When booting from the SD card, make sure that the DIP switches are set to SD card.
+# By that, the board reads the u-boot firmware from the SD instead of the internal flash.
+# This is required to boot efi with the correct device tree, which is included in the fit image.
+
+# SPL
+part --source rawcopy --sourceparams "file=/usr/lib/u-boot/starfive-visionfive2/u-boot-spl.bin.normal.out" --fixed-size 2M --part-type 2E54B353-1271-4842-806F-E436D6AF6985
+# U-Boot FIT
+part --source rawcopy --sourceparams "file=/usr/lib/u-boot/starfive-visionfive2/u-boot.itb" --fixed-size 4M --part-type BC13C2FF-59E6-4262-A352-B275FD6F7172
+# EFI - DTB comes from U-Boot, not hardcoded in loader entry
+part /boot --source bootimg-efi-isar --sourceparams "loader=systemd-boot" --use-uuid --label efi --part-type EF00 --align 1024
+# rootfs
+part / --source rootfs --use-uuid --fstype ext4 --mkfs-extraopts "-T default" --label image --active --align 1024 --exclude-path=boot/
+
+bootloader --ptable gpt --timeout=0 --append "console=tty0 console=ttyS0,115200 earlycon rootwait"
-- 
2.43.0
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.