diff mbox series

[v6,3/5] boot/opensbi: new package

Message ID 20190320230422.13592-3-alistair.francis@wdc.com
State Accepted
Headers show
Series [v6,1/5] board/qemu/riscv32-virt: Convert defconfig into a fragment | expand

Commit Message

Alistair Francis March 20, 2019, 11:05 p.m. UTC
OpenSBI is a much improved alternative to BBL (riscv-pk). Add OpenSBI
support to buildroot.

Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
---
 DEVELOPERS              |  1 +
 boot/Config.in          |  1 +
 boot/opensbi/Config.in  | 25 +++++++++++++++++++++++++
 boot/opensbi/opensbi.mk | 37 +++++++++++++++++++++++++++++++++++++
 4 files changed, 64 insertions(+)
 create mode 100644 boot/opensbi/Config.in
 create mode 100644 boot/opensbi/opensbi.mk

Comments

Thomas Petazzoni March 26, 2019, 1:57 p.m. UTC | #1
Hello,

On Wed, 20 Mar 2019 23:05:21 +0000
Alistair Francis <Alistair.Francis@wdc.com> wrote:

> OpenSBI is a much improved alternative to BBL (riscv-pk). Add OpenSBI
> support to buildroot.
> 
> Signed-off-by: Alistair Francis <alistair.francis@wdc.com>

I have applied, but after doing a few changes for things that were not
completely correct. See below.

> +OPENSBI_VERSION = v0.3
> +OPENSBI_SITE = $(call github,riscv,opensbi,$(OPENSBI_VERSION))
> +OPENSBI_LICENSE = BSD-2-Clause
> +OPENSBI_LICENSE_FILES = COPYING.BSD
> +OPENSBI_INSTALL_IMAGES = YES

This is only really needed when OPENSBI_PLAT != "", so I've moved this
statement inside the appropriate condition.

I've added OPENSBI_INSTALL_TARGET = NO, because we're not installing
anything to target.

But more importantly, I've added OPENSBI_INSTALL_STAGING = YES, without
which your OPENSBI_INSTALL_STAGING_CMDS is never called. I'm not sure
how you tested this, but it clearly couldn't work as is.

> +# Install libsbi.a in the host lib dir so it can be linked in the future.

The library is not installed in host dir. So I've changed this to
rather explain why we install in usr/share/opensbi and not in usr/lib.

Applied with those issues fixed. Thanks!

Thomas
Alistair Francis March 26, 2019, 10:21 p.m. UTC | #2
On Tue, Mar 26, 2019 at 6:57 AM Thomas Petazzoni
<thomas.petazzoni@bootlin.com> wrote:
>
> Hello,
>
> On Wed, 20 Mar 2019 23:05:21 +0000
> Alistair Francis <Alistair.Francis@wdc.com> wrote:
>
> > OpenSBI is a much improved alternative to BBL (riscv-pk). Add OpenSBI
> > support to buildroot.
> >
> > Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
>
> I have applied, but after doing a few changes for things that were not
> completely correct. See below.

Thanks for applying this and the rest of the series.

>
> > +OPENSBI_VERSION = v0.3
> > +OPENSBI_SITE = $(call github,riscv,opensbi,$(OPENSBI_VERSION))
> > +OPENSBI_LICENSE = BSD-2-Clause
> > +OPENSBI_LICENSE_FILES = COPYING.BSD
> > +OPENSBI_INSTALL_IMAGES = YES
>
> This is only really needed when OPENSBI_PLAT != "", so I've moved this
> statement inside the appropriate condition.
>
> I've added OPENSBI_INSTALL_TARGET = NO, because we're not installing
> anything to target.

Thanks

>
> But more importantly, I've added OPENSBI_INSTALL_STAGING = YES, without
> which your OPENSBI_INSTALL_STAGING_CMDS is never called. I'm not sure
> how you tested this, but it clearly couldn't work as is.

Ah, I tested it in the previous version when I was using the Image
install, but must have missed checking it was installed in the latest
version. Sorry about that.

>
> > +# Install libsbi.a in the host lib dir so it can be linked in the future.
>
> The library is not installed in host dir. So I've changed this to
> rather explain why we install in usr/share/opensbi and not in usr/lib.

Thanks for this.

Alistair

>
> Applied with those issues fixed. Thanks!
>
> Thomas
> --
> Thomas Petazzoni, CTO, Bootlin
> Embedded Linux and Kernel engineering
> https://bootlin.com
diff mbox series

Patch

