boot/opensbi: add support for version configuration
authorThomas Petazzoni <thomas.petazzoni@bootlin.com>
Thu, 29 Apr 2021 07:46:32 +0000 (09:46 +0200)
committerPeter Korsgaard <peter@korsgaard.com>
Fri, 30 Apr 2021 07:46:21 +0000 (09:46 +0200)
OpenSBI contains platform-specific code, so very much like Linux,
U-Boot or other bootloaders, using the upstream version of OpenSBI
will very often not be sufficient.

This commit therefore adds the possibility of specifying a custom
version of OpenSBI, either custom from upstream, custom tarball, or
custom from Git. Support for other version control systems has not
been implemented for now, but could be added later if needed.

Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
boot/opensbi/Config.in
boot/opensbi/opensbi.mk

index b9b0ace8af41314e01cda1b2edfe228157a369f7..83f40f04faa5da843e807c2a5ff1fce4fa289733 100644 (file)
@@ -13,6 +13,57 @@ config BR2_TARGET_OPENSBI
          https://github.com/riscv/opensbi.git
 
 if BR2_TARGET_OPENSBI
+choice
+       prompt "OpenSBI Version"
+       help
+         Select the specific OpenSBI version you want to use
+
+config BR2_TARGET_OPENSBI_LATEST_VERSION
+       bool "0.8"
+
+config BR2_TARGET_OPENSBI_CUSTOM_VERSION
+       bool "Custom version"
+       help
+         This option allows to use a specific official versions
+
+config BR2_TARGET_OPENSBI_CUSTOM_TARBALL
+       bool "Custom tarball"
+
+config BR2_TARGET_OPENSBI_CUSTOM_GIT
+       bool "Custom Git repository"
+
+endchoice
+
+config BR2_TARGET_OPENSBI_CUSTOM_VERSION_VALUE
+       string "OpenSBI version"
+       depends on BR2_TARGET_OPENSBI_CUSTOM_VERSION
+
+config BR2_TARGET_OPENSBI_CUSTOM_TARBALL_LOCATION
+       string "URL of custom OpenSBI tarball"
+       depends on BR2_TARGET_OPENSBI_CUSTOM_TARBALL
+
+if BR2_TARGET_OPENSBI_CUSTOM_GIT
+
+config BR2_TARGET_OPENSBI_CUSTOM_REPO_URL
+       string "URL of custom repository"
+
+config BR2_TARGET_OPENSBI_CUSTOM_REPO_VERSION
+       string "Custom repository version"
+       help
+         Revision to use in the typical format used by Git. E.G. a
+         sha id, a tag, branch, ..
+
+endif
+
+config BR2_TARGET_OPENSBI_VERSION
+       string
+       default "0.8"   if BR2_TARGET_OPENSBI_LATEST_VERSION
+       default BR2_TARGET_OPENSBI_CUSTOM_VERSION_VALUE \
+               if BR2_TARGET_OPENSBI_CUSTOM_VERSION
+       default "custom"        if BR2_TARGET_OPENSBI_CUSTOM_TARBALL
+       default BR2_TARGET_OPENSBI_CUSTOM_REPO_VERSION \
+               if BR2_TARGET_OPENSBI_CUSTOM_GIT
+
 config BR2_TARGET_OPENSBI_PLAT
        string "OpenSBI Platform"
        default ""
index 60b87c268dcc0204f79b67dc34e0ec88a3151200..250a6078afbf526e345be564eb2c07be88436654 100644 (file)
@@ -4,13 +4,30 @@
 #
 ################################################################################
 
-OPENSBI_VERSION = 0.8
+OPENSBI_VERSION = $(call qstrip,$(BR2_TARGET_OPENSBI_VERSION))
+
+ifeq ($(OPENSBI_VERSION),custom)
+# Handle custom OpenSBI tarballs as specified by the configuration
+OPENSBI_TARBALL = $(call qstrip,$(BR2_TARGET_OPENSBI_CUSTOM_TARBALL_LOCATION))
+OPENSBI_SITE = $(patsubst %/,%,$(dir $(OPENSBI_TARBALL)))
+OPENSBI_SOURCE = $(notdir $(OPENSBI_TARBALL))
+else ifeq ($(BR2_TARGET_OPENSBI_CUSTOM_GIT),y)
+OPENSBI_SITE = $(call qstrip,$(BR2_TARGET_OPENSBI_CUSTOM_REPO_URL))
+OPENSBI_SITE_METHOD = git
+else
+# Handle official OpenSBI versions
 OPENSBI_SITE = $(call github,riscv,opensbi,v$(OPENSBI_VERSION))
+endif
+
 OPENSBI_LICENSE = BSD-2-Clause
 OPENSBI_LICENSE_FILES = COPYING.BSD
 OPENSBI_INSTALL_TARGET = NO
 OPENSBI_INSTALL_STAGING = YES
 
+ifeq ($(BR2_TARGET_OPENSBI)$(BR2_TARGET_OPENSBI_LATEST_VERSION),y)
+BR_NO_CHECK_HASH_FOR += $(OPENSBI_SOURCE)
+endif
+
 OPENSBI_MAKE_ENV = \
        CROSS_COMPILE=$(TARGET_CROSS)