--- /dev/null
+#
+# Copyright (C) 2020 Zoltan HERPAI
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=opensbi
+PKG_RELEASE:=0.8
+
+PKG_SOURCE_PROTO:=git
+PKG_SOURCE_URL=https://github.com/riscv/opensbi
+PKG_SOURCE_DATE:=2020-12-19
+PKG_SOURCE_VERSION:=a029bd90c63307e9ef2d7ddbaa2eb2c799fca98a
+
+PKG_BUILD_DIR = $(BUILD_DIR)/$(PKG_NAME)-$(BUILD_VARIANT)/$(PKG_NAME)-$(PKG_VERSION)
+
+PKG_TARGETS:=bin
+PKG_FLAGS:=nonshared
+PKG_LICENSE:=BSD-2-Clause
+PKG_LICENSE_FILES:=COPYING.BSD
+PKG_BUILD_PARALLEL:=1
+
+PKG_MAINTAINER:=Zoltan HERPAI <wigyori@uid0.hu>
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/opensbi
+ SECTION:=boot
+ CATEGORY:=Boot Loaders
+ DEPENDS:=@TARGET_riscv64
+ VARIANT:=$(subst opensbi-,,$(1))
+ URL:=https://github.com/riscv/opensbi/blob/master/README.md
+endef
+
+define Package/opensbi-sifive_fu540
+ $(Package/opensbi)
+ TITLE:=OpenSBI for SiFive Unleashed (FU540)
+ OPENSBI_IMAGE:=fw_dynamic.bin
+ OPENSBI_PLATFORM:=sifive/fu540
+endef
+
+define Package/opensbi-generic
+ $(Package/opensbi)
+ TITLE:=OpenSBI generic
+ OPENSBI_IMAGE:=fw_dynamic.bin
+ OPENSBI_PLATFORM:=generic
+endef
+
+define Package/opensbi-qemu-virt
+ $(Package/opensbi)
+ TITLE:=OpenSBI generic
+ OPENSBI_IMAGE:=fw_dynamic.bin
+ OPENSBI_PLATFORM:=qemu/virt
+endef
+
+export GCC_HONOUR_COPTS=s
+
+MAKE_VARS = \
+ CROSS_COMPILE="$(TARGET_CROSS)"
+
+# $(eval $(Package/opensbi-sifive_fu540)) \
+# $(eval $(Package/opensbi-${OPENSBI_PLATFORM})) \
+
+define Build/Compile
+ $(eval $(Package/opensbi-sifive_fu540)) \
+ +$(MAKE_VARS) $(MAKE) -C $(PKG_BUILD_DIR) \
+ PLATFORM=$(OPENSBI_PLATFORM)
+endef
+
+# PLATFORM=$(OPENSBI_PLATFORM) \
+# FW_FDT_PATH=$(STAGING_DIR_IMAGE)/$(DTS)
+#endef
+
+# FW_PAYLOAD_PATH=$(STAGING_DIR_IMAGE)/$(subst /,_/$(OPENSBI_PLATFORM)-u-boot.bin \
+
+
+define Build/InstallDev
+ $(INSTALL_DIR) $(STAGING_DIR_IMAGE)
+ $(CP) $(PKG_BUILD_DIR)/build/platform/$(OPENSBI_PLATFORM)/firmware/fw_dynamic.bin $(STAGING_DIR_IMAGE)/fw_dynamic-${BUILD_VARIANT}.bin
+endef
+
+$(eval $(call BuildPackage,opensbi-sifive_fu540))
+$(eval $(call BuildPackage,opensbi-generic))
+$(eval $(call BuildPackage,opensbi-qemu-virt))