firmware: opensbi: add package for RISC-V
authorZoltan HERPAI <wigyori@uid0.hu>
Sun, 26 Jan 2020 22:45:48 +0000 (23:45 +0100)
committerZoltan HERPAI <wigyori@uid0.hu>
Thu, 4 Mar 2021 00:04:34 +0000 (01:04 +0100)
Signed-off-by: Zoltan HERPAI <wigyori@uid0.hu>
package/boot/opensbi/Makefile [new file with mode: 0644]

diff --git a/package/boot/opensbi/Makefile b/package/boot/opensbi/Makefile
new file mode 100644 (file)
index 0000000..6699cc2
--- /dev/null
@@ -0,0 +1,87 @@
+#
+# 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))