[PATCH 0/3] Simplify OpenSBI builds

2 views
Skip to first unread message

Jan Kiszka

unread,
Oct 29, 2025, 2:08:22 PM (yesterday) Oct 29
to isar-users
Introduce a class to simplify recipes for building custom OpenSBI
firmware.

This is also a pilot to switch from the "require .inc" to a more common
"inherit" pattern for pulling such helpers.

Note that the fu540 conversion is only build-tested - I no longer have
access to such a board.

Jan

Jan Kiszka (3):
meta: Add class for building custom OpenSBI firmware
opensbi-starfive-visionfive2: Use new obensbi class
opensbi-sifive-fu540: Use new obensbi class

RECIPE-API-CHANGELOG.md | 6 ++++
.../opensbi/files/sifive-fu540-rules | 12 --------
.../opensbi/files/starfive-visionfive2-rules | 12 --------
.../opensbi/opensbi-sifive-fu540_1.1.bb | 15 +++-------
.../opensbi-starfive-visionfive2_1.4.bb | 17 ++++-------
meta/classes/opensbi.bbclass | 28 +++++++++++++++++++
meta/recipes-bsp/opensbi/rules.tmpl | 19 +++++++++++++
7 files changed, 62 insertions(+), 47 deletions(-)
delete mode 100644 meta-isar/recipes-bsp/opensbi/files/sifive-fu540-rules
delete mode 100644 meta-isar/recipes-bsp/opensbi/files/starfive-visionfive2-rules
create mode 100644 meta/classes/opensbi.bbclass
create mode 100644 meta/recipes-bsp/opensbi/rules.tmpl

--
2.51.0

Jan Kiszka

unread,
Oct 29, 2025, 2:08:22 PM (yesterday) Oct 29
to isar-users
From: Jan Kiszka <jan.k...@siemens.com>

This is supposed to simplify this customization task.

For the first time, this deviates from the *-custom.inc pattern used for
many other targets, using a class which is shorter to inherit. Other
targets should be converted to this pattern later on.

Signed-off-by: Jan Kiszka <jan.k...@siemens.com>
---
RECIPE-API-CHANGELOG.md | 6 ++++++
meta/classes/opensbi.bbclass | 28 ++++++++++++++++++++++++++++
meta/recipes-bsp/opensbi/rules.tmpl | 19 +++++++++++++++++++
3 files changed, 53 insertions(+)
create mode 100644 meta/classes/opensbi.bbclass
create mode 100644 meta/recipes-bsp/opensbi/rules.tmpl

diff --git a/RECIPE-API-CHANGELOG.md b/RECIPE-API-CHANGELOG.md
index cf04fa5c..1826667a 100644
--- a/RECIPE-API-CHANGELOG.md
+++ b/RECIPE-API-CHANGELOG.md
@@ -791,3 +791,9 @@ Set `Rules-Requires-Root: no` in `debian/control` files to prevent unnecessary
invocation of fakeroot during package builds. This follows Debian guidelines
recommending not to use fakeroot when no privileged operations (e.g., `chown`,
root file modifications) are required.
+
+### Add opensbi class to simplify custom OpenSBI builds
+
+A new class called `opensbi` has been introduced that shall help writing
+shorter recipes for custom OpenSBI builds. Usage examples can be found in
+`meta-isar/recipes/bsp/opensbi`.
diff --git a/meta/classes/opensbi.bbclass b/meta/classes/opensbi.bbclass
new file mode 100644
index 00000000..4475bd95
--- /dev/null
+++ b/meta/classes/opensbi.bbclass
@@ -0,0 +1,28 @@
+# Custom OpenSBI build
+#
+# This software is a part of ISAR.
+# Copyright (c) Siemens AG, 2025
+#
+# SPDX-License-Identifier: MIT
+
+inherit dpkg
+
+DESCRIPTION ?= "Custom OpenSBI"
+
+FILESPATH:append = ":${LAYERDIR_core}/recipes-bsp/opensbi"
+SRC_URI += "file://rules.tmpl"
+
+OPENSBI_PLATFORM ?= "generic"
+OPENSBI_EXTRA_BUILDARGS ?= ""
+
+TEMPLATE_FILES = "rules.tmpl"
+TEMPLATE_VARS += "OPENSBI_PLATFORM OPENSBI_EXTRA_BUILDARGS"
+
+do_prepare_build[cleandirs] += "${S}/debian"
+do_prepare_build() {
+ deb_debianize
+
+ for bin in ${OPENSBI_BIN}; do
+ echo "build/platform/${OPENSBI_PLATFORM}/firmware/$bin /usr/lib/opensbi/${MACHINE}/" >> ${S}/debian/install
+ done
+}
diff --git a/meta/recipes-bsp/opensbi/rules.tmpl b/meta/recipes-bsp/opensbi/rules.tmpl
new file mode 100644
index 00000000..935d033e
--- /dev/null
+++ b/meta/recipes-bsp/opensbi/rules.tmpl
@@ -0,0 +1,19 @@
+#!/usr/bin/make -f
+
+# Debian rules for custom OpenSBI build
+#
+# This software is a part of ISAR.
+# Copyright (c) Siemens AG, 2025
+#
+# SPDX-License-Identifier: MIT
+
+ifneq ($(DEB_BUILD_GNU_TYPE),$(DEB_HOST_GNU_TYPE))
+export CROSS_COMPILE=$(DEB_HOST_GNU_TYPE)-
+endif
+
+override_dh_auto_build:
+ CFLAGS= LDFLAGS= $(MAKE) $(PARALLEL_MAKE) PLATFORM=${OPENSBI_PLATFORM} \
+ ${OPENSBI_EXTRA_BUILDARGS}
+
+%:
+ dh $@
--
2.51.0

Reply all
Reply to author
Forward
0 new messages