From 22058917ae1a52c2624763e1b5983907f97d422c Mon Sep 17 00:00:00 2001 From: Zoltan HERPAI Date: Sun, 26 Jan 2020 23:46:18 +0100 Subject: [PATCH] uboot-riscv64: add new package Signed-off-by: Zoltan HERPAI --- package/boot/uboot-riscv64/Makefile | 55 +++++++++++++++++++ ...-environment-for-dtc-binary-location.patch | 35 ++++++++++++ package/boot/uboot-riscv64/uEnv-default.txt | 4 ++ 3 files changed, 94 insertions(+) create mode 100644 package/boot/uboot-riscv64/Makefile create mode 100644 package/boot/uboot-riscv64/patches/100-mkimage-check-environment-for-dtc-binary-location.patch create mode 100644 package/boot/uboot-riscv64/uEnv-default.txt diff --git a/package/boot/uboot-riscv64/Makefile b/package/boot/uboot-riscv64/Makefile new file mode 100644 index 0000000000..8cfe2e533b --- /dev/null +++ b/package/boot/uboot-riscv64/Makefile @@ -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 index 0000000000..482aa1a369 --- /dev/null +++ b/package/boot/uboot-riscv64/patches/100-mkimage-check-environment-for-dtc-binary-location.patch @@ -0,0 +1,35 @@ +From 637800493945ffed2f454756300437a4ec86e3b1 Mon Sep 17 00:00:00 2001 +From: Hauke Mehrtens +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 +Cc: Simon Glass +--- + 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 index 0000000000..01dc51f85d --- /dev/null +++ b/package/boot/uboot-riscv64/uEnv-default.txt @@ -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 -- 2.30.2