diff mbox series

[v4,3/5] boot/opensbi: Initial commit of OpenSBI for RISC-V

Message ID 20190319181449.25067-3-alistair.francis@wdc.com
State Changes Requested
Headers show
Series [v4,1/5] board/qemu/riscv32-virt: Update linux config | expand

Commit Message

Alistair Francis March 19, 2019, 6:15 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 | 32 ++++++++++++++++++++++++++++++++
 4 files changed, 59 insertions(+)
 create mode 100644 boot/opensbi/Config.in
 create mode 100644 boot/opensbi/opensbi.mk

Comments

Thomas Petazzoni March 19, 2019, 9:09 p.m. UTC | #1
Hello,

I was about to apply this patch, but there is still an issue (see
below). Since a new iteration will be needed, I'll point out some minor
nits as well that I would have normally fixed myself when applying, but
that you can fix together with the more significant issue.

First minor nit: the commit title should be "boot/opensbi: new package"

On Tue, 19 Mar 2019 18:15:48 +0000
Alistair Francis <Alistair.Francis@wdc.com> wrote:


> diff --git a/boot/opensbi/opensbi.mk b/boot/opensbi/opensbi.mk
> new file mode 100644
> index 0000000000..13dffb9ce0
> --- /dev/null
> +++ b/boot/opensbi/opensbi.mk
> @@ -0,0 +1,32 @@
> +################################################################################
> +#
> +# OpenSBI

opensbi in lower-case

> +#
> +################################################################################
> +
> +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

So the issue that I have is that this package doesn't install anything
when OPENSBI_PLAT is empty. It doesn't install any image, it doesn't
install any library to STAGING_DIR.

Should the libplatsbi.a library be installed in
$(STAGING_DIR)/usr/lib ? This location is normally for regular Linux
user-space libraries, which I suppose libplatsbi.a is not. Perhaps it
should be in another location ?

In any case, it should be installed somewhere, otherwise the package is
pretty meaningless when OPENSBI_PLAT is empty.

Thanks!

Thomas
Alistair Francis March 20, 2019, 12:37 a.m. UTC | #2
On Tue, Mar 19, 2019 at 2:09 PM Thomas Petazzoni
<thomas.petazzoni@bootlin.com> wrote:
>
> Hello,
>
> I was about to apply this patch, but there is still an issue (see
> below). Since a new iteration will be needed, I'll point out some minor
> nits as well that I would have normally fixed myself when applying, but
> that you can fix together with the more significant issue.
>
> First minor nit: the commit title should be "boot/opensbi: new package"
>
> On Tue, 19 Mar 2019 18:15:48 +0000
> Alistair Francis <Alistair.Francis@wdc.com> wrote:
>
>
> > diff --git a/boot/opensbi/opensbi.mk b/boot/opensbi/opensbi.mk
> > new file mode 100644
> > index 0000000000..13dffb9ce0
> > --- /dev/null
> > +++ b/boot/opensbi/opensbi.mk
> > @@ -0,0 +1,32 @@
> > +################################################################################
> > +#
> > +# OpenSBI
>
> opensbi in lower-case
>
> > +#
> > +################################################################################
> > +
> > +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
>
> So the issue that I have is that this package doesn't install anything
> when OPENSBI_PLAT is empty. It doesn't install any image, it doesn't
> install any library to STAGING_DIR.
>
> Should the libplatsbi.a library be installed in
> $(STAGING_DIR)/usr/lib ? This location is normally for regular Linux
> user-space libraries, which I suppose libplatsbi.a is not. Perhaps it
> should be in another location ?
>
> In any case, it should be installed somewhere, otherwise the package is
> pretty meaningless when OPENSBI_PLAT is empty.

Fixed in v5.

Alistair

>
> 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..13dffb9ce0
--- /dev/null
+++ b/boot/opensbi/opensbi.mk
@@ -0,0 +1,32 @@ 
+################################################################################
+#
+# 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
+
+$(eval $(generic-package))