uboot-riscv64: add new package
authorZoltan HERPAI <wigyori@uid0.hu>
Sun, 26 Jan 2020 22:46:18 +0000 (23:46 +0100)
committerZoltan HERPAI <wigyori@uid0.hu>
Thu, 4 Mar 2021 00:04:39 +0000 (01:04 +0100)
Signed-off-by: Zoltan HERPAI <wigyori@uid0.hu>
package/boot/uboot-riscv64/Makefile [new file with mode: 0644]
package/boot/uboot-riscv64/patches/100-mkimage-check-environment-for-dtc-binary-location.patch [new file with mode: 0644]
package/boot/uboot-riscv64/uEnv-default.txt [new file with mode: 0644]

diff --git a/package/boot/uboot-riscv64/Makefile b/package/boot/uboot-riscv64/Makefile
new file mode 100644 (file)
index 0000000..8cfe2e5
--- /dev/null
@@ -0,0 +1,55 @@
+#
+# Copyright (C) 2013-2020 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+include $(INCLUDE_DIR)/kernel.mk
+
+PKG_RELEASE:=1
+
+PKG_VERSION:=2020.10
+PKG_HASH:=0d481bbdc05c0ee74908ec2f56a6daa53166cc6a78a0e4fac2ac5d025770a622
+#https://ftp.denx.de/pub/u-boot/u-boot-2020.10.tar.bz2
+
+include $(INCLUDE_DIR)/u-boot.mk
+include $(INCLUDE_DIR)/package.mk
+
+define U-Boot/Default
+  BUILD_TARGET:=riscv64
+  BUILD_DEVICES=$(1)
+  UBOOT_IMAGE:=u-boot.itb
+  DTS_DIR:=arch/riscv/dts
+  UBOOT_DTS:=hifive-unleashed-a00.dtb
+  UENV:=default
+  DEFAULT:=y
+endef
+
+define U-Boot/sifive_fu540
+  NAME:=SiFive Unleashed
+  OPENSBI:=sifive_fu540
+  DEPENDS:=+opensbi-sifive_fu540
+  BUILD_DEVICES:=sifive_fu540
+endef
+
+#DEPENDS:=+opensbi-sifive_fu540
+
+UBOOT_TARGETS := \
+       sifive_fu540
+
+UBOOT_MAKE_FLAGS += \
+       OPENSBI=$(STAGING_DIR_IMAGE)/fw_dynamic-${OPENSBI}.bin
+
+define Build/InstallDev
+       $(INSTALL_DIR) $(STAGING_DIR_IMAGE)
+       $(INSTALL_BIN) $(PKG_BUILD_DIR)/$(UBOOT_IMAGE) $(STAGING_DIR_IMAGE)/$(BUILD_VARIANT)-$(UBOOT_IMAGE)
+       $(INSTALL_BIN) $(PKG_BUILD_DIR)/spl/u-boot-spl.bin $(STAGING_DIR_IMAGE)/$(BUILD_VARIANT)-$(UBOOT_IMAGE)-spl
+       $(INSTALL_BIN) $(PKG_BUILD_DIR)/$(DTS_DIR)/$(UBOOT_DTS) $(STAGING_DIR_IMAGE)/$(UBOOT_DTS)
+
+       mkimage -C none -A arm -T script -d uEnv-$(UENV).txt \
+               $(STAGING_DIR_IMAGE)/$(BUILD_DEVICES)-boot.scr
+endef
+
+$(eval $(call BuildPackage/U-Boot))
diff --git a/package/boot/uboot-riscv64/patches/100-mkimage-check-environment-for-dtc-binary-location.patch b/package/boot/uboot-riscv64/patches/100-mkimage-check-environment-for-dtc-binary-location.patch
new file mode 100644 (file)
index 0000000..482aa1a
--- /dev/null
@@ -0,0 +1,35 @@
+From 637800493945ffed2f454756300437a4ec86e3b1 Mon Sep 17 00:00:00 2001
+From: Hauke Mehrtens <hauke@hauke-m.de>
+Date: Wed, 19 Jul 2017 22:23:15 +0200
+Subject: mkimage: check environment for dtc binary location
+
+Currently mkimage assumes the dtc binary is in the path and fails
+otherwise. This patch makes it check the DTC environment variable first
+for the dtc binary and then fall back to the default path. This makes
+it possible to call the u-boot build with make DTC=... and build a fit
+image with the dtc binary not being the the default path.
+
+Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
+Cc: Simon Glass <sjg@chromium.org>
+---
+ tools/fit_image.c | 7 ++++++-
+ 1 file changed, 6 insertions(+), 1 deletion(-)
+
+--- a/tools/fit_image.c
++++ b/tools/fit_image.c
+@@ -726,9 +726,14 @@ static int fit_handle_file(struct image_
+               }
+               *cmd = '\0';
+       } else if (params->datafile) {
++              const char* dtc = getenv("DTC");
++
++              if (!dtc)
++                      dtc = MKIMAGE_DTC;
++
+               /* dtc -I dts -O dtb -p 500 -o tmpfile datafile */
+               snprintf(cmd, sizeof(cmd), "%s %s -o \"%s\" \"%s\"",
+-                       MKIMAGE_DTC, params->dtc, tmpfile, params->datafile);
++                       dtc, params->dtc, tmpfile, params->datafile);
+               debug("Trying to execute \"%s\"\n", cmd);
+       } else {
+               snprintf(cmd, sizeof(cmd), "cp \"%s\" \"%s\"",
diff --git a/package/boot/uboot-riscv64/uEnv-default.txt b/package/boot/uboot-riscv64/uEnv-default.txt
new file mode 100644 (file)
index 0000000..01dc51f
--- /dev/null
@@ -0,0 +1,4 @@
+setenv loadkernel fatload mmc 0:3 \$kernel_addr_r uImage
+setenv bootargs console=ttySIF0,115200 earlycon=sbi root=/dev/mmcblk0p4 rootwait
+setenv uenvcmd run loadkernel \&\& bootm \$kernel_addr_r
+run uenvcmd