diff --git a/DEVELOPERS b/DEVELOPERS
index 3e0ac08e11..91eda42949 100644
--- a/DEVELOPERS
+++ b/DEVELOPERS
@@ -122,6 +122,7 @@  F:	package/kvazaar/
 F:	package/v4l2loopback/
 
 N:	Alistair Francis <alistair@alistair23.me>
+F:	boot/opensbi/
 F:	package/xen/
 
 N:	Alvaro G. M <alvaro.gamez@hazent.com>
diff --git a/boot/Config.in b/boot/Config.in
index 74481e7545..97bd3de6e9 100644
--- a/boot/Config.in
+++ b/boot/Config.in
@@ -14,6 +14,7 @@  source "boot/lpc32xxcdl/Config.in"
 source "boot/mv-ddr-marvell/Config.in"
 source "boot/mxs-bootlets/Config.in"
 source "boot/optee-os/Config.in"
+source "boot/opensbi/Config.in"
 source "boot/riscv-pk/Config.in"
 source "boot/s500-bootloader/Config.in"
 source "boot/shim/Config.in"
diff --git a/boot/opensbi/Config.in b/boot/opensbi/Config.in
new file mode 100644
index 0000000000..5f3cc13312
--- /dev/null
+++ b/boot/opensbi/Config.in
@@ -0,0 +1,25 @@ 
+config BR2_TARGET_OPENSBI
+	bool "opensbi"
+	depends on BR2_riscv
+	help
+	  OpenSBI aims to provide an open-source and extensible
+	  implementation of the RISC-V SBI specification for a platform
+	  specific firmware (M-mode) and a general purpose OS,
+	  hypervisor or bootloader (S-mode or HS-mode). OpenSBI
+	  implementation can be easily extended by RISC-V platform or
+	  System-on-Chip vendors to fit a particular hadware
+	  configuration.
+
+	  https://github.com/riscv/opensbi.git
+
+if BR2_TARGET_OPENSBI
+config BR2_TARGET_OPENSBI_PLAT
+	string "OpenSBI Platform"
+	default ""
+	help
+	  Specifies the OpenSBI platform to build. If no platform is
+	  specified only the OpenSBI platform independent static
+	  library libsbi.a is built. If a platform is specified then
+	  the platform specific static library libplatsbi.a and firmware
+	  examples are built.
+endif
diff --git a/boot/opensbi/opensbi.mk b/boot/opensbi/opensbi.mk
new file mode 100644
index 0000000000..ba4ff06c28
--- /dev/null
+++ b/boot/opensbi/opensbi.mk
@@ -0,0 +1,37 @@ 
+################################################################################
+#
+# opensbi
+#
+################################################################################
+
+OPENSBI_VERSION = v0.3
+OPENSBI_SITE = $(call github,riscv,opensbi,$(OPENSBI_VERSION))
+OPENSBI_LICENSE = BSD-2-Clause
+OPENSBI_LICENSE_FILES = COPYING.BSD
+OPENSBI_INSTALL_IMAGES = YES
+
+OPENSBI_MAKE_ENV = \
+	CROSS_COMPILE=$(TARGET_CROSS)
+
+OPENSBI_PLAT = $(call qstrip,$(BR2_TARGET_OPENSBI_PLAT))
+ifneq ($(OPENSBI_PLAT),)
+OPENSBI_MAKE_ENV += PLATFORM=$(OPENSBI_PLAT)
+endif
+
+define OPENSBI_BUILD_CMDS
+	$(TARGET_MAKE_ENV) $(OPENSBI_MAKE_ENV) $(MAKE) -C $(@D)
+endef
+
+ifneq ($(OPENSBI_PLAT),)
+define OPENSBI_INSTALL_IMAGES_CMDS
+	$(INSTALL) -m 0644 -D $(@D)/build/platform/$(OPENSBI_PLAT)/firmware/fw_jump.bin $(BINARIES_DIR)/fw_jump.bin
+	$(INSTALL) -m 0644 -D $(@D)/build/platform/$(OPENSBI_PLAT)/firmware/fw_jump.elf $(BINARIES_DIR)/fw_jump.elf
+endef
+endif
+
+# Install libsbi.a in the host lib dir so it can be linked in the future.
+define OPENSBI_INSTALL_STAGING_CMDS
+	$(INSTALL) -m 0644 -D $(@D)/build/lib/libsbi.a $(STAGING_DIR)/usr/share/opensbi/libsbi.a
+endef
+
+$(eval $(generic-package))