cv18x0: update target and add uboot package
authorZoltan HERPAI <wigyori@uid0.hu>
Tue, 30 Apr 2024 09:26:30 +0000 (11:26 +0200)
committerZoltan HERPAI <wigyori@uid0.hu>
Tue, 30 Apr 2024 09:26:30 +0000 (11:26 +0200)
Signed-off-by: Zoltan HERPAI <wigyori@uid0.hu>
package/boot/uboot-cv18x0/110-no-kwbimage.patch [new file with mode: 0644]
package/boot/uboot-cv18x0/Makefile [new file with mode: 0644]
package/boot/uboot-cv18x0/patches/100-mkimage-check-environment-for-dtc-binary-location.patch [new file with mode: 0644]
package/boot/uboot-cv18x0/patches/130-fix-mkimage-host-build.patch [new file with mode: 0644]
package/boot/uboot-cv18x0/uEnv-default.txt [new file with mode: 0644]
target/linux/cv18x0/image/Makefile

diff --git a/package/boot/uboot-cv18x0/110-no-kwbimage.patch b/package/boot/uboot-cv18x0/110-no-kwbimage.patch
new file mode 100644 (file)
index 0000000..65d14f5
--- /dev/null
@@ -0,0 +1,10 @@
+--- a/tools/Makefile
++++ b/tools/Makefile
+@@ -119,7 +119,6 @@ dumpimage-mkimage-objs := aisimage.o \
+                       imximage.o \
+                       imx8image.o \
+                       imx8mimage.o \
+-                      kwbimage.o \
+                       lib/md5.o \
+                       lpc32xximage.o \
+                       mxsimage.o \
diff --git a/package/boot/uboot-cv18x0/Makefile b/package/boot/uboot-cv18x0/Makefile
new file mode 100644 (file)
index 0000000..8a39acf
--- /dev/null
@@ -0,0 +1,61 @@
+# SPDX-License-Identifier: GPL-2.0-only
+#
+# Copyright (C) 2022 OpenWrt.org
+#
+
+include $(TOPDIR)/rules.mk
+include $(INCLUDE_DIR)/kernel.mk
+
+PKG_RELEASE:=1
+PKG_VERSION:=2024-04-29
+PKG_SOURCE_PROTO:=git
+PKG_SOURCE_URL:=https://github.com/u-boot/u-boot
+PKG_SOURCE_VERSION:=174ac987655c888017c82df1883c0c2ea0dc2495
+
+UBOOT_USE_INTREE_DTC:=1
+
+include $(INCLUDE_DIR)/u-boot.mk
+include $(INCLUDE_DIR)/package.mk
+
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.zst
+PKG_MIRROR_HASH:=67b790ac40473fe8f6078a90b02533e30e4196830a43754cb50587a7ec6155bb
+
+define U-Boot/Default
+  BUILD_TARGET:=cv18x0
+  BUILD_DEVICES=$(1)
+  UBOOT_IMAGE:=u-boot.itb
+  DTS_DIR:=arch/riscv/dts
+  UENV:=default
+  DEFAULT:=y
+endef
+
+define U-Boot/milkv_duo
+  NAME:=MilkV Duo
+  OPENSBI:=generic
+  DEPENDS:=+opensbi_generic
+  UBOOT_DTS:=cv1800-milkv-duo.dts
+  BUILD_DEVICES:=milkv_duo
+endef
+
+UBOOT_TARGETS := \
+       milkv_duo
+
+UBOOT_MAKE_FLAGS += \
+        OPENSBI=$(STAGING_DIR_IMAGE)/fw_dynamic-${OPENSBI}.bin
+
+define Build/Configure
+       $(call Build/Configure/U-Boot)
+       sed -i 's/CONFIG_TOOLS_LIBCRYPTO=y/# CONFIG_TOOLS_LIBCRYPTO is not set/' $(PKG_BUILD_DIR)/.config
+endef
+
+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-cv18x0/patches/100-mkimage-check-environment-for-dtc-binary-location.patch b/package/boot/uboot-cv18x0/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-cv18x0/patches/130-fix-mkimage-host-build.patch b/package/boot/uboot-cv18x0/patches/130-fix-mkimage-host-build.patch
new file mode 100644 (file)
index 0000000..cd65c13
--- /dev/null
@@ -0,0 +1,24 @@
+--- a/tools/image-host.c
++++ b/tools/image-host.c
+@@ -1125,6 +1125,7 @@ static int fit_config_add_verification_d
+  * 2) get public key (X509_get_pubkey)
+  * 3) provide der format (d2i_RSAPublicKey)
+  */
++#ifdef CONFIG_TOOLS_LIBCRYPTO
+ static int read_pub_key(const char *keydir, const void *name,
+                       unsigned char **pubkey, int *pubkey_len)
+ {
+@@ -1178,6 +1179,13 @@ err_cert:
+       fclose(f);
+       return ret;
+ }
++#else
++static int read_pub_key(const char *keydir, const void *name,
++                      unsigned char **pubkey, int *pubkey_len)
++{
++      return -ENOSYS;
++}
++#endif
+ int fit_pre_load_data(const char *keydir, void *keydest, void *fit)
+ {
diff --git a/package/boot/uboot-cv18x0/uEnv-default.txt b/package/boot/uboot-cv18x0/uEnv-default.txt
new file mode 100644 (file)
index 0000000..8468a3c
--- /dev/null
@@ -0,0 +1,5 @@
+setenv loadkernel fatload mmc 0:3 \$kernel_addr_r Image
+setenv loaddtb fatload mmc 0:3 \$fdt_addr_r dtb
+setenv bootargs console=ttySIF0,115200 earlycon=sbi root=/dev/mmcblk0p4 rootwait
+setenv uenvcmd run loadkernel \&\& run loaddtb \&\& booti \$kernel_addr_r - \$fdt_addr_r
+run uenvcmd
index 33a7397bf77d8b56fb82f196e2e19990eed730fa..3293cfeb1f3fdfbbdc8080a7ee30ac134f62de41 100644 (file)
@@ -36,21 +36,12 @@ define Device/Default
   IMAGE/sdcard.img.gz := riscv-sdcard | append-metadata | gzip
 endef
 
-define Device/sifive_unleashed
-  DEVICE_VENDOR := SiFive
-  DEVICE_MODEL := Unleashed (FU540)
-  DEVICE_DTS := sifive/hifive-unleashed-a00
-  UBOOT := sifive_unleashed
+define Device/milkv_duo
+  DEVICE_VENDOR := MilkV
+  DEVICE_MODEL := Duo
+  DEVICE_DTS := sophgo/cv1800b-milkv-duo
+  UBOOT := milkv_duo
 endef
-TARGET_DEVICES += sifive_unleashed
-
-define Device/sifive_unmatched
-  DEVICE_VENDOR := SiFive
-  DEVICE_MODEL := Unmatched (FU740)
-  DEVICE_DTS := sifive/hifive-unmatched-a00
-  DEVICE_PACKAGES += kmod-eeprom-at24 kmod-hwmon-lm90
-  UBOOT := sifive_unmatched
-endef
-TARGET_DEVICES += sifive_unmatched
+TARGET_DEVICES += milkv_duo
 
 $(eval $(call BuildImage))