boot/opensbi: support building an out-of-tree platform
cover boot/opensbi: support building an out-of-tree platform
Resending: I sent this on 2026-08-13 and it hasn't had any comments. The patches are unchanged, rebased onto current master.
OpenSBI can build a platform that lives outside its source tree via PLATFORM_DIR. For a board whose platform is not upstream - as is the case for LiteX/VexRiscv - that is considerably simpler than patching a platform directory into the OpenSBI source or maintaining a custom tarball, and it decouples the platform from the OpenSBI release so upstream can be tracked.
Patch 1 replaces the BR2_TARGET_OPENSBI_PLAT string with a choice of reference platform, external platform, or no platform. Three existing conditionals compared that symbol against the empty string; they are moved to !BR2_TARGET_OPENSBI_PLAT_NONE, as leaving them referring to the removed symbol would silently have disabled INSTALL_JUMP_IMG and INSTALL_DYNAMIC_IMG and produced no firmware at all. The 13 in-tree defconfigs that set the old symbol are converted, and a Config.in.legacy entry carries an existing value over to the reference platform.
Tested when I first sent this:
- The external platform path is what builds OpenSBI 1.5.1, 1.6 and 1.9 for a LiteX/VexRiscv rv32 target here; all three boot to a shell on hardware (ALINX AX7035, xc7a35t).
- qemu_riscv64_virt_defconfig builds clean and installs its firmware from build/platform/generic/firmware/, exercising the reference platform path. The resulting fw_jump.bin boots under qemu-system-riscv64 to a login prompt (OpenSBI v1.6, Linux 6.18.7).
What I've re-checked since the rebase:
- All 13 converted defconfigs generate a configuration and resolve OPENSBI_PLAT=generic, and none of them sets BR2_LEGACY.
- An old-style configuration setting BR2_TARGET_OPENSBI_PLAT="generic" still converts to BR2_TARGET_OPENSBI_PLAT_REF with the name carried over, and sets BR2_LEGACY as expected.
- check-symbols is clean, and the checkpackagelib and checksymbolslib unit tests pass. check-package reports nothing on the changed files beyond the two missing-BR2_DOWNLOAD_FORCE_CHECK_HASHES warnings master already has on the sipeed_lichee_rv defconfigs.
Richard Vodden (2):
boot/opensbi: allow building against an external platform
DEVELOPERS: add Richard Vodden for boot/opensbi
Config.in.legacy | 18 ++++++++ DEVELOPERS | 3 ++ boot/opensbi/Config.in | 55 +++++++++++++++++++------ boot/opensbi/opensbi.mk | 16 +++++-- configs/andes_ae350_45_defconfig | 3 +- configs/hifive_unleashed_defconfig | 3 +- configs/hifive_unmatched_defconfig | 3 +- configs/nezha_defconfig | 3 +- configs/pine64_star64_defconfig | 3 +- configs/qemu_riscv32_virt_defconfig | 3 +- configs/qemu_riscv64_virt_defconfig | 3 +- configs/sipeed_lichee_rv_defconfig | 3 +- configs/sipeed_lichee_rv_dock_defconfig | 3 +- configs/sipeed_licheepi_4a_defconfig | 3 +- configs/spike_riscv32_defconfig | 3 +- configs/spike_riscv64_defconfig | 3 +- configs/visionfive2_defconfig | 3 +- 17 files changed, 103 insertions(+), 28 deletions(-)
base-commit: a962be2eea146e06661712159698bc7cbf3305f2
Signature · 6 lines
2.47.0 _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot
PATCH RESEND 1/2 boot/opensbi: allow building against an external platform
OpenSBI can build a platform that lives outside its source tree by setting PLATFORM_DIR. For a board whose platform is not upstream, that is considerably simpler than patching a platform directory into the OpenSBI source or maintaining a custom tarball.
Replace the BR2_TARGET_OPENSBI_PLAT string with a choice of reference platform, external platform, or no platform, and pass either PLATFORM or PLATFORM_DIR accordingly. When PLATFORM is unset OpenSBI derives it from the basename of PLATFORM_DIR and builds into build/platform/$(PLATFORM), so OPENSBI_PLAT is set to that basename in order for the install step to find the firmware. A trailing slash on the directory is stripped, as $(notdir) would otherwise yield an empty string.
The three conditionals that previously tested BR2_TARGET_OPENSBI_PLAT against the empty string now test !BR2_TARGET_OPENSBI_PLAT_NONE. Leaving them referring to the removed symbol would have silently disabled BR2_TARGET_OPENSBI_INSTALL_JUMP_IMG and INSTALL_DYNAMIC_IMG, producing no firmware at all.
The in-tree defconfigs that set the old symbol are converted, and a legacy entry carries an existing value over to the reference platform.
--- Config.in.legacy | 18 ++++++++ boot/opensbi/Config.in | 55 +++++++++++++++++++------ boot/opensbi/opensbi.mk | 16 +++++-- configs/andes_ae350_45_defconfig | 3 +- configs/hifive_unleashed_defconfig | 3 +- configs/hifive_unmatched_defconfig | 3 +- configs/nezha_defconfig | 3 +- configs/pine64_star64_defconfig | 3 +- configs/qemu_riscv32_virt_defconfig | 3 +- configs/qemu_riscv64_virt_defconfig | 3 +- configs/sipeed_lichee_rv_defconfig | 3 +- configs/sipeed_lichee_rv_dock_defconfig | 3 +- configs/sipeed_licheepi_4a_defconfig | 3 +- configs/spike_riscv32_defconfig | 3 +- configs/spike_riscv64_defconfig | 3 +- configs/visionfive2_defconfig | 3 +- 16 files changed, 100 insertions(+), 28 deletions(-)
Config.in.legacy +18 -0
@@ -146,6 +146,24 @@ endif comment "Legacy options removed in 2026.11" +config BR2_TARGET_OPENSBI_PLAT + string "OpenSBI platform has been replaced" + help + The OpenSBI platform is now selected with the "OpenSBI + platform type" choice, which additionally allows building + against a platform directory kept outside the OpenSBI source + tree. + + Select "Reference platform" to keep the previous behaviour; + the platform name has been carried over automatically. + +config BR2_TARGET_OPENSBI_PLAT_WRAP + bool + default y if BR2_TARGET_OPENSBI_PLAT != "" + select BR2_LEGACY + +# Note: BR2_TARGET_OPENSBI_PLAT is still referenced from boot/opensbi/Config.in + config BR2_PACKAGE_LIBCPPRESTSDK bool "libcpprestsdk has been removed" select BR2_LEGACY
boot/opensbi/Config.in +43 -12
82 lines not on this page · raw message
boot/opensbi/opensbi.mk +13 -3
@@ -32,11 +32,21 @@ OPENSBI_MAKE_ENV = \ CROSS_COMPILE=$(TARGET_CROSS) \ $(call qstrip,$(BR2_TARGET_OPENSBI_ADDITIONAL_VARIABLES)) -OPENSBI_PLAT = $(call qstrip,$(BR2_TARGET_OPENSBI_PLAT)) -ifneq ($(OPENSBI_PLAT),) +ifeq ($(BR2_TARGET_OPENSBI_PLAT_REF),y) +OPENSBI_PLAT = $(call qstrip,$(BR2_TARGET_OPENSBI_PLAT_REF_NAME)) OPENSBI_MAKE_ENV += PLATFORM=$(OPENSBI_PLAT) endif +# OpenSBI derives PLATFORM from $(basename PLATFORM_DIR) when PLATFORM is unset, +# and builds into build/platform/$(PLATFORM)/ -- so OPENSBI_PLAT must match that +# for the install step below to find the firmware. patsubst strips any trailing +# slash, which would otherwise make notdir return an empty string. +ifeq ($(BR2_TARGET_OPENSBI_PLAT_EXT),y) +OPENSBI_PLAT_EXT_DIR = $(patsubst %/,%,$(call qstrip,$(BR2_TARGET_OPENSBI_PLAT_EXT_DIR))) +OPENSBI_PLAT = $(notdir $(OPENSBI_PLAT_EXT_DIR)) +OPENSBI_MAKE_ENV += PLATFORM_DIR=$(OPENSBI_PLAT_EXT_DIR) +endif + ifeq ($(BR2_TARGET_OPENSBI_LINUX_PAYLOAD),y) OPENSBI_DEPENDENCIES += linux OPENSBI_MAKE_ENV += FW_PAYLOAD_PATH="$(BINARIES_DIR)/Image"
@@ -69,7 +79,7 @@ OPENSBI_INSTALL_IMAGES = YES OPENSBI_FW_IMAGES += payload endif -ifneq ($(OPENSBI_PLAT),) +ifneq ($(BR2_TARGET_OPENSBI_PLAT_NONE),y) define OPENSBI_INSTALL_IMAGES_CMDS $(foreach f,$(OPENSBI_FW_IMAGES),\ $(INSTALL) -m 0644 -D $(@D)/build/platform/$(OPENSBI_PLAT)/firmware/fw_$(f).bin \
configs/andes_ae350_45_defconfig +2 -1
@@ -21,7 +21,8 @@ BR2_TARGET_ROOTFS_EXT2_4=y BR2_TARGET_OPENSBI=y BR2_TARGET_OPENSBI_CUSTOM_VERSION=y BR2_TARGET_OPENSBI_CUSTOM_VERSION_VALUE="1.6" -BR2_TARGET_OPENSBI_PLAT="generic" +BR2_TARGET_OPENSBI_PLAT_REF=y +BR2_TARGET_OPENSBI_PLAT_REF_NAME="generic" # BR2_TARGET_OPENSBI_INSTALL_JUMP_IMG is not set BR2_TARGET_UBOOT=y BR2_TARGET_UBOOT_BUILD_SYSTEM_KCONFIG=y
configs/hifive_unleashed_defconfig +2 -1
@@ -27,7 +27,8 @@ BR2_TARGET_ROOTFS_EXT2_4=y BR2_TARGET_OPENSBI=y BR2_TARGET_OPENSBI_CUSTOM_VERSION=y BR2_TARGET_OPENSBI_CUSTOM_VERSION_VALUE="1.2" -BR2_TARGET_OPENSBI_PLAT="generic" +BR2_TARGET_OPENSBI_PLAT_REF=y +BR2_TARGET_OPENSBI_PLAT_REF_NAME="generic" BR2_TARGET_UBOOT=y BR2_TARGET_UBOOT_BUILD_SYSTEM_KCONFIG=y BR2_TARGET_UBOOT_CUSTOM_VERSION=y
configs/hifive_unmatched_defconfig +2 -1
@@ -27,7 +27,8 @@ BR2_TARGET_ROOTFS_EXT2_4=y BR2_TARGET_OPENSBI=y BR2_TARGET_OPENSBI_CUSTOM_VERSION=y BR2_TARGET_OPENSBI_CUSTOM_VERSION_VALUE="1.2" -BR2_TARGET_OPENSBI_PLAT="generic" +BR2_TARGET_OPENSBI_PLAT_REF=y +BR2_TARGET_OPENSBI_PLAT_REF_NAME="generic" BR2_TARGET_UBOOT=y BR2_TARGET_UBOOT_BUILD_SYSTEM_KCONFIG=y BR2_TARGET_UBOOT_CUSTOM_VERSION=y
configs/nezha_defconfig +2 -1
@@ -21,7 +21,8 @@ BR2_TARGET_ROOTFS_EXT2_4=y BR2_TARGET_OPENSBI=y BR2_TARGET_OPENSBI_CUSTOM_VERSION=y BR2_TARGET_OPENSBI_CUSTOM_VERSION_VALUE="1.4" -BR2_TARGET_OPENSBI_PLAT="generic" +BR2_TARGET_OPENSBI_PLAT_REF=y +BR2_TARGET_OPENSBI_PLAT_REF_NAME="generic" # BR2_TARGET_OPENSBI_INSTALL_JUMP_IMG is not set BR2_TARGET_UBOOT=y BR2_TARGET_UBOOT_BUILD_SYSTEM_KCONFIG=y
configs/pine64_star64_defconfig +2 -1
@@ -17,7 +17,8 @@ BR2_TARGET_ROOTFS_EXT2=y BR2_TARGET_ROOTFS_EXT2_4=y BR2_TARGET_ROOTFS_EXT2_SIZE="100M" BR2_TARGET_OPENSBI=y -BR2_TARGET_OPENSBI_PLAT="generic" +BR2_TARGET_OPENSBI_PLAT_REF=y +BR2_TARGET_OPENSBI_PLAT_REF_NAME="generic" # BR2_TARGET_OPENSBI_INSTALL_JUMP_IMG is not set BR2_TARGET_UBOOT=y BR2_TARGET_UBOOT_BUILD_SYSTEM_KCONFIG=y
configs/qemu_riscv32_virt_defconfig +2 -1
@@ -14,6 +14,7 @@ BR2_TARGET_ROOTFS_EXT2=y BR2_TARGET_OPENSBI=y BR2_TARGET_OPENSBI_CUSTOM_VERSION=y BR2_TARGET_OPENSBI_CUSTOM_VERSION_VALUE="1.6" -BR2_TARGET_OPENSBI_PLAT="generic" +BR2_TARGET_OPENSBI_PLAT_REF=y +BR2_TARGET_OPENSBI_PLAT_REF_NAME="generic" BR2_PACKAGE_HOST_QEMU=y BR2_PACKAGE_HOST_QEMU_SYSTEM_MODE=y
configs/qemu_riscv64_virt_defconfig +2 -1
@@ -13,6 +13,7 @@ BR2_TARGET_ROOTFS_EXT2=y BR2_TARGET_OPENSBI=y BR2_TARGET_OPENSBI_CUSTOM_VERSION=y BR2_TARGET_OPENSBI_CUSTOM_VERSION_VALUE="1.6" -BR2_TARGET_OPENSBI_PLAT="generic" +BR2_TARGET_OPENSBI_PLAT_REF=y +BR2_TARGET_OPENSBI_PLAT_REF_NAME="generic" BR2_PACKAGE_HOST_QEMU=y BR2_PACKAGE_HOST_QEMU_SYSTEM_MODE=y
configs/sipeed_lichee_rv_defconfig +2 -1
@@ -16,7 +16,8 @@ BR2_TARGET_ROOTFS_EXT2_4=y BR2_TARGET_OPENSBI=y BR2_TARGET_OPENSBI_CUSTOM_VERSION=y BR2_TARGET_OPENSBI_CUSTOM_VERSION_VALUE="1.2" -BR2_TARGET_OPENSBI_PLAT="generic" +BR2_TARGET_OPENSBI_PLAT_REF=y +BR2_TARGET_OPENSBI_PLAT_REF_NAME="generic" # BR2_TARGET_OPENSBI_INSTALL_JUMP_IMG is not set BR2_TARGET_UBOOT=y BR2_TARGET_UBOOT_BUILD_SYSTEM_KCONFIG=y
configs/sipeed_lichee_rv_dock_defconfig +2 -1
@@ -24,7 +24,8 @@ BR2_TARGET_ROOTFS_EXT2_4=y BR2_TARGET_OPENSBI=y BR2_TARGET_OPENSBI_CUSTOM_VERSION=y BR2_TARGET_OPENSBI_CUSTOM_VERSION_VALUE="1.2" -BR2_TARGET_OPENSBI_PLAT="generic" +BR2_TARGET_OPENSBI_PLAT_REF=y +BR2_TARGET_OPENSBI_PLAT_REF_NAME="generic" # BR2_TARGET_OPENSBI_INSTALL_JUMP_IMG is not set BR2_TARGET_UBOOT=y BR2_TARGET_UBOOT_BUILD_SYSTEM_KCONFIG=y
configs/sipeed_licheepi_4a_defconfig +2 -1
@@ -30,7 +30,8 @@ BR2_TARGET_OPENSBI=y BR2_TARGET_OPENSBI_CUSTOM_GIT=y BR2_TARGET_OPENSBI_CUSTOM_REPO_URL="https://github.com/revyos/thead-opensbi.git" BR2_TARGET_OPENSBI_CUSTOM_REPO_VERSION="61d7484c752a5e4c464d5dc18e21d9ac67fbbefa" -BR2_TARGET_OPENSBI_PLAT="generic" +BR2_TARGET_OPENSBI_PLAT_REF=y +BR2_TARGET_OPENSBI_PLAT_REF_NAME="generic" BR2_TARGET_UBOOT=y BR2_TARGET_UBOOT_BOARDNAME="light_lpi4a" BR2_TARGET_UBOOT_CUSTOM_GIT=y
configs/spike_riscv32_defconfig +2 -1
@@ -12,6 +12,7 @@ BR2_TARGET_ROOTFS_CPIO=y BR2_TARGET_OPENSBI=y BR2_TARGET_OPENSBI_CUSTOM_VERSION=y BR2_TARGET_OPENSBI_CUSTOM_VERSION_VALUE="1.6" -BR2_TARGET_OPENSBI_PLAT="generic" +BR2_TARGET_OPENSBI_PLAT_REF=y +BR2_TARGET_OPENSBI_PLAT_REF_NAME="generic" BR2_TARGET_OPENSBI_LINUX_PAYLOAD=y BR2_PACKAGE_HOST_RISCV_ISA_SIM=y
configs/spike_riscv64_defconfig +2 -1
@@ -11,6 +11,7 @@ BR2_TARGET_ROOTFS_CPIO=y BR2_TARGET_OPENSBI=y BR2_TARGET_OPENSBI_CUSTOM_VERSION=y BR2_TARGET_OPENSBI_CUSTOM_VERSION_VALUE="1.6" -BR2_TARGET_OPENSBI_PLAT="generic" +BR2_TARGET_OPENSBI_PLAT_REF=y +BR2_TARGET_OPENSBI_PLAT_REF_NAME="generic" BR2_TARGET_OPENSBI_LINUX_PAYLOAD=y BR2_PACKAGE_HOST_RISCV_ISA_SIM=y
configs/visionfive2_defconfig +2 -1
@@ -21,7 +21,8 @@ BR2_TARGET_ROOTFS_EXT2_4=y BR2_TARGET_OPENSBI=y BR2_TARGET_OPENSBI_CUSTOM_VERSION=y BR2_TARGET_OPENSBI_CUSTOM_VERSION_VALUE="1.8.1" -BR2_TARGET_OPENSBI_PLAT="generic" +BR2_TARGET_OPENSBI_PLAT_REF=y +BR2_TARGET_OPENSBI_PLAT_REF_NAME="generic" # BR2_TARGET_OPENSBI_INSTALL_JUMP_IMG is not set BR2_TARGET_OPENSBI_ADDITIONAL_VARIABLES="FW_TEXT_START=0x40000000 FW_OPTIONS=0" BR2_TARGET_UBOOT=y
Signature · 6 lines
2.47.0 _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot
PATCH RESEND 2/2 DEVELOPERS: add Richard Vodden for boot/opensbi
In reply to Richard Vodden--- DEVELOPERS | 3 +++ 1 file changed, 3 insertions(+)
DEVELOPERS +3 -0
@@ -2903,6 +2903,9 @@ N: Richard Braun <[email protected]> F: package/curlftpfs/ F: package/tzdata/ +N: Richard Vodden <[email protected]> +F: boot/opensbi/ + N: RJ Ascani <[email protected]> F: package/azmq/
Signature · 6 lines
2.47.0 _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